xiongzhu 11 ay önce
ebeveyn
işleme
e16734c55e

+ 1 - 1
app/build.gradle

@@ -24,7 +24,7 @@ android {
         applicationId "com.example.modifier"
         minSdk 33
         targetSdk 34
-        versionCode 165
+        versionCode 166
         versionName "1.0.1"
         archivesBaseName = "modifier-${versionCode}"
 

+ 0 - 10
app/src/main/java/com/example/modifier/MainActivity.kt

@@ -50,14 +50,6 @@ class MainActivity : AppCompatActivity() {
         }
     }
 
-    var storageRegister = registerForActivityResult(ActivityResultContracts.RequestPermission()) {
-        if (it) {
-            Log.i(TAG, "Storage Permission Granted")
-        } else {
-            Log.e(TAG, "Storage Permission Denied")
-        }
-    }
-
     override fun onCreate(savedInstanceState: Bundle?) {
         Log.i(TAG, "onCreate")
         super.onCreate(savedInstanceState)
@@ -85,9 +77,7 @@ class MainActivity : AppCompatActivity() {
                     return@launch
                 }
 
-                //request system_alert permission
                 withContext(Dispatchers.Main) {
-                    storageRegister.launch(android.Manifest.permission.WRITE_EXTERNAL_STORAGE)
                     requestAccessibilityPermission()
                 }
             }

+ 2 - 5
app/src/main/java/com/example/modifier/repo/BackupRepository.kt

