xiongzhu há 10 meses atrás
pai
commit
391dab0495

+ 5 - 3
app/src/main/java/com/example/modifier/data/AppState.kt

@@ -4,8 +4,10 @@ import com.example.modifier.enums.ReqState
 
 data class AppState(
     val send: Boolean,
-    val executedNum: Int,
-    val successNum: Int,
+    val singleExecuted: Int,
+    val singleSuccess: Int,
+    val groupExecuted: Int,
+    val groupSuccess: Int,
     val requestedNum: Int,
     val running: Boolean,
     val preparing: Boolean,
@@ -13,7 +15,7 @@ data class AppState(
     val suspended: Boolean,
     val reqState: ReqState,
     val storing: Boolean = false,
-    val failure:Int = 0
+    val failure: Int = 0
 ) {
 
     val busy: Boolean

+ 33 - 4
app/src/main/java/com/example/modifier/repo/AppStateRepo.kt

@@ -31,13 +31,17 @@ class AppStateRepo private constructor(private val context: Context) {
         val EXECUTED_NUM = intPreferencesKey("executed_num")
         val SUCCESS_NUM = intPreferencesKey("success_num")
         val REQUESTED_NUM = intPreferencesKey("requested_num")
+        val GROUP_EXECUTED_NUM = intPreferencesKey("group_executed_num")
+        val GROUP_SUCCESS_NUM = intPreferencesKey("group_success_num")
     }
 
     val appState = MutableStateFlow(
         AppState(
             send = false,
-            executedNum = 0,
-            successNum = 0,
+            singleExecuted = 0,
+            singleSuccess = 0,
+            groupExecuted = 0,
+            groupSuccess = 0,
             requestedNum = 0,
             running = false,
             preparing = false,
@@ -53,8 +57,10 @@ class AppStateRepo private constructor(private val context: Context) {
                 appState.update {
                     it.copy(
                         send = preferences[PreferencesKeys.SEND] ?: false,
-                        executedNum = preferences[PreferencesKeys.EXECUTED_NUM] ?: 0,
-                        successNum = preferences[PreferencesKeys.SUCCESS_NUM] ?: 0,
+                        singleExecuted = preferences[PreferencesKeys.EXECUTED_NUM] ?: 0,
+                        singleSuccess = preferences[PreferencesKeys.SUCCESS_NUM] ?: 0,
+                        groupExecuted = preferences[PreferencesKeys.GROUP_EXECUTED_NUM] ?: 0,
+                        groupSuccess = preferences[PreferencesKeys.GROUP_SUCCESS_NUM] ?: 0,
                         requestedNum = preferences[PreferencesKeys.REQUESTED_NUM] ?: 0
                     )
                 }
@@ -73,6 +79,17 @@ class AppStateRepo private constructor(private val context: Context) {
         }
     }
 
+    suspend fun incrementGroupExecutedNum(num: Int = 1, success: Boolean) {
+        context.appStateDataStore.edit { preferences ->
+            val executedNum = (preferences[PreferencesKeys.GROUP_EXECUTED_NUM] ?: 0) + num
+            preferences[PreferencesKeys.GROUP_EXECUTED_NUM] = executedNum
+            if (success) {
+                val successNum = (preferences[PreferencesKeys.GROUP_SUCCESS_NUM] ?: 0) + num
+                preferences[PreferencesKeys.GROUP_SUCCESS_NUM] = successNum
+            }
+        }
+    }
+
     suspend fun incrementRequestedNum() {
         context.appStateDataStore.edit { preferences ->
             val requestedNum = (preferences[PreferencesKeys.REQUESTED_NUM] ?: 0) + 1
@@ -101,6 +118,18 @@ class AppStateRepo private constructor(private val context: Context) {
         }
     }
 
+    suspend fun resetGroupExecutedNum() {
+        context.appStateDataStore.edit { preferences ->
+            preferences[PreferencesKeys.GROUP_EXECUTED_NUM] = 0
+        }
+    }
+
+    suspend fun resetGroupSuccessNum() {
+        context.appStateDataStore.edit { preferences ->
+            preferences[PreferencesKeys.GROUP_SUCCESS_NUM] = 0
+        }
+    }
+
     suspend fun resetRequestedNum() {
         context.appStateDataStore.edit { preferences ->
             preferences[PreferencesKeys.REQUESTED_NUM] = 0

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

@@ -127,7 +127,7 @@ class ModifierService : AccessibilityService() {
                     withContext(Dispatchers.Main) {
                         binding.swSend.isChecked = it.send
                         binding.btnReq.isEnabled = it.reqState == ReqState.NONE
-                        binding.tvCount.text = "${it.successNum} / ${it.executedNum}"
+                        binding.tvCount.text = "${it.singleSuccess} / ${it.singleExecuted}"
                         if (it.suspended) {
                             binding.btnReq.backgroundTintList = ContextCompat.getColorStateList(
                                 binding.root.context,

+ 6 - 19
app/src/main/java/com/example/modifier/service/ScreenController.kt

@@ -222,7 +222,7 @@ class ScreenController(val context: AccessibilityService, private val inspector:
         node.parent.performAction(AccessibilityNodeInfo.ACTION_CLICK)
     }
 
-    suspend fun createGroup(numbers: Array<String>) {
+    suspend fun createGroup(numbers: Array<String>):Boolean {
         val intent = Intent(Intent.ACTION_SENDTO)
         intent.data = Uri.parse("sms:")
         intent.putExtra("exit_on_sent", true)
@@ -233,7 +233,7 @@ class ScreenController(val context: AccessibilityService, private val inspector:
         val createGroup = context.rootInActiveWindow.findByText("Create group")
         if (createGroup == null) {
             Log.e(TAG, "not found Create group")
-            return
+            return false
         }
         createGroup.parent.performAction(AccessibilityNodeInfo.ACTION_CLICK)
         delay(500)
@@ -243,31 +243,18 @@ class ScreenController(val context: AccessibilityService, private val inspector:
         val next = context.rootInActiveWindow.findByText("Next")
         if (next == null) {
             Log.e(TAG, "not found Next")
-            return
+            return false
         }
         next.parent.performAction(AccessibilityNodeInfo.ACTION_CLICK)
         delay(500)
         val done = context.rootInActiveWindow.findByText("Done")
         if (done == null) {
             Log.e(TAG, "not found Done")
-            return
+            return false
         }
         done.parent.performAction(AccessibilityNodeInfo.ACTION_CLICK)
-        val res = TraverseResult()
-        withTimeoutOrNull(5000) {
-            while (true) {
-                inspector.traverseNode(res)
-                if (res.isRcsCapable) {
-                    return@withTimeoutOrNull
-                }
-                delay(500)
-            }
-        }
-        if (res.isRcsCapable) {
-            Log.i(TAG, "createGroup: RCS capable")
-        } else {
-            Log.e(TAG, "createGroup: not RCS capable")
-        }
+
+        return true
     }
 
     suspend fun leaveGroup(): Boolean {

+ 23 - 11
app/src/main/java/com/example/modifier/service/TaskRunner.kt

@@ -1,7 +1,6 @@
 package com.example.modifier.service
 
 import android.content.Context
-import android.os.Build
 import android.os.Environment
 import android.util.Log
 import android.view.accessibility.AccessibilityNodeInfo
@@ -14,7 +13,6 @@ import com.example.modifier.constants.CMD_BACK
 import com.example.modifier.constants.CMD_CONVERSATION_LIST_ACTIVITY
 import com.example.modifier.constants.CMD_MESSAGING_APP
 import com.example.modifier.constants.CMD_RCS_SETTINGS_ACTIVITY
-import com.example.modifier.constants.PACKAGE_CLEAN_SMS
 import com.example.modifier.constants.PACKAGE_GMS
 import com.example.modifier.constants.PACKAGE_MESSAGING
 import com.example.modifier.enums.RcsConfigureState
@@ -31,7 +29,6 @@ import com.example.modifier.http.ktorClient
 import com.example.modifier.http.response.SysConfigResponse
 import com.example.modifier.model.InstallApkAction
 import com.example.modifier.model.RunScriptAction
-import com.example.modifier.model.SpoofedInfo
 import com.example.modifier.model.TaskAction
 import com.example.modifier.model.TaskConfig
 import com.example.modifier.model.TaskExecutionResult
@@ -47,7 +44,6 @@ import com.example.modifier.utils.genICCID
 import com.example.modifier.utils.genIMEI
 import com.example.modifier.utils.genIMSI
 import com.example.modifier.utils.genMacAddress
-import com.example.modifier.utils.genSerialNo
 import com.example.modifier.utils.getContext
 import com.example.modifier.utils.isOldVersion
 import com.example.modifier.utils.resetAll
@@ -173,7 +169,7 @@ class TaskRunner(
             )
             Log.i(
                 TAG,
-                "executedNum: ${appStateRepo.appState.value.executedNum}, successNum: ${appStateRepo.appState.value.successNum}"
+                "executedNum: ${appStateRepo.appState.value.singleExecuted}, successNum: ${appStateRepo.appState.value.singleSuccess}"
             )
             delay(2000)
             return success
@@ -183,6 +179,22 @@ class TaskRunner(
         return false
     }
 
+    suspend fun groupSend(
+        to: Array<String>,
+        body: String?,
+        img: String?,
+        taskConfig: TaskConfig
+    ): Boolean {
+        if (img?.isNotBlank() == true) return false
+        if (!screenController.createGroup(to)) {
+            appStateRepo.incrementGroupExecutedNum(1, false)
+            return false
+        }
+        val res = TraverseResult()
+
+        return false
+    }
+
     suspend fun runTask(
         taskAction: TaskAction,
         onSuccess: (List<TaskExecutionResult>) -> Unit,
@@ -199,7 +211,7 @@ class TaskRunner(
             requestMode = if (taskAction.data.config.useBackup) 2 else 1
 
             if (!spoofedInfoRepo.spoofedInfo.value.available ||
-                (taskAction.data.config.checkConnection && appStateRepo.appState.value.executedNum == 0)
+                (taskAction.data.config.checkConnection && appStateRepo.appState.value.singleExecuted == 0)
             ) {
                 appStateRepo.updateRuntimeFlags(checkingConnection = true)
                 if (!spoofedInfoRepo.spoofedInfo.value.available || !checkRcsA10y()) {
@@ -234,10 +246,10 @@ class TaskRunner(
             shellRun(CMD_BACK)
             delay(5000)
             onSuccess(results)
-            if (taskConfig.singleQty in 1..appStateRepo.appState.value.successNum) {
+            if (taskConfig.singleQty in 1..appStateRepo.appState.value.singleSuccess) {
                 delay(3000)
                 requestNumberOnTask()
-            } else if (taskConfig.cleanCount in 1..appStateRepo.appState.value.executedNum && !appPrefsRepo.appPrefs.value.preventClean) {
+            } else if (taskConfig.cleanCount in 1..appStateRepo.appState.value.singleExecuted && !appPrefsRepo.appPrefs.value.preventClean) {
                 delay(3000)
                 clearConv();
                 shellRun(CMD_MESSAGING_APP)
@@ -555,7 +567,7 @@ class TaskRunner(
         if (spoofedInfoRepo.spoofedInfo.value.available) {
             backupRepository.backup(
                 type = "auto",
-                sendCount = appStateRepo.appState.value.successNum
+                sendCount = appStateRepo.appState.value.singleSuccess
             )
         }
 
@@ -782,11 +794,11 @@ class TaskRunner(
         storeNumberJob = CoroutineScope(coroutineContext).launch {
             try {
                 appStateRepo.updateRuntimeFlags(storing = true)
-                if (spoofedInfoRepo.spoofedInfo.value.available && appStateRepo.appState.value.successNum <= 5) {
+                if (spoofedInfoRepo.spoofedInfo.value.available && appStateRepo.appState.value.singleSuccess <= 5) {
                     screenController.toggleRcsSwitch(false)
                     backupRepository.backup(
                         type = "auto",
-                        sendCount = appStateRepo.appState.value.successNum,
+                        sendCount = appStateRepo.appState.value.singleSuccess,
                         stock = 1
                     )
                     screenController.toggleRcsSwitch(true)