|
@@ -23,7 +23,6 @@ import android.view.accessibility.AccessibilityEvent
|
|
|
import android.view.accessibility.AccessibilityNodeInfo
|
|
import android.view.accessibility.AccessibilityNodeInfo
|
|
|
import android.widget.CompoundButton
|
|
import android.widget.CompoundButton
|
|
|
import android.widget.FrameLayout
|
|
import android.widget.FrameLayout
|
|
|
-import android.widget.Toast
|
|
|
|
|
import androidx.datastore.core.DataStore
|
|
import androidx.datastore.core.DataStore
|
|
|
import androidx.datastore.preferences.core.Preferences
|
|
import androidx.datastore.preferences.core.Preferences
|
|
|
import androidx.datastore.preferences.preferencesDataStore
|
|
import androidx.datastore.preferences.preferencesDataStore
|
|
@@ -34,7 +33,6 @@ import androidx.lifecycle.liveData
|
|
|
import com.example.modifier.BuildConfig
|
|
import com.example.modifier.BuildConfig
|
|
|
import com.example.modifier.CMD_BACK
|
|
import com.example.modifier.CMD_BACK
|
|
|
import com.example.modifier.CMD_CONVERSATION_LIST_ACTIVITY
|
|
import com.example.modifier.CMD_CONVERSATION_LIST_ACTIVITY
|
|
|
-import com.example.modifier.CMD_HOME
|
|
|
|
|
import com.example.modifier.CMD_MESSAGING_APP
|
|
import com.example.modifier.CMD_MESSAGING_APP
|
|
|
import com.example.modifier.CMD_RCS_SETTINGS_ACTIVITY
|
|
import com.example.modifier.CMD_RCS_SETTINGS_ACTIVITY
|
|
|
import com.example.modifier.Global
|
|
import com.example.modifier.Global
|
|
@@ -82,7 +80,10 @@ import org.apache.commons.lang3.RandomStringUtils
|
|
|
import org.json.JSONException
|
|
import org.json.JSONException
|
|
|
import org.json.JSONObject
|
|
import org.json.JSONObject
|
|
|
import java.time.LocalDateTime
|
|
import java.time.LocalDateTime
|
|
|
-import java.time.format.DateTimeFormatter
|
|
|
|
|
|
|
+import java.time.ZoneId
|
|
|
|
|
+import java.time.ZoneOffset
|
|
|
|
|
+import java.time.ZonedDateTime
|
|
|
|
|
+import java.time.temporal.ChronoUnit
|
|
|
import java.util.Optional
|
|
import java.util.Optional
|
|
|
import java.util.concurrent.atomic.AtomicReference
|
|
import java.util.concurrent.atomic.AtomicReference
|
|
|
import java.util.concurrent.locks.ReentrantLock
|
|
import java.util.concurrent.locks.ReentrantLock
|
|
@@ -94,12 +95,13 @@ import kotlin.time.Duration.Companion.hours
|
|
|
import kotlin.time.Duration.Companion.minutes
|
|
import kotlin.time.Duration.Companion.minutes
|
|
|
import kotlin.time.Duration.Companion.seconds
|
|
import kotlin.time.Duration.Companion.seconds
|
|
|
|
|
|
|
|
|
|
+
|
|
|
val Context.dataStore: DataStore<Preferences> by preferencesDataStore(name = "serverConfig")
|
|
val Context.dataStore: DataStore<Preferences> by preferencesDataStore(name = "serverConfig")
|
|
|
|
|
|
|
|
@SuppressLint("SetTextI18n")
|
|
@SuppressLint("SetTextI18n")
|
|
|
class ModifierService : AccessibilityService(), Emitter.Listener {
|
|
class ModifierService : AccessibilityService(), Emitter.Listener {
|
|
|
companion object {
|
|
companion object {
|
|
|
- private const val TAG = "ModifierService"
|
|
|
|
|
|
|
+ private const val TAG = "ModifierService1"
|
|
|
|
|
|
|
|
const val NAME: String = BuildConfig.APPLICATION_ID + ".service.ModifierService"
|
|
const val NAME: String = BuildConfig.APPLICATION_ID + ".service.ModifierService"
|
|
|
|
|
|
|
@@ -491,6 +493,19 @@ class ModifierService : AccessibilityService(), Emitter.Listener {
|
|
|
return false
|
|
return false
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ fun getNodes(node: AccessibilityNodeInfo? = null): List<AccessibilityNodeInfo> {
|
|
|
|
|
+ fun traverseChildren(node: AccessibilityNodeInfo): List<AccessibilityNodeInfo> {
|
|
|
|
|
+ val result = mutableListOf<AccessibilityNodeInfo>()
|
|
|
|
|
+ for (i in 0 until node.childCount) {
|
|
|
|
|
+ val child = node.getChild(i)
|
|
|
|
|
+ result.add(child)
|
|
|
|
|
+ result.addAll(traverseChildren(child))
|
|
|
|
|
+ }
|
|
|
|
|
+ return result
|
|
|
|
|
+ }
|
|
|
|
|
+ return traverseChildren(node ?: rootInActiveWindow)
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
private fun traverseNode(node: AccessibilityNodeInfo?, result: TraverseResult) {
|
|
private fun traverseNode(node: AccessibilityNodeInfo?, result: TraverseResult) {
|
|
|
if (node == null) {
|
|
if (node == null) {
|
|
|
return
|
|
return
|
|
@@ -583,18 +598,26 @@ class ModifierService : AccessibilityService(), Emitter.Listener {
|
|
|
val inflater = LayoutInflater.from(newContext)
|
|
val inflater = LayoutInflater.from(newContext)
|
|
|
binding = FloatingWindowBinding.inflate(inflater, mLayout, true)
|
|
binding = FloatingWindowBinding.inflate(inflater, mLayout, true)
|
|
|
binding.swSend.text = Global.name
|
|
binding.swSend.text = Global.name
|
|
|
|
|
+ binding.tvVersion.text = "v${BuildConfig.VERSION_CODE}"
|
|
|
windowManager.addView(mLayout, layoutParams)
|
|
windowManager.addView(mLayout, layoutParams)
|
|
|
|
|
|
|
|
- val maxX = width - binding.root.measuredWidth
|
|
|
|
|
- val maxY = height - binding.root.measuredHeight
|
|
|
|
|
|
|
+
|
|
|
|
|
+ var maxX = 0
|
|
|
|
|
+ var maxY = 0
|
|
|
|
|
+ binding.root.measure(View.MeasureSpec.EXACTLY, View.MeasureSpec.EXACTLY)
|
|
|
|
|
+ binding.root.post {
|
|
|
|
|
+ maxX = width - binding.root.measuredWidth
|
|
|
|
|
+ maxY = height - binding.root.measuredHeight
|
|
|
|
|
+ Log.i(TAG, "measured: $maxX, $maxY")
|
|
|
|
|
+ layoutParams.x = maxX
|
|
|
|
|
+ windowManager.updateViewLayout(mLayout, layoutParams)
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
val downX = AtomicReference(0f)
|
|
val downX = AtomicReference(0f)
|
|
|
val downY = AtomicReference(0f)
|
|
val downY = AtomicReference(0f)
|
|
|
val downParamX = AtomicReference(0)
|
|
val downParamX = AtomicReference(0)
|
|
|
val downParamY = AtomicReference(0)
|
|
val downParamY = AtomicReference(0)
|
|
|
|
|
|
|
|
- layoutParams.x = maxX
|
|
|
|
|
- windowManager.updateViewLayout(mLayout, layoutParams)
|
|
|
|
|
-
|
|
|
|
|
val touchListener = OnTouchListener { v, event ->
|
|
val touchListener = OnTouchListener { v, event ->
|
|
|
when (event.action) {
|
|
when (event.action) {
|
|
|
MotionEvent.ACTION_DOWN -> {
|
|
MotionEvent.ACTION_DOWN -> {
|
|
@@ -624,7 +647,6 @@ class ModifierService : AccessibilityService(), Emitter.Listener {
|
|
|
}
|
|
}
|
|
|
false
|
|
false
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
binding.swSend.setOnTouchListener(touchListener)
|
|
binding.swSend.setOnTouchListener(touchListener)
|
|
|
|
|
|
|
|
binding.swConnect.isChecked = true
|
|
binding.swConnect.isChecked = true
|
|
@@ -730,199 +752,213 @@ class ModifierService : AccessibilityService(), Emitter.Listener {
|
|
|
}
|
|
}
|
|
|
requestNumberCount++
|
|
requestNumberCount++
|
|
|
requesting.postValue(true)
|
|
requesting.postValue(true)
|
|
|
- val result = withTimeoutOrNull(1.hours) {
|
|
|
|
|
|
|
+ var requestSuccess = false
|
|
|
|
|
+ withTimeoutOrNull(1.hours) {
|
|
|
while (true) {
|
|
while (true) {
|
|
|
- var rcsRes: RcsNumberResponse? = null
|
|
|
|
|
- rcsConfigureState.postValue(RcsConfigureState.NOT_CONFIGURED)
|
|
|
|
|
|
|
+ try {
|
|
|
|
|
+ rcsConfigureState.postValue(RcsConfigureState.NOT_CONFIGURED)
|
|
|
|
|
|
|
|
- withTimeoutOrNull(10.minutes) {
|
|
|
|
|
- var retry = 0
|
|
|
|
|
- while (true) {
|
|
|
|
|
- withContext(Dispatchers.Main) {
|
|
|
|
|
- binding.tvLog.text = "requesting number...${++retry}"
|
|
|
|
|
- }
|
|
|
|
|
- try {
|
|
|
|
|
- val response = KtorClient.put(
|
|
|
|
|
- RcsNumberApi()
|
|
|
|
|
- ) {
|
|
|
|
|
- contentType(ContentType.Application.Json)
|
|
|
|
|
- setBody(
|
|
|
|
|
- RcsNumberRequest(
|
|
|
|
|
- deviceId = Utils.getUniqueID(),
|
|
|
|
|
- taskId = currentTaskId
|
|
|
|
|
- )
|
|
|
|
|
- )
|
|
|
|
|
- }
|
|
|
|
|
- rcsRes = response.body<RcsNumberResponse>()
|
|
|
|
|
- Log.i(TAG, "requestNumber response: $rcsRes")
|
|
|
|
|
- break
|
|
|
|
|
- } catch (exception: Exception) {
|
|
|
|
|
- exception.printStackTrace()
|
|
|
|
|
- delay(2000)
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ withContext(Dispatchers.Main) {
|
|
|
|
|
+ binding.tvLog.text = "requesting number..."
|
|
|
}
|
|
}
|
|
|
- }
|
|
|
|
|
- if (rcsRes == null) {
|
|
|
|
|
- Log.e(TAG, "requesting success, waiting for logs...")
|
|
|
|
|
- continue
|
|
|
|
|
- }
|
|
|
|
|
|
|
|
|
|
- withContext(Dispatchers.Main) {
|
|
|
|
|
- binding.tvLog.text = ""
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ val response = KtorClient.put(
|
|
|
|
|
+ RcsNumberApi()
|
|
|
|
|
+ ) {
|
|
|
|
|
+ contentType(ContentType.Application.Json)
|
|
|
|
|
+ setBody(
|
|
|
|
|
+ RcsNumberRequest(
|
|
|
|
|
+ deviceId = Utils.getUniqueID(),
|
|
|
|
|
+ taskId = currentTaskId
|
|
|
|
|
+ )
|
|
|
|
|
+ )
|
|
|
|
|
+ }
|
|
|
|
|
+ var rcsNumber = response.body<RcsNumberResponse>()
|
|
|
|
|
+ Log.i(TAG, "requestNumber response: $rcsNumber")
|
|
|
|
|
|
|
|
- Global.save(
|
|
|
|
|
- TelephonyConfig(
|
|
|
|
|
- rcsRes!!.number,
|
|
|
|
|
- rcsRes!!.mcc,
|
|
|
|
|
- rcsRes!!.mnc,
|
|
|
|
|
- RandomStringUtils.randomNumeric(20),
|
|
|
|
|
- rcsRes!!.mcc + rcsRes!!.mnc + RandomStringUtils.randomNumeric(
|
|
|
|
|
- 15 - rcsRes!!.mcc.length - rcsRes!!.mnc.length
|
|
|
|
|
- ),
|
|
|
|
|
- Utils.generateIMEI(),
|
|
|
|
|
- rcsRes!!.country
|
|
|
|
|
|
|
+ withContext(Dispatchers.Main) {
|
|
|
|
|
+ binding.tvLog.text = "requesting success, waiting for logs..."
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ Global.save(
|
|
|
|
|
+ TelephonyConfig(
|
|
|
|
|
+ rcsNumber.number,
|
|
|
|
|
+ rcsNumber.mcc,
|
|
|
|
|
+ rcsNumber.mnc,
|
|
|
|
|
+ RandomStringUtils.randomNumeric(20),
|
|
|
|
|
+ rcsNumber.mcc + rcsNumber.mnc + RandomStringUtils.randomNumeric(
|
|
|
|
|
+ 15 - rcsNumber.mcc.length - rcsNumber.mnc.length
|
|
|
|
|
+ ),
|
|
|
|
|
+ Utils.generateIMEI(),
|
|
|
|
|
+ rcsNumber.country
|
|
|
|
|
+ )
|
|
|
)
|
|
)
|
|
|
- )
|
|
|
|
|
|
|
|
|
|
- var otpTimeout = 60.seconds
|
|
|
|
|
- if (requestNumberCount > 5) {
|
|
|
|
|
- otpTimeout = 60.seconds
|
|
|
|
|
- val resetSuccess = withTimeoutOrNull(5.minutes) {
|
|
|
|
|
- while (true) {
|
|
|
|
|
- withContext(Dispatchers.Main) {
|
|
|
|
|
- binding.tvLog.text = "Waiting for logs..."
|
|
|
|
|
- }
|
|
|
|
|
- rcsConfigureState.postValue(RcsConfigureState.NOT_CONFIGURED)
|
|
|
|
|
- resetAll()
|
|
|
|
|
- val switchAppear = withTimeoutOrNull(60.seconds) {
|
|
|
|
|
- while (true) {
|
|
|
|
|
- if (rcsConfigureState.value == RcsConfigureState.WAITING_FOR_DEFAULT_ON) {
|
|
|
|
|
- break
|
|
|
|
|
|
|
+ if (requestNumberCount > 999999999) {
|
|
|
|
|
+ val resetSuccess = withTimeoutOrNull(5.minutes) {
|
|
|
|
|
+ while (true) {
|
|
|
|
|
+ withContext(Dispatchers.Main) {
|
|
|
|
|
+ binding.tvLog.text = "Waiting for RCS switch on..."
|
|
|
|
|
+ }
|
|
|
|
|
+ rcsConfigureState.postValue(RcsConfigureState.NOT_CONFIGURED)
|
|
|
|
|
+ resetAll()
|
|
|
|
|
+ val switchAppear = withTimeoutOrNull(2.minutes) {
|
|
|
|
|
+ while (true) {
|
|
|
|
|
+ if (rcsConfigureState.value == RcsConfigureState.WAITING_FOR_DEFAULT_ON) {
|
|
|
|
|
+ break
|
|
|
|
|
+ }
|
|
|
|
|
+ delay(1.seconds)
|
|
|
}
|
|
}
|
|
|
- delay(1.seconds)
|
|
|
|
|
|
|
+ true
|
|
|
|
|
+ } ?: false
|
|
|
|
|
+ if (!switchAppear) {
|
|
|
|
|
+ Log.e(TAG, "RCS not entered default on state, retrying...")
|
|
|
|
|
+ continue
|
|
|
}
|
|
}
|
|
|
- true
|
|
|
|
|
- } ?: false
|
|
|
|
|
- if (!switchAppear) {
|
|
|
|
|
- Log.e(TAG, "RCS not entered default on state, retrying...")
|
|
|
|
|
- continue
|
|
|
|
|
- }
|
|
|
|
|
- Utils.runAsRoot(
|
|
|
|
|
- CMD_RCS_SETTINGS_ACTIVITY,
|
|
|
|
|
- "sleep 1"
|
|
|
|
|
- )
|
|
|
|
|
- val res = TraverseResult()
|
|
|
|
|
- traverseNode(rootInActiveWindow, res)
|
|
|
|
|
- if (res.rcsSwitch == null) {
|
|
|
|
|
- Log.e(TAG, "RCS switch not found, retrying...")
|
|
|
|
|
- continue
|
|
|
|
|
|
|
+ Utils.runAsRoot(
|
|
|
|
|
+ CMD_RCS_SETTINGS_ACTIVITY,
|
|
|
|
|
+ "sleep 1"
|
|
|
|
|
+ )
|
|
|
|
|
+ val res = TraverseResult()
|
|
|
|
|
+ traverseNode(rootInActiveWindow, res)
|
|
|
|
|
+ if (res.rcsSwitch == null) {
|
|
|
|
|
+ Log.e(TAG, "RCS switch not found, retrying...")
|
|
|
|
|
+ continue
|
|
|
|
|
+ }
|
|
|
|
|
+ val rect = Rect()
|
|
|
|
|
+ res.rcsSwitch!!.getBoundsInScreen(rect)
|
|
|
|
|
+ Utils.runAsRoot(
|
|
|
|
|
+ "input tap ${rect.centerX()} ${rect.centerY()}",
|
|
|
|
|
+ "sleep 1",
|
|
|
|
|
+ CMD_BACK,
|
|
|
|
|
+ CMD_RCS_SETTINGS_ACTIVITY,
|
|
|
|
|
+ )
|
|
|
|
|
+ Log.i(TAG, "RCS switch turned on, waiting for state change...")
|
|
|
|
|
+ val resetSuccess = waitForRcsState(
|
|
|
|
|
+ arrayOf(
|
|
|
|
|
+ RcsConfigureState.READY,
|
|
|
|
|
+ RcsConfigureState.RETRY
|
|
|
|
|
+ ), 2.minutes
|
|
|
|
|
+ )
|
|
|
|
|
+ Log.i(TAG, "waitForRcsState: $resetSuccess")
|
|
|
|
|
+ Global.suspend(gms = true, sms = true)
|
|
|
|
|
+ delay(1000)
|
|
|
|
|
+ Global.unsuspend(gms = true, sms = true)
|
|
|
|
|
+ delay(1000)
|
|
|
|
|
+ requestNumberCount = 0
|
|
|
|
|
+ break
|
|
|
}
|
|
}
|
|
|
- val rect = Rect()
|
|
|
|
|
- res.rcsSwitch!!.getBoundsInScreen(rect)
|
|
|
|
|
- Utils.runAsRoot(
|
|
|
|
|
- "input tap ${rect.centerX()} ${rect.centerY()}",
|
|
|
|
|
- "sleep 1",
|
|
|
|
|
- CMD_BACK,
|
|
|
|
|
- CMD_RCS_SETTINGS_ACTIVITY,
|
|
|
|
|
- )
|
|
|
|
|
- Log.i(TAG, "RCS switch turned on, waiting for state change...")
|
|
|
|
|
-
|
|
|
|
|
- val resetSuccess = waitForRcsState(
|
|
|
|
|
- arrayOf(
|
|
|
|
|
- RcsConfigureState.READY,
|
|
|
|
|
- RcsConfigureState.RETRY
|
|
|
|
|
- ), 60.seconds
|
|
|
|
|
- )
|
|
|
|
|
- Log.i(TAG, "waitForRcsState: $resetSuccess")
|
|
|
|
|
-
|
|
|
|
|
- requestNumberCount = 0
|
|
|
|
|
- break
|
|
|
|
|
|
|
+ true
|
|
|
|
|
+ } ?: false
|
|
|
|
|
+ if (!resetSuccess) {
|
|
|
|
|
+ Log.e(TAG, "RCS reset failed, retrying...")
|
|
|
|
|
+ continue
|
|
|
}
|
|
}
|
|
|
- true
|
|
|
|
|
- } ?: false
|
|
|
|
|
- if (!resetSuccess) {
|
|
|
|
|
- Log.e(TAG, "RCS reset failed, retrying...")
|
|
|
|
|
- continue
|
|
|
|
|
}
|
|
}
|
|
|
- } else {
|
|
|
|
|
- Global.revealMessaging()
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ Utils.runAsRoot(CMD_MESSAGING_APP)
|
|
|
|
|
+ withContext(Dispatchers.Main) {
|
|
|
|
|
+ binding.tvLog.text = "Waiting for logs..."
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
- if (waitForRcsState(
|
|
|
|
|
- arrayOf(RcsConfigureState.WAITING_FOR_OTP),
|
|
|
|
|
- otpTimeout
|
|
|
|
|
- ) != RcsConfigureState.WAITING_FOR_OTP
|
|
|
|
|
- ) {
|
|
|
|
|
- Log.e(TAG, "RCS not entered waiting for OTP state, retrying...")
|
|
|
|
|
- continue
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ if (rcsNumber.expiryTime.isBefore(LocalDateTime.now())) {
|
|
|
|
|
+ Log.e(TAG, "RCS number expired, retrying...")
|
|
|
|
|
+ continue
|
|
|
|
|
+ }
|
|
|
|
|
+ val sendOtpTimeout = ChronoUnit.SECONDS.between(
|
|
|
|
|
+ LocalDateTime.now(),
|
|
|
|
|
+ rcsNumber.expiryTime
|
|
|
|
|
+ ).seconds
|
|
|
|
|
+ if (sendOtpTimeout < 60.seconds) {
|
|
|
|
|
+ Log.e(TAG, "OTP timeout too short, retrying...")
|
|
|
|
|
+ continue
|
|
|
|
|
+ }
|
|
|
|
|
+ if (waitForRcsState(
|
|
|
|
|
+ arrayOf(RcsConfigureState.WAITING_FOR_OTP),
|
|
|
|
|
+ sendOtpTimeout
|
|
|
|
|
+ ) != RcsConfigureState.WAITING_FOR_OTP
|
|
|
|
|
+ ) {
|
|
|
|
|
+ Log.e(TAG, "RCS not entered waiting for OTP state, retrying...")
|
|
|
|
|
+ continue
|
|
|
|
|
+ }
|
|
|
|
|
+ if (rcsNumber.expiryTime.isBefore(LocalDateTime.now())) {
|
|
|
|
|
+ Log.e(TAG, "RCS number expired, retrying...")
|
|
|
|
|
+ continue
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
- withTimeoutOrNull(60.seconds) {
|
|
|
|
|
- while (true) {
|
|
|
|
|
- try {
|
|
|
|
|
- rcsRes = KtorClient.get(RcsNumberApi.Id(id = rcsRes!!.id))
|
|
|
|
|
- .body<RcsNumberResponse>()
|
|
|
|
|
- Log.i(TAG, "wait for otp response: $rcsRes")
|
|
|
|
|
- if (rcsRes!!.status == RcsNumberResponse.STATUS_SUCCESS) {
|
|
|
|
|
- break
|
|
|
|
|
|
|
+ withTimeoutOrNull(60.seconds) {
|
|
|
|
|
+ while (true) {
|
|
|
|
|
+ try {
|
|
|
|
|
+ rcsNumber = KtorClient.get(RcsNumberApi.Id(id = rcsNumber.id))
|
|
|
|
|
+ .body<RcsNumberResponse>()
|
|
|
|
|
+ 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(TAG, "wait for otp Error: ${exception.stackTrace}")
|
|
|
}
|
|
}
|
|
|
- } catch (exception: Exception) {
|
|
|
|
|
- Log.e(TAG, "wait for otp Error: ${exception.stackTrace}")
|
|
|
|
|
|
|
+ delay(2.seconds)
|
|
|
}
|
|
}
|
|
|
- delay(2.seconds)
|
|
|
|
|
}
|
|
}
|
|
|
- }
|
|
|
|
|
|
|
|
|
|
- if (rcsRes!!.status != RcsNumberResponse.STATUS_SUCCESS) {
|
|
|
|
|
- Log.e(TAG, "OTP not received, retrying...")
|
|
|
|
|
- continue
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ if (rcsNumber.status != RcsNumberResponse.STATUS_SUCCESS) {
|
|
|
|
|
+ Log.e(TAG, "OTP not received, retrying...")
|
|
|
|
|
+ continue
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
- val match =
|
|
|
|
|
- Regex("Your Messenger verification code is G-(\\d{6})")
|
|
|
|
|
- .matchEntire(rcsRes!!.message!!)
|
|
|
|
|
- if (match != null) {
|
|
|
|
|
- val otp = match.groupValues[1]
|
|
|
|
|
- Log.i(TAG, "OTP: $otp")
|
|
|
|
|
- val sender = "3538"
|
|
|
|
|
- val msg = "Your Messenger verification code is G-$otp"
|
|
|
|
|
-
|
|
|
|
|
- val configured = run a@{
|
|
|
|
|
- repeat(2) {
|
|
|
|
|
- Global.sendSmsIntent(sender, msg)
|
|
|
|
|
- val state =
|
|
|
|
|
- waitForRcsState(
|
|
|
|
|
- arrayOf(
|
|
|
|
|
- RcsConfigureState.CONFIGURED,
|
|
|
|
|
- RcsConfigureState.RETRY
|
|
|
|
|
- ), 60.seconds
|
|
|
|
|
- )
|
|
|
|
|
- if (state == RcsConfigureState.CONFIGURED) {
|
|
|
|
|
- return@a true
|
|
|
|
|
- } else if (state == RcsConfigureState.RETRY) {
|
|
|
|
|
- waitForRcsState(
|
|
|
|
|
- arrayOf(RcsConfigureState.WAITING_FOR_OTP),
|
|
|
|
|
- 60.seconds
|
|
|
|
|
- )
|
|
|
|
|
- } else {
|
|
|
|
|
- Log.e(TAG, "verifyOtp fail, retrying...")
|
|
|
|
|
|
|
+ val match =
|
|
|
|
|
+ Regex("Your Messenger verification code is G-(\\d{6})")
|
|
|
|
|
+ .matchEntire(rcsNumber.message!!)
|
|
|
|
|
+ if (match != null) {
|
|
|
|
|
+ val otp = match.groupValues[1]
|
|
|
|
|
+ Log.i(TAG, "OTP: $otp")
|
|
|
|
|
+ val sender = "3538"
|
|
|
|
|
+ val msg = "Your Messenger verification code is G-$otp"
|
|
|
|
|
+
|
|
|
|
|
+ val configured = run configuring@{
|
|
|
|
|
+ repeat(2) {
|
|
|
|
|
+ Global.sendSmsIntent(sender, msg)
|
|
|
|
|
+ val state =
|
|
|
|
|
+ waitForRcsState(
|
|
|
|
|
+ arrayOf(
|
|
|
|
|
+ RcsConfigureState.CONFIGURED,
|
|
|
|
|
+ RcsConfigureState.RETRY
|
|
|
|
|
+ ), 60.seconds
|
|
|
|
|
+ )
|
|
|
|
|
+ when (state) {
|
|
|
|
|
+ RcsConfigureState.CONFIGURED -> {
|
|
|
|
|
+ return@configuring true
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ RcsConfigureState.RETRY -> {
|
|
|
|
|
+ waitForRcsState(
|
|
|
|
|
+ arrayOf(RcsConfigureState.WAITING_FOR_OTP),
|
|
|
|
|
+ 60.seconds
|
|
|
|
|
+ )
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ else -> {
|
|
|
|
|
+ Log.e(TAG, "verifyOtp fail, retrying...")
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
|
|
+ false
|
|
|
|
|
+ }
|
|
|
|
|
+ if (!configured) {
|
|
|
|
|
+ Log.e(TAG, "RCS not configured, retrying...")
|
|
|
|
|
+ continue
|
|
|
|
|
+ } else {
|
|
|
|
|
+ requestSuccess = true
|
|
|
|
|
+ break
|
|
|
}
|
|
}
|
|
|
- false
|
|
|
|
|
- }
|
|
|
|
|
- if (!configured) {
|
|
|
|
|
- Log.e(TAG, "RCS not configured, retrying...")
|
|
|
|
|
- continue
|
|
|
|
|
- } else {
|
|
|
|
|
- break
|
|
|
|
|
}
|
|
}
|
|
|
|
|
+ } catch (e: Exception) {
|
|
|
|
|
+ Log.e(TAG, "requestNumberError: ${e.message}", e)
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
- true
|
|
|
|
|
- } ?: false
|
|
|
|
|
|
|
+ }
|
|
|
requesting.postValue(false)
|
|
requesting.postValue(false)
|
|
|
- if (result) {
|
|
|
|
|
|
|
+ if (requestSuccess) {
|
|
|
sendCount = 0
|
|
sendCount = 0
|
|
|
counter = 0
|
|
counter = 0
|
|
|
Log.i(TAG, "requestNumber success")
|
|
Log.i(TAG, "requestNumber success")
|
|
@@ -930,7 +966,6 @@ class ModifierService : AccessibilityService(), Emitter.Listener {
|
|
|
canSend = false
|
|
canSend = false
|
|
|
Log.e(TAG, "requestNumber failed")
|
|
Log.e(TAG, "requestNumber failed")
|
|
|
}
|
|
}
|
|
|
- Utils.runAsRoot(CMD_BACK)
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
suspend fun checkRcsAvailability(): Boolean {
|
|
suspend fun checkRcsAvailability(): Boolean {
|