@@ -43,7 +43,7 @@ class BackupRepository(
     }
 
     suspend fun backup(type: String, sendCount: Int, stock: Int = 0): BackupItem? {
-        if(!ROOT_ACCESS) return null
+        if (!ROOT_ACCESS) return null
         AppStateRepo.instance.updateRuntimeFlags(reqState = ReqState.BACKUP)
         val spoofedSimInfoRepo = SpoofedSimInfoRepo.instance
         clearConv()
@@ -253,10 +253,7 @@ class BackupRepository(
 
         if (success) {
             Log.i(TAG, "restore: success")
-            spoofedSimInfoRepo.updateSpoofedSimInfo(
-                spoofedSimInfo = simInfo.copy(available = true),
-                suspend = false
-            )
+            spoofedSimInfoRepo.updateAvailable(available = true)
             if (backup.stock == 1) {
                 backup.stock = 2
                 dao.update(backup)

+ 89 - 66
app/src/main/java/com/example/modifier/repo/SpoofedSimInfoRepo.kt

@@ -17,6 +17,8 @@ import com.example.modifier.constants.PACKAGE_GMS
 import com.example.modifier.constants.PACKAGE_MESSAGING
 import com.example.modifier.constants.SIMView
 import com.example.modifier.extension.kill
+import com.example.modifier.extension.resume
+import com.example.modifier.extension.suspend
 import com.example.modifier.model.SpoofedSimInfo
 import com.example.modifier.utils.ApduChannel
 import com.example.modifier.utils.ROOT_ACCESS
@@ -133,19 +135,27 @@ class SpoofedSimInfoRepo private constructor(private val context: Context) {
         }
         try {
             if (ROOT_ACCESS) {
-                if (suspend == true) {
-                    suspendPackage(PACKAGE_GMS, PACKAGE_MESSAGING)
-                }
                 shellRun(
-                    "setprop persist.spoof.number ${spoofedSimInfo.number}",
-                    "setprop persist.spoof.mcc ${spoofedSimInfo.mcc}",
-                    "setprop persist.spoof.mnc ${spoofedSimInfo.mnc}",
-                    "setprop persist.spoof.iccid ${spoofedSimInfo.iccid}",
-                    "setprop persist.spoof.imsi ${spoofedSimInfo.imsi}",
-                    "setprop persist.spoof.imei ${spoofedSimInfo.imei}",
-                    "setprop persist.spoof.country ${spoofedSimInfo.country}",
-                    "setprop persist.spoof.carrier.id ${spoofedSimInfo.carrierId}",
-                    "setprop persist.spoof.carrier.name '${spoofedSimInfo.carrierName}'",
+                    *(when {
+                        suspend == true -> arrayOf(
+                            PACKAGE_GMS.suspend(),
+                            "sleep 1",
+                            PACKAGE_MESSAGING.suspend(),
+                            "sleep 1"
+                        )
+
+                        else -> emptyArray()
+                    } + arrayOf(
+                        "setprop persist.spoof.number ${spoofedSimInfo.number}",
+                        "setprop persist.spoof.mcc ${spoofedSimInfo.mcc}",
+                        "setprop persist.spoof.mnc ${spoofedSimInfo.mnc}",
+                        "setprop persist.spoof.iccid ${spoofedSimInfo.iccid}",
+                        "setprop persist.spoof.imsi ${spoofedSimInfo.imsi}",
+                        "setprop persist.spoof.imei ${spoofedSimInfo.imei}",
+                        "setprop persist.spoof.country ${spoofedSimInfo.country}",
+                        "setprop persist.spoof.carrier.id ${spoofedSimInfo.carrierId}",
+                        "setprop persist.spoof.carrier.name '${spoofedSimInfo.carrierName}'",
+                    ))
                 )
 
                 val context = getContext()
@@ -169,80 +179,86 @@ class SpoofedSimInfoRepo private constructor(private val context: Context) {
 
             } else {
                 if (suspend == true) {
-                    suspendPackage(PACKAGE_GMS, PACKAGE_MESSAGING)
                     shellRun(
+                        PACKAGE_GMS.suspend(),
                         PACKAGE_GMS.kill(),
+                        PACKAGE_MESSAGING.suspend(),
                         PACKAGE_MESSAGING.kill()
                     )
+                }
 
+                val plmn = spoofedSimInfo.mcc + spoofedSimInfo.mnc
+                val plmnHex = SimEncoder.encPLMN(spoofedSimInfo.mcc + spoofedSimInfo.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(spoofedSimInfo.iccid))
 
-                    val plmn = spoofedSimInfo.mcc + spoofedSimInfo.mnc
-                    val plmnHex = SimEncoder.encPLMN(spoofedSimInfo.mcc + spoofedSimInfo.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(spoofedSimInfo.iccid))
-
-                    apduChannel.select(SIMView.FID_MF)
-                    apduChannel.select(SIMView.FID_DF_TELECOM)
-                    apduChannel.select(SIMView.FID_EF_MSISDN)
-                    apduChannel.writeRecord(
-                        1, SimEncoder.encMSISDN(spoofedSimInfo.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(spoofedSimInfo.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(spoofedSimInfo.imsi))
+                apduChannel.select(SIMView.FID_MF)
+                apduChannel.select(SIMView.FID_DF_GSM)
+                apduChannel.select(SIMView.FID_EF_IMSI)
+                apduChannel.writeBinary(SimEncoder.encIMSI(spoofedSimInfo.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'))
 
-                    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(spoofedSimInfo.number)
-                    apduChannel.close()
+                val apduChannel1 = ApduChannel(telephonyManager, SIMView.AID_USIM)
+                apduChannel1.writeMSISDN_USIM(spoofedSimInfo.number)
+                apduChannel.close()
 
-                    telephonyManager.rebootModem()
-                    delay(5000)
+                telephonyManager.rebootModem()
+                delay(10000)
 
+                if (suspend == true) {
                     shellRun(
                         PACKAGE_GMS.kill(),
-                        PACKAGE_MESSAGING.kill()
+                        PACKAGE_MESSAGING.kill(),
+                        PACKAGE_GMS.resume(),
+                        "sleep 1",
+                        PACKAGE_MESSAGING.resume(),
+                        "sleep 1",
+                        PACKAGE_MESSAGING.resume(),
+                        "sleep 1"
                     )
-                    delay(1000)
-                    resumePackage(PACKAGE_GMS, PACKAGE_MESSAGING)
                 }
             }
         } catch (e: Exception) {
@@ -250,6 +266,12 @@ class SpoofedSimInfoRepo private constructor(private val context: Context) {
         }
     }
 
+    suspend fun updateAvailable(available: Boolean) {
+        context.simInfoDataStore.edit {
+            it[PreferencesKeys.AVAILABLE] = available
+        }
+    }
+
     suspend fun mock() {
         if (isOldVersion(context)) {
             val content = getContext().assets.open("us_numbers.txt").bufferedReader().use {
@@ -275,7 +297,8 @@ class SpoofedSimInfoRepo private constructor(private val context: Context) {
                             available = false,
                             carrierId = "1779",
                             carrierName = "Cricket Wireless"
-                        )
+                        ),
+                        suspend = false
                     )
                 }
         } else {

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

@@ -93,7 +93,7 @@ class ModifierService : AccessibilityService() {
     private lateinit var uiContext: Context
 
     override fun onAccessibilityEvent(event: AccessibilityEvent) {
-        Log.w(TAG, "AccessibilityEvent: type=${event.eventType} text=${event.text}")
+//        Log.w(TAG, "AccessibilityEvent: type=${event.eventType} text=${event.text}")
         if (event.eventType == AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED) {
             if (event.text.any { it.contains("允许 USB 调试吗?") || it.contains("Allow USB debugging?") }) {
                 CoroutineScope(Dispatchers.IO).launch {

+ 17 - 13
app/src/main/java/com/example/modifier/service/TaskRunner.kt

@@ -279,13 +279,25 @@ class TaskRunner(
                         )
                         switchAppear = gmsgStateRepo.waitForRcsState(
                             arrayOf(RcsConfigureState.WAITING_FOR_TOS),
-                            5.minutes
+                            3.minutes
                         )?.let {
                             it == RcsConfigureState.WAITING_FOR_TOS
                         }
                         if (switchAppear != true) {
-                            Log.e(TAG, "RCS not entered default on state, retrying...")
-                            continue
+                            shellRun(
+                                PACKAGE_GMS.kill(), PACKAGE_MESSAGING.kill(), "sleep 1",
+                                CMD_MESSAGING_APP
+                            )
+                            switchAppear = gmsgStateRepo.waitForRcsState(
+                                arrayOf(RcsConfigureState.WAITING_FOR_TOS),
+                                2.minutes
+                            )?.let {
+                                it == RcsConfigureState.WAITING_FOR_TOS
+                            }
+                            if (switchAppear != true) {
+                                Log.e(TAG, "RCS not entered default on state, retrying...")
+                                continue
+                            }
                         }
                     }
                     if (!screenController.toggleRcsSwitch(false)) {
@@ -566,10 +578,7 @@ class TaskRunner(
             false
         }
         if (requestSuccess == true) {
-            spoofedSimInfoRepo.updateSpoofedSimInfo(
-                spoofedSimInfo = spoofedSimInfoRepo.spoofedSimInfo.value.copy(available = true),
-                suspend = false
-            )
+            spoofedSimInfoRepo.updateAvailable(available = true)
             appStateRepo.resetSuccessNum()
             appStateRepo.resetExecutedNum()
             Log.i(TAG, "requestNumber success")
@@ -762,12 +771,7 @@ class TaskRunner(
                             reset()
                         }
                         requestNumberAtomic(store = true)
-                        spoofedSimInfoRepo.updateSpoofedSimInfo(
-                            spoofedSimInfo = spoofedSimInfoRepo.spoofedSimInfo.value.copy(
-                                available = true
-                            ),
-                            suspend = false
-                        )
+                        spoofedSimInfoRepo.updateAvailable(available = true)
                         screenController.toggleRcsSwitch(false)
                         backupRepository.backup(type = "auto", sendCount = 0, stock = 1)
                         RcsNumberApi.updateStockFlag(

+ 1 - 4
app/src/main/java/com/example/modifier/ui/utils/UtilsFragment.kt

@@ -100,10 +100,7 @@ class UtilsFragment : Fragment() {
                 val otp = binding.etOtp.text.toString()
                 withContext(Dispatchers.IO) {
                     injectOTP(otp)
-                    spoofedSimInfoRepo.updateSpoofedSimInfo(
-                        spoofedSimInfo = spoofedSimInfoRepo.spoofedSimInfo.value.copy(available = true),
-                        suspend = false
-                    )
+                    spoofedSimInfoRepo.updateAvailable(available = true)
                     appStateRepo.resetSuccessNum()
                     appStateRepo.resetExecutedNum()
                 }

+ 3 - 0
app/src/main/java/com/example/modifier/utils/ADB.kt

@@ -89,6 +89,9 @@ class ADB {
                 }
                 process.outputStream.bufferedWriter().use { writer ->
                     commands.forEach { command ->
+                        writer.write("echo '>$command'")
+                        writer.newLine()
+                        writer.flush()
                         writer.write(command)
                         writer.newLine()
                         writer.flush()

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

@@ -99,10 +99,9 @@ suspend fun resetAll() {
     try {
         clearConv()
         shellRun(
-            PACKAGE_MESSAGING.suspend(),
-            PACKAGE_MESSAGING.kill(),
-            PACKAGE_MESSAGING.clear(),
+            "settings put secure location_mode 0",
             PACKAGE_GSF.clear(),
+            "sleep 1",
             PACKAGE_GMS.clear(),
             "sleep 1",
             CMD_START_PLAY_STORE,
@@ -111,7 +110,6 @@ suspend fun resetAll() {
             "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",
@@ -139,8 +137,10 @@ suspend fun resetAll() {
             "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(),
+            PACKAGE_MESSAGING.clear(),
+            "sleep 3",
+            CMD_MESSAGING_APP,
+            "sleep 3",
             CMD_MESSAGING_APP
         )
     } catch (e: Exception) {