|
@@ -1,12 +1,10 @@
|
|
|
package com.example.modifier.service
|
|
package com.example.modifier.service
|
|
|
|
|
|
|
|
import android.accessibilityservice.AccessibilityService
|
|
import android.accessibilityservice.AccessibilityService
|
|
|
-import android.accessibilityservice.AccessibilityServiceInfo
|
|
|
|
|
import android.annotation.SuppressLint
|
|
import android.annotation.SuppressLint
|
|
|
import android.content.ComponentName
|
|
import android.content.ComponentName
|
|
|
import android.content.Context
|
|
import android.content.Context
|
|
|
import android.graphics.PixelFormat
|
|
import android.graphics.PixelFormat
|
|
|
-import android.graphics.Rect
|
|
|
|
|
import android.os.Build
|
|
import android.os.Build
|
|
|
import android.os.Handler
|
|
import android.os.Handler
|
|
|
import android.os.Looper
|
|
import android.os.Looper
|
|
@@ -29,7 +27,6 @@ import androidx.appcompat.widget.PopupMenu
|
|
|
import androidx.core.content.ContextCompat
|
|
import androidx.core.content.ContextCompat
|
|
|
import com.example.modifier.BuildConfig
|
|
import com.example.modifier.BuildConfig
|
|
|
import com.example.modifier.Global
|
|
import com.example.modifier.Global
|
|
|
-import com.example.modifier.Global.backup
|
|
|
|
|
import com.example.modifier.Global.restartModifier
|
|
import com.example.modifier.Global.restartModifier
|
|
|
import com.example.modifier.R
|
|
import com.example.modifier.R
|
|
|
import com.example.modifier.TraverseResult
|
|
import com.example.modifier.TraverseResult
|
|
@@ -42,11 +39,11 @@ import com.example.modifier.constants.PACKAGE_GMS
|
|
|
import com.example.modifier.constants.PACKAGE_MESSAGING
|
|
import com.example.modifier.constants.PACKAGE_MESSAGING
|
|
|
import com.example.modifier.data.AppDatabase
|
|
import com.example.modifier.data.AppDatabase
|
|
|
import com.example.modifier.data.AppPreferences
|
|
import com.example.modifier.data.AppPreferences
|
|
|
-import com.example.modifier.data.AppPreferencesRepository
|
|
|
|
|
|
|
+import com.example.modifier.repo.AppPreferencesRepository
|
|
|
import com.example.modifier.data.AppState
|
|
import com.example.modifier.data.AppState
|
|
|
-import com.example.modifier.data.AppStateRepository
|
|
|
|
|
|
|
+import com.example.modifier.repo.AppStateRepository
|
|
|
import com.example.modifier.data.BackupItemDao
|
|
import com.example.modifier.data.BackupItemDao
|
|
|
-import com.example.modifier.data.GoogleMessageStateRepository
|
|
|
|
|
|
|
+import com.example.modifier.repo.GoogleMessageStateRepository
|
|
|
import com.example.modifier.databinding.FloatingWindowBinding
|
|
import com.example.modifier.databinding.FloatingWindowBinding
|
|
|
import com.example.modifier.enums.RcsConfigureState
|
|
import com.example.modifier.enums.RcsConfigureState
|
|
|
import com.example.modifier.enums.RcsConnectionStatus
|
|
import com.example.modifier.enums.RcsConnectionStatus
|
|
@@ -60,14 +57,19 @@ import com.example.modifier.http.response.DeviceResponse
|
|
|
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
|
|
|
-import com.example.modifier.model.SimInfo
|
|
|
|
|
|
|
+import com.example.modifier.model.SpoofedSimInfo
|
|
|
import com.example.modifier.model.SocketCallback
|
|
import com.example.modifier.model.SocketCallback
|
|
|
import com.example.modifier.model.TaskAction
|
|
import com.example.modifier.model.TaskAction
|
|
|
import com.example.modifier.model.TaskConfig
|
|
import com.example.modifier.model.TaskConfig
|
|
|
import com.example.modifier.model.TaskExecutionResult
|
|
import com.example.modifier.model.TaskExecutionResult
|
|
|
|
|
+import com.example.modifier.repo.BackupRepository
|
|
|
|
|
+import com.example.modifier.repo.SpoofedSimInfoRepository
|
|
|
import com.example.modifier.serializer.Json
|
|
import com.example.modifier.serializer.Json
|
|
|
import com.example.modifier.utils.changeClashProfile
|
|
import com.example.modifier.utils.changeClashProfile
|
|
|
import com.example.modifier.utils.clearConv
|
|
import com.example.modifier.utils.clearConv
|
|
|
|
|
+import com.example.modifier.utils.genICCID
|
|
|
|
|
+import com.example.modifier.utils.genIMEI
|
|
|
|
|
+import com.example.modifier.utils.genIMSI
|
|
|
import com.example.modifier.utils.hasRootAccess
|
|
import com.example.modifier.utils.hasRootAccess
|
|
|
import com.example.modifier.utils.isClashInstalled
|
|
import com.example.modifier.utils.isClashInstalled
|
|
|
import com.example.modifier.utils.isOldVersion
|
|
import com.example.modifier.utils.isOldVersion
|
|
@@ -116,7 +118,6 @@ import org.json.JSONObject
|
|
|
import java.io.File
|
|
import java.io.File
|
|
|
import java.time.LocalDateTime
|
|
import java.time.LocalDateTime
|
|
|
import java.time.temporal.ChronoUnit
|
|
import java.time.temporal.ChronoUnit
|
|
|
-import java.util.Optional
|
|
|
|
|
import java.util.Timer
|
|
import java.util.Timer
|
|
|
import java.util.TimerTask
|
|
import java.util.TimerTask
|
|
|
import java.util.concurrent.atomic.AtomicReference
|
|
import java.util.concurrent.atomic.AtomicReference
|
|
@@ -145,10 +146,10 @@ class ModifierService : AccessibilityService(), Emitter.Listener {
|
|
|
private var currentTaskId = 0
|
|
private var currentTaskId = 0
|
|
|
private var lastSend = 0L
|
|
private var lastSend = 0L
|
|
|
|
|
|
|
|
- private val backupItemDao: BackupItemDao by lazy {
|
|
|
|
|
|
|
+ private val backupItemDao by lazy {
|
|
|
AppDatabase.getDatabase(this).itemDao()
|
|
AppDatabase.getDatabase(this).itemDao()
|
|
|
}
|
|
}
|
|
|
- private val appPreferencesRepository: AppPreferencesRepository by lazy {
|
|
|
|
|
|
|
+ private val appPreferencesRepository by lazy {
|
|
|
AppPreferencesRepository(this)
|
|
AppPreferencesRepository(this)
|
|
|
}
|
|
}
|
|
|
private lateinit var appPreferences: StateFlow<AppPreferences>
|
|
private lateinit var appPreferences: StateFlow<AppPreferences>
|
|
@@ -156,17 +157,24 @@ class ModifierService : AccessibilityService(), Emitter.Listener {
|
|
|
AppStateRepository(this)
|
|
AppStateRepository(this)
|
|
|
}
|
|
}
|
|
|
private lateinit var appState: StateFlow<AppState>
|
|
private lateinit var appState: StateFlow<AppState>
|
|
|
- private val googleMessageStateRepository: GoogleMessageStateRepository by lazy {
|
|
|
|
|
|
|
+ private val googleMessageStateRepository by lazy {
|
|
|
GoogleMessageStateRepository(this)
|
|
GoogleMessageStateRepository(this)
|
|
|
}
|
|
}
|
|
|
private var requestMode = 1;
|
|
private var requestMode = 1;
|
|
|
private var currentActivity = ""
|
|
private var currentActivity = ""
|
|
|
- private val screenInspector: ScreenInspector by lazy {
|
|
|
|
|
|
|
+ private val screenInspector by lazy {
|
|
|
ScreenInspector(this)
|
|
ScreenInspector(this)
|
|
|
}
|
|
}
|
|
|
- private val screenController: ScreenController by lazy {
|
|
|
|
|
|
|
+ private val screenController by lazy {
|
|
|
ScreenController(this, screenInspector)
|
|
ScreenController(this, screenInspector)
|
|
|
}
|
|
}
|
|
|
|
|
+ private val spoofedSimInfoRepository by lazy {
|
|
|
|
|
+ SpoofedSimInfoRepository(this)
|
|
|
|
|
+ }
|
|
|
|
|
+ private lateinit var spoofedSimInfo: StateFlow<SpoofedSimInfo>
|
|
|
|
|
+ private val backupRepository by lazy {
|
|
|
|
|
+ BackupRepository(this, backupItemDao, spoofedSimInfoRepository)
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
fun connect() {
|
|
fun connect() {
|
|
|
try {
|
|
try {
|
|
@@ -208,6 +216,7 @@ class ModifierService : AccessibilityService(), Emitter.Listener {
|
|
|
CoroutineScope(Dispatchers.IO).launch {
|
|
CoroutineScope(Dispatchers.IO).launch {
|
|
|
appState = appStateRepository.getAppState()
|
|
appState = appStateRepository.getAppState()
|
|
|
appPreferences = appPreferencesRepository.getAppPreferences()
|
|
appPreferences = appPreferencesRepository.getAppPreferences()
|
|
|
|
|
+ spoofedSimInfo = spoofedSimInfoRepository.stateFlow()
|
|
|
appStateRepository.updateRuntimeFlags(preparing = true)
|
|
appStateRepository.updateRuntimeFlags(preparing = true)
|
|
|
val hasRoot = run checkRoot@{
|
|
val hasRoot = run checkRoot@{
|
|
|
repeat(30) {
|
|
repeat(30) {
|
|
@@ -745,7 +754,7 @@ class ModifierService : AccessibilityService(), Emitter.Listener {
|
|
|
val dataObj = JSONObject()
|
|
val dataObj = JSONObject()
|
|
|
dataObj.put("canSend", appState.value.send)
|
|
dataObj.put("canSend", appState.value.send)
|
|
|
dataObj.put("busy", appState.value.busy)
|
|
dataObj.put("busy", appState.value.busy)
|
|
|
- dataObj.put("currentCountry", Global.simInfo.country)
|
|
|
|
|
|
|
+ dataObj.put("currentCountry", spoofedSimInfo.value.country)
|
|
|
data.put("data", dataObj)
|
|
data.put("data", dataObj)
|
|
|
mSocket.emit("message", data)
|
|
mSocket.emit("message", data)
|
|
|
} catch (e: JSONException) {
|
|
} catch (e: JSONException) {
|
|
@@ -763,7 +772,7 @@ class ModifierService : AccessibilityService(), Emitter.Listener {
|
|
|
binding.tvLog.text = "Waiting for RCS switch on..."
|
|
binding.tvLog.text = "Waiting for RCS switch on..."
|
|
|
}
|
|
}
|
|
|
googleMessageStateRepository.updateRcsState(RcsConfigureState.NOT_CONFIGURED)
|
|
googleMessageStateRepository.updateRcsState(RcsConfigureState.NOT_CONFIGURED)
|
|
|
- Global.saveMock()
|
|
|
|
|
|
|
+ spoofedSimInfoRepository.mock()
|
|
|
resetAll()
|
|
resetAll()
|
|
|
var switchAppear = googleMessageStateRepository.waitForRcsState(
|
|
var switchAppear = googleMessageStateRepository.waitForRcsState(
|
|
|
arrayOf(RcsConfigureState.WAITING_FOR_TOS),
|
|
arrayOf(RcsConfigureState.WAITING_FOR_TOS),
|
|
@@ -829,7 +838,7 @@ class ModifierService : AccessibilityService(), Emitter.Listener {
|
|
|
binding.tvLog.text = "Waiting for RCS switch on..."
|
|
binding.tvLog.text = "Waiting for RCS switch on..."
|
|
|
}
|
|
}
|
|
|
googleMessageStateRepository.updateRcsState(RcsConfigureState.NOT_CONFIGURED)
|
|
googleMessageStateRepository.updateRcsState(RcsConfigureState.NOT_CONFIGURED)
|
|
|
- Global.saveMock()
|
|
|
|
|
|
|
+ spoofedSimInfoRepository.mock()
|
|
|
resetAll()
|
|
resetAll()
|
|
|
var switchAppear = googleMessageStateRepository.waitForRcsState(
|
|
var switchAppear = googleMessageStateRepository.waitForRcsState(
|
|
|
arrayOf(RcsConfigureState.WAITING_FOR_DEFAULT_ON),
|
|
arrayOf(RcsConfigureState.WAITING_FOR_DEFAULT_ON),
|
|
@@ -903,9 +912,9 @@ class ModifierService : AccessibilityService(), Emitter.Listener {
|
|
|
|
|
|
|
|
appStateRepository.updateRuntimeFlags(requesting = true)
|
|
appStateRepository.updateRuntimeFlags(requesting = true)
|
|
|
|
|
|
|
|
- if (Global.simInfo.available == true) {
|
|
|
|
|
- backup(
|
|
|
|
|
- backupItemDao = backupItemDao,
|
|
|
|
|
|
|
+ if (spoofedSimInfo.value.available) {
|
|
|
|
|
+ backupRepository.backup(
|
|
|
|
|
+ spoofedSimInfo = spoofedSimInfo.value,
|
|
|
type = "auto",
|
|
type = "auto",
|
|
|
sendCount = appState.value.executedNum,
|
|
sendCount = appState.value.executedNum,
|
|
|
fresh = fresh
|
|
fresh = fresh
|
|
@@ -953,15 +962,19 @@ class ModifierService : AccessibilityService(), Emitter.Listener {
|
|
|
|
|
|
|
|
if (requestMode == 2 && !noBackup) {
|
|
if (requestMode == 2 && !noBackup) {
|
|
|
val backup = backupItemDao.findBackupForRestore(
|
|
val backup = backupItemDao.findBackupForRestore(
|
|
|
- Global.simInfo.number,
|
|
|
|
|
|
|
+ spoofedSimInfo.value.number,
|
|
|
System.currentTimeMillis() - 2 * 24 * 60 * 60 * 1000
|
|
System.currentTimeMillis() - 2 * 24 * 60 * 60 * 1000
|
|
|
)
|
|
)
|
|
|
if (backup != null) {
|
|
if (backup != null) {
|
|
|
- if (Global.restore(backup)) {
|
|
|
|
|
|
|
+ if (backupRepository.restore(backup)) {
|
|
|
requestSuccess = true
|
|
requestSuccess = true
|
|
|
break
|
|
break
|
|
|
} else {
|
|
} else {
|
|
|
- backup(backupItemDao, "auto", 0)
|
|
|
|
|
|
|
+ backupRepository.backup(
|
|
|
|
|
+ spoofedSimInfo = spoofedSimInfo.value,
|
|
|
|
|
+ type = "auto",
|
|
|
|
|
+ sendCount = 0
|
|
|
|
|
+ )
|
|
|
continue
|
|
continue
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
@@ -1002,21 +1015,19 @@ class ModifierService : AccessibilityService(), Emitter.Listener {
|
|
|
binding.tvLog.text = "Requesting success, waiting for logs..."
|
|
binding.tvLog.text = "Requesting success, waiting for logs..."
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- Global.save(
|
|
|
|
|
- SimInfo(
|
|
|
|
|
- rcsNumber.number,
|
|
|
|
|
- rcsNumber.mcc,
|
|
|
|
|
- rcsNumber.mnc,
|
|
|
|
|
- Global.genICCID(rcsNumber.mnc, rcsNumber.areaCode),
|
|
|
|
|
- rcsNumber.mcc + rcsNumber.mnc + RandomStringUtils.randomNumeric(
|
|
|
|
|
- 15 - rcsNumber.mcc.length - rcsNumber.mnc.length
|
|
|
|
|
- ),
|
|
|
|
|
- Utils.generateIMEI(),
|
|
|
|
|
- rcsNumber.country,
|
|
|
|
|
- rcsNumber.areaCode,
|
|
|
|
|
- false,
|
|
|
|
|
- rcsNumber.carrierId,
|
|
|
|
|
- rcsNumber.carrierName,
|
|
|
|
|
|
|
+ spoofedSimInfoRepository.updateSpoofedSimInfo(
|
|
|
|
|
+ SpoofedSimInfo(
|
|
|
|
|
+ number = rcsNumber.number,
|
|
|
|
|
+ mcc = rcsNumber.mcc,
|
|
|
|
|
+ mnc = rcsNumber.mnc,
|
|
|
|
|
+ iccid = genICCID(rcsNumber.mnc, rcsNumber.areaCode),
|
|
|
|
|
+ imsi = genIMSI(rcsNumber.mcc + rcsNumber.mnc),
|
|
|
|
|
+ imei = genIMEI(),
|
|
|
|
|
+ country = rcsNumber.country,
|
|
|
|
|
+ areaCode = rcsNumber.areaCode,
|
|
|
|
|
+ available = false,
|
|
|
|
|
+ carrierId = rcsNumber.carrierId,
|
|
|
|
|
+ carrierName = rcsNumber.carrierName,
|
|
|
)
|
|
)
|
|
|
)
|
|
)
|
|
|
|
|
|
|
@@ -1180,8 +1191,11 @@ class ModifierService : AccessibilityService(), Emitter.Listener {
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
if (requestSuccess) {
|
|
if (requestSuccess) {
|
|
|
- Global.simInfo.available = true
|
|
|
|
|
- Global.save()
|
|
|
|
|
|
|
+ spoofedSimInfoRepository.updateSpoofedSimInfo(
|
|
|
|
|
+ spoofedSimInfo = spoofedSimInfo.value.copy(
|
|
|
|
|
+ available = true
|
|
|
|
|
+ )
|
|
|
|
|
+ )
|
|
|
appStateRepository.resetSuccessNum()
|
|
appStateRepository.resetSuccessNum()
|
|
|
appStateRepository.resetExecutedNum()
|
|
appStateRepository.resetExecutedNum()
|
|
|
Log.i(com.example.modifier.TAG, "requestNumber success")
|
|
Log.i(com.example.modifier.TAG, "requestNumber success")
|