|
|
@@ -81,6 +81,7 @@ import org.json.JSONObject
|
|
|
import java.io.File
|
|
|
import java.time.LocalDateTime
|
|
|
import java.time.temporal.ChronoUnit
|
|
|
+import kotlin.time.Duration.Companion.days
|
|
|
import kotlin.time.Duration.Companion.hours
|
|
|
import kotlin.time.Duration.Companion.minutes
|
|
|
import kotlin.time.Duration.Companion.seconds
|
|
|
@@ -194,7 +195,7 @@ class TaskRunner(
|
|
|
appStateRepository.updateRuntimeFlags(checkingConnection = false)
|
|
|
}
|
|
|
|
|
|
- appStateRepository.updateRuntimeFlags(running = true)
|
|
|
+ appStateRepository.updateRuntimeFlags(running = true, checkingConnection = false)
|
|
|
val success = ArrayList<Int>()
|
|
|
val fail = ArrayList<Int>()
|
|
|
for (i in 0 until taskAction.data.tasks.size) {
|
|
|
@@ -432,7 +433,7 @@ class TaskRunner(
|
|
|
if (requestMode == 2 && !noBackup) {
|
|
|
val backup = backupRepository.findBackupForRestore(
|
|
|
spoofedSimInfo.value.number,
|
|
|
- System.currentTimeMillis() - 2 * 24 * 60 * 60 * 1000
|
|
|
+ System.currentTimeMillis() - 2.days.inWholeMilliseconds
|
|
|
)
|
|
|
if (backup != null) {
|
|
|
if (backupRepository.restore(backup)) {
|
|
|
@@ -522,16 +523,10 @@ class TaskRunner(
|
|
|
needRest = true
|
|
|
}
|
|
|
if (RcsConfigureState.REPLAY_REQUEST == googleMessageStateRepository.rcsConfigureState.value) {
|
|
|
- Log.e(
|
|
|
- TAG,
|
|
|
- "REPLAY_REQUEST detected, may reset after 3 retry ($retry)"
|
|
|
- )
|
|
|
+ Log.e(TAG, "REPLAY_REQUEST detected, may reset after 3 retry ($retry)")
|
|
|
retry++
|
|
|
}
|
|
|
- Log.e(
|
|
|
- TAG,
|
|
|
- "RCS not entered waiting for OTP state, retrying..."
|
|
|
- )
|
|
|
+ Log.e(TAG, "RCS not entered waiting for OTP state, retrying...")
|
|
|
continue
|
|
|
}
|
|
|
|
|
|
@@ -567,10 +562,7 @@ class TaskRunner(
|
|
|
break
|
|
|
}
|
|
|
} catch (exception: Exception) {
|
|
|
- Log.e(
|
|
|
- TAG,
|
|
|
- "wait for otp Error: ${exception.stackTrace}"
|
|
|
- )
|
|
|
+ Log.e(TAG, "wait for otp Error: ${exception.stackTrace}")
|
|
|
}
|
|
|
delay(2.seconds)
|
|
|
}
|
|
|
@@ -615,10 +607,7 @@ class TaskRunner(
|
|
|
}
|
|
|
|
|
|
else -> {
|
|
|
- Log.e(
|
|
|
- TAG,
|
|
|
- "verifyOtp fail, retrying..."
|
|
|
- )
|
|
|
+ Log.e(TAG, "verifyOtp fail, retrying...")
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
@@ -701,35 +690,30 @@ class TaskRunner(
|
|
|
}
|
|
|
|
|
|
suspend fun checkRcsAvailability(): Boolean {
|
|
|
- appStateRepository.updateRuntimeFlags(checkingConnection = true)
|
|
|
val availability = run checkAvailability@{
|
|
|
val rcsConnected = checkRcsConnectivity()
|
|
|
if (!rcsConnected) {
|
|
|
return@checkAvailability false
|
|
|
}
|
|
|
|
|
|
- var config: SysConfigResponse
|
|
|
val checkRcsAvailabilityNumbers = mutableListOf<String>()
|
|
|
- withTimeoutOrNull(60.seconds) {
|
|
|
- try {
|
|
|
- config = ktorClient(appPreferences.value.server).get(
|
|
|
- SysConfigApi.Id(
|
|
|
- SysConfigApi(),
|
|
|
- "check_availability_numbers"
|
|
|
- )
|
|
|
- )
|
|
|
- .body<SysConfigResponse>()
|
|
|
- Log.i(TAG, "sysConfig response: $config")
|
|
|
- checkRcsAvailabilityNumbers.addAll(
|
|
|
- config.value.split(",").map { it.trim() })
|
|
|
-
|
|
|
- } catch (exception: Exception) {
|
|
|
- Log.e(
|
|
|
- TAG,
|
|
|
- "sysConfig Error: ${exception.message}",
|
|
|
- exception
|
|
|
+ try {
|
|
|
+ val config = ktorClient(appPreferences.value.server).get(
|
|
|
+ SysConfigApi.Id(
|
|
|
+ SysConfigApi(),
|
|
|
+ "check_availability_numbers"
|
|
|
)
|
|
|
- }
|
|
|
+ )
|
|
|
+ .body<SysConfigResponse>()
|
|
|
+ Log.i(TAG, "sysConfig response: $config")
|
|
|
+ checkRcsAvailabilityNumbers.addAll(
|
|
|
+ config.value.split(",").map { it.trim() })
|
|
|
+ } catch (exception: Exception) {
|
|
|
+ Log.e(
|
|
|
+ TAG,
|
|
|
+ "sysConfig Error: ${exception.message}",
|
|
|
+ exception
|
|
|
+ )
|
|
|
}
|
|
|
|
|
|
if (checkRcsAvailabilityNumbers.isEmpty()) {
|
|
|
@@ -762,7 +746,6 @@ class TaskRunner(
|
|
|
}
|
|
|
false
|
|
|
}
|
|
|
- appStateRepository.updateRuntimeFlags(checkingConnection = false)
|
|
|
return availability
|
|
|
}
|
|
|
|