xiongzhu 10 hónapja
szülő
commit
4fe7452f05

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

@@ -428,9 +428,23 @@ class ModifierService : AccessibilityService() {
                         }
                     }
 
-                    R.id.group_details -> {
+                    R.id.create_group -> {
                         delay(1500)
-                        screenController.groupDetails()
+                        screenController.createGroup(
+                            arrayOf(
+                                "+17812178092",
+                                "+13206309083",
+                                "+12723059522",
+                                "+17799708239",
+                                "+19852084968",
+                                "+15084960960"
+                            )
+                        )
+                    }
+
+                    R.id.leave_group -> {
+                        delay(1500)
+                        screenController.leaveGroup()
                     }
                 }
             }

+ 59 - 7
app/src/main/java/com/example/modifier/service/ScreenController.kt

@@ -5,24 +5,28 @@ import android.accessibilityservice.GestureDescription
 import android.content.Intent
 import android.graphics.Path
 import android.graphics.Rect
+import android.net.Uri
 import android.provider.Settings
 import android.util.Log
 import android.view.accessibility.AccessibilityNodeInfo
 import androidx.core.content.ContextCompat
+import androidx.core.content.FileProvider.getUriForFile
+import com.example.modifier.BuildConfig
 import com.example.modifier.R
 import com.example.modifier.TraverseResult
 import com.example.modifier.constants.CMD_BACK
 import com.example.modifier.constants.CMD_RCS_SETTINGS_ACTIVITY
+import com.example.modifier.constants.PACKAGE_MESSAGING
 import com.example.modifier.utils.currentActivity
 import com.example.modifier.utils.findAllScrollable
 import com.example.modifier.utils.findById
 import com.example.modifier.utils.findByText
 import com.example.modifier.utils.findFirstByDesc
 import com.example.modifier.utils.findFirstByIdAndText
+import com.example.modifier.utils.getContext
 import com.example.modifier.utils.shellRun
-import kotlinx.coroutines.Dispatchers
+import com.example.modifier.utils.smsIntent
 import kotlinx.coroutines.delay
-import kotlinx.coroutines.withContext
 import kotlinx.coroutines.withTimeoutOrNull
 
 class ScreenController(val context: AccessibilityService, private val inspector: ScreenInspector) {
@@ -218,10 +222,58 @@ class ScreenController(val context: AccessibilityService, private val inspector:
         node.parent.performAction(AccessibilityNodeInfo.ACTION_CLICK)
     }
 
-    suspend fun groupDetails(): Boolean {
+    suspend fun createGroup(numbers: Array<String>) {
+        val intent = Intent(Intent.ACTION_SENDTO)
+        intent.data = Uri.parse("sms:")
+        intent.putExtra("exit_on_sent", true)
+        intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
+        intent.setPackage(PACKAGE_MESSAGING)
+        context.startActivity(intent)
+        delay(1000)
+        val createGroup = context.rootInActiveWindow.findByText("Create group")
+        if (createGroup == null) {
+            Log.e(TAG, "not found Create group")
+            return
+        }
+        createGroup.parent.performAction(AccessibilityNodeInfo.ACTION_CLICK)
+        delay(500)
+        shellRun(*(numbers.flatMap {
+            listOf("input text $it", "input keyevent 66")
+        }).toTypedArray())
+        val next = context.rootInActiveWindow.findByText("Next")
+        if (next == null) {
+            Log.e(TAG, "not found Next")
+            return
+        }
+        next.parent.performAction(AccessibilityNodeInfo.ACTION_CLICK)
+        delay(500)
+        val done = context.rootInActiveWindow.findByText("Done")
+        if (done == null) {
+            Log.e(TAG, "not found Done")
+            return
+        }
+        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")
+        }
+    }
+
+    suspend fun leaveGroup(): Boolean {
         val more = context.rootInActiveWindow.findFirstByDesc("More")
         if (more == null) {
-            Log.e(TAG, "not found More")
+            Log.e(TAG, "leaveGroup: not found More")
             return false
         }
         more.parent.performAction(AccessibilityNodeInfo.ACTION_CLICK)
@@ -229,7 +281,7 @@ class ScreenController(val context: AccessibilityService, private val inspector:
         val groupDetails = context.rootInActiveWindow.findByText("Group details")
         if (groupDetails == null) {
             inspector.traverseNode(TraverseResult(), true)
-            Log.e(TAG, "not found Group details")
+            Log.e(TAG, "leaveGroup: not found Group details")
             return false
         }
         groupDetails.performAction(AccessibilityNodeInfo.ACTION_CLICK)
@@ -237,7 +289,7 @@ class ScreenController(val context: AccessibilityService, private val inspector:
         delay(500)
         val leave = context.rootInActiveWindow.findById("Leave group")
         if (leave == null) {
-            Log.e(TAG, "not found Leave group")
+            Log.e(TAG, "leaveGroup: not found Leave group")
             return false
         }
         leave.performAction(AccessibilityNodeInfo.ACTION_CLICK)
@@ -247,7 +299,7 @@ class ScreenController(val context: AccessibilityService, private val inspector:
             Log.e(TAG, "not found OK")
             return false
         }
-        Log.i(TAG, "groupDetails: click OK")
+        Log.i(TAG, "leaveGroup: click OK")
         ok.parent.performAction(AccessibilityNodeInfo.ACTION_CLICK)
         return true
     }

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

@@ -423,7 +423,7 @@ class TaskRunner(
         appStateRepo.updateRuntimeFlags(reqState = ReqState.OTP_1)
 
         spoofedInfoRepo.updateSpoofedSimInfo(
-            SpoofedInfo(
+            spoofedInfoRepo.spoofedInfo.value.copy(
                 numberId = rcsNumber.id,
                 number = rcsNumber.number,
                 mcc = rcsNumber.mcc,
@@ -445,6 +445,7 @@ class TaskRunner(
                 gmsAid = genAndroidId(),
                 rootAid = genAndroidId(),
             )
+
         )
         val tosAgreeJob = CoroutineScope(coroutineContext).launch {
             run tos@{

+ 7 - 0
app/src/main/java/com/example/modifier/utils/AccessibilityNodeInfo.kt

@@ -107,4 +107,11 @@ fun AccessibilityNodeInfo.findById(id: String): AccessibilityNodeInfo? {
         }
     }
     return null
+}
+
+fun AccessibilityNodeInfo.clickableParent(): AccessibilityNodeInfo? {
+    if (this.isClickable) {
+        return this
+    }
+    return this.parent?.clickableParent()
 }

+ 5 - 2
app/src/main/res/menu/more.xml

@@ -35,6 +35,9 @@
         android:id="@+id/reset_counter"
         android:title="计数清零" />
     <item
-        android:id="@+id/group_details"
-        android:title="group_details" />
+        android:id="@+id/create_group"
+        android:title="建群" />
+    <item
+        android:id="@+id/leave_group"
+        android:title="退群" />
 </menu>