|
@@ -61,13 +61,11 @@ import com.example.modifier.enums.RcsConnectionStatus
|
|
|
import com.example.modifier.extension.kill
|
|
import com.example.modifier.extension.kill
|
|
|
import com.example.modifier.hasRootAccess
|
|
import com.example.modifier.hasRootAccess
|
|
|
import com.example.modifier.http.KtorClient
|
|
import com.example.modifier.http.KtorClient
|
|
|
-import com.example.modifier.http.KtorClient1
|
|
|
|
|
import com.example.modifier.http.api.DeviceApi
|
|
import com.example.modifier.http.api.DeviceApi
|
|
|
import com.example.modifier.http.api.RcsNumberApi
|
|
import com.example.modifier.http.api.RcsNumberApi
|
|
|
import com.example.modifier.http.api.SysConfigApi
|
|
import com.example.modifier.http.api.SysConfigApi
|
|
|
import com.example.modifier.http.request.RcsNumberRequest
|
|
import com.example.modifier.http.request.RcsNumberRequest
|
|
|
import com.example.modifier.http.response.DeviceResponse
|
|
import com.example.modifier.http.response.DeviceResponse
|
|
|
-import com.example.modifier.http.response.ErrorResponse
|
|
|
|
|
import com.example.modifier.http.response.RcsNumberResponse
|
|
import com.example.modifier.http.response.RcsNumberResponse
|
|
|
import com.example.modifier.http.response.SysConfigResponse
|
|
import com.example.modifier.http.response.SysConfigResponse
|
|
|
import com.example.modifier.model.InstallApkAction
|
|
import com.example.modifier.model.InstallApkAction
|
|
@@ -81,12 +79,13 @@ import com.google.android.material.color.DynamicColors
|
|
|
import io.ktor.client.HttpClient
|
|
import io.ktor.client.HttpClient
|
|
|
import io.ktor.client.call.body
|
|
import io.ktor.client.call.body
|
|
|
import io.ktor.client.engine.okhttp.OkHttp
|
|
import io.ktor.client.engine.okhttp.OkHttp
|
|
|
-import io.ktor.client.plugins.ClientRequestException
|
|
|
|
|
import io.ktor.client.plugins.HttpResponseValidator
|
|
import io.ktor.client.plugins.HttpResponseValidator
|
|
|
import io.ktor.client.plugins.ServerResponseException
|
|
import io.ktor.client.plugins.ServerResponseException
|
|
|
import io.ktor.client.plugins.resources.get
|
|
import io.ktor.client.plugins.resources.get
|
|
|
import io.ktor.client.plugins.resources.post
|
|
import io.ktor.client.plugins.resources.post
|
|
|
import io.ktor.client.plugins.resources.put
|
|
import io.ktor.client.plugins.resources.put
|
|
|
|
|
+import io.ktor.client.plugins.retry
|
|
|
|
|
+import io.ktor.client.plugins.timeout
|
|
|
import io.ktor.client.request.prepareGet
|
|
import io.ktor.client.request.prepareGet
|
|
|
import io.ktor.client.request.setBody
|
|
import io.ktor.client.request.setBody
|
|
|
import io.ktor.http.ContentType
|
|
import io.ktor.http.ContentType
|
|
@@ -1283,6 +1282,9 @@ class ModifierService : AccessibilityService(), Emitter.Listener {
|
|
|
) {
|
|
) {
|
|
|
contentType(ContentType.Application.Json)
|
|
contentType(ContentType.Application.Json)
|
|
|
setBody(req)
|
|
setBody(req)
|
|
|
|
|
+ timeout {
|
|
|
|
|
+ requestTimeoutMillis = 60 * 1000
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
var rcsNumber = response.body<RcsNumberResponse>()
|
|
var rcsNumber = response.body<RcsNumberResponse>()
|
|
|
Log.i(TAG, "requestNumber response: $rcsNumber")
|
|
Log.i(TAG, "requestNumber response: $rcsNumber")
|
|
@@ -1346,22 +1348,17 @@ class ModifierService : AccessibilityService(), Emitter.Listener {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
launch {
|
|
launch {
|
|
|
- run OtpState@{
|
|
|
|
|
- repeat(3) {
|
|
|
|
|
- try {
|
|
|
|
|
- KtorClient.post(
|
|
|
|
|
- RcsNumberApi.Id.OtpState(
|
|
|
|
|
- RcsNumberApi.Id(
|
|
|
|
|
- RcsNumberApi(),
|
|
|
|
|
- rcsNumber.id
|
|
|
|
|
- )
|
|
|
|
|
- )
|
|
|
|
|
|
|
+ try {
|
|
|
|
|
+ KtorClient.post(
|
|
|
|
|
+ RcsNumberApi.Id.OtpState(
|
|
|
|
|
+ RcsNumberApi.Id(
|
|
|
|
|
+ RcsNumberApi(),
|
|
|
|
|
+ rcsNumber.id
|
|
|
)
|
|
)
|
|
|
- return@OtpState
|
|
|
|
|
- } catch (e: Exception) {
|
|
|
|
|
- Log.e(TAG, "Send OtpState Error: ${e.message}", e)
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ )
|
|
|
|
|
+ )
|
|
|
|
|
+ } catch (e: Exception) {
|
|
|
|
|
+ Log.e(TAG, "Send OtpState Error: ${e.message}", e)
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -1434,26 +1431,21 @@ class ModifierService : AccessibilityService(), Emitter.Listener {
|
|
|
continue
|
|
continue
|
|
|
} else {
|
|
} else {
|
|
|
launch {
|
|
launch {
|
|
|
- run ConfiguredState@{
|
|
|
|
|
- repeat(3) {
|
|
|
|
|
- try {
|
|
|
|
|
- KtorClient.post(
|
|
|
|
|
- RcsNumberApi.Id.Configured(
|
|
|
|
|
- RcsNumberApi.Id(
|
|
|
|
|
- RcsNumberApi(),
|
|
|
|
|
- rcsNumber.id
|
|
|
|
|
- )
|
|
|
|
|
- )
|
|
|
|
|
- )
|
|
|
|
|
- return@ConfiguredState
|
|
|
|
|
- } catch (e: Exception) {
|
|
|
|
|
- Log.e(
|
|
|
|
|
- TAG,
|
|
|
|
|
- "Send ConfiguredState Error: ${e.message}",
|
|
|
|
|
- e
|
|
|
|
|
|
|
+ try {
|
|
|
|
|
+ KtorClient.post(
|
|
|
|
|
+ RcsNumberApi.Id.Configured(
|
|
|
|
|
+ RcsNumberApi.Id(
|
|
|
|
|
+ RcsNumberApi(),
|
|
|
|
|
+ rcsNumber.id
|
|
|
)
|
|
)
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ )
|
|
|
|
|
+ )
|
|
|
|
|
+ } catch (e: Exception) {
|
|
|
|
|
+ Log.e(
|
|
|
|
|
+ TAG,
|
|
|
|
|
+ "Send ConfiguredState Error: ${e.message}",
|
|
|
|
|
+ e
|
|
|
|
|
+ )
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
requestSuccess = true
|
|
requestSuccess = true
|
|
@@ -1519,26 +1511,28 @@ class ModifierService : AccessibilityService(), Emitter.Listener {
|
|
|
var config: SysConfigResponse
|
|
var config: SysConfigResponse
|
|
|
val checkRcsAvailabilityNumbers = mutableListOf<String>()
|
|
val checkRcsAvailabilityNumbers = mutableListOf<String>()
|
|
|
withTimeoutOrNull(60.seconds) {
|
|
withTimeoutOrNull(60.seconds) {
|
|
|
- while (true) {
|
|
|
|
|
- try {
|
|
|
|
|
- config = KtorClient.get(
|
|
|
|
|
- SysConfigApi.Id(
|
|
|
|
|
- SysConfigApi(),
|
|
|
|
|
- "check_availability_numbers"
|
|
|
|
|
- )
|
|
|
|
|
|
|
+ try {
|
|
|
|
|
+ config = KtorClient.get(
|
|
|
|
|
+ SysConfigApi.Id(
|
|
|
|
|
+ SysConfigApi(),
|
|
|
|
|
+ "check_availability_numbers"
|
|
|
)
|
|
)
|
|
|
- .body<SysConfigResponse>()
|
|
|
|
|
- Log.i(TAG, "sysConfig response: $config")
|
|
|
|
|
- checkRcsAvailabilityNumbers.addAll(
|
|
|
|
|
- config.value.split(",").map { it.trim() })
|
|
|
|
|
- break
|
|
|
|
|
- } catch (exception: Exception) {
|
|
|
|
|
- Log.e(TAG, "sysConfig Error: ${exception.message}", exception)
|
|
|
|
|
- }
|
|
|
|
|
- delay(1.seconds)
|
|
|
|
|
|
|
+ )
|
|
|
|
|
+ .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()) {
|
|
|
|
|
+ Log.e(TAG, "checkRcsAvailabilityNumbers is empty")
|
|
|
|
|
+ return true
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
checkRcsAvailabilityNumbers.forEach {
|
|
checkRcsAvailabilityNumbers.forEach {
|
|
|
startActivity(smsIntent(it, ""))
|
|
startActivity(smsIntent(it, ""))
|
|
|
val s = withTimeoutOrNull(5.seconds) {
|
|
val s = withTimeoutOrNull(5.seconds) {
|