xiongzhu 11 miesięcy temu
rodzic
commit
70ba874843

+ 1 - 1
app/build.gradle

@@ -22,7 +22,7 @@ android {
     }
     defaultConfig {
         applicationId "com.example.modifier"
-        minSdk 33
+        minSdk 31
         targetSdk 34
         versionCode 167
         versionName "1.0.1"

+ 38 - 5
app/src/main/java/com/example/modifier/MainActivity.kt

@@ -14,13 +14,15 @@ import androidx.appcompat.app.AppCompatActivity
 import androidx.navigation.fragment.NavHostFragment
 import androidx.navigation.ui.NavigationUI.setupWithNavController
 import com.example.modifier.databinding.ActivityMainBinding
+import com.example.modifier.databinding.DialogProgressBinding
+import com.example.modifier.databinding.DialogUpdateBinding
 import com.example.modifier.service.ModifierService
+import com.example.modifier.utils.ADB
 import com.example.modifier.utils.ROOT_ACCESS
 import com.example.modifier.utils.enableAccessibility
 import com.example.modifier.utils.enableOverlay
 import com.example.modifier.utils.getIPAddress
 import com.example.modifier.utils.hasRootAccess
-import com.example.modifier.utils.syncTime
 import com.google.android.material.dialog.MaterialAlertDialogBuilder
 import kotlinx.coroutines.CoroutineScope
 import kotlinx.coroutines.Dispatchers
@@ -74,13 +76,44 @@ class MainActivity : AppCompatActivity() {
                 }
                 enableOverlay()
             } else {
-                if (ModifierService.instance != null) {
-                    return@launch
+                val dialog = withContext(Dispatchers.Main) {
+                    val dialogBinding = DialogProgressBinding.inflate(layoutInflater)
+                    dialogBinding.progressDialogText.text = "Waiting for ADB connection"
+                    MaterialAlertDialogBuilder(this@MainActivity)
+                        .setView(dialogBinding.root)
+                        .setCancelable(false)
+                        .show()
                 }
 
-                withContext(Dispatchers.Main) {
-                    requestAccessibilityPermission()
+                if (ADB.connect()) {
+                    dialog.dismiss()
+                    if (!enableAccessibility()) {
+                        val intent = Intent(Settings.ACTION_ACCESSIBILITY_SETTINGS)
+                        intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
+                        startActivity(intent)
+                        delay(1000);
+                        finish();
+                    }
+                } else {
+                    dialog.dismiss()
+                    withContext(Dispatchers.Main) {
+                        MaterialAlertDialogBuilder(this@MainActivity)
+                            .setTitle("Error")
+                            .setMessage("Failed to connect to ADB")
+                            .setCancelable(false)
+                            .setPositiveButton("Exit") { _, _ ->
+                                finish()
+                            }
+                            .show()
+                    }
                 }
+//                if (ModifierService.instance != null) {
+//                    return@launch
+//                }
+//
+//                withContext(Dispatchers.Main) {
+//                    requestAccessibilityPermission()
+//                }
             }
             Log.i("getIPAddress", getIPAddress().joinToString())
         }

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

@@ -1,12 +1,12 @@
 package com.example.modifier.extension
 
-fun String.suspend(): String {
-    return "pm suspend $this"
-}
-
-fun String.resume(): String {
-    return "pm unsuspend $this"
-}
+//fun String.suspend(): String {
+//    return "pm suspend $this"
+//}
+//
+//fun String.resume(): String {
+//    return "pm unsuspend $this"
+//}
 
 fun String.clear(): String {
     return "pm clear $this"

+ 34 - 19
app/src/main/java/com/example/modifier/repo/SpoofedSimInfoRepo.kt

@@ -3,6 +3,7 @@ package com.example.modifier.repo
 import android.Manifest
 import android.annotation.SuppressLint
 import android.content.Context
+import android.os.Build
 import android.telephony.SubscriptionManager
 import android.telephony.TelephonyManager
 import android.util.Log
@@ -17,8 +18,6 @@ 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
@@ -29,9 +28,7 @@ import com.example.modifier.utils.genIMSI
 import com.example.modifier.utils.getContext
 import com.example.modifier.utils.hasPermission
 import com.example.modifier.utils.isOldVersion
-import com.example.modifier.utils.resumePackage
 import com.example.modifier.utils.shellRun
-import com.example.modifier.utils.suspendPackage
 import kotlinx.coroutines.CoroutineScope
 import kotlinx.coroutines.Dispatchers
 import kotlinx.coroutines.delay
@@ -138,10 +135,8 @@ class SpoofedSimInfoRepo private constructor(private val context: Context) {
                 shellRun(
                     *(when {
                         suspend == true -> arrayOf(
-                            PACKAGE_GMS.suspend(),
-                            "sleep 1",
-                            PACKAGE_MESSAGING.suspend(),
-                            "sleep 1"
+                            PACKAGE_GMS.kill(),
+                            PACKAGE_MESSAGING.kill(),
                         )
 
                         else -> emptyArray()
@@ -174,15 +169,16 @@ class SpoofedSimInfoRepo private constructor(private val context: Context) {
                     }
                 }
                 if (suspend == true) {
-                    resumePackage(PACKAGE_GMS, PACKAGE_MESSAGING)
+                    shellRun(
+                        PACKAGE_GMS.kill(),
+                        PACKAGE_MESSAGING.kill()
+                    )
                 }
 
             } else {
                 if (suspend == true) {
                     shellRun(
-                        PACKAGE_GMS.suspend(),
                         PACKAGE_GMS.kill(),
-                        PACKAGE_MESSAGING.suspend(),
                         PACKAGE_MESSAGING.kill()
                     )
                 }
@@ -248,19 +244,38 @@ class SpoofedSimInfoRepo private constructor(private val context: Context) {
                 apduChannel1.writeMSISDN_USIM(spoofedSimInfo.number)
                 apduChannel.close()
 
-                telephonyManager.rebootModem()
-                delay(10000)
+                if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
+                    telephonyManager.rebootModem()
+                }
+
+                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:${spoofedSimInfo.iccid}")
+                                if (it.iccId == spoofedSimInfo.iccid) {
+                                    Log.i(TAG, "rebootModem: success")
+                                    return@rebootModem
+                                }
+                            }
+                        }.onFailure {
+                            Log.e(TAG, "Error reading ICCID: ${it.message}", it)
+                        }
+                        delay(2000)
+                    }
+                }
 
                 if (suspend == true) {
                     shellRun(
                         PACKAGE_GMS.kill(),
+                        "sleep 3",
                         PACKAGE_MESSAGING.kill(),
-                        PACKAGE_GMS.resume(),
-                        "sleep 1",
-                        PACKAGE_MESSAGING.resume(),
-                        "sleep 1",
-                        PACKAGE_MESSAGING.resume(),
-                        "sleep 1"
+                        "sleep 3"
                     )
                 }
             }

+ 0 - 54
app/src/main/java/com/example/modifier/ui/utils/UtilsFragment.kt

@@ -43,10 +43,8 @@ import com.example.modifier.utils.clear
 import com.example.modifier.utils.clearConv
 import com.example.modifier.utils.killPhoneProcess
 import com.example.modifier.utils.resetAll
-import com.example.modifier.utils.resumePackage
 import com.example.modifier.utils.shellRun
 import com.example.modifier.utils.injectOTP
-import com.example.modifier.utils.suspendPackage
 import com.example.modifier.utils.syncTime
 import com.google.android.material.dialog.MaterialAlertDialogBuilder
 import io.ktor.client.call.body
@@ -133,58 +131,6 @@ class UtilsFragment : Fragment() {
             }
         }
 
-        binding.btnSuspend.setOnClickListener {
-            binding.btnSuspend.isEnabled = false
-            Utils.makeLoadingButton(context, binding.btnSuspend)
-            lifecycleScope.launch {
-
-                val packages = mutableListOf<String>()
-                if (binding.cbGsf.isChecked) {
-                    packages.add(PACKAGE_GSF)
-                }
-                if (binding.cbGms.isChecked) {
-                    packages.add(PACKAGE_GMS)
-                }
-                if (binding.cbSms.isChecked) {
-                    packages.add(PACKAGE_MESSAGING)
-                }
-                withContext(Dispatchers.IO) {
-                    suspendPackage(*packages.toTypedArray())
-                }
-                binding.btnSuspend.setIconResource(R.drawable.ic_done)
-                binding.btnSuspend.text = "OK"
-                delay(1500)
-                binding.btnSuspend.isEnabled = true
-                binding.btnSuspend.icon = null
-                binding.btnSuspend.text = "Suspend"
-            }
-        }
-        binding.btnUnsuspend.setOnClickListener {
-            binding.btnUnsuspend.isEnabled = false
-            Utils.makeLoadingButton(context, binding.btnUnsuspend)
-            lifecycleScope.launch {
-                val packages = mutableListOf<String>()
-                if (binding.cbGsf.isChecked) {
-                    packages.add(PACKAGE_GSF)
-                }
-                if (binding.cbGms.isChecked) {
-                    packages.add(PACKAGE_GMS)
-                }
-                if (binding.cbSms.isChecked) {
-                    packages.add(PACKAGE_MESSAGING)
-                }
-                withContext(Dispatchers.IO) {
-                    resumePackage(*packages.toTypedArray())
-                }
-                binding.btnUnsuspend.setIconResource(R.drawable.ic_done)
-                binding.btnUnsuspend.text = "OK"
-                delay(1500)
-                binding.btnUnsuspend.isEnabled = true
-                binding.btnUnsuspend.icon = null
-                binding.btnUnsuspend.text = "Unsuspend"
-            }
-        }
-
         binding.btnStartFrida.setOnClickListener {
             lifecycleScope.launch {
                 withContext(Dispatchers.IO) {

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

@@ -19,12 +19,12 @@ class ADB {
             return run ls@{
                 repeat(1000) {
                     adb("connect", "localhost:5555")
-                    delay(5000)
+                    delay(2000)
                     adb("devices")
                     if (adb("shell", "echo", "hello").exitCode == 0) {
                         return@ls true
                     }
-                    delay(3000)
+                    delay(2000)
                 }
                 return@ls false
             }

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

@@ -17,6 +17,7 @@ import com.example.modifier.Utils
 import com.example.modifier.constants.PACKAGE_CLEAN_SMS
 import com.example.modifier.constants.PACKAGE_MESSAGING
 import com.example.modifier.constants.PACKAGE_TELEPHONY
+import com.example.modifier.extension.kill
 import kotlinx.coroutines.Dispatchers
 import kotlinx.coroutines.delay
 import kotlinx.coroutines.withContext
@@ -87,7 +88,7 @@ suspend fun clearConv() {
     try {
         if (ROOT_ACCESS) {
             val sqlite3 = sqlite3path()
-            suspendPackage(PACKAGE_MESSAGING)
+            shellRun(PACKAGE_MESSAGING.kill())
             val dataDir = ContextCompat.getDataDir(context)
             val providerDir = File(dataDir, "telephony_provider/$model")
             if (!providerDir.exists()) {
@@ -121,7 +122,7 @@ suspend fun clearConv() {
                 "$sqlite3 /data/data/$PACKAGE_MESSAGING/databases/bugle_db \"DELETE FROM rcs_remote_capabilities_cache;\"",
                 *cmds.toTypedArray(),
             )
-            resumePackage(PACKAGE_MESSAGING)
+            shellRun(PACKAGE_MESSAGING.kill())
         } else {
             val packageManager = context.packageManager
             try {

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

@@ -1,7 +1,5 @@
 package com.example.modifier.utils
 
-import androidx.core.content.ContextCompat
-import 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
@@ -10,53 +8,20 @@ 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 com.example.modifier.http.api.SysConfigApi
-import com.example.modifier.http.ktorClient
-import com.example.modifier.http.response.SysConfigResponse
-import io.ktor.client.call.body
-import io.ktor.client.plugins.resources.get
-import kotlinx.coroutines.delay
-import java.io.File
-
-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<String> = 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'")
         }
@@ -75,19 +40,6 @@ suspend fun clear(gsf: Boolean, gms: Boolean, sms: Boolean) {
             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<String>())
     } catch (e: Exception) {

+ 1 - 1
app/src/main/java/com/example/modifier/utils/System.kt

@@ -81,7 +81,7 @@ suspend fun hasRootAccess(): Boolean {
     var rootAccess = false
     try {
         val p = withContext(Dispatchers.IO) {
-            ProcessBuilder("su", "-M", "-c", "echo", "imrooted").start()
+            ProcessBuilder("su", "-c", "echo imrooted").start()
         }
         var output = ""
         coroutineScope {

+ 26 - 0
app/src/main/res/layout/dialog_progress.xml

@@ -0,0 +1,26 @@
+<?xml version="1.0" encoding="utf-8"?>
+<layout xmlns:android="http://schemas.android.com/apk/res/android"
+    xmlns:app="http://schemas.android.com/apk/res-auto"
+    xmlns:tools="http://schemas.android.com/tools">
+
+    <LinearLayout
+        android:layout_width="match_parent"
+        android:layout_height="match_parent"
+        android:gravity="start|center"
+        android:orientation="horizontal"
+        android:padding="32dp">
+
+        <com.google.android.material.progressindicator.CircularProgressIndicator
+            android:layout_width="wrap_content"
+            android:layout_height="wrap_content"
+            android:indeterminate="true" />
+
+        <TextView
+            android:id="@+id/progress_dialog_text"
+            android:layout_width="wrap_content"
+            android:layout_height="wrap_content"
+            android:layout_marginLeft="16dp"
+            android:text="Loading"
+            android:textSize="16sp" />
+    </LinearLayout>
+</layout>

+ 0 - 22
app/src/main/res/layout/fragment_utils.xml

@@ -92,28 +92,6 @@
                                 android:layout_weight="1"
                                 android:text="Stop" />
                         </LinearLayout>
-
-                        <LinearLayout
-                            android:layout_width="match_parent"
-                            android:layout_height="wrap_content"
-                            android:layout_marginTop="8dp"
-                            android:orientation="horizontal">
-
-                            <com.google.android.material.button.MaterialButton
-                                android:id="@+id/btn_suspend"
-                                android:layout_width="0dp"
-                                android:layout_height="wrap_content"
-                                android:layout_weight="1"
-                                android:text="Suspend" />
-
-                            <com.google.android.material.button.MaterialButton
-                                android:id="@+id/btn_unsuspend"
-                                android:layout_width="0dp"
-                                android:layout_height="wrap_content"
-                                android:layout_marginLeft="16dp"
-                                android:layout_weight="1"
-                                android:text="Unsuspend" />
-                        </LinearLayout>
                     </LinearLayout>
                 </com.google.android.material.card.MaterialCardView>