加入多项 Hook 策略

This commit is contained in:
2022-01-25 04:06:27 +08:00
parent a5b1a57a93
commit 8b2663c3cb
4 changed files with 53 additions and 7 deletions

View File

@@ -23,6 +23,8 @@
package com.fankes.tsbattery.hook
import android.app.Activity
import android.app.Service
import android.content.Intent
import android.os.Build
import android.os.Bundle
import android.util.Log
@@ -237,6 +239,30 @@ class HookMain : IXposedHookLoadPackage {
}
})
}
/** Hook CoreService 全部方法 */
runWithoutError("CoreServiceAllMethods") {
if (XPrefUtils.getBoolean(HookMedium.ENABLE_QQTIM_CORESERVICE_BAN))
lpparam.classLoader.loadClass("$QQ_PACKAGE_NAME.app.CoreService")
.methods.forEach {
if (it.name != "onCreate" && it.name != "onDestroy" && it.name != "onBind")
XposedBridge.hookMethod(it, replaceToNull)
}
}
/** Hook CoreService 启动方法 */
runWithoutError("CoreService") {
if (XPrefUtils.getBoolean(HookMedium.ENABLE_QQTIM_CORESERVICE_BAN))
XposedHelpers.findAndHookMethod(
"$QQ_PACKAGE_NAME.app.CoreService",
lpparam.classLoader, "onCreate",
object : XC_MethodHook() {
override fun afterHookedMethod(param: MethodHookParam?) {
(param?.thisObject as? Service)?.apply {
stopService(Intent(applicationContext, javaClass))
}
}
})
}
/** 关闭保守模式后不再仅仅作用于系统电源锁 */
if (!XPrefUtils.getBoolean(HookMedium.ENABLE_QQTIM_WHITE_MODE)) {
runWithoutError("BaseChatPie(first time)") {
@@ -401,6 +427,8 @@ class HookMain : IXposedHookLoadPackage {
}
/** 微信 */
WECHAT_PACKAGE_NAME -> {
/** 判断是否关闭 Hook */
if (XPrefUtils.getBoolean(HookMedium.DISABLE_WECHAT_HOOK)) return
lpparam.hookSystemWakeLock()
/** 判断是否开启提示模块运行信息 */
if (XPrefUtils.getBoolean(HookMedium.ENABLE_RUN_INFO))

View File

@@ -34,9 +34,9 @@ object HookMedium {
const val ENABLE_HIDE_ICON = "_hide_icon"
const val ENABLE_RUN_INFO = "_tip_run_info"
const val ENABLE_QQTIM_WHITE_MODE = "_qqtim_white_mode"
const val ENABLE_QQTIM_CORESERVICE = "_qqtim_core_service"
const val ENABLE_QQTIM_CORESERVICE_CHILD = "_qqtim_core_service_child"
const val ENABLE_WECHAT_HOOK = "_wechat_hook"
const val ENABLE_QQTIM_CORESERVICE_BAN = "_qqtim_core_service_ban"
const val ENABLE_QQTIM_CORESERVICE_CHILD_BAN = "_qqtim_core_service_child_ban"
const val DISABLE_WECHAT_HOOK = "_disable_wechat_hook"
const val ENABLE_MODULE_VERSION = "_module_version"
const val SELF_PACKAGE_NAME = "com.fankes.tsbattery"

View File

@@ -139,17 +139,35 @@ class MainActivity : AppCompatActivity() {
}
}
/** 初始化 View */
val protectModeSwitch = findViewById<SwitchCompat>(R.id.protect_mode_switch)
val qqTimProtectModeSwitch = findViewById<SwitchCompat>(R.id.qqtim_protect_mode_switch)
val qqTimCoreServiceSwitch = findViewById<SwitchCompat>(R.id.shut_core_sv_qqtim_switch)
val qqTimCoreServiceKnSwitch = findViewById<SwitchCompat>(R.id.shut_core_sv_kn_qqtim_switch)
val wechatDisableHookSwitch = findViewById<SwitchCompat>(R.id.disable_wechat_sv_switch)
val hideIconInLauncherSwitch = findViewById<SwitchCompat>(R.id.hide_icon_in_launcher_switch)
val notifyModuleInfoSwitch = findViewById<SwitchCompat>(R.id.notify_module_info_switch)
/** 获取 Sp 存储的信息 */
protectModeSwitch.isChecked = getBoolean(HookMedium.ENABLE_QQTIM_WHITE_MODE)
qqTimProtectModeSwitch.isChecked = getBoolean(HookMedium.ENABLE_QQTIM_WHITE_MODE)
qqTimCoreServiceSwitch.isChecked = getBoolean(HookMedium.ENABLE_QQTIM_CORESERVICE_BAN)
qqTimCoreServiceKnSwitch.isChecked = getBoolean(HookMedium.ENABLE_QQTIM_CORESERVICE_CHILD_BAN)
wechatDisableHookSwitch.isChecked = getBoolean(HookMedium.DISABLE_WECHAT_HOOK)
hideIconInLauncherSwitch.isChecked = getBoolean(HookMedium.ENABLE_HIDE_ICON)
notifyModuleInfoSwitch.isChecked = getBoolean(HookMedium.ENABLE_RUN_INFO)
protectModeSwitch.setOnCheckedChangeListener { btn, b ->
qqTimProtectModeSwitch.setOnCheckedChangeListener { btn, b ->
if (!btn.isPressed) return@setOnCheckedChangeListener
putBoolean(HookMedium.ENABLE_QQTIM_WHITE_MODE, b)
}
qqTimCoreServiceSwitch.setOnCheckedChangeListener { btn, b ->
if (!btn.isPressed) return@setOnCheckedChangeListener
putBoolean(HookMedium.ENABLE_QQTIM_CORESERVICE_BAN, b)
}
qqTimCoreServiceKnSwitch.setOnCheckedChangeListener { btn, b ->
if (!btn.isPressed) return@setOnCheckedChangeListener
putBoolean(HookMedium.ENABLE_QQTIM_CORESERVICE_CHILD_BAN, b)
}
wechatDisableHookSwitch.setOnCheckedChangeListener { btn, b ->
if (!btn.isPressed) return@setOnCheckedChangeListener
putBoolean(HookMedium.DISABLE_WECHAT_HOOK, b)
}
hideIconInLauncherSwitch.setOnCheckedChangeListener { btn, b ->
if (!btn.isPressed) return@setOnCheckedChangeListener
putBoolean(HookMedium.ENABLE_HIDE_ICON, b)

View File

@@ -313,7 +313,7 @@
</LinearLayout>
<com.fankes.tsbattery.view.MaterialSwitch
android:id="@+id/protect_mode_switch"
android:id="@+id/qqtim_protect_mode_switch"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="启用保守模式"