mirror of
https://github.com/fankes/TSBattery.git
synced 2025-09-04 09:45:41 +08:00
加入多项 Hook 策略
This commit is contained in:
@@ -122,7 +122,7 @@ class HookMain : IXposedHookLoadPackage {
|
||||
replaceToNull(BASE_CHAT_PIE, "bj")
|
||||
replaceToNull(BASE_CHAT_PIE, "bk")
|
||||
}
|
||||
"8.8.55" -> {
|
||||
"8.8.55", "8.8.68" -> {
|
||||
replaceToNull(BASE_CHAT_PIE, "bk")
|
||||
replaceToNull(BASE_CHAT_PIE, "bl")
|
||||
}
|
||||
@@ -224,7 +224,7 @@ class HookMain : IXposedHookLoadPackage {
|
||||
msg = "[提示模块运行信息功能已打开]\n\n" +
|
||||
"模块工作看起来一切正常,请自行测试是否能达到省电效果。\n\n" +
|
||||
"已生效模块版本:${XPrefUtils.getString(HookMedium.ENABLE_MODULE_VERSION)}\n" +
|
||||
"当前模式:${if (XPrefUtils.getBoolean(HookMedium.ENABLE_WHITE_MODE)) "保守模式" else "完全模式"}" +
|
||||
"当前模式:${if (XPrefUtils.getBoolean(HookMedium.ENABLE_QQTIM_WHITE_MODE)) "保守模式" else "完全模式"}" +
|
||||
"\n\n包名:${packageName}\n版本:$versionName($versionCode)" +
|
||||
"\n\n模块只对挂后台锁屏情况下有省电效果,请不要将过多的群提醒,消息通知打开,这样子在使用过程时照样会极其耗电。\n\n" +
|
||||
"如果你不想看到此提示。请在模块设置中关闭“提示模块运行信息”,此设置默认关闭。\n\n" +
|
||||
@@ -238,7 +238,7 @@ class HookMain : IXposedHookLoadPackage {
|
||||
})
|
||||
}
|
||||
/** 关闭保守模式后不再仅仅作用于系统电源锁 */
|
||||
if (!XPrefUtils.getBoolean(HookMedium.ENABLE_WHITE_MODE)) {
|
||||
if (!XPrefUtils.getBoolean(HookMedium.ENABLE_QQTIM_WHITE_MODE)) {
|
||||
runWithoutError("BaseChatPie(first time)") {
|
||||
/** 通过在 SplashActivity 里取到应用的版本号 */
|
||||
XposedHelpers.findAndHookMethod(
|
||||
@@ -276,6 +276,7 @@ class HookMain : IXposedHookLoadPackage {
|
||||
/**
|
||||
* Hook 掉一个一像素保活 [Activity] 真的我怎么都想不到讯哥的程序员做出这种事情
|
||||
* 这个东西经过测试会在锁屏的时候吊起来,解锁的时候自动 finish(),无限耍流氓耗电
|
||||
* 2022/1/25 后期查证:锁屏界面消息快速回复窗口的解锁后拉起保活界面,也是毒瘤
|
||||
*/
|
||||
XposedHelpers.findAndHookMethod(
|
||||
"$QQ_PACKAGE_NAME.activity.QQLSUnlockActivity",
|
||||
@@ -308,9 +309,10 @@ class HookMain : IXposedHookLoadPackage {
|
||||
}
|
||||
)
|
||||
/**
|
||||
* 这个东西同上,不知道是啥时候调用
|
||||
* 这个东西同上
|
||||
* 反正也是一个一像素保活的 [Activity]
|
||||
* 讯哥的程序员真的有你的
|
||||
* 2022/1/25 后期查证:锁屏界面消息快速回复窗口
|
||||
*/
|
||||
XposedHelpers.findAndHookMethod(
|
||||
"$QQ_PACKAGE_NAME.activity.QQLSActivity\$14",
|
||||
|
@@ -33,7 +33,10 @@ object HookMedium {
|
||||
|
||||
const val ENABLE_HIDE_ICON = "_hide_icon"
|
||||
const val ENABLE_RUN_INFO = "_tip_run_info"
|
||||
const val ENABLE_WHITE_MODE = "_white_mode"
|
||||
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_MODULE_VERSION = "_module_version"
|
||||
|
||||
const val SELF_PACKAGE_NAME = "com.fankes.tsbattery"
|
||||
@@ -63,20 +66,20 @@ object HookMedium {
|
||||
var result: Bundle? = null
|
||||
try {
|
||||
result = it.contentResolver.call(uri, "active", null, null)
|
||||
} catch (e: RuntimeException) {
|
||||
} catch (_: RuntimeException) {
|
||||
// TaiChi is killed, try invoke
|
||||
try {
|
||||
val intent = Intent("me.weishu.exp.ACTION_ACTIVE")
|
||||
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
|
||||
it.startActivity(intent)
|
||||
} catch (e1: Throwable) {
|
||||
} catch (_: Throwable) {
|
||||
return false
|
||||
}
|
||||
}
|
||||
if (result == null) result = it.contentResolver.call(uri, "active", null, null)
|
||||
if (result == null) return false
|
||||
isExp = result.getBoolean("active", false)
|
||||
} catch (ignored: Throwable) {
|
||||
} catch (_: Throwable) {
|
||||
}
|
||||
}
|
||||
return isExp
|
||||
|
@@ -58,9 +58,9 @@ class MainActivity : AppCompatActivity() {
|
||||
|
||||
private const val moduleVersion = BuildConfig.VERSION_NAME
|
||||
private const val qqSupportVersion =
|
||||
"8.8.17、8.8.23、8.8.35、8.8.38、8.8.50、8.8.55 (8.5.5~8.8.55)"
|
||||
"8.8.17、8.8.23、8.8.35、8.8.38、8.8.50、8.8.55、8.8.68 (8.5.5~8.8.68)"
|
||||
private const val timSupportVersion = "2+、3+ (并未完全测试每个版本)"
|
||||
private const val wechatSupportVersion = "全版本仅支持基础省电,更多功能敬请期待"
|
||||
private const val wechatSupportVersion = "全版本仅支持基础省电,更多功能依然画饼"
|
||||
|
||||
/** 声明当前实例 */
|
||||
var instance: MainActivity? = null
|
||||
@@ -143,12 +143,12 @@ class MainActivity : AppCompatActivity() {
|
||||
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_WHITE_MODE)
|
||||
protectModeSwitch.isChecked = getBoolean(HookMedium.ENABLE_QQTIM_WHITE_MODE)
|
||||
hideIconInLauncherSwitch.isChecked = getBoolean(HookMedium.ENABLE_HIDE_ICON)
|
||||
notifyModuleInfoSwitch.isChecked = getBoolean(HookMedium.ENABLE_RUN_INFO)
|
||||
protectModeSwitch.setOnCheckedChangeListener { btn, b ->
|
||||
if (!btn.isPressed) return@setOnCheckedChangeListener
|
||||
putBoolean(HookMedium.ENABLE_WHITE_MODE, b)
|
||||
putBoolean(HookMedium.ENABLE_QQTIM_WHITE_MODE, b)
|
||||
}
|
||||
hideIconInLauncherSwitch.setOnCheckedChangeListener { btn, b ->
|
||||
if (!btn.isPressed) return@setOnCheckedChangeListener
|
||||
|
@@ -282,8 +282,35 @@
|
||||
android:elevation="0dp"
|
||||
android:gravity="center"
|
||||
android:orientation="vertical"
|
||||
android:paddingLeft="15dp"
|
||||
android:paddingRight="15dp">
|
||||
android:padding="15dp">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginBottom="10dp"
|
||||
android:gravity="center|start">
|
||||
|
||||
<ImageView
|
||||
android:layout_width="15dp"
|
||||
android:layout_height="15dp"
|
||||
android:layout_marginEnd="5dp"
|
||||
android:src="@mipmap/qq_icon" />
|
||||
|
||||
<ImageView
|
||||
android:layout_width="15dp"
|
||||
android:layout_height="15dp"
|
||||
android:layout_marginEnd="10dp"
|
||||
android:src="@mipmap/tim_icon" />
|
||||
|
||||
<TextView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:alpha="0.85"
|
||||
android:singleLine="true"
|
||||
android:text="QQ、TIM"
|
||||
android:textColor="#FF323B42"
|
||||
android:textSize="12sp" />
|
||||
</LinearLayout>
|
||||
|
||||
<com.fankes.tsbattery.view.MaterialSwitch
|
||||
android:id="@+id/protect_mode_switch"
|
||||
@@ -299,7 +326,94 @@
|
||||
android:layout_marginBottom="10dp"
|
||||
android:alpha="0.6"
|
||||
android:lineSpacingExtra="6dp"
|
||||
android:text="此选项默认关闭,默认情况下模块将会干掉 QQ 和 TIM 自身的电源锁控制类,开启后模块将只对系统电源锁生效,如果你的 QQ 或 TIM 视频通话等设置发生了故障,可以尝试开启这个功能,开启后请重启 QQ 或 TIM,暂不支持微信。"
|
||||
android:text="此选项默认关闭,默认情况下模块将会干掉 QQ 和 TIM 自身的电源锁控制类,开启后模块将只对系统电源锁生效,如果你的 QQ 或 TIM 视频通话等设置发生了故障,可以尝试开启这个功能,开启后请重启 QQ 或 TIM。"
|
||||
android:textColor="#777777"
|
||||
android:textSize="12sp" />
|
||||
|
||||
<com.fankes.tsbattery.view.MaterialSwitch
|
||||
android:id="@+id/shut_core_sv_qqtim_switch"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="关闭 CoreService"
|
||||
android:textColor="#FF323B42"
|
||||
android:textSize="15sp" />
|
||||
|
||||
<TextView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginBottom="10dp"
|
||||
android:alpha="0.6"
|
||||
android:lineSpacingExtra="6dp"
|
||||
android:text="关闭后可能会影响消息接收与视频通话,但是会达到省电效果,如果你的系统拥有推送服务(HMS)或(GMS)可以尝试关闭。"
|
||||
android:textColor="#777777"
|
||||
android:textSize="12sp" />
|
||||
|
||||
<com.fankes.tsbattery.view.MaterialSwitch
|
||||
android:id="@+id/shut_core_sv_kn_qqtim_switch"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="关闭 CoreService$KernelService"
|
||||
android:textColor="#FF323B42"
|
||||
android:textSize="15sp" />
|
||||
|
||||
<TextView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:alpha="0.6"
|
||||
android:lineSpacingExtra="6dp"
|
||||
android:text="这是一个辅助子服务,理论主服务关闭后子服务同样不会被启动,建议在保证消息接收的前提下可以尝试关闭子服务。"
|
||||
android:textColor="#777777"
|
||||
android:textSize="12sp" />
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginLeft="15dp"
|
||||
android:layout_marginTop="10dp"
|
||||
android:layout_marginRight="15dp"
|
||||
android:background="@drawable/permotion_round"
|
||||
android:elevation="0dp"
|
||||
android:gravity="center"
|
||||
android:orientation="vertical"
|
||||
android:padding="15dp">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginBottom="10dp"
|
||||
android:gravity="center|start">
|
||||
|
||||
<ImageView
|
||||
android:layout_width="15dp"
|
||||
android:layout_height="15dp"
|
||||
android:layout_marginEnd="10dp"
|
||||
android:src="@mipmap/wechat_icon" />
|
||||
|
||||
<TextView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:alpha="0.85"
|
||||
android:singleLine="true"
|
||||
android:text="微信"
|
||||
android:textColor="#FF323B42"
|
||||
android:textSize="12sp" />
|
||||
</LinearLayout>
|
||||
|
||||
<com.fankes.tsbattery.view.MaterialSwitch
|
||||
android:id="@+id/disable_wechat_sv_switch"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="停用省电策略"
|
||||
android:textColor="#FF323B42"
|
||||
android:textSize="15sp" />
|
||||
|
||||
<TextView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:alpha="0.6"
|
||||
android:lineSpacingExtra="6dp"
|
||||
android:text="选择停用后模块将不再对微信生效,可解决通话耳边不会黑屏和闪退问题,微信省电功能依然在开发,敬请期待。"
|
||||
android:textColor="#777777"
|
||||
android:textSize="12sp" />
|
||||
</LinearLayout>
|
||||
|
Reference in New Issue
Block a user