|
@@ -27,7 +27,7 @@ import com.example.modifier.TraverseResult
|
|
|
import com.example.modifier.baseTag
|
|
import com.example.modifier.baseTag
|
|
|
import com.example.modifier.data.AppDatabase
|
|
import com.example.modifier.data.AppDatabase
|
|
|
import com.example.modifier.databinding.FloatingWindowBinding
|
|
import com.example.modifier.databinding.FloatingWindowBinding
|
|
|
-import com.example.modifier.enums.RequestNumberState
|
|
|
|
|
|
|
+import com.example.modifier.enums.ReqState
|
|
|
import com.example.modifier.http.api.RcsNumberApi
|
|
import com.example.modifier.http.api.RcsNumberApi
|
|
|
import com.example.modifier.repo.AppPrefsRepo
|
|
import com.example.modifier.repo.AppPrefsRepo
|
|
|
import com.example.modifier.repo.AppStateRepo
|
|
import com.example.modifier.repo.AppStateRepo
|
|
@@ -47,6 +47,7 @@ import kotlinx.coroutines.CoroutineScope
|
|
|
import kotlinx.coroutines.Dispatchers
|
|
import kotlinx.coroutines.Dispatchers
|
|
|
import kotlinx.coroutines.FlowPreview
|
|
import kotlinx.coroutines.FlowPreview
|
|
|
import kotlinx.coroutines.delay
|
|
import kotlinx.coroutines.delay
|
|
|
|
|
+import kotlinx.coroutines.flow.collect
|
|
|
import kotlinx.coroutines.flow.debounce
|
|
import kotlinx.coroutines.flow.debounce
|
|
|
import kotlinx.coroutines.launch
|
|
import kotlinx.coroutines.launch
|
|
|
import kotlinx.coroutines.withContext
|
|
import kotlinx.coroutines.withContext
|
|
@@ -174,11 +175,16 @@ class ModifierService : AccessibilityService() {
|
|
|
gmsgStateRepository,
|
|
gmsgStateRepository,
|
|
|
backupRepository,
|
|
backupRepository,
|
|
|
)
|
|
)
|
|
|
|
|
+ launch {
|
|
|
|
|
+ appStateRepo.appState.debounce(200).collect {
|
|
|
|
|
+ socketClient.reportDeviceStatues()
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
launch {
|
|
launch {
|
|
|
appStateRepo.appState.collect {
|
|
appStateRepo.appState.collect {
|
|
|
withContext(Dispatchers.Main) {
|
|
withContext(Dispatchers.Main) {
|
|
|
binding.swSend.isChecked = it.send
|
|
binding.swSend.isChecked = it.send
|
|
|
- binding.btnReq.isEnabled = !it.requesting
|
|
|
|
|
|
|
+ binding.btnReq.isEnabled = it.reqState == ReqState.NONE
|
|
|
binding.tvCount.text = "${it.successNum} / ${it.executedNum}"
|
|
binding.tvCount.text = "${it.successNum} / ${it.executedNum}"
|
|
|
if (it.suspended) {
|
|
if (it.suspended) {
|
|
|
binding.btnReq.backgroundTintList = ContextCompat.getColorStateList(
|
|
binding.btnReq.backgroundTintList = ContextCompat.getColorStateList(
|
|
@@ -191,43 +197,48 @@ class ModifierService : AccessibilityService() {
|
|
|
R.color.btn_color
|
|
R.color.btn_color
|
|
|
)
|
|
)
|
|
|
}
|
|
}
|
|
|
- when (it.requestNumberState) {
|
|
|
|
|
- RequestNumberState.IDLE -> {
|
|
|
|
|
|
|
+ when (it.reqState) {
|
|
|
|
|
+ ReqState.NONE -> {
|
|
|
binding.tvStatus.visibility = GONE
|
|
binding.tvStatus.visibility = GONE
|
|
|
binding.tvStatus.text = ""
|
|
binding.tvStatus.text = ""
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- RequestNumberState.RESET -> {
|
|
|
|
|
|
|
+ ReqState.CLEAN -> {
|
|
|
|
|
+ binding.tvStatus.visibility = VISIBLE
|
|
|
|
|
+ binding.tvStatus.text = "cleaning messages"
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ ReqState.RESET -> {
|
|
|
binding.tvStatus.visibility = VISIBLE
|
|
binding.tvStatus.visibility = VISIBLE
|
|
|
binding.tvStatus.text = "resetting GMS"
|
|
binding.tvStatus.text = "resetting GMS"
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- RequestNumberState.BACKUP -> {
|
|
|
|
|
|
|
+ ReqState.BACKUP -> {
|
|
|
binding.tvStatus.visibility = VISIBLE
|
|
binding.tvStatus.visibility = VISIBLE
|
|
|
binding.tvStatus.text = "backing up"
|
|
binding.tvStatus.text = "backing up"
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- RequestNumberState.RESTORE -> {
|
|
|
|
|
|
|
+ ReqState.RESTORE -> {
|
|
|
binding.tvStatus.visibility = VISIBLE
|
|
binding.tvStatus.visibility = VISIBLE
|
|
|
binding.tvStatus.text = "restoring"
|
|
binding.tvStatus.text = "restoring"
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- RequestNumberState.REQUEST -> {
|
|
|
|
|
|
|
+ ReqState.REQUEST -> {
|
|
|
binding.tvStatus.visibility = VISIBLE
|
|
binding.tvStatus.visibility = VISIBLE
|
|
|
binding.tvStatus.text = "requesting number"
|
|
binding.tvStatus.text = "requesting number"
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- RequestNumberState.OTP_1 -> {
|
|
|
|
|
|
|
+ ReqState.OTP_1 -> {
|
|
|
binding.tvStatus.visibility = VISIBLE
|
|
binding.tvStatus.visibility = VISIBLE
|
|
|
binding.tvStatus.text = "waiting for OTP sent"
|
|
binding.tvStatus.text = "waiting for OTP sent"
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- RequestNumberState.OTP_2 -> {
|
|
|
|
|
|
|
+ ReqState.OTP_2 -> {
|
|
|
binding.tvStatus.visibility = VISIBLE
|
|
binding.tvStatus.visibility = VISIBLE
|
|
|
binding.tvStatus.text = "waiting for OTP received"
|
|
binding.tvStatus.text = "waiting for OTP received"
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- RequestNumberState.CONFIG -> {
|
|
|
|
|
|
|
+ ReqState.CONFIG -> {
|
|
|
binding.tvStatus.visibility = VISIBLE
|
|
binding.tvStatus.visibility = VISIBLE
|
|
|
binding.tvStatus.text = "waiting for configuration"
|
|
binding.tvStatus.text = "waiting for configuration"
|
|
|
}
|
|
}
|
|
@@ -336,9 +347,10 @@ class ModifierService : AccessibilityService() {
|
|
|
val popup = PopupMenu(context, v)
|
|
val popup = PopupMenu(context, v)
|
|
|
popup.menuInflater.inflate(menuRes, popup.menu)
|
|
popup.menuInflater.inflate(menuRes, popup.menu)
|
|
|
popup.menu.findItem(R.id.store_numbers).isEnabled =
|
|
popup.menu.findItem(R.id.store_numbers).isEnabled =
|
|
|
- !appStateRepo.appRuntimeFlags.value.storing
|
|
|
|
|
|
|
+ !appStateRepo.appState.value.storing
|
|
|
|
|
+ popup.menu.findItem(R.id.check_availability).isEnabled =
|
|
|
|
|
+ !appStateRepo.appState.value.checkingConnection
|
|
|
popup.setOnMenuItemClickListener { item ->
|
|
popup.setOnMenuItemClickListener { item ->
|
|
|
- binding.btnMore.isEnabled = false
|
|
|
|
|
CoroutineScope(Dispatchers.IO).launch {
|
|
CoroutineScope(Dispatchers.IO).launch {
|
|
|
when (item.itemId) {
|
|
when (item.itemId) {
|
|
|
R.id.inspect -> {
|
|
R.id.inspect -> {
|
|
@@ -347,7 +359,9 @@ class ModifierService : AccessibilityService() {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
R.id.check_availability -> {
|
|
R.id.check_availability -> {
|
|
|
|
|
+ appStateRepo.updateRuntimeFlags(checkingConnection = true)
|
|
|
taskRunner.checkRcsA10y()
|
|
taskRunner.checkRcsA10y()
|
|
|
|
|
+ appStateRepo.updateRuntimeFlags(checkingConnection = false)
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
R.id.toggle_on -> {
|
|
R.id.toggle_on -> {
|
|
@@ -364,7 +378,7 @@ class ModifierService : AccessibilityService() {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
R.id.store_numbers -> {
|
|
R.id.store_numbers -> {
|
|
|
- if (!appStateRepo.appRuntimeFlags.value.storing) {
|
|
|
|
|
|
|
+ if (!appStateRepo.appState.value.storing) {
|
|
|
launch {
|
|
launch {
|
|
|
storeNumbers()
|
|
storeNumbers()
|
|
|
}
|
|
}
|
|
@@ -387,10 +401,6 @@ class ModifierService : AccessibilityService() {
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
- withContext(Dispatchers.Main) {
|
|
|
|
|
- binding.btnMore.isEnabled = true
|
|
|
|
|
- }
|
|
|
|
|
}
|
|
}
|
|
|
true
|
|
true
|
|
|
}
|
|
}
|
|
@@ -402,17 +412,19 @@ class ModifierService : AccessibilityService() {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
private suspend fun storeNumbers() {
|
|
private suspend fun storeNumbers() {
|
|
|
|
|
+ val num = appPrefsRepo.appPrefs.value.storeNum
|
|
|
|
|
+ if (num <= 0) {
|
|
|
|
|
+ return
|
|
|
|
|
+ }
|
|
|
appStateRepo.updateRuntimeFlags(storing = true)
|
|
appStateRepo.updateRuntimeFlags(storing = true)
|
|
|
var success = true
|
|
var success = true
|
|
|
var retry = 0
|
|
var retry = 0
|
|
|
- val num = 10
|
|
|
|
|
repeat(num) {
|
|
repeat(num) {
|
|
|
Log.i(TAG, "storeNumbers: $it")
|
|
Log.i(TAG, "storeNumbers: $it")
|
|
|
try {
|
|
try {
|
|
|
if (success || retry > 3) {
|
|
if (success || retry > 3) {
|
|
|
taskRunner.reset()
|
|
taskRunner.reset()
|
|
|
}
|
|
}
|
|
|
- appStateRepo.updateRuntimeFlags(requesting = true)
|
|
|
|
|
taskRunner.requestNumberAtomic()
|
|
taskRunner.requestNumberAtomic()
|
|
|
spoofedSimInfoRepo.updateSpoofedSimInfo(
|
|
spoofedSimInfoRepo.updateSpoofedSimInfo(
|
|
|
spoofedSimInfo = spoofedSimInfoRepo.spoofedSimInfo.value.copy(
|
|
spoofedSimInfo = spoofedSimInfoRepo.spoofedSimInfo.value.copy(
|
|
@@ -420,27 +432,26 @@ class ModifierService : AccessibilityService() {
|
|
|
),
|
|
),
|
|
|
suspend = false
|
|
suspend = false
|
|
|
)
|
|
)
|
|
|
- appStateRepo.updateRuntimeFlags(requesting = false)
|
|
|
|
|
- if (it < num - 1) {
|
|
|
|
|
- appStateRepo.updateRuntimeFlags(requestNumberState = RequestNumberState.BACKUP)
|
|
|
|
|
- taskRunner.screenController.toggleRcsSwitch(false)
|
|
|
|
|
- backupRepository.backup(type = "auto", sendCount = 0, stock = 1)
|
|
|
|
|
- RcsNumberApi.updateStockFlag(
|
|
|
|
|
- id = spoofedSimInfoRepo.spoofedSimInfo.value.numberId,
|
|
|
|
|
- flag = 1
|
|
|
|
|
- )
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ appStateRepo.updateRuntimeFlags(reqState = ReqState.BACKUP)
|
|
|
|
|
+ taskRunner.screenController.toggleRcsSwitch(false)
|
|
|
|
|
+ backupRepository.backup(type = "auto", sendCount = 0, stock = 1)
|
|
|
|
|
+ RcsNumberApi.updateStockFlag(
|
|
|
|
|
+ id = spoofedSimInfoRepo.spoofedSimInfo.value.numberId,
|
|
|
|
|
+ flag = 1
|
|
|
|
|
+ )
|
|
|
success = true
|
|
success = true
|
|
|
retry = 0
|
|
retry = 0
|
|
|
} catch (e: Exception) {
|
|
} catch (e: Exception) {
|
|
|
- appStateRepo.updateRuntimeFlags(requesting = false)
|
|
|
|
|
success = false
|
|
success = false
|
|
|
retry++
|
|
retry++
|
|
|
Log.i(TAG, "Error store number, retry: $retry", e)
|
|
Log.i(TAG, "Error store number, retry: $retry", e)
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
+ if (success) {
|
|
|
|
|
+ taskRunner.reset()
|
|
|
|
|
+ }
|
|
|
appStateRepo.updateRuntimeFlags(
|
|
appStateRepo.updateRuntimeFlags(
|
|
|
- requestNumberState = RequestNumberState.IDLE,
|
|
|
|
|
|
|
+ reqState = ReqState.NONE,
|
|
|
storing = false
|
|
storing = false
|
|
|
)
|
|
)
|
|
|
}
|
|
}
|