xiongzhu 10 달 전
부모
커밋
075cdb96ee

+ 2 - 2
app/src/main/java/com/example/modifier/extension/packageManager.kt

@@ -25,11 +25,11 @@ fun String.unhide(): String {
 }
 
 fun String.disable(): String {
-    return "pm disable-user $this"
+    return "pm disable-user --user 0 $this"
 }
 
 fun String.enable(): String {
-    return "pm enable $this"
+    return "pm enable --user 0 $this"
 }
 
 fun String.launch(): String {

+ 1 - 0
app/src/main/java/com/example/modifier/repo/BackupRepository.kt

@@ -210,6 +210,7 @@ class BackupRepository(
             "pm revoke com.google.android.gms android.permission.DUMP",
             "sleep 30",
             PACKAGE_MESSAGING.enable(),
+            "cmd role add-role-holder android.app.role.SMS $PACKAGE_MESSAGING",
             "sleep 1",
             CMD_MESSAGING_APP,
             "sleep 5",

+ 87 - 84
app/src/main/java/com/example/modifier/repo/SpoofedInfoRepo.kt

@@ -18,11 +18,14 @@ import com.example.modifier.constants.PACKAGE_GMS
 import com.example.modifier.constants.PACKAGE_MESSAGING
 import com.example.modifier.constants.PACKAGE_PLAY
 import com.example.modifier.constants.SIMView
+import com.example.modifier.extension.disable
+import com.example.modifier.extension.enable
 import com.example.modifier.extension.kill
 import com.example.modifier.extension.resume
 import com.example.modifier.extension.suspend
 import com.example.modifier.model.SpoofedInfo
 import com.example.modifier.utils.ApduChannel
+import com.example.modifier.utils.ROOT_ACCESS
 import com.example.modifier.utils.SimEncoder
 import com.example.modifier.utils.genAndroidId
 import com.example.modifier.utils.genICCID
@@ -199,110 +202,110 @@ class SpoofedInfoRepo private constructor(private val context: Context) {
             }
             if (suspend == true) {
                 shellRun(
-                    PACKAGE_MESSAGING.suspend(),
-                    PACKAGE_PLAY.suspend(),
-                    PACKAGE_GMS.suspend(),
                     PACKAGE_GMS.kill(),
                     PACKAGE_PLAY.kill(),
                     PACKAGE_MESSAGING.kill(),
+                    PACKAGE_MESSAGING.disable(),
                 )
             }
             val context = getContext()
 
-            runCatching {
-                val plmn = spoofedInfo.mcc + spoofedInfo.mnc
-                val plmnHex = SimEncoder.encPLMN(spoofedInfo.mcc + spoofedInfo.mnc)
-                val plmnwactHex = SimEncoder.encPLMNwAcT("$plmn:4000,$plmn:8000,$plmn:0080")
-                val fplmn =
-                    SimEncoder.encPLMN("46000,46001,46002,46006,46007,46011,46012,46015,46020")
-                val telephonyManager =
-                    context.getSystemService(Context.TELEPHONY_SERVICE) as TelephonyManager
-                val apduChannel = ApduChannel(telephonyManager, SIMView.AID_CUSTOM)
-                apduChannel.select(SIMView.FID_MF)
-                apduChannel.select(SIMView.FID_EF_ICCID)
-                apduChannel.writeBinary(SimEncoder.encICCID(spoofedInfo.iccid))
+            if (!ROOT_ACCESS) {
+                runCatching {
+                    val plmn = spoofedInfo.mcc + spoofedInfo.mnc
+                    val plmnHex = SimEncoder.encPLMN(spoofedInfo.mcc + spoofedInfo.mnc)
+                    val plmnwactHex = SimEncoder.encPLMNwAcT("$plmn:4000,$plmn:8000,$plmn:0080")
+                    val fplmn =
+                        SimEncoder.encPLMN("46000,46001,46002,46006,46007,46011,46012,46015,46020")
+                    val telephonyManager =
+                        context.getSystemService(Context.TELEPHONY_SERVICE) as TelephonyManager
+                    val apduChannel = ApduChannel(telephonyManager, SIMView.AID_CUSTOM)
+                    apduChannel.select(SIMView.FID_MF)
+                    apduChannel.select(SIMView.FID_EF_ICCID)
+                    apduChannel.writeBinary(SimEncoder.encICCID(spoofedInfo.iccid))
 
-                apduChannel.select(SIMView.FID_MF)
-                apduChannel.select(SIMView.FID_DF_TELECOM)
-                apduChannel.select(SIMView.FID_EF_MSISDN)
-                apduChannel.writeRecord(
-                    1, SimEncoder.encMSISDN(spoofedInfo.number)
-                        .padStart(56, 'F')
-                )
+                    apduChannel.select(SIMView.FID_MF)
+                    apduChannel.select(SIMView.FID_DF_TELECOM)
+                    apduChannel.select(SIMView.FID_EF_MSISDN)
+                    apduChannel.writeRecord(
+                        1, SimEncoder.encMSISDN(spoofedInfo.number)
+                            .padStart(56, 'F')
+                    )
 
-                apduChannel.select(SIMView.FID_MF)
-                apduChannel.select(SIMView.FID_DF_GSM)
-                apduChannel.select(SIMView.FID_EF_IMSI)
-                apduChannel.writeBinary(SimEncoder.encIMSI(spoofedInfo.imsi))
+                    apduChannel.select(SIMView.FID_MF)
+                    apduChannel.select(SIMView.FID_DF_GSM)
+                    apduChannel.select(SIMView.FID_EF_IMSI)
+                    apduChannel.writeBinary(SimEncoder.encIMSI(spoofedInfo.imsi))
 
-                apduChannel.select(SIMView.FID_EF_PLMNSEL)
-                apduChannel.writeBinary(plmnHex.padEnd(120, 'f'))
+                    apduChannel.select(SIMView.FID_EF_PLMNSEL)
+                    apduChannel.writeBinary(plmnHex.padEnd(120, 'f'))
 
-                apduChannel.select(SIMView.FID_EF_EHPLMN)
-                apduChannel.writeBinary(plmnHex.padEnd(24, 'f'))
+                    apduChannel.select(SIMView.FID_EF_EHPLMN)
+                    apduChannel.writeBinary(plmnHex.padEnd(24, 'f'))
 
-                apduChannel.select(SIMView.FID_EF_PLMNWACT)
-                apduChannel.writeBinary(plmnwactHex.padEnd(240, 'f'))
+                    apduChannel.select(SIMView.FID_EF_PLMNWACT)
+                    apduChannel.writeBinary(plmnwactHex.padEnd(240, 'f'))
 
-                apduChannel.select(SIMView.FID_EF_OPLMNWACT)
-                apduChannel.writeBinary(plmnwactHex.padEnd(120, 'f'))
+                    apduChannel.select(SIMView.FID_EF_OPLMNWACT)
+                    apduChannel.writeBinary(plmnwactHex.padEnd(120, 'f'))
 
-                apduChannel.select(SIMView.FID_EF_HPLMNWACT)
-                apduChannel.writeBinary(plmnwactHex.padEnd(40, 'f'))
+                    apduChannel.select(SIMView.FID_EF_HPLMNWACT)
+                    apduChannel.writeBinary(plmnwactHex.padEnd(40, 'f'))
 
-                apduChannel.select(SIMView.FID_EF_FPLMN)
-                apduChannel.writeBinary(fplmn.padEnd(60, 'f'))
+                    apduChannel.select(SIMView.FID_EF_FPLMN)
+                    apduChannel.writeBinary(fplmn.padEnd(60, 'f'))
 
-                apduChannel.select(SIMView.FID_EF_SPN)
-                apduChannel.writeBinary("01542d4d6f62696c65ffffffffffffffff") //T-Mobile
+                    apduChannel.select(SIMView.FID_EF_SPN)
+                    apduChannel.writeBinary("01542d4d6f62696c65ffffffffffffffff") //T-Mobile
 
-                if (plmn.isNotEmpty()) {
-                    if (plmn.length == 5) {
-                        apduChannel.select(SIMView.FID_EF_AD)
-                        apduChannel.writeBinary("00000102")
-                    } else if (plmn.length == 6) {
-                        apduChannel.select(SIMView.FID_EF_AD)
-                        apduChannel.writeBinary("00000103")
+                    if (plmn.isNotEmpty()) {
+                        if (plmn.length == 5) {
+                            apduChannel.select(SIMView.FID_EF_AD)
+                            apduChannel.writeBinary("00000102")
+                        } else if (plmn.length == 6) {
+                            apduChannel.select(SIMView.FID_EF_AD)
+                            apduChannel.writeBinary("00000103")
+                        }
                     }
-                }
-                apduChannel.close()
+                    apduChannel.close()
 
-                val apduChannel1 = ApduChannel(telephonyManager, SIMView.AID_USIM)
-                apduChannel1.writeMSISDN_USIM(spoofedInfo.number)
-                apduChannel.close()
+                    val apduChannel1 = ApduChannel(telephonyManager, SIMView.AID_USIM)
+                    apduChannel1.writeMSISDN_USIM(spoofedInfo.number)
+                    apduChannel.close()
 
-                runCatching {
-                    val mClass = Class.forName("android.telephony.TelephonyManager")
-                    val rebootRadio = mClass.getDeclaredMethod("rebootRadio")
-                    rebootRadio.isAccessible = true
-                    rebootRadio.invoke(telephonyManager)
-                    Log.i(TAG, "rebootRadio: success")
-                }.onFailure {
-                    Log.e(TAG, "Error rebootRadio: ${it.message}", it)
-                }
+                    runCatching {
+                        val mClass = Class.forName("android.telephony.TelephonyManager")
+                        val rebootRadio = mClass.getDeclaredMethod("rebootRadio")
+                        rebootRadio.isAccessible = true
+                        rebootRadio.invoke(telephonyManager)
+                        Log.i(TAG, "rebootRadio: success")
+                    }.onFailure {
+                        Log.e(TAG, "Error rebootRadio: ${it.message}", it)
+                    }
 
-                val subscriptionManager =
-                    context.getSystemService(Context.TELEPHONY_SUBSCRIPTION_SERVICE) as SubscriptionManager
+                    val subscriptionManager =
+                        context.getSystemService(Context.TELEPHONY_SUBSCRIPTION_SERVICE) as SubscriptionManager
 
-                run rebootModem@{
-                    repeat(20) {
-                        runCatching {
-                            val activeSubscriptionInfoList =
-                                subscriptionManager.activeSubscriptionInfoList
-                            activeSubscriptionInfoList?.forEach {
-                                Log.i(TAG, "iccid:${it.iccId} target:${spoofedInfo.iccid}")
-                                if (it.iccId == spoofedInfo.iccid) {
-                                    Log.i(TAG, "rebootModem: success")
-                                    if (Build.DEVICE == "redfin") {
-                                        delay(10000)
+                    run rebootModem@{
+                        repeat(20) {
+                            runCatching {
+                                val activeSubscriptionInfoList =
+                                    subscriptionManager.activeSubscriptionInfoList
+                                activeSubscriptionInfoList?.forEach {
+                                    Log.i(TAG, "iccid:${it.iccId} target:${spoofedInfo.iccid}")
+                                    if (it.iccId == spoofedInfo.iccid) {
+                                        Log.i(TAG, "rebootModem: success")
+                                        if (Build.DEVICE == "redfin") {
+                                            delay(10000)
+                                        }
+                                        return@rebootModem
+                                    } else {
+                                        delay(2000)
                                     }
-                                    return@rebootModem
-                                } else {
-                                    delay(2000)
                                 }
+                            }.onFailure {
+                                Log.e(TAG, "Error reading ICCID: ${it.message}", it)
                             }
-                        }.onFailure {
-                            Log.e(TAG, "Error reading ICCID: ${it.message}", it)
                         }
                     }
                 }
@@ -310,12 +313,11 @@ class SpoofedInfoRepo private constructor(private val context: Context) {
 
             if (suspend == true) {
                 shellRun(
-                    PACKAGE_GMS.resume(),
-                    PACKAGE_PLAY.resume(),
-                    PACKAGE_MESSAGING.resume(),
                     PACKAGE_PLAY.kill(),
                     PACKAGE_GMS.kill(),
-                    PACKAGE_MESSAGING.kill(),
+                    "sleep 5",
+                    PACKAGE_MESSAGING.enable(),
+                    "cmd role add-role-holder android.app.role.SMS $PACKAGE_MESSAGING",
                 )
             }
 
@@ -398,7 +400,8 @@ class SpoofedInfoRepo private constructor(private val context: Context) {
                             androidId = genAndroidId(),
                             gmsAid = genAndroidId(),
                             rootAid = genAndroidId()
-                        )
+                        ),
+                        suspend = false
                     )
                 }
         }

+ 1 - 2
app/src/main/java/com/example/modifier/service/TaskRunner.kt

@@ -544,7 +544,7 @@ class TaskRunner(
             return
         }
         appStateRepo.updateRuntimeFlags(reqState = ReqState.CLEAN)
-        clearConv()
+        clearConv(restoreRole = false)
         if (spoofedInfoRepo.spoofedInfo.value.available) {
             backupRepository.backup(
                 type = "auto",
@@ -572,7 +572,6 @@ class TaskRunner(
                     }
 
                     needRest = needRest || appStateRepo.appState.value.requestedNum >= 5
-                            || spoofedInfoRepo.spoofedInfo.value.available
                     if (needRest && !appPrefsRepo.appPrefs.value.preventReset) {
                         reset()
                         needRest = false

+ 4 - 2
app/src/main/java/com/example/modifier/utils/GoogleMessage.kt

@@ -80,7 +80,7 @@ fun isOldVersion(context: Context): Boolean {
     return oldVersion
 }
 
-suspend fun clearConv() {
+suspend fun clearConv(restoreRole: Boolean = true) {
     try {
         val context = getContext()
         val packageManager = context.packageManager
@@ -114,7 +114,9 @@ suspend fun clearConv() {
                     .putExtra("clean", true)
             )
             delay(3000)
-            shellRun("cmd role add-role-holder android.app.role.SMS $PACKAGE_MESSAGING")
+            if (restoreRole) {
+                shellRun("cmd role add-role-holder android.app.role.SMS $PACKAGE_MESSAGING")
+            }
         }
 
         if (ROOT_ACCESS) {

+ 5 - 2
app/src/main/java/com/example/modifier/utils/Package.kt

@@ -9,6 +9,7 @@ import com.example.modifier.constants.PACKAGE_GSF
 import com.example.modifier.constants.PACKAGE_MESSAGING
 import com.example.modifier.constants.PACKAGE_PLAY
 import com.example.modifier.extension.clear
+import com.example.modifier.extension.disable
 import com.example.modifier.extension.kill
 
 suspend fun clear(gsf: Boolean, gms: Boolean, sms: Boolean) {
@@ -60,6 +61,7 @@ suspend fun resetAll() {
             PACKAGE_GMS.clear(),
             "sleep 1",
             PACKAGE_PLAY.clear(),
+            PACKAGE_PLAY.disable(),
             "sleep 1",
             CMD_HOME,
             "sleep 10",
@@ -93,11 +95,12 @@ suspend fun resetAll() {
             "pm revoke com.google.android.gms android.permission.BODY_SENSORS",
             "pm revoke com.google.android.gms android.permission.DUMP",
             "sleep 10",
+            "cmd role add-role-holder android.app.role.SMS $PACKAGE_MESSAGING",
             PACKAGE_MESSAGING.clear(),
-            "sleep 3",
             CMD_MESSAGING_APP,
             "sleep 3",
-            CMD_MESSAGING_APP
+            CMD_MESSAGING_APP.kill(),
+            "sleep 3",
         )
     } catch (e: Exception) {
         e.printStackTrace()