|
@@ -5,24 +5,28 @@ import android.accessibilityservice.GestureDescription
|
|
|
import android.content.Intent
|
|
import android.content.Intent
|
|
|
import android.graphics.Path
|
|
import android.graphics.Path
|
|
|
import android.graphics.Rect
|
|
import android.graphics.Rect
|
|
|
|
|
+import android.net.Uri
|
|
|
import android.provider.Settings
|
|
import android.provider.Settings
|
|
|
import android.util.Log
|
|
import android.util.Log
|
|
|
import android.view.accessibility.AccessibilityNodeInfo
|
|
import android.view.accessibility.AccessibilityNodeInfo
|
|
|
import androidx.core.content.ContextCompat
|
|
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.R
|
|
|
import com.example.modifier.TraverseResult
|
|
import com.example.modifier.TraverseResult
|
|
|
import com.example.modifier.constants.CMD_BACK
|
|
import com.example.modifier.constants.CMD_BACK
|
|
|
import com.example.modifier.constants.CMD_RCS_SETTINGS_ACTIVITY
|
|
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.currentActivity
|
|
|
import com.example.modifier.utils.findAllScrollable
|
|
import com.example.modifier.utils.findAllScrollable
|
|
|
import com.example.modifier.utils.findById
|
|
import com.example.modifier.utils.findById
|
|
|
import com.example.modifier.utils.findByText
|
|
import com.example.modifier.utils.findByText
|
|
|
import com.example.modifier.utils.findFirstByDesc
|
|
import com.example.modifier.utils.findFirstByDesc
|
|
|
import com.example.modifier.utils.findFirstByIdAndText
|
|
import com.example.modifier.utils.findFirstByIdAndText
|
|
|
|
|
+import com.example.modifier.utils.getContext
|
|
|
import com.example.modifier.utils.shellRun
|
|
import com.example.modifier.utils.shellRun
|
|
|
-import kotlinx.coroutines.Dispatchers
|
|
|
|
|
|
|
+import com.example.modifier.utils.smsIntent
|
|
|
import kotlinx.coroutines.delay
|
|
import kotlinx.coroutines.delay
|
|
|
-import kotlinx.coroutines.withContext
|
|
|
|
|
import kotlinx.coroutines.withTimeoutOrNull
|
|
import kotlinx.coroutines.withTimeoutOrNull
|
|
|
|
|
|
|
|
class ScreenController(val context: AccessibilityService, private val inspector: ScreenInspector) {
|
|
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)
|
|
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")
|
|
val more = context.rootInActiveWindow.findFirstByDesc("More")
|
|
|
if (more == null) {
|
|
if (more == null) {
|
|
|
- Log.e(TAG, "not found More")
|
|
|
|
|
|
|
+ Log.e(TAG, "leaveGroup: not found More")
|
|
|
return false
|
|
return false
|
|
|
}
|
|
}
|
|
|
more.parent.performAction(AccessibilityNodeInfo.ACTION_CLICK)
|
|
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")
|
|
val groupDetails = context.rootInActiveWindow.findByText("Group details")
|
|
|
if (groupDetails == null) {
|
|
if (groupDetails == null) {
|
|
|
inspector.traverseNode(TraverseResult(), true)
|
|
inspector.traverseNode(TraverseResult(), true)
|
|
|
- Log.e(TAG, "not found Group details")
|
|
|
|
|
|
|
+ Log.e(TAG, "leaveGroup: not found Group details")
|
|
|
return false
|
|
return false
|
|
|
}
|
|
}
|
|
|
groupDetails.performAction(AccessibilityNodeInfo.ACTION_CLICK)
|
|
groupDetails.performAction(AccessibilityNodeInfo.ACTION_CLICK)
|
|
@@ -237,7 +289,7 @@ class ScreenController(val context: AccessibilityService, private val inspector:
|
|
|
delay(500)
|
|
delay(500)
|
|
|
val leave = context.rootInActiveWindow.findById("Leave group")
|
|
val leave = context.rootInActiveWindow.findById("Leave group")
|
|
|
if (leave == null) {
|
|
if (leave == null) {
|
|
|
- Log.e(TAG, "not found Leave group")
|
|
|
|
|
|
|
+ Log.e(TAG, "leaveGroup: not found Leave group")
|
|
|
return false
|
|
return false
|
|
|
}
|
|
}
|
|
|
leave.performAction(AccessibilityNodeInfo.ACTION_CLICK)
|
|
leave.performAction(AccessibilityNodeInfo.ACTION_CLICK)
|
|
@@ -247,7 +299,7 @@ class ScreenController(val context: AccessibilityService, private val inspector:
|
|
|
Log.e(TAG, "not found OK")
|
|
Log.e(TAG, "not found OK")
|
|
|
return false
|
|
return false
|
|
|
}
|
|
}
|
|
|
- Log.i(TAG, "groupDetails: click OK")
|
|
|
|
|
|
|
+ Log.i(TAG, "leaveGroup: click OK")
|
|
|
ok.parent.performAction(AccessibilityNodeInfo.ACTION_CLICK)
|
|
ok.parent.performAction(AccessibilityNodeInfo.ACTION_CLICK)
|
|
|
return true
|
|
return true
|
|
|
}
|
|
}
|