package com.example.modifier.utils import com.example.modifier.constants.CMD_HOME import com.example.modifier.constants.CMD_MESSAGING_APP import com.example.modifier.constants.CMD_START_PLAY_STORE import com.example.modifier.constants.PACKAGE_GMS import com.example.modifier.constants.PACKAGE_GSF import com.example.modifier.constants.PACKAGE_MESSAGING import com.example.modifier.extension.clear import com.example.modifier.extension.kill import com.example.modifier.extension.resume import com.example.modifier.extension.suspend import kotlinx.coroutines.delay suspend fun suspendPackage(vararg packages: String) { packages.forEach { shellRun( it.suspend(), it.kill() ) delay(1000) } } suspend fun resumePackage(vararg packages: String) { packages.forEach { shellRun( it.resume(), it.kill() ) delay(1000) } } suspend fun clear(gsf: Boolean, gms: Boolean, sms: Boolean) { try { suspendPackage(PACKAGE_GSF, PACKAGE_GMS, PACKAGE_MESSAGING) val cmds: MutableList = ArrayList() // suspend if (gsf) { cmds.add(PACKAGE_GSF.suspend()) cmds.add(PACKAGE_GSF.kill()) cmds.add("echo 'gsf suspended'") } if (gms) { cmds.add(PACKAGE_GMS.suspend()) cmds.add(PACKAGE_GMS.kill()) cmds.add("echo 'gms suspended'") } if (sms) { cmds.add(PACKAGE_MESSAGING.suspend()) cmds.add(PACKAGE_MESSAGING.kill()) cmds.add("echo 'sms suspended'") } cmds.add("sleep 1") // clear if (gsf) { cmds.add(PACKAGE_GSF.clear()) cmds.add("echo 'cleared gsf'") } if (gms) { cmds.add(PACKAGE_GMS.clear()) cmds.add("echo 'cleared gms'") } if (sms) { cmds.add(PACKAGE_MESSAGING.clear()) cmds.add("echo 'cleared sms'") } cmds.add("sleep 1") // unsuspend if (gsf) { cmds.add(PACKAGE_GSF.resume()) cmds.add("echo 'gsf unsuspend'") } if (gms) { cmds.add(PACKAGE_GMS.resume()) cmds.add("echo 'gms unsuspend'") } if (sms) { cmds.add(PACKAGE_MESSAGING.resume()) cmds.add("echo 'sms unsuspend'") } cmds.add("sleep 1") shellRun(*cmds.toTypedArray()) } catch (e: Exception) { e.printStackTrace() } } suspend fun resetAll() { try { clearConv() shellRun( PACKAGE_MESSAGING.suspend(), PACKAGE_MESSAGING.kill(), PACKAGE_MESSAGING.clear(), PACKAGE_GSF.clear(), PACKAGE_GMS.clear(), "sleep 1", CMD_START_PLAY_STORE, "sleep 1", CMD_HOME, "sleep 10", PACKAGE_GMS.clear(), "sleep 2", "settings put secure location_mode 0", // "pm revoke com.google.android.gms android.permission.GET_ACCOUNTS", // "pm revoke com.google.android.gms android.permission.SYSTEM_ALERT_WINDOW", // "pm revoke com.google.android.gms android.permission.POST_NOTIFICATIONS", // "pm revoke com.google.android.gms android.permission.READ_CONTACTS", // "pm revoke com.google.android.gms android.permission.CAMERA", // "pm revoke com.google.android.gms android.permission.RECEIVE_MMS", // "pm revoke com.google.android.gms android.permission.GET_APP_OPS_STATS", // "pm revoke com.google.android.gms android.permission.PROCESS_OUTGOING_CALLS", // "pm revoke com.google.android.gms android.permission.BLUETOOTH_CONNECT", // "pm revoke com.google.android.gms android.permission.BLUETOOTH_SCAN", // "pm revoke com.google.android.gms android.permission.BLUETOOTH_ADVERTISE", // "pm revoke com.google.android.gms android.permission.NEARBY_WIFI_DEVICES", // "pm revoke com.google.android.gms android.permission.UWB_RANGING", // "pm revoke com.google.android.gms android.permission.READ_CALL_LOG", // "pm revoke com.google.android.gms android.permission.WRITE_CONTACTS", // "pm revoke com.google.android.gms android.permission.CALL_PHONE", // "pm revoke com.google.android.gms android.permission.RECORD_AUDIO", // "pm revoke com.google.android.gms android.permission.READ_LOGS", // "pm revoke com.google.android.gms android.permission.READ_MEDIA_AUDIO", // "pm revoke com.google.android.gms android.permission.READ_MEDIA_IMAGES", // "pm revoke com.google.android.gms android.permission.READ_MEDIA_VIDEO", // "pm revoke com.google.android.gms android.permission.ACCESS_MEDIA_LOCATION", // "pm revoke com.google.android.gms android.permission.ACCESS_BROADCAST_RESPONSE_STATS", // "pm revoke com.google.android.gms android.permission.WRITE_CALL_LOG", // "pm revoke com.google.android.gms android.permission.BODY_SENSORS", // "pm revoke com.google.android.gms android.permission.DUMP", "sleep 2", PACKAGE_MESSAGING.kill(), PACKAGE_MESSAGING.resume(), CMD_MESSAGING_APP ) } catch (e: Exception) { e.printStackTrace() } }