|
@@ -1089,35 +1089,37 @@ class ModifierService : AccessibilityService(), Emitter.Listener {
|
|
|
try {
|
|
try {
|
|
|
val device = KtorClient.get(DeviceApi.Id(id = Utils.getUniqueID()))
|
|
val device = KtorClient.get(DeviceApi.Id(id = Utils.getUniqueID()))
|
|
|
.body<DeviceResponse>()
|
|
.body<DeviceResponse>()
|
|
|
|
|
+ if (Global.isClashInstalled()) {
|
|
|
|
|
|
|
|
- val prefs = getSharedPreferences("settings", Context.MODE_PRIVATE)
|
|
|
|
|
- if (TextUtils.isEmpty(device.clashProfile)) {
|
|
|
|
|
- prefs.edit()
|
|
|
|
|
- .remove("clash_profile")
|
|
|
|
|
- .apply()
|
|
|
|
|
- val intent = Intent()
|
|
|
|
|
- intent.action = "com.github.metacubex.clash.meta.action.STOP_CLASH"
|
|
|
|
|
- intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
|
|
|
|
|
- startActivity(intent)
|
|
|
|
|
- } else {
|
|
|
|
|
- val oldProfile = prefs.getString("clash_profile", "")
|
|
|
|
|
- if (oldProfile != device.clashProfile) {
|
|
|
|
|
|
|
+ val prefs = getSharedPreferences("settings", Context.MODE_PRIVATE)
|
|
|
|
|
+ if (TextUtils.isEmpty(device.clashProfile)) {
|
|
|
prefs.edit()
|
|
prefs.edit()
|
|
|
- .putString("clash_profile", device.clashProfile)
|
|
|
|
|
|
|
+ .remove("clash_profile")
|
|
|
.apply()
|
|
.apply()
|
|
|
val intent = Intent()
|
|
val intent = Intent()
|
|
|
- intent.action = "com.github.metacubex.clash.meta.action.USE_PROFILE"
|
|
|
|
|
- intent.putExtra(
|
|
|
|
|
- "base64",
|
|
|
|
|
- Base64.encodeToString(
|
|
|
|
|
- device.clashProfile!!.toByteArray(),
|
|
|
|
|
- Base64.DEFAULT
|
|
|
|
|
- )
|
|
|
|
|
- )
|
|
|
|
|
- intent.putExtra("name", device.pinCountry)
|
|
|
|
|
|
|
+ intent.action = "com.github.metacubex.clash.meta.action.STOP_CLASH"
|
|
|
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
|
|
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
|
|
|
startActivity(intent)
|
|
startActivity(intent)
|
|
|
- delay(5000)
|
|
|
|
|
|
|
+ } else {
|
|
|
|
|
+ val oldProfile = prefs.getString("clash_profile", "")
|
|
|
|
|
+ if (oldProfile != device.clashProfile) {
|
|
|
|
|
+ prefs.edit()
|
|
|
|
|
+ .putString("clash_profile", device.clashProfile)
|
|
|
|
|
+ .apply()
|
|
|
|
|
+ val intent = Intent()
|
|
|
|
|
+ intent.action = "com.github.metacubex.clash.meta.action.USE_PROFILE"
|
|
|
|
|
+ intent.putExtra(
|
|
|
|
|
+ "base64",
|
|
|
|
|
+ Base64.encodeToString(
|
|
|
|
|
+ device.clashProfile!!.toByteArray(),
|
|
|
|
|
+ Base64.DEFAULT
|
|
|
|
|
+ )
|
|
|
|
|
+ )
|
|
|
|
|
+ intent.putExtra("name", device.pinCountry)
|
|
|
|
|
+ intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
|
|
|
|
|
+ startActivity(intent)
|
|
|
|
|
+ delay(5000)
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|