|
@@ -213,7 +213,7 @@ class TaskRunner(
|
|
|
return@run true
|
|
return@run true
|
|
|
}
|
|
}
|
|
|
appStateRepo.incrementGroupExecutedNum(1, success)
|
|
appStateRepo.incrementGroupExecutedNum(1, success)
|
|
|
- return true
|
|
|
|
|
|
|
+ return success
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
suspend fun runTask(
|
|
suspend fun runTask(
|
|
@@ -232,7 +232,7 @@ class TaskRunner(
|
|
|
requestMode = if (taskAction.data.config.useBackup) 2 else 1
|
|
requestMode = if (taskAction.data.config.useBackup) 2 else 1
|
|
|
|
|
|
|
|
if (!spoofedInfoRepo.spoofedInfo.value.available ||
|
|
if (!spoofedInfoRepo.spoofedInfo.value.available ||
|
|
|
- (taskAction.data.config.checkConnection && appStateRepo.appState.value.singleExecuted == 0)
|
|
|
|
|
|
|
+ (taskAction.data.config.checkConnection && appStateRepo.appState.value.singleExecuted == 0 && appStateRepo.appState.value.groupExecuted == 0)
|
|
|
) {
|
|
) {
|
|
|
appStateRepo.updateRuntimeFlags(checkingConnection = true)
|
|
appStateRepo.updateRuntimeFlags(checkingConnection = true)
|
|
|
if (!spoofedInfoRepo.spoofedInfo.value.available || !checkRcsA10y()) {
|
|
if (!spoofedInfoRepo.spoofedInfo.value.available || !checkRcsA10y()) {
|
|
@@ -254,7 +254,7 @@ class TaskRunner(
|
|
|
val results = mutableListOf<TaskExecutionResult>()
|
|
val results = mutableListOf<TaskExecutionResult>()
|
|
|
|
|
|
|
|
while (tasks.isNotEmpty() && taskConfig.groupMode && tasks.size > 2 && appStateRepo.appState.value.groupExecuted < taskConfig.groupQty) {
|
|
while (tasks.isNotEmpty() && taskConfig.groupMode && tasks.size > 2 && appStateRepo.appState.value.groupExecuted < taskConfig.groupQty) {
|
|
|
- val items = tasks.take(taskConfig.groupQty)
|
|
|
|
|
|
|
+ val items = tasks.take(taskConfig.groupSize)
|
|
|
tasks.removeAll(items)
|
|
tasks.removeAll(items)
|
|
|
val groupSent = groupSend(
|
|
val groupSent = groupSend(
|
|
|
to = items.map { it.number }.toTypedArray(),
|
|
to = items.map { it.number }.toTypedArray(),
|
|
@@ -266,13 +266,13 @@ class TaskRunner(
|
|
|
TaskExecutionResult(
|
|
TaskExecutionResult(
|
|
|
id = it.id,
|
|
id = it.id,
|
|
|
numberId = spoofedInfoRepo.spoofedInfo.value.numberId,
|
|
numberId = spoofedInfoRepo.spoofedInfo.value.numberId,
|
|
|
- sent = true,
|
|
|
|
|
|
|
+ sent = 1,
|
|
|
delivery = if (groupSent) 1 else 0
|
|
delivery = if (groupSent) 1 else 0
|
|
|
)
|
|
)
|
|
|
})
|
|
})
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- while (tasks.isNotEmpty()) {
|
|
|
|
|
|
|
+ while (tasks.isNotEmpty() && appStateRepo.appState.value.singleExecuted < taskConfig.singleQty) {
|
|
|
val taskItem = tasks[0]
|
|
val taskItem = tasks[0]
|
|
|
tasks.removeAt(0)
|
|
tasks.removeAt(0)
|
|
|
val result = TaskExecutionResult(
|
|
val result = TaskExecutionResult(
|
|
@@ -282,11 +282,29 @@ class TaskRunner(
|
|
|
results.add(result)
|
|
results.add(result)
|
|
|
try {
|
|
try {
|
|
|
gmsgStateRepo.addToWatchList(result)
|
|
gmsgStateRepo.addToWatchList(result)
|
|
|
- result.sent = send(taskItem.number, taskItem.message, taskItem.img, taskConfig)
|
|
|
|
|
|
|
+ result.sent = if (send(
|
|
|
|
|
+ taskItem.number,
|
|
|
|
|
+ taskItem.message,
|
|
|
|
|
+ taskItem.img,
|
|
|
|
|
+ taskConfig
|
|
|
|
|
+ )
|
|
|
|
|
+ ) 1 else 0
|
|
|
} catch (e: Exception) {
|
|
} catch (e: Exception) {
|
|
|
Log.e(TAG, "runTaskError: ${e.message}", e)
|
|
Log.e(TAG, "runTaskError: ${e.message}", e)
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
|
|
+ while (tasks.isNotEmpty()) {
|
|
|
|
|
+ val taskItem = tasks[0]
|
|
|
|
|
+ tasks.removeAt(0)
|
|
|
|
|
+ results.add(
|
|
|
|
|
+ TaskExecutionResult(
|
|
|
|
|
+ id = taskItem.id,
|
|
|
|
|
+ sent = 2
|
|
|
|
|
+ )
|
|
|
|
|
+ )
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
shellRun(CMD_BACK)
|
|
shellRun(CMD_BACK)
|
|
|
delay(5000)
|
|
delay(5000)
|
|
|
onSuccess(results)
|
|
onSuccess(results)
|
|
@@ -303,7 +321,7 @@ class TaskRunner(
|
|
|
delay(2000)
|
|
delay(2000)
|
|
|
}
|
|
}
|
|
|
appStateRepo.updateRuntimeFlags(running = false)
|
|
appStateRepo.updateRuntimeFlags(running = false)
|
|
|
- if (taskAction.data.config.checkConnection && results.none { it.sent }) {
|
|
|
|
|
|
|
+ if (taskAction.data.config.checkConnection && results.none { it.sent == 1 }) {
|
|
|
appStateRepo.updateRuntimeFlags(checkingConnection = true)
|
|
appStateRepo.updateRuntimeFlags(checkingConnection = true)
|
|
|
if (!checkRcsA10y()) {
|
|
if (!checkRcsA10y()) {
|
|
|
onError(Exception("RCS not available"))
|
|
onError(Exception("RCS not available"))
|
|
@@ -607,6 +625,7 @@ class TaskRunner(
|
|
|
return
|
|
return
|
|
|
}
|
|
}
|
|
|
appStateRepo.updateRuntimeFlags(reqState = ReqState.CLEAN)
|
|
appStateRepo.updateRuntimeFlags(reqState = ReqState.CLEAN)
|
|
|
|
|
+ DeviceApi.removePinTask(appPrefsRepo.appPrefs.value.id)
|
|
|
clearConv(restoreRole = false)
|
|
clearConv(restoreRole = false)
|
|
|
if (spoofedInfoRepo.spoofedInfo.value.available) {
|
|
if (spoofedInfoRepo.spoofedInfo.value.available) {
|
|
|
backupRepository.backup(
|
|
backupRepository.backup(
|
|
@@ -658,6 +677,8 @@ class TaskRunner(
|
|
|
spoofedInfoRepo.updateAvailable(available = true)
|
|
spoofedInfoRepo.updateAvailable(available = true)
|
|
|
appStateRepo.resetSuccessNum()
|
|
appStateRepo.resetSuccessNum()
|
|
|
appStateRepo.resetExecutedNum()
|
|
appStateRepo.resetExecutedNum()
|
|
|
|
|
+ appStateRepo.resetGroupExecutedNum()
|
|
|
|
|
+ appStateRepo.resetGroupSuccessNum()
|
|
|
Log.i(TAG, "requestNumber success")
|
|
Log.i(TAG, "requestNumber success")
|
|
|
} else {
|
|
} else {
|
|
|
Log.e(TAG, "requestNumber failed")
|
|
Log.e(TAG, "requestNumber failed")
|
|
@@ -891,7 +912,7 @@ class TaskRunner(
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- suspend fun cancelStoreNumber() {
|
|
|
|
|
|
|
+ fun cancelStoreNumber() {
|
|
|
if (storeNumberJob != null) {
|
|
if (storeNumberJob != null) {
|
|
|
if (storeNumberJob!!.isActive) {
|
|
if (storeNumberJob!!.isActive) {
|
|
|
storeNumberJob!!.cancel()
|
|
storeNumberJob!!.cancel()
|