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 = "请输入被动地址",
|
||||
error = "输入的地址不合法",
|
||||
checker = {
|
||||
it.isNotBlank()
|
||||
it.startsWith("ws://") || it.startsWith("wss://") || it.isBlank()
|
||||
},
|
||||
confirm = {
|
||||
if (it.startsWith("ws://") || it.startsWith("wss://")) {
|
||||
if (it.startsWith("ws://") || it.startsWith("wss://") || it.isBlank()) {
|
||||
ShamrockConfig.setWsAddr(ctx, wsAddress.value)
|
||||
AppRuntime.log("设置被动WebSocket地址为[${wsAddress.value}]。")
|
||||
} else {
|
||||
|
@ -14,10 +14,11 @@ internal object ShamrockConfig {
|
||||
if (it.exists()) it.delete()
|
||||
it.mkdirs()
|
||||
}
|
||||
private val Config: ServiceConfig
|
||||
get() = GlobalJson5.decodeFromString(ConfigDir.resolve("config.json").also {
|
||||
private val Config: ServiceConfig by lazy {
|
||||
GlobalJson5.decodeFromString(ConfigDir.resolve("config.json").also {
|
||||
if (!it.exists()) it.writeText("{}")
|
||||
}.readText())
|
||||
}
|
||||
|
||||
fun isInit(): Boolean {
|
||||
val mmkv = MMKVFetcher.mmkvWithId("shamrock_config")
|
||||
@ -54,7 +55,7 @@ internal object ShamrockConfig {
|
||||
Config.passiveWebSocket = intent.getStringExtra("ws_addr")?.split(",", "|", ",")?.filter { address ->
|
||||
Config.passiveWebSocket?.any {
|
||||
it.address == address
|
||||
} == false
|
||||
} != true
|
||||
}?.map {
|
||||
ConnectionConfig(address = it)
|
||||
}?.toMutableList()
|
||||
|
@ -1,6 +1,7 @@
|
||||
package moe.fuqiuluo.shamrock.utils
|
||||
|
||||
import android.annotation.SuppressLint
|
||||
import android.app.ActivityManager
|
||||
import android.content.Context
|
||||
import android.content.Context.BATTERY_SERVICE
|
||||
import android.content.Intent
|
||||
@ -8,6 +9,7 @@ import android.content.IntentFilter
|
||||
import android.content.pm.PackageInfo
|
||||
import android.os.BatteryManager
|
||||
import android.os.Build
|
||||
import android.os.Process
|
||||
import android.provider.Settings
|
||||
import kotlinx.serialization.Serializable
|
||||
import mqq.app.MobileQQ
|
||||
@ -50,6 +52,14 @@ internal object PlatformUtils {
|
||||
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 {
|
||||
val ctx = MobileQQ.getContext()
|
||||
return kotlin.runCatching {
|
||||
|
@ -118,8 +118,13 @@ internal class XposedEntry: IXposedHookLoadPackage {
|
||||
|
||||
log("Process Name = " + MobileQQ.getMobileQQ().qqProcessName.apply {
|
||||
// if (!contains("msf", ignoreCase = true)) return // 非MSF进程 退出
|
||||
if (contains("peak")) {
|
||||
PlatformUtils.killProcess(ctx, this)
|
||||
}
|
||||
})
|
||||
|
||||
PlatformUtils.isTim()
|
||||
|
||||
// MSG LISTENER 进程运行在主进程
|
||||
// API 也应该开放在主进程
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user