mirror of
https://github.com/whitechi73/OpenShamrock.git
synced 2024-08-14 13:12:17 +08:00
Shamrock
: わけのわからないフラッシュバックを修復する
Signed-off-by: WhiteChi <whitechi73@outlook.com>
This commit is contained in:
parent
4adf2eb84a
commit
688041b6be
@ -257,10 +257,10 @@ private fun APIInfoCard(
|
|||||||
hint = "请输入被动地址",
|
hint = "请输入被动地址",
|
||||||
error = "输入的地址不合法",
|
error = "输入的地址不合法",
|
||||||
checker = {
|
checker = {
|
||||||
it.isNotBlank()
|
it.startsWith("ws://") || it.startsWith("wss://") || it.isBlank()
|
||||||
},
|
},
|
||||||
confirm = {
|
confirm = {
|
||||||
if (it.startsWith("ws://") || it.startsWith("wss://")) {
|
if (it.startsWith("ws://") || it.startsWith("wss://") || it.isBlank()) {
|
||||||
ShamrockConfig.setWsAddr(ctx, wsAddress.value)
|
ShamrockConfig.setWsAddr(ctx, wsAddress.value)
|
||||||
AppRuntime.log("设置被动WebSocket地址为[${wsAddress.value}]。")
|
AppRuntime.log("设置被动WebSocket地址为[${wsAddress.value}]。")
|
||||||
} else {
|
} else {
|
||||||
|
@ -14,10 +14,11 @@ internal object ShamrockConfig {
|
|||||||
if (it.exists()) it.delete()
|
if (it.exists()) it.delete()
|
||||||
it.mkdirs()
|
it.mkdirs()
|
||||||
}
|
}
|
||||||
private val Config: ServiceConfig
|
private val Config: ServiceConfig by lazy {
|
||||||
get() = GlobalJson5.decodeFromString(ConfigDir.resolve("config.json").also {
|
GlobalJson5.decodeFromString(ConfigDir.resolve("config.json").also {
|
||||||
if (!it.exists()) it.writeText("{}")
|
if (!it.exists()) it.writeText("{}")
|
||||||
}.readText())
|
}.readText())
|
||||||
|
}
|
||||||
|
|
||||||
fun isInit(): Boolean {
|
fun isInit(): Boolean {
|
||||||
val mmkv = MMKVFetcher.mmkvWithId("shamrock_config")
|
val mmkv = MMKVFetcher.mmkvWithId("shamrock_config")
|
||||||
@ -54,7 +55,7 @@ internal object ShamrockConfig {
|
|||||||
Config.passiveWebSocket = intent.getStringExtra("ws_addr")?.split(",", "|", ",")?.filter { address ->
|
Config.passiveWebSocket = intent.getStringExtra("ws_addr")?.split(",", "|", ",")?.filter { address ->
|
||||||
Config.passiveWebSocket?.any {
|
Config.passiveWebSocket?.any {
|
||||||
it.address == address
|
it.address == address
|
||||||
} == false
|
} != true
|
||||||
}?.map {
|
}?.map {
|
||||||
ConnectionConfig(address = it)
|
ConnectionConfig(address = it)
|
||||||
}?.toMutableList()
|
}?.toMutableList()
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
package moe.fuqiuluo.shamrock.utils
|
package moe.fuqiuluo.shamrock.utils
|
||||||
|
|
||||||
import android.annotation.SuppressLint
|
import android.annotation.SuppressLint
|
||||||
|
import android.app.ActivityManager
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.content.Context.BATTERY_SERVICE
|
import android.content.Context.BATTERY_SERVICE
|
||||||
import android.content.Intent
|
import android.content.Intent
|
||||||
@ -8,6 +9,7 @@ import android.content.IntentFilter
|
|||||||
import android.content.pm.PackageInfo
|
import android.content.pm.PackageInfo
|
||||||
import android.os.BatteryManager
|
import android.os.BatteryManager
|
||||||
import android.os.Build
|
import android.os.Build
|
||||||
|
import android.os.Process
|
||||||
import android.provider.Settings
|
import android.provider.Settings
|
||||||
import kotlinx.serialization.Serializable
|
import kotlinx.serialization.Serializable
|
||||||
import mqq.app.MobileQQ
|
import mqq.app.MobileQQ
|
||||||
@ -50,6 +52,14 @@ internal object PlatformUtils {
|
|||||||
return MobileQQ.getMobileQQ().qqProcessName == "com.tencent.tim"
|
return MobileQQ.getMobileQQ().qqProcessName == "com.tencent.tim"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun killProcess(context: Context, processName: String) {
|
||||||
|
for (processInfo in (context.getSystemService(Context.ACTIVITY_SERVICE) as ActivityManager).runningAppProcesses) {
|
||||||
|
if (processInfo.processName == processName) {
|
||||||
|
Process.killProcess(processInfo.pid)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
fun getDeviceBattery(): DeviceBattery {
|
fun getDeviceBattery(): DeviceBattery {
|
||||||
val ctx = MobileQQ.getContext()
|
val ctx = MobileQQ.getContext()
|
||||||
return kotlin.runCatching {
|
return kotlin.runCatching {
|
||||||
|
@ -118,8 +118,13 @@ internal class XposedEntry: IXposedHookLoadPackage {
|
|||||||
|
|
||||||
log("Process Name = " + MobileQQ.getMobileQQ().qqProcessName.apply {
|
log("Process Name = " + MobileQQ.getMobileQQ().qqProcessName.apply {
|
||||||
// if (!contains("msf", ignoreCase = true)) return // 非MSF进程 退出
|
// if (!contains("msf", ignoreCase = true)) return // 非MSF进程 退出
|
||||||
|
if (contains("peak")) {
|
||||||
|
PlatformUtils.killProcess(ctx, this)
|
||||||
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
PlatformUtils.isTim()
|
||||||
|
|
||||||
// MSG LISTENER 进程运行在主进程
|
// MSG LISTENER 进程运行在主进程
|
||||||
// API 也应该开放在主进程
|
// API 也应该开放在主进程
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user