|
|
@@ -16,7 +16,9 @@ import android.view.Gravity
|
|
|
import android.view.LayoutInflater
|
|
|
import android.view.MotionEvent
|
|
|
import android.view.View
|
|
|
+import android.view.View.GONE
|
|
|
import android.view.View.OnTouchListener
|
|
|
+import android.view.View.VISIBLE
|
|
|
import android.view.WindowManager
|
|
|
import android.view.accessibility.AccessibilityEvent
|
|
|
import android.view.accessibility.AccessibilityNodeInfo
|
|
|
@@ -27,6 +29,7 @@ import androidx.appcompat.widget.PopupMenu
|
|
|
import androidx.core.content.ContextCompat
|
|
|
import com.example.modifier.BuildConfig
|
|
|
import com.example.modifier.R
|
|
|
+import com.example.modifier.TAG
|
|
|
import com.example.modifier.TraverseResult
|
|
|
import com.example.modifier.constants.CMD_BACK
|
|
|
import com.example.modifier.constants.CMD_CONVERSATION_LIST_ACTIVITY
|
|
|
@@ -43,6 +46,7 @@ import com.example.modifier.repo.GoogleMessageStateRepository
|
|
|
import com.example.modifier.databinding.FloatingWindowBinding
|
|
|
import com.example.modifier.enums.RcsConfigureState
|
|
|
import com.example.modifier.enums.RcsConnectionStatus
|
|
|
+import com.example.modifier.enums.RequestNumberState
|
|
|
import com.example.modifier.extension.kill
|
|
|
import com.example.modifier.http.api.DeviceApi
|
|
|
import com.example.modifier.http.api.RcsNumberApi
|
|
|
@@ -103,6 +107,7 @@ import io.socket.client.Socket
|
|
|
import io.socket.emitter.Emitter
|
|
|
import kotlinx.coroutines.CoroutineScope
|
|
|
import kotlinx.coroutines.Dispatchers
|
|
|
+import kotlinx.coroutines.coroutineScope
|
|
|
import kotlinx.coroutines.delay
|
|
|
import kotlinx.coroutines.flow.StateFlow
|
|
|
import kotlinx.coroutines.launch
|
|
|
@@ -118,6 +123,7 @@ import java.time.temporal.ChronoUnit
|
|
|
import java.util.Timer
|
|
|
import java.util.TimerTask
|
|
|
import java.util.concurrent.atomic.AtomicReference
|
|
|
+import kotlin.coroutines.coroutineContext
|
|
|
import kotlin.math.max
|
|
|
import kotlin.math.min
|
|
|
import kotlin.time.Duration.Companion.hours
|
|
|
@@ -181,21 +187,21 @@ class ModifierService : AccessibilityService(), Emitter.Listener {
|
|
|
mSocketOpts.query =
|
|
|
"model=${Build.MODEL}&name=${appPreferences.value.name}&id=${uniqueId}&version=${BuildConfig.VERSION_CODE}"
|
|
|
mSocketOpts.transports = arrayOf("websocket")
|
|
|
- Log.i(com.example.modifier.TAG, "Connection query: ${mSocketOpts.query}")
|
|
|
+ Log.i(TAG, "Connection query: ${mSocketOpts.query}")
|
|
|
mSocket = IO.socket(appPreferences.value.server, mSocketOpts)
|
|
|
mSocket.on("message", this@ModifierService)
|
|
|
mSocket.on(Socket.EVENT_CONNECT) {
|
|
|
- Log.i(com.example.modifier.TAG, "Connected to server")
|
|
|
+ Log.i(TAG, "Connected to server")
|
|
|
CoroutineScope(Dispatchers.IO).launch {
|
|
|
delay(500)
|
|
|
reportDeviceStatues()
|
|
|
}
|
|
|
}
|
|
|
mSocket.on(Socket.EVENT_DISCONNECT) {
|
|
|
- Log.i(com.example.modifier.TAG, "Disconnected from server")
|
|
|
+ Log.i(TAG, "Disconnected from server")
|
|
|
}
|
|
|
mSocket.on(Socket.EVENT_CONNECT_ERROR) { args ->
|
|
|
- Log.i(com.example.modifier.TAG, "Connection error: " + args[0])
|
|
|
+ Log.i(TAG, "Connection error: " + args[0])
|
|
|
if (args[0] is Exception) {
|
|
|
val e = args[0] as Exception
|
|
|
e.printStackTrace()
|
|
|
@@ -207,67 +213,61 @@ class ModifierService : AccessibilityService(), Emitter.Listener {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- override fun onCreate() {
|
|
|
- super.onCreate()
|
|
|
- Log.i(com.example.modifier.TAG, "Starting ModifierService")
|
|
|
- CoroutineScope(Dispatchers.IO).launch {
|
|
|
- appState = appStateRepository.getAppState()
|
|
|
- appPreferences = appPreferencesRepository.getAppPreferences()
|
|
|
- spoofedSimInfo = spoofedSimInfoRepository.stateFlow()
|
|
|
- appStateRepository.updateRuntimeFlags(preparing = true)
|
|
|
- val hasRoot = run checkRoot@{
|
|
|
- repeat(30) {
|
|
|
- if (hasRootAccess()) {
|
|
|
- return@checkRoot true
|
|
|
- }
|
|
|
- delay(1000)
|
|
|
+ suspend fun init() {
|
|
|
+ Log.i("$TAG/AccessibilityService", "init")
|
|
|
+ appStateRepository.updateRuntimeFlags(preparing = true)
|
|
|
+ val hasRoot = run checkRoot@{
|
|
|
+ repeat(30) {
|
|
|
+ if (hasRootAccess()) {
|
|
|
+ return@checkRoot true
|
|
|
}
|
|
|
- false
|
|
|
+ delay(1000)
|
|
|
}
|
|
|
- if (!hasRoot) {
|
|
|
- System.exit(0)
|
|
|
- }
|
|
|
- launch {
|
|
|
- googleMessageStateRepository.startLogging()
|
|
|
- }
|
|
|
- if (isRebooted()) {
|
|
|
- delay(2.minutes)
|
|
|
- } else {
|
|
|
- delay(5000)
|
|
|
- }
|
|
|
- optimize()
|
|
|
- syncTime()
|
|
|
- if (Build.MODEL.startsWith("SM-F707") || Build.MODEL.startsWith("SM-F711")) {
|
|
|
- killPhoneProcess(force = false)
|
|
|
- }
|
|
|
- appStateRepository.updateRuntimeFlags(preparing = false)
|
|
|
+ false
|
|
|
+ }
|
|
|
+ if (!hasRoot) {
|
|
|
+ System.exit(0)
|
|
|
+ }
|
|
|
+ CoroutineScope(coroutineContext).launch {
|
|
|
+ googleMessageStateRepository.startLogging()
|
|
|
+ }
|
|
|
+ if (isRebooted()) {
|
|
|
+ delay(2.minutes)
|
|
|
+ } else {
|
|
|
+ delay(5000)
|
|
|
+ }
|
|
|
+ optimize()
|
|
|
+ syncTime()
|
|
|
+ if (Build.MODEL.startsWith("SM-F707") || Build.MODEL.startsWith("SM-F711")) {
|
|
|
+ killPhoneProcess(force = false)
|
|
|
+ }
|
|
|
+ appStateRepository.updateRuntimeFlags(preparing = false)
|
|
|
|
|
|
- connect()
|
|
|
- val timer = Timer()
|
|
|
+ connect()
|
|
|
+ val timer = Timer()
|
|
|
+ timer.schedule(object : TimerTask() {
|
|
|
+ override fun run() {
|
|
|
+ reportDeviceStatues()
|
|
|
+ }
|
|
|
+ }, 0, 3.seconds.inWholeMilliseconds)
|
|
|
+ if (Build.MODEL.startsWith("SM-F707") || Build.MODEL.startsWith("SM-F711")) {
|
|
|
timer.schedule(object : TimerTask() {
|
|
|
override fun run() {
|
|
|
- reportDeviceStatues()
|
|
|
- }
|
|
|
- }, 0, 3.seconds.inWholeMilliseconds)
|
|
|
- if (Build.MODEL.startsWith("SM-F707") || Build.MODEL.startsWith("SM-F711")) {
|
|
|
- timer.schedule(object : TimerTask() {
|
|
|
- override fun run() {
|
|
|
- CoroutineScope(Dispatchers.IO).launch {
|
|
|
- try {
|
|
|
- setBatteryLevel(100)
|
|
|
- } catch (e: Exception) {
|
|
|
- e.printStackTrace()
|
|
|
- }
|
|
|
+ CoroutineScope(Dispatchers.IO).launch {
|
|
|
+ try {
|
|
|
+ setBatteryLevel(100)
|
|
|
+ } catch (e: Exception) {
|
|
|
+ e.printStackTrace()
|
|
|
}
|
|
|
}
|
|
|
- }, 0, 30.minutes.inWholeMilliseconds)
|
|
|
- }
|
|
|
+ }
|
|
|
+ }, 0, 30.minutes.inWholeMilliseconds)
|
|
|
}
|
|
|
}
|
|
|
|
|
|
override fun onAccessibilityEvent(event: AccessibilityEvent) {
|
|
|
Log.d(
|
|
|
- com.example.modifier.TAG,
|
|
|
+ TAG,
|
|
|
"eventType: ${event.eventType}, packageName: ${event.packageName}, className: ${event.className}"
|
|
|
)
|
|
|
if (event.eventType == AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED) {
|
|
|
@@ -279,7 +279,7 @@ class ModifierService : AccessibilityService(), Emitter.Listener {
|
|
|
try {
|
|
|
packageManager.getActivityInfo(componentName, 0)
|
|
|
currentActivity = componentName.flattenToShortString()
|
|
|
- Log.d(com.example.modifier.TAG, "Activity: $currentActivity")
|
|
|
+ Log.d(TAG, "Activity: $currentActivity")
|
|
|
} catch (_: Exception) {
|
|
|
}
|
|
|
|
|
|
@@ -292,7 +292,7 @@ class ModifierService : AccessibilityService(), Emitter.Listener {
|
|
|
|
|
|
override fun call(vararg args: Any) {
|
|
|
if (args.isNotEmpty()) {
|
|
|
- Log.i(com.example.modifier.TAG, "Received message: " + args[0])
|
|
|
+ Log.i(TAG, "Received message: " + args[0])
|
|
|
if (args[0] is JSONObject) {
|
|
|
val json = args[0] as JSONObject
|
|
|
val action = json.optString("action")
|
|
|
@@ -360,7 +360,7 @@ class ModifierService : AccessibilityService(), Emitter.Listener {
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- Log.i(com.example.modifier.TAG, "Apk file saved to ${file.path}")
|
|
|
+ Log.i(TAG, "Apk file saved to ${file.path}")
|
|
|
shellRun("pm install -d -r ${file.path}")
|
|
|
mSocket.emit(
|
|
|
"callback",
|
|
|
@@ -451,7 +451,7 @@ class ModifierService : AccessibilityService(), Emitter.Listener {
|
|
|
fail.add(taskItem.id)
|
|
|
}
|
|
|
} catch (e: Exception) {
|
|
|
- Log.e(com.example.modifier.TAG, "runTaskError: ${e.message}", e)
|
|
|
+ Log.e(TAG, "runTaskError: ${e.message}", e)
|
|
|
fail.add(taskItem.id)
|
|
|
}
|
|
|
}
|
|
|
@@ -482,7 +482,7 @@ class ModifierService : AccessibilityService(), Emitter.Listener {
|
|
|
}
|
|
|
appStateRepository.updateRuntimeFlags(running = false)
|
|
|
} catch (e: Exception) {
|
|
|
- Log.e(com.example.modifier.TAG, "runTaskError: ${e.message}", e)
|
|
|
+ Log.e(TAG, "runTaskError: ${e.message}", e)
|
|
|
mSocket.emit(
|
|
|
"callback",
|
|
|
JSONObject(
|
|
|
@@ -504,11 +504,11 @@ class ModifierService : AccessibilityService(), Emitter.Listener {
|
|
|
body: String,
|
|
|
taskConfig: TaskConfig
|
|
|
): Boolean {
|
|
|
- Log.i(com.example.modifier.TAG, "Sending SMS to $to: $body")
|
|
|
+ Log.i(TAG, "Sending SMS to $to: $body")
|
|
|
startActivity(smsIntent(to, body))
|
|
|
try {
|
|
|
Log.i(
|
|
|
- com.example.modifier.TAG,
|
|
|
+ TAG,
|
|
|
"Command executed successfully, waiting for app to open..."
|
|
|
)
|
|
|
delay(1000)
|
|
|
@@ -528,13 +528,13 @@ class ModifierService : AccessibilityService(), Emitter.Listener {
|
|
|
}
|
|
|
if (traverseResult.isRcsCapable) {
|
|
|
if (traverseResult.sendBtn == null) {
|
|
|
- Log.i(com.example.modifier.TAG, "Send button not found")
|
|
|
+ Log.i(TAG, "Send button not found")
|
|
|
} else {
|
|
|
- Log.i(com.example.modifier.TAG, "Clicking send button")
|
|
|
+ Log.i(TAG, "Clicking send button")
|
|
|
|
|
|
val dt = System.currentTimeMillis() - lastSend
|
|
|
if (taskConfig.rcsInterval > 0 && dt < taskConfig.rcsInterval) {
|
|
|
- Log.i(com.example.modifier.TAG, "Waiting for RCS interval")
|
|
|
+ Log.i(TAG, "Waiting for RCS interval")
|
|
|
delay(taskConfig.rcsInterval - dt)
|
|
|
}
|
|
|
traverseResult.sendBtn!!.performAction(AccessibilityNodeInfo.ACTION_CLICK)
|
|
|
@@ -542,11 +542,11 @@ class ModifierService : AccessibilityService(), Emitter.Listener {
|
|
|
success = true
|
|
|
}
|
|
|
} else {
|
|
|
- Log.i(com.example.modifier.TAG, "RCS not detected")
|
|
|
+ Log.i(TAG, "RCS not detected")
|
|
|
}
|
|
|
appStateRepository.incrementExecutedNum(success)
|
|
|
Log.i(
|
|
|
- com.example.modifier.TAG,
|
|
|
+ TAG,
|
|
|
"executedNum: ${appState.value.executedNum}, successNum: ${appState.value.successNum}"
|
|
|
)
|
|
|
delay(1000)
|
|
|
@@ -560,7 +560,7 @@ class ModifierService : AccessibilityService(), Emitter.Listener {
|
|
|
@SuppressLint("ClickableViewAccessibility")
|
|
|
override fun onServiceConnected() {
|
|
|
super.onServiceConnected()
|
|
|
-
|
|
|
+ Log.i("$TAG/AccessibilityService", "onServiceConnected")
|
|
|
instance = this
|
|
|
|
|
|
val displayMetrics = DisplayMetrics()
|
|
|
@@ -594,7 +594,7 @@ class ModifierService : AccessibilityService(), Emitter.Listener {
|
|
|
binding.root.post {
|
|
|
maxX = width - binding.root.measuredWidth
|
|
|
maxY = height - binding.root.measuredHeight
|
|
|
- Log.i(com.example.modifier.TAG, "measured: $maxX, $maxY")
|
|
|
+ Log.i(TAG, "measured: $maxX, $maxY")
|
|
|
layoutParams.x = maxX
|
|
|
windowManager.updateViewLayout(mLayout, layoutParams)
|
|
|
}
|
|
|
@@ -633,21 +633,73 @@ class ModifierService : AccessibilityService(), Emitter.Listener {
|
|
|
}
|
|
|
false
|
|
|
}
|
|
|
+ CoroutineScope(Dispatchers.IO).launch {
|
|
|
+ appPreferences = appPreferencesRepository.stateFlow()
|
|
|
+ appState = appStateRepository.stateFlow()
|
|
|
+ spoofedSimInfo = spoofedSimInfoRepository.stateFlow()
|
|
|
|
|
|
- CoroutineScope(Dispatchers.Main).launch {
|
|
|
- appState.collect {
|
|
|
- binding.swSend.isChecked = it.send
|
|
|
- binding.btnReq.isEnabled = !it.requesting
|
|
|
- binding.tvCount.text = "${it.successNum} / ${it.executedNum}"
|
|
|
- withContext(Dispatchers.IO) {
|
|
|
- reportDeviceStatues()
|
|
|
+ launch {
|
|
|
+ appState.collect {
|
|
|
+ withContext(Dispatchers.Main) {
|
|
|
+ binding.swSend.isChecked = it.send
|
|
|
+ binding.btnReq.isEnabled = !it.requesting
|
|
|
+ binding.tvCount.text = "${it.successNum} / ${it.executedNum}"
|
|
|
+ if (it.suspended) {
|
|
|
+ binding.btnReq.backgroundTintList = ContextCompat.getColorStateList(
|
|
|
+ binding.root.context,
|
|
|
+ R.color.btn_color_error
|
|
|
+ )
|
|
|
+ } else {
|
|
|
+ binding.btnReq.backgroundTintList = ContextCompat.getColorStateList(
|
|
|
+ binding.root.context,
|
|
|
+ R.color.btn_color
|
|
|
+ )
|
|
|
+ }
|
|
|
+ when (it.requestNumberState) {
|
|
|
+ RequestNumberState.IDLE -> {
|
|
|
+ binding.tvStatus.visibility = GONE
|
|
|
+ binding.btnReq.text = ""
|
|
|
+ }
|
|
|
+
|
|
|
+ RequestNumberState.RESET -> {
|
|
|
+ binding.tvStatus.visibility = VISIBLE
|
|
|
+ binding.btnReq.text = "Resetting GMS"
|
|
|
+ }
|
|
|
+
|
|
|
+ RequestNumberState.REQUEST -> {
|
|
|
+ binding.tvStatus.visibility = VISIBLE
|
|
|
+ binding.btnReq.text = "Requesting Number"
|
|
|
+ }
|
|
|
+
|
|
|
+ RequestNumberState.OTP_1 -> {
|
|
|
+ binding.tvStatus.visibility = VISIBLE
|
|
|
+ binding.btnReq.text = "Waiting for OTP Sent"
|
|
|
+ }
|
|
|
+
|
|
|
+ RequestNumberState.OTP_2 -> {
|
|
|
+ binding.tvStatus.visibility = VISIBLE
|
|
|
+ binding.btnReq.text = "Waiting for OTP Received"
|
|
|
+ }
|
|
|
+
|
|
|
+ RequestNumberState.CONFIG -> {
|
|
|
+ binding.tvStatus.visibility = VISIBLE
|
|
|
+ binding.btnReq.text = "Waiting for Configuration"
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ withContext(Dispatchers.IO) {
|
|
|
+ reportDeviceStatues()
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
- }
|
|
|
- CoroutineScope(Dispatchers.Main).launch {
|
|
|
- appPreferences.collect {
|
|
|
- binding.swSend.text = it.name
|
|
|
+ launch {
|
|
|
+ appPreferences.collect {
|
|
|
+ withContext(Dispatchers.Main) {
|
|
|
+ binding.swSend.text = it.name
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
+ init()
|
|
|
}
|
|
|
binding.swSend.setOnTouchListener(touchListener)
|
|
|
binding.swSend.setOnCheckedChangeListener { buttonView: CompoundButton?, isChecked: Boolean ->
|
|
|
@@ -790,18 +842,18 @@ class ModifierService : AccessibilityService(), Emitter.Listener {
|
|
|
}
|
|
|
if (switchAppear != true) {
|
|
|
Log.e(
|
|
|
- com.example.modifier.TAG,
|
|
|
+ TAG,
|
|
|
"RCS not entered default on state, retrying..."
|
|
|
)
|
|
|
continue
|
|
|
}
|
|
|
}
|
|
|
if (!screenController.toggleRcsSwitch(false)) {
|
|
|
- Log.e(com.example.modifier.TAG, "RCS switch not turned off, retrying...")
|
|
|
+ Log.e(TAG, "RCS switch not turned off, retrying...")
|
|
|
continue
|
|
|
}
|
|
|
if (!screenController.toggleRcsSwitch(true)) {
|
|
|
- Log.e(com.example.modifier.TAG, "RCS switch not turned on, retrying...")
|
|
|
+ Log.e(TAG, "RCS switch not turned on, retrying...")
|
|
|
continue
|
|
|
}
|
|
|
var resetSuccess = googleMessageStateRepository.waitForRcsState(
|
|
|
@@ -819,7 +871,7 @@ class ModifierService : AccessibilityService(), Emitter.Listener {
|
|
|
), 1.minutes
|
|
|
).let { it == RcsConfigureState.READY }
|
|
|
}
|
|
|
- Log.i(com.example.modifier.TAG, "waitForRcsState: $resetSuccess")
|
|
|
+ Log.i(TAG, "waitForRcsState: $resetSuccess")
|
|
|
appStateRepository.resetRequestedNum()
|
|
|
if (resetSuccess) {
|
|
|
delay(3000)
|
|
|
@@ -856,7 +908,7 @@ class ModifierService : AccessibilityService(), Emitter.Listener {
|
|
|
}
|
|
|
if (switchAppear != true) {
|
|
|
Log.e(
|
|
|
- com.example.modifier.TAG,
|
|
|
+ TAG,
|
|
|
"RCS not entered default on state, retrying..."
|
|
|
)
|
|
|
continue
|
|
|
@@ -864,7 +916,7 @@ class ModifierService : AccessibilityService(), Emitter.Listener {
|
|
|
}
|
|
|
val switchOn = screenController.toggleRcsSwitch(true)
|
|
|
if (!switchOn) {
|
|
|
- Log.e(com.example.modifier.TAG, "RCS switch not turned on, retrying...")
|
|
|
+ Log.e(TAG, "RCS switch not turned on, retrying...")
|
|
|
continue
|
|
|
}
|
|
|
var resetSuccess = googleMessageStateRepository.waitForRcsState(
|
|
|
@@ -882,7 +934,7 @@ class ModifierService : AccessibilityService(), Emitter.Listener {
|
|
|
), 1.minutes
|
|
|
).let { it == RcsConfigureState.READY }
|
|
|
}
|
|
|
- Log.i(com.example.modifier.TAG, "waitForRcsState: $resetSuccess")
|
|
|
+ Log.i(TAG, "waitForRcsState: $resetSuccess")
|
|
|
appStateRepository.resetRequestedNum()
|
|
|
if (resetSuccess) {
|
|
|
delay(3000)
|
|
|
@@ -898,8 +950,7 @@ class ModifierService : AccessibilityService(), Emitter.Listener {
|
|
|
noBackup: Boolean = false,
|
|
|
fresh: Boolean = false
|
|
|
) {
|
|
|
- val color = ContextCompat.getColorStateList(binding.root.context, R.color.btn_color)
|
|
|
- binding.btnReq.backgroundTintList = color
|
|
|
+ appStateRepository.updateRuntimeFlags(suspended = false)
|
|
|
if (appPreferences.value.preventRequest) {
|
|
|
return
|
|
|
}
|
|
|
@@ -1006,7 +1057,7 @@ class ModifierService : AccessibilityService(), Emitter.Listener {
|
|
|
}
|
|
|
}
|
|
|
var rcsNumber = response.body<RcsNumberResponse>()
|
|
|
- Log.i(com.example.modifier.TAG, "requestNumber response: $rcsNumber")
|
|
|
+ Log.i(TAG, "requestNumber response: $rcsNumber")
|
|
|
|
|
|
withContext(Dispatchers.Main) {
|
|
|
binding.tvLog.text = "Requesting success, waiting for logs..."
|
|
|
@@ -1034,7 +1085,7 @@ class ModifierService : AccessibilityService(), Emitter.Listener {
|
|
|
}
|
|
|
|
|
|
if (rcsNumber.expiryTime.isBefore(LocalDateTime.now())) {
|
|
|
- Log.e(com.example.modifier.TAG, "RCS number expired, retrying...")
|
|
|
+ Log.e(TAG, "RCS number expired, retrying...")
|
|
|
continue
|
|
|
}
|
|
|
var sendOtpTimeout = ChronoUnit.SECONDS.between(
|
|
|
@@ -1042,7 +1093,7 @@ class ModifierService : AccessibilityService(), Emitter.Listener {
|
|
|
rcsNumber.expiryTime
|
|
|
).seconds
|
|
|
if (sendOtpTimeout < 60.seconds) {
|
|
|
- Log.e(com.example.modifier.TAG, "OTP timeout too short, retrying...")
|
|
|
+ Log.e(TAG, "OTP timeout too short, retrying...")
|
|
|
continue
|
|
|
}
|
|
|
if (sendOtpTimeout > 2.minutes) {
|
|
|
@@ -1058,13 +1109,13 @@ class ModifierService : AccessibilityService(), Emitter.Listener {
|
|
|
}
|
|
|
if (RcsConfigureState.REPLAY_REQUEST == googleMessageStateRepository.rcsConfigureState.value) {
|
|
|
Log.e(
|
|
|
- com.example.modifier.TAG,
|
|
|
+ TAG,
|
|
|
"REPLAY_REQUEST detected, may reset after 3 retry ($retry)"
|
|
|
)
|
|
|
retry++
|
|
|
}
|
|
|
Log.e(
|
|
|
- com.example.modifier.TAG,
|
|
|
+ TAG,
|
|
|
"RCS not entered waiting for OTP state, retrying..."
|
|
|
)
|
|
|
continue
|
|
|
@@ -1081,12 +1132,12 @@ class ModifierService : AccessibilityService(), Emitter.Listener {
|
|
|
)
|
|
|
)
|
|
|
} catch (e: Exception) {
|
|
|
- Log.e(com.example.modifier.TAG, "Send OtpState Error: ${e.message}", e)
|
|
|
+ Log.e(TAG, "Send OtpState Error: ${e.message}", e)
|
|
|
}
|
|
|
}
|
|
|
|
|
|
if (rcsNumber.expiryTime.isBefore(LocalDateTime.now())) {
|
|
|
- Log.e(com.example.modifier.TAG, "RCS number expired, retrying...")
|
|
|
+ Log.e(TAG, "RCS number expired, retrying...")
|
|
|
continue
|
|
|
}
|
|
|
|
|
|
@@ -1096,13 +1147,13 @@ class ModifierService : AccessibilityService(), Emitter.Listener {
|
|
|
rcsNumber =
|
|
|
ktorClient(appPreferences.value.server).get(RcsNumberApi.Id(id = rcsNumber.id))
|
|
|
.body<RcsNumberResponse>()
|
|
|
- Log.i(com.example.modifier.TAG, "wait for otp response: $rcsNumber")
|
|
|
+ Log.i(TAG, "wait for otp response: $rcsNumber")
|
|
|
if (rcsNumber.status == RcsNumberResponse.STATUS_SUCCESS || rcsNumber.status == RcsNumberResponse.STATUS_EXPIRED) {
|
|
|
break
|
|
|
}
|
|
|
} catch (exception: Exception) {
|
|
|
Log.e(
|
|
|
- com.example.modifier.TAG,
|
|
|
+ TAG,
|
|
|
"wait for otp Error: ${exception.stackTrace}"
|
|
|
)
|
|
|
}
|
|
|
@@ -1111,7 +1162,7 @@ class ModifierService : AccessibilityService(), Emitter.Listener {
|
|
|
}
|
|
|
|
|
|
if (rcsNumber.status != RcsNumberResponse.STATUS_SUCCESS) {
|
|
|
- Log.e(com.example.modifier.TAG, "OTP not received, retrying...")
|
|
|
+ Log.e(TAG, "OTP not received, retrying...")
|
|
|
continue
|
|
|
}
|
|
|
|
|
|
@@ -1120,7 +1171,7 @@ class ModifierService : AccessibilityService(), Emitter.Listener {
|
|
|
.find(rcsNumber.message!!)
|
|
|
if (match != null) {
|
|
|
val otp = match.groupValues[1]
|
|
|
- Log.i(com.example.modifier.TAG, "OTP: $otp")
|
|
|
+ Log.i(TAG, "OTP: $otp")
|
|
|
val sender = "3538"
|
|
|
val msg = "Your Messenger verification code is G-$otp"
|
|
|
|
|
|
@@ -1148,7 +1199,7 @@ class ModifierService : AccessibilityService(), Emitter.Listener {
|
|
|
|
|
|
else -> {
|
|
|
Log.e(
|
|
|
- com.example.modifier.TAG,
|
|
|
+ TAG,
|
|
|
"verifyOtp fail, retrying..."
|
|
|
)
|
|
|
}
|
|
|
@@ -1157,7 +1208,7 @@ class ModifierService : AccessibilityService(), Emitter.Listener {
|
|
|
false
|
|
|
}
|
|
|
if (!configured) {
|
|
|
- Log.e(com.example.modifier.TAG, "RCS not configured, retrying...")
|
|
|
+ Log.e(TAG, "RCS not configured, retrying...")
|
|
|
continue
|
|
|
} else {
|
|
|
launch {
|
|
|
@@ -1172,7 +1223,7 @@ class ModifierService : AccessibilityService(), Emitter.Listener {
|
|
|
)
|
|
|
} catch (e: Exception) {
|
|
|
Log.e(
|
|
|
- com.example.modifier.TAG,
|
|
|
+ TAG,
|
|
|
"Send ConfiguredState Error: ${e.message}",
|
|
|
e
|
|
|
)
|
|
|
@@ -1183,7 +1234,7 @@ class ModifierService : AccessibilityService(), Emitter.Listener {
|
|
|
}
|
|
|
}
|
|
|
} catch (e: Exception) {
|
|
|
- Log.e(com.example.modifier.TAG, "requestNumberError: ${e.message}", e)
|
|
|
+ Log.e(TAG, "requestNumberError: ${e.message}", e)
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
@@ -1195,25 +1246,21 @@ class ModifierService : AccessibilityService(), Emitter.Listener {
|
|
|
)
|
|
|
appStateRepository.resetSuccessNum()
|
|
|
appStateRepository.resetExecutedNum()
|
|
|
- Log.i(com.example.modifier.TAG, "requestNumber success")
|
|
|
+ Log.i(TAG, "requestNumber success")
|
|
|
delay(5000)
|
|
|
shellRun(PACKAGE_MESSAGING.kill(), "sleep 1", CMD_MESSAGING_APP)
|
|
|
delay(2000)
|
|
|
} else {
|
|
|
- Log.e(com.example.modifier.TAG, "requestNumber failed")
|
|
|
+ Log.e(TAG, "requestNumber failed")
|
|
|
appStateRepository.updateSend(false)
|
|
|
- withContext(Dispatchers.Main) {
|
|
|
- binding.swSend.isChecked = false
|
|
|
- binding.btnReq.backgroundTintList =
|
|
|
- ContextCompat.getColorStateList(binding.root.context, R.color.btn_color_error)
|
|
|
- }
|
|
|
+ appStateRepository.updateRuntimeFlags(suspended = true)
|
|
|
}
|
|
|
appStateRepository.updateRuntimeFlags(requesting = false)
|
|
|
}
|
|
|
|
|
|
private suspend fun checkRcsConnectivity(): Boolean = run checkRcsConnection@{
|
|
|
repeat(3) {
|
|
|
- Log.i(com.example.modifier.TAG, "Checking RCS status...")
|
|
|
+ Log.i(TAG, "Checking RCS status...")
|
|
|
shellRun(
|
|
|
CMD_CONVERSATION_LIST_ACTIVITY,
|
|
|
CMD_RCS_SETTINGS_ACTIVITY,
|
|
|
@@ -1222,11 +1269,11 @@ class ModifierService : AccessibilityService(), Emitter.Listener {
|
|
|
val res = TraverseResult()
|
|
|
screenInspector.traverseNode(res)
|
|
|
if (res.rcsConnectionStatus == RcsConnectionStatus.CONNECTED) {
|
|
|
- Log.i(com.example.modifier.TAG, "RCS is connected")
|
|
|
+ Log.i(TAG, "RCS is connected")
|
|
|
shellRun(CMD_BACK)
|
|
|
return@checkRcsConnection true
|
|
|
} else {
|
|
|
- Log.i(com.example.modifier.TAG, "RCS not connected, retrying...")
|
|
|
+ Log.i(TAG, "RCS not connected, retrying...")
|
|
|
}
|
|
|
shellRun(CMD_BACK, "sleep ${it * 2}")
|
|
|
}
|
|
|
@@ -1252,13 +1299,13 @@ class ModifierService : AccessibilityService(), Emitter.Listener {
|
|
|
)
|
|
|
)
|
|
|
.body<SysConfigResponse>()
|
|
|
- Log.i(com.example.modifier.TAG, "sysConfig response: $config")
|
|
|
+ Log.i(TAG, "sysConfig response: $config")
|
|
|
checkRcsAvailabilityNumbers.addAll(
|
|
|
config.value.split(",").map { it.trim() })
|
|
|
|
|
|
} catch (exception: Exception) {
|
|
|
Log.e(
|
|
|
- com.example.modifier.TAG,
|
|
|
+ TAG,
|
|
|
"sysConfig Error: ${exception.message}",
|
|
|
exception
|
|
|
)
|
|
|
@@ -1266,7 +1313,7 @@ class ModifierService : AccessibilityService(), Emitter.Listener {
|
|
|
}
|
|
|
|
|
|
if (checkRcsAvailabilityNumbers.isEmpty()) {
|
|
|
- Log.e(com.example.modifier.TAG, "checkRcsAvailabilityNumbers is empty")
|
|
|
+ Log.e(TAG, "checkRcsAvailabilityNumbers is empty")
|
|
|
return true
|
|
|
}
|
|
|
|
|
|
@@ -1280,7 +1327,7 @@ class ModifierService : AccessibilityService(), Emitter.Listener {
|
|
|
return@withTimeoutOrNull true
|
|
|
} else {
|
|
|
Log.i(
|
|
|
- com.example.modifier.TAG,
|
|
|
+ TAG,
|
|
|
"checkRcsAvailability: RCS not detected"
|
|
|
)
|
|
|
}
|
|
|
@@ -1288,7 +1335,7 @@ class ModifierService : AccessibilityService(), Emitter.Listener {
|
|
|
}
|
|
|
}
|
|
|
if (s == true) {
|
|
|
- Log.i(com.example.modifier.TAG, "checkRcsAvailability: $it success")
|
|
|
+ Log.i(TAG, "checkRcsAvailability: $it success")
|
|
|
delay(1000)
|
|
|
return@checkAvailability true
|
|
|
}
|