xiongzhu 10 달 전
부모
커밋
b281fc94dc
2개의 변경된 파일10개의 추가작업 그리고 29개의 파일을 삭제
  1. 9 5
      app/src/main/java/com/example/modifier/service/TaskRunner.kt
  2. 1 24
      app/src/main/java/com/example/modifier/utils/System.kt

+ 9 - 5
app/src/main/java/com/example/modifier/service/TaskRunner.kt

@@ -257,7 +257,7 @@ class TaskRunner(
         }
     }
 
-    suspend fun reset() {
+    suspend fun reset(mock: Boolean = true) {
         val context = getContext()
         val dir = ContextCompat.getExternalCacheDirs(context)[0]
 //        val pifPath = File(dir, "pif1.json").path
@@ -269,7 +269,9 @@ class TaskRunner(
                     delay(100)
                     appStateRepo.updateRuntimeFlags(reqState = ReqState.RESET)
                     gmsgStateRepo.updateRcsState(RcsConfigureState.NOT_CONFIGURED)
-                    spoofedInfoRepo.mock()
+                    if (mock) {
+                        spoofedInfoRepo.mock()
+                    }
                     resetAll()
                     var switchAppear = gmsgStateRepo.waitForRcsState(
                         arrayOf(RcsConfigureState.WAITING_FOR_TOS),
@@ -399,7 +401,7 @@ class TaskRunner(
 //        shellRun("rm /data/adb/pif.json")
     }
 
-    private suspend fun requestNumberAtomic(store: Boolean? = false) {
+    private suspend fun requestNumberAtomic(store: Boolean? = false, reset: Boolean = false) {
         appStateRepo.updateRuntimeFlags(reqState = ReqState.REQUEST)
         gmsgStateRepo.updateRcsState(RcsConfigureState.NOT_CONFIGURED)
         val device = DeviceApi.getDevice(appPrefsRepo.appPrefs.value.id)
@@ -464,6 +466,9 @@ class TaskRunner(
         if (sendOtpTimeout > 2.minutes) {
             sendOtpTimeout = 2.minutes
         }
+        if (reset) {
+            reset()
+        }
         if (gmsgStateRepo.waitForRcsState(
                 arrayOf(RcsConfigureState.WAITING_FOR_OTP),
                 sendOtpTimeout
@@ -573,12 +578,11 @@ class TaskRunner(
 
                     needRest = needRest || appStateRepo.appState.value.requestedNum >= 5
                     if (needRest && !appPrefsRepo.appPrefs.value.preventReset) {
-                        reset()
                         needRest = false
                     }
 
                     appStateRepo.incrementRequestedNum()
-                    requestNumberAtomic()
+                    requestNumberAtomic(reset = needRest)
                     return@withTimeoutOrNull true
                 } catch (e: Exception) {
                     if (e is RequestNumberException) {

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

@@ -229,30 +229,7 @@ suspend fun killPhoneProcess(force: Boolean = false): Boolean {
                 return true
             }
         }
-        run kill@{
-            repeat(3) {
-                val pid = shellRun("pidof com.android.phone").first.trim()
-                if (!Regex("[0-9]+").matches(pid)) {
-                    Log.e(systemTag, "killPhoneProcess: pid not found")
-                    return true
-                }
-                Log.i(systemTag, "killPhoneProcess: pid=$pid")
-                shellRun("kill -9 $pid")
-                delay(1000)
-
-                val pidNew = shellRun("pidof com.android.phone").first.trim()
-                if (pidNew == pid) {
-                    Log.e(
-                        systemTag,
-                        "killPhoneProcess: failed to kill phone process"
-                    )
-                } else {
-                    Log.i(systemTag, "killPhoneProcess: success, new pid: $pidNew")
-                    shellRun("kill -9 $pid", "setprop phonekilled yes")
-                    return true
-                }
-            }
-        }
+        shellRun("kill -9 $(pidof com.android.phone)")
     } catch (e: Exception) {
         Log.e(systemTag, "Error Kill Phone", e)
     }