25 Commits
3.0 ... 3.1

Author SHA1 Message Date
7a1c53ed17 Update Version to 3.1 Support QQ 8.8.68 2022-01-25 05:51:16 +08:00
a4d62137a2 优化代码,适配 Play 版本 2022-01-25 05:47:14 +08:00
beb8da210d 优化代码,适配 Play 版本 2022-01-25 05:45:23 +08:00
60aecc67bf 优化文案 2022-01-25 05:23:46 +08:00
69faade0e4 优化代码 2022-01-25 05:22:13 +08:00
4ecc694dd4 优化代码 2022-01-25 05:14:44 +08:00
674f0a9cd7 优化代码 2022-01-25 04:59:39 +08:00
b14b9e02e2 优化代码 2022-01-25 04:58:19 +08:00
bacff6b275 加入快捷跳转应用信息页面操作 2022-01-25 04:36:38 +08:00
5eb2729eb6 加入多项 Hook 策略 2022-01-25 04:22:58 +08:00
d93b4bdc7f 加入多项 Hook 策略 2022-01-25 04:17:37 +08:00
f1e64c293c 加入多项 Hook 策略 2022-01-25 04:10:34 +08:00
8b2663c3cb 加入多项 Hook 策略 2022-01-25 04:06:27 +08:00
a5b1a57a93 加入多项 Hook 策略 2022-01-25 03:46:44 +08:00
d2dd6c9f88 Update README.md 2022-01-24 11:30:02 +08:00
e4d1ea8519 优化代码 2022-01-24 06:13:21 +08:00
d293e4656d 优化代码 2022-01-24 06:05:35 +08:00
731cfc13d4 优化代码 2022-01-24 05:54:13 +08:00
342128a692 优化代码 2022-01-24 05:52:27 +08:00
c08facd9f6 优化代码 2022-01-24 05:49:57 +08:00
3dfd69dbc7 优化代码 2022-01-24 05:48:35 +08:00
d13aee534e 优化代码注释 2022-01-24 05:42:49 +08:00
9f8f21dc9a 优化注释 2022-01-24 05:42:40 +08:00
90258a07c1 日常维护 2022-01-24 05:06:37 +08:00
c6bed6549e Update Version to 3.0 The brand new theme Material You. 2022-01-09 21:33:17 +08:00
16 changed files with 577 additions and 176 deletions

3
.idea/misc.xml generated
View File

@@ -4,10 +4,11 @@
<option name="filePathToZoomLevelMap">
<map>
<entry key="app/src/main/res/drawable-v24/dark_round.xml" value="0.4482051282051282" />
<entry key="app/src/main/res/drawable/button_round.xml" value="0.44871794871794873" />
<entry key="app/src/main/res/drawable/dark_round.xml" value="0.4482051282051282" />
<entry key="app/src/main/res/drawable/permotion_round.xml" value="0.4482051282051282" />
<entry key="app/src/main/res/drawable/red_round.xml" value="0.4482051282051282" />
<entry key="app/src/main/res/layout/activity_main.xml" value="0.375" />
<entry key="app/src/main/res/layout/activity_main.xml" value="0.3586910327241819" />
</map>
</option>
</component>

6
.idea/vcs.xml generated Normal file
View File

@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="$PROJECT_DIR$" vcs="Git" />
</component>
</project>

View File

@@ -2,7 +2,7 @@
![Eclipse Marketplace](https://img.shields.io/badge/build-passing-brightgreen)
![Eclipse Marketplace](https://img.shields.io/badge/license-GPL3.0-blue)
![Eclipse Marketplace](https://img.shields.io/badge/version-v2.5-green)
![Eclipse Marketplace](https://img.shields.io/badge/version-v3.1-green)
<br/><br/>
![banner](https://github.com/fankes/TSBattery/blob/master/banner.png)<br/>
TSBattery a new way to save your battery avoid cancer apps hacker it.<br/>
@@ -11,7 +11,7 @@ TSBattery 是一个旨在使 QQ、TIM、微信 变得更省电的开源 Xposed
# 开始使用
点击下载最新版本
<a href='https://github.com/fankes/TSBattery/releases'>![Eclipse Marketplace](https://img.shields.io/badge/download-v3.0-green)</a>
<a href='https://github.com/fankes/TSBattery/releases'>![Eclipse Marketplace](https://img.shields.io/badge/download-v3.1-green)</a>
<br/><br/>
⚠️适配说明:此模块支持原生 Xposed、Lsposed(作用域 QQ、TIM、微信 如果不起作用勾选系统框架)、EdXposed(不推荐)、太极无极(阴和阳)、Pine(梦境模块)
@@ -30,7 +30,7 @@ TSBattery 是一个旨在使 QQ、TIM、微信 变得更省电的开源 Xposed
- [GPL-3.0](https://www.gnu.org/licenses/gpl-3.0.html)
```
Copyright (C) 2020-2021 Fankes Studio(qzmmcn@163.com)
Copyright (C) 2020-2022 Fankes Studio(qzmmcn@163.com)
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by

View File

@@ -22,8 +22,8 @@ android {
minSdkVersion 22
//noinspection ExpiredTargetSdkVersion
targetSdkVersion 26
versionCode 9
versionName "3.0"
versionCode 10
versionName "3.1"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
@@ -54,9 +54,9 @@ dependencies {
implementation 'com.gyf.immersionbar:immersionbar-ktx:3.0.0'
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
implementation 'androidx.core:core-ktx:1.7.0'
implementation 'androidx.appcompat:appcompat:1.4.0'
implementation 'com.google.android.material:material:1.4.0'
implementation 'androidx.constraintlayout:constraintlayout:2.1.2'
implementation 'androidx.appcompat:appcompat:1.4.1'
implementation 'com.google.android.material:material:1.5.0'
implementation 'androidx.constraintlayout:constraintlayout:2.1.3'
testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'androidx.test.ext:junit:1.1.3'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'

Binary file not shown.

View File

@@ -11,8 +11,8 @@
"type": "SINGLE",
"filters": [],
"attributes": [],
"versionCode": 7,
"versionName": "2.4",
"versionCode": 10,
"versionName": "3.1",
"outputFile": "app-release.apk"
}
],

View File

@@ -32,7 +32,10 @@ class TSApplication : Application() {
/** 全局静态实例 */
private var context: TSApplication? = null
/** 调用全局静态实例 */
/**
* 调用全局静态实例
* @return [TSApplication]
*/
val appContext get() = context ?: error("App is death")
}

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
@@ -44,6 +46,10 @@ class HookMain : IXposedHookLoadPackage {
companion object {
/** 旧版类名 */
private const val BASE_CHAT_PIE_LEGACY = "activity.BaseChatPie"
/** 新版类名 */
private const val BASE_CHAT_PIE = "activity.aio.core.BaseChatPie"
}
@@ -104,6 +110,10 @@ class HookMain : IXposedHookLoadPackage {
*/
private fun XC_LoadPackage.LoadPackageParam.hookQQBaseChatPie(version: String) {
when (version) {
"8.2.11" -> {
replaceToNull(BASE_CHAT_PIE_LEGACY, "bE")
replaceToNull(BASE_CHAT_PIE_LEGACY, "aV")
}
"8.8.17" -> {
replaceToNull(BASE_CHAT_PIE, "bd")
replaceToNull(BASE_CHAT_PIE, "be")
@@ -122,7 +132,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")
}
@@ -170,6 +180,179 @@ class HookMain : IXposedHookLoadPackage {
}
}
/** 增加通知栏文本显示守护状态 */
private fun XC_LoadPackage.LoadPackageParam.hookNotification() =
runWithoutError("Notification") {
XposedHelpers.findAndHookMethod(
"android.app.Notification\$Builder",
classLoader,
"setContentText",
CharSequence::class.java,
object : XC_MethodHook() {
override fun beforeHookedMethod(param: MethodHookParam?) {
when (param?.args?.get(0) as? CharSequence?) {
"QQ正在后台运行" ->
param.args?.set(0, "QQ正在后台运行 - TSBattery 守护中")
"TIM正在后台运行" ->
param.args?.set(0, "TIM正在后台运行 - TSBattery 守护中")
}
}
})
}
/** 提示模块运行信息 QQ、TIM、微信 */
private fun XC_LoadPackage.LoadPackageParam.hookModuleRunningInfo() =
if (packageName != WECHAT_PACKAGE_NAME)
runWithoutError("SplashActivity") {
/** 判断是否开启提示模块运行信息 */
if (XPrefUtils.getBoolean(HookMedium.ENABLE_RUN_INFO))
XposedHelpers.findAndHookMethod(
"$QQ_PACKAGE_NAME.activity.SplashActivity",
classLoader,
"doOnCreate",
Bundle::class.java,
object : XC_MethodHook() {
override fun afterHookedMethod(param: MethodHookParam?) {
/**
* Hook 启动界面的第一个 [Activity]
* QQ 和 TIM 都是一样的类
* 在里面加入提示运行信息的对话框测试模块是否激活
*/
(param?.thisObject as? Activity?)?.apply {
showDialog {
title = "TSBattery 已激活"
msg = "[提示模块运行信息功能已打开]\n\n" +
"模块工作看起来一切正常,请自行测试是否能达到省电效果。\n\n" +
"已生效模块版本:${XPrefUtils.getString(HookMedium.ENABLE_MODULE_VERSION)}\n" +
"当前模式:${if (XPrefUtils.getBoolean(HookMedium.ENABLE_QQTIM_WHITE_MODE)) "保守模式" else "完全模式"}" +
"\n\n包名:${packageName}\n版本:$versionName($versionCode)" +
"\n\n模块只对挂后台锁屏情况下有省电效果,请不要将过多的群提醒,消息通知打开,这样子在使用过程时照样会极其耗电。\n\n" +
"如果你不想看到此提示。请在模块设置中关闭“提示模块运行信息”,此设置默认关闭。\n\n" +
"持续常驻使用 QQ 依然会耗电,任何软件都是如此,模块无法帮你做到前台不耗电,永远记住这一点。\n\n" +
"开发者 酷安 @星夜不荟\n未经允许禁止转载、修改或复制我的劳动成果。"
confirmButton(text = "我知道了")
noCancelable()
}
}
}
})
}
else
runWithoutError("LauncherUI") {
/** 判断是否开启提示模块运行信息 */
if (XPrefUtils.getBoolean(HookMedium.ENABLE_RUN_INFO))
XposedHelpers.findAndHookMethod(
"$WECHAT_PACKAGE_NAME.ui.LauncherUI",
classLoader,
"onCreate",
Bundle::class.java,
object : XC_MethodHook() {
override fun afterHookedMethod(param: MethodHookParam?) {
/**
* Hook 启动界面的第一个 [Activity]
* 在里面加入提示运行信息的对话框测试模块是否激活
*/
(param?.thisObject as? Activity?)?.apply {
showDialog(isUseBlackTheme = true) {
title = "TSBattery 已激活"
msg = "[提示模块运行信息功能已打开]\n\n" +
"模块工作看起来一切正常,请自行测试是否能达到省电效果。\n\n" +
"已生效模块版本:${XPrefUtils.getString(HookMedium.ENABLE_MODULE_VERSION)}\n" +
"当前模式:基础省电" +
"\n\n包名:${packageName}\n版本:$versionName($versionCode)" +
"\n\n当前只支持微信的基础省电,即系统电源锁,后续会继续适配微信相关的省电功能(在新建文件夹了)。\n\n" +
"如果你不想看到此提示。请在模块设置中关闭“提示模块运行信息”,此设置默认关闭。\n\n" +
"持续常驻使用微信依然会耗电,任何软件都是如此,模块无法帮你做到前台不耗电,永远记住这一点。\n\n" +
"开发者 酷安 @星夜不荟\n未经允许禁止转载、修改或复制我的劳动成果。"
confirmButton(text = "我知道了")
noCancelable()
}
}
}
})
}
/** Hook CoreService QQ、TIM */
private fun XC_LoadPackage.LoadPackageParam.hookCoreService() {
/** Hook CoreService 指定方法 */
if (packageName == QQ_PACKAGE_NAME)
runWithoutError("CoreServiceKnownMethods") {
if (XPrefUtils.getBoolean(HookMedium.ENABLE_QQTIM_CORESERVICE_BAN)) {
XposedHelpers.findAndHookMethod(
"$QQ_PACKAGE_NAME.app.CoreService",
classLoader, "startTempService", replaceToNull
)
XposedHelpers.findAndHookMethod(
"$QQ_PACKAGE_NAME.app.CoreService",
classLoader, "startCoreService", Boolean::class.java, replaceToNull
)
XposedHelpers.findAndHookMethod(
"$QQ_PACKAGE_NAME.app.CoreService",
classLoader,
"onStartCommand",
Intent::class.java, Int::class.java, Int::class.java,
object : XC_MethodReplacement() {
override fun replaceHookedMethod(param: MethodHookParam?) = 2
})
logD("hook CoreService OK!")
}
}
/** Hook CoreService 启动方法 */
runWithoutError("CoreService") {
if (XPrefUtils.getBoolean(HookMedium.ENABLE_QQTIM_CORESERVICE_BAN)) {
XposedHelpers.findAndHookMethod(
"$QQ_PACKAGE_NAME.app.CoreService",
classLoader, "onCreate",
object : XC_MethodHook() {
override fun afterHookedMethod(param: MethodHookParam?) {
(param?.thisObject as? Service)?.apply {
runWithoutError("StopCoreService") {
stopForeground(true)
stopService(Intent(applicationContext, javaClass))
logD("Shutdown CoreService OK!")
}
}
}
})
logD("hook CoreService [onCreate] OK!")
}
}
/** Hook CoreService$KernelService 启动方法 */
runWithoutError("CoreService\$KernelService") {
if (XPrefUtils.getBoolean(HookMedium.ENABLE_QQTIM_CORESERVICE_CHILD_BAN)) {
XposedHelpers.findAndHookMethod(
"$QQ_PACKAGE_NAME.app.CoreService\$KernelService",
classLoader, "onCreate",
object : XC_MethodHook() {
override fun afterHookedMethod(param: MethodHookParam?) {
(param?.thisObject as? Service)?.apply {
runWithoutError("StopKernelService") {
stopForeground(true)
stopService(Intent(applicationContext, javaClass))
logD("Shutdown CoreService\$KernelService OK!")
}
}
}
})
XposedHelpers.findAndHookMethod(
"$QQ_PACKAGE_NAME.app.CoreService\$KernelService",
classLoader,
"onStartCommand",
Intent::class.java, Int::class.java, Int::class.java,
object : XC_MethodReplacement() {
override fun replaceHookedMethod(param: MethodHookParam?) = 2
})
logD("hook CoreService\$KernelService [onCreate] OK!")
}
}
}
override fun handleLoadPackage(lpparam: XC_LoadPackage.LoadPackageParam?) {
if (lpparam == null) return
when (lpparam.packageName) {
@@ -181,64 +364,25 @@ class HookMain : IXposedHookLoadPackage {
"isHooked",
replaceToTrue
)
/** 经过测试 QQ 与 TIM 这两个是一个模子里面的东西,所以他们的类名也基本上是一样的 */
QQ_PACKAGE_NAME, TIM_PACKAGE_NAME -> {
lpparam.hookSystemWakeLock()
/** 增加通知栏文本显示守护状态 */
runWithoutError("Notification") {
XposedHelpers.findAndHookMethod(
"android.app.Notification\$Builder",
lpparam.classLoader,
"setContentText",
CharSequence::class.java,
object : XC_MethodHook() {
override fun beforeHookedMethod(param: MethodHookParam?) {
when (param?.args?.get(0) as? CharSequence?) {
"QQ正在后台运行" ->
param.args?.set(0, "QQ正在后台运行 - TSBattery 守护中")
"TIM正在后台运行" ->
param.args?.set(0, "TIM正在后台运行 - TSBattery 守护中")
}
}
})
/** Hook TIM */
TIM_PACKAGE_NAME ->
lpparam.apply {
hookSystemWakeLock()
hookNotification()
hookModuleRunningInfo()
hookCoreService()
logD("hook Completed!")
}
/** Hook QQ */
QQ_PACKAGE_NAME -> {
lpparam.apply {
hookSystemWakeLock()
hookNotification()
hookModuleRunningInfo()
hookCoreService()
}
/** 判断是否开启提示模块运行信息 */
if (XPrefUtils.getBoolean(HookMedium.ENABLE_RUN_INFO))
runWithoutError("SplashActivity") {
/**
* Hook 启动界面的第一个 [Activity]
* QQ 和 TIM 都是一样的类
* 在里面加入提示运行信息的对话框测试模块是否激活
*/
XposedHelpers.findAndHookMethod(
"$QQ_PACKAGE_NAME.activity.SplashActivity",
lpparam.classLoader,
"doOnCreate",
Bundle::class.java,
object : XC_MethodHook() {
override fun afterHookedMethod(param: MethodHookParam?) {
(param?.thisObject as? Activity?)?.apply {
showDialog {
title = "TSBattery 已激活"
content = "[提示模块运行信息功能已打开]\n\n" +
"模块工作看起来一切正常,请自行测试是否能达到省电效果。\n\n" +
"已生效模块版本:${XPrefUtils.getString(HookMedium.ENABLE_MODULE_VERSION)}\n" +
"当前模式:${if (XPrefUtils.getBoolean(HookMedium.ENABLE_WHITE_MODE)) "保守模式" else "完全模式"}" +
"\n\n包名:${packageName}\n版本:$versionName($versionCode)" +
"\n\n模块只对挂后台锁屏情况下有省电效果,请不要将过多的群提醒,消息通知打开,这样子在使用过程时照样会极其耗电。\n\n" +
"如果你不想看到此提示。请在模块设置中关闭“提示模块运行信息”,此设置默认关闭。\n\n" +
"持续常驻使用 QQ 依然会耗电,任何软件都是如此,模块无法帮你做到前台不耗电,永远记住这一点。\n\n" +
"开发者 酷安 @星夜不荟\n未经允许禁止转载、修改或复制我的劳动成果。"
addConfirmButton("我知道了")
noCancelable()
}
}
}
})
}
/** 关闭保守模式后不再仅仅作用于系统电源锁 */
if (!XPrefUtils.getBoolean(HookMedium.ENABLE_WHITE_MODE)) {
if (!XPrefUtils.getBoolean(HookMedium.ENABLE_QQTIM_WHITE_MODE)) {
runWithoutError("BaseChatPie(first time)") {
/** 通过在 SplashActivity 里取到应用的版本号 */
XposedHelpers.findAndHookMethod(
@@ -250,13 +394,8 @@ class HookMain : IXposedHookLoadPackage {
override fun beforeHookedMethod(param: MethodHookParam?) {
val self = param?.thisObject as? Activity ?: return
val name = self.packageName
val version = self.versionName
/** 这个地方我们只处理 QQ */
runWithoutError("BaseChatPie") {
if (name == QQ_PACKAGE_NAME)
lpparam.hookQQBaseChatPie(version)
}
runWithoutError("BaseChatPie") { lpparam.hookQQBaseChatPie(version) }
}
})
}
@@ -276,6 +415,7 @@ class HookMain : IXposedHookLoadPackage {
/**
* Hook 掉一个一像素保活 [Activity] 真的我怎么都想不到讯哥的程序员做出这种事情
* 这个东西经过测试会在锁屏的时候吊起来,解锁的时候自动 finish(),无限耍流氓耗电
* 2022/1/25 后期查证:锁屏界面消息快速回复窗口的解锁后拉起保活界面,也是毒瘤
*/
XposedHelpers.findAndHookMethod(
"$QQ_PACKAGE_NAME.activity.QQLSUnlockActivity",
@@ -308,9 +448,10 @@ class HookMain : IXposedHookLoadPackage {
}
)
/**
* 这个东西同上,不知道是啥时候调用
* 这个东西同上
* 反正也是一个一像素保活的 [Activity]
* 讯哥的程序员真的有你的
* 2022/1/25 后期查证:锁屏界面消息快速回复窗口
*/
XposedHelpers.findAndHookMethod(
"$QQ_PACKAGE_NAME.activity.QQLSActivity\$14",
@@ -327,6 +468,7 @@ class HookMain : IXposedHookLoadPackage {
* 带给用户的却是 shit 一样的体验
* 里面有各种使用 Handler 和 Timer 的各种耗时常驻后台耗电办法持续接收消息
* 直接循环全部方法全部干掉
* 👮🏻 经过排查 Play 版本没这个类...... Emmmm 不想说啥了
*/
lpparam.classLoader.loadClass("com.tencent.qapmsdk.qqbattery.monitor.WakeLockMonitor")
.apply {
@@ -399,43 +541,14 @@ class HookMain : IXposedHookLoadPackage {
}
/** 微信 */
WECHAT_PACKAGE_NAME -> {
lpparam.hookSystemWakeLock()
/** 判断是否开启提示模块运行信息 */
if (XPrefUtils.getBoolean(HookMedium.ENABLE_RUN_INFO))
runWithoutError("LauncherUI") {
/**
* Hook 启动界面的第一个 [Activity]
* 在里面加入提示运行信息的对话框测试模块是否激活
*/
XposedHelpers.findAndHookMethod(
"$WECHAT_PACKAGE_NAME.ui.LauncherUI",
lpparam.classLoader,
"onCreate",
Bundle::class.java,
object : XC_MethodHook() {
override fun afterHookedMethod(param: MethodHookParam?) {
(param?.thisObject as? Activity?)?.apply {
showDialog {
title = "TSBattery 已激活"
content = "[提示模块运行信息功能已打开]\n\n" +
"模块工作看起来一切正常,请自行测试是否能达到省电效果。\n\n" +
"已生效模块版本:${XPrefUtils.getString(HookMedium.ENABLE_MODULE_VERSION)}\n" +
"当前模式:基础省电" +
"\n\n包名:${packageName}\n版本:$versionName($versionCode)" +
"\n\n当前只支持微信的基础省电,即系统电源锁,后续会继续适配微信相关的省电功能(在新建文件夹了)。\n\n" +
"如果你不想看到此提示。请在模块设置中关闭“提示模块运行信息”,此设置默认关闭。\n\n" +
"持续常驻使用微信依然会耗电,任何软件都是如此,模块无法帮你做到前台不耗电,永远记住这一点。\n\n" +
"开发者 酷安 @星夜不荟\n未经允许禁止转载、修改或复制我的劳动成果。"
addConfirmButton("我知道了")
noCancelable()
}
}
}
})
}
/** 判断是否关闭 Hook */
if (XPrefUtils.getBoolean(HookMedium.DISABLE_WECHAT_HOOK)) return
lpparam.apply {
hookSystemWakeLock()
hookModuleRunningInfo()
}
// TODO 新建文件夹
logD("それが機能するかどうかはわかりません")
logD("ウイチャット:それが機能するかどうかはわかりませんでした")
}
}
}

View File

@@ -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_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"
@@ -44,7 +47,7 @@ object HookMedium {
/**
* 判断模块是否激活
* 在 [HookMain] 中 Hook 掉此方法
* @return 激活状态
* @return [Boolean] 激活状态
*/
fun isHooked(): Boolean {
Log.d("TSBattery", "isHooked: true")
@@ -52,8 +55,8 @@ object HookMedium {
}
/**
* 新增太极判断方式
* @return 是否激活
* 太极激活判断方式
* @return [Boolean] 是否激活
*/
private fun isExpModuleActive(): Boolean {
var isExp = false
@@ -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

View File

@@ -48,6 +48,7 @@ import com.fankes.tsbattery.hook.HookMedium.TIM_PACKAGE_NAME
import com.fankes.tsbattery.hook.HookMedium.WECHAT_PACKAGE_NAME
import com.fankes.tsbattery.utils.FileUtils
import com.fankes.tsbattery.utils.isInstall
import com.fankes.tsbattery.utils.openSelfSetting
import com.fankes.tsbattery.utils.showDialog
import com.gyf.immersionbar.ImmersionBar
import java.io.File
@@ -58,9 +59,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.2.11(Play)、8.8.17、8.8.23、8.8.35、8.8.38、8.8.50、8.8.55、8.8.68 (8.2.11、8.5.5~8.8.68)"
private const val timSupportVersion = "2+、3+ (并未完全测试每个版本)"
private const val wechatSupportVersion = "全版本仅支持基础省电,更多功能敬请期待"
private const val wechatSupportVersion = "全版本仅支持基础省电,更多功能依然画饼"
/** 声明当前实例 */
var instance: MainActivity? = null
@@ -92,14 +93,14 @@ class MainActivity : AppCompatActivity() {
} else
showDialog {
title = "模块没有激活"
content = "检测到模块没有激活,模块需要 Xposed 环境依赖," +
msg = "检测到模块没有激活,模块需要 Xposed 环境依赖," +
"同时需要系统拥有 Root 权限(太极阴可以免 Root)" +
"请自行查看本页面使用帮助与说明第三条。\n" +
"太极、应用转生、梦境(Pine)和第三方 Xposed 激活后" +
"可能不会提示激活,若想验证是否激活请打开“提示模块运行信息”自行检查," +
"如果生效就代表模块运行正常,这里的激活状态只是一个显示意义上的存在。\n" +
"太极(无极)在 MIUI 设备上会提示打开授权,请进行允许,然后再次打开本应用查看激活状态。"
addConfirmButton("我知道了")
confirmButton(text = "我知道了")
noCancelable()
}
/** 设置安装状态 */
@@ -113,8 +114,8 @@ class MainActivity : AppCompatActivity() {
setOnClickListener {
showDialog {
title = "兼容的 QQ 版本"
content = qqSupportVersion
addConfirmButton("我知道了")
msg = qqSupportVersion
confirmButton(text = "我知道了")
}
}
}
@@ -123,8 +124,8 @@ class MainActivity : AppCompatActivity() {
setOnClickListener {
showDialog {
title = "兼容的 TIM 版本"
content = timSupportVersion
addConfirmButton("我知道了")
msg = timSupportVersion
confirmButton(text = "我知道了")
}
}
}
@@ -133,22 +134,40 @@ class MainActivity : AppCompatActivity() {
setOnClickListener {
showDialog {
title = "兼容的微信版本"
content = wechatSupportVersion
addConfirmButton("我知道了")
msg = wechatSupportVersion
confirmButton(text = "我知道了")
}
}
}
/** 初始化 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("_white_mode")
hideIconInLauncherSwitch.isChecked = getBoolean("_hide_icon")
notifyModuleInfoSwitch.isChecked = getBoolean("_tip_run_info")
protectModeSwitch.setOnCheckedChangeListener { btn, b ->
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)
qqTimProtectModeSwitch.setOnCheckedChangeListener { btn, b ->
if (!btn.isPressed) return@setOnCheckedChangeListener
putBoolean(HookMedium.ENABLE_WHITE_MODE, b)
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
@@ -163,6 +182,12 @@ class MainActivity : AppCompatActivity() {
if (!btn.isPressed) return@setOnCheckedChangeListener
putBoolean(HookMedium.ENABLE_RUN_INFO, b)
}
/** 快捷操作 QQ */
findViewById<View>(R.id.quick_qq_button).setOnClickListener { openSelfSetting(QQ_PACKAGE_NAME) }
/** 快捷操作 TIM */
findViewById<View>(R.id.quick_tim_button).setOnClickListener { openSelfSetting(TIM_PACKAGE_NAME) }
/** 快捷操作微信 */
findViewById<View>(R.id.quick_wechat_button).setOnClickListener { openSelfSetting(WECHAT_PACKAGE_NAME) }
/** 恰饭! */
findViewById<View>(R.id.link_with_follow_me).setOnClickListener {
try {
@@ -194,7 +219,7 @@ class MainActivity : AppCompatActivity() {
/**
* 判断模块是否激活
* @return 激活状态
* @return [Boolean] 激活状态
*/
private fun isHooked() = HookMedium.isHooked()
@@ -216,7 +241,7 @@ class MainActivity : AppCompatActivity() {
/**
* 获取保存的值
* @param key 名称
* @return 保存的值
* @return [Boolean] 保存的值
*/
private fun getBoolean(key: String) =
getSharedPreferences(
@@ -274,7 +299,7 @@ class MainActivity : AppCompatActivity() {
file.setExecutable(true, false)
}
}
} catch (e: Exception) {
} catch (_: Exception) {
Toast.makeText(this, "无法写入模块设置,请检查权限\n如果此提示一直显示,请不要双开模块", Toast.LENGTH_SHORT).show()
}
}

View File

@@ -27,23 +27,28 @@ import android.content.Context
import android.graphics.Color
import android.graphics.drawable.GradientDrawable
/**
* 构造对话框
* @param isUseBlackTheme 是否使用深色主题
* @param it 对话框方法体
*/
fun Context.showDialog(it: DialogBuilder.() -> Unit) = DialogBuilder(this).apply(it).show()
fun Context.showDialog(isUseBlackTheme: Boolean = false, it: DialogBuilder.() -> Unit) =
DialogBuilder(this, isUseBlackTheme).apply(it).show()
/**
* 对话框构造器
* @param context 实例
* @param isUseBlackTheme 是否使用深色主题
*/
class DialogBuilder(private val context: Context) {
class DialogBuilder(private val context: Context, private val isUseBlackTheme: Boolean) {
private var instance: AlertDialog.Builder? = null // 实例对象
init {
instance = AlertDialog.Builder(context, android.R.style.Theme_Material_Light_Dialog)
instance = AlertDialog.Builder(
context,
if (isUseBlackTheme) android.R.style.Theme_Material_Dialog else android.R.style.Theme_Material_Light_Dialog
)
}
/** 设置对话框不可关闭 */
@@ -56,8 +61,8 @@ class DialogBuilder(private val context: Context) {
instance?.setTitle(value)
}
/** 设置对话框内容 */
var content
/** 设置对话框消息内容 */
var msg
get() = ""
set(value) {
instance?.setMessage(value)
@@ -65,33 +70,34 @@ class DialogBuilder(private val context: Context) {
/**
* 设置对话框确定按钮
* @param content 按钮文本内容
* @param text 按钮文本内容
* @param it 点击事件
*/
fun addConfirmButton(content: String, it: () -> Unit = {}) =
instance?.setPositiveButton(content) { _, _ -> it() }
fun confirmButton(text: String = "确定", it: () -> Unit = {}) =
instance?.setPositiveButton(text) { _, _ -> it() }
/**
* 设置对话框取消按钮
* @param content 按钮文本内容
* @param text 按钮文本内容
* @param it 点击事件
*/
fun addCancelButton(content: String, it: () -> Unit = {}) =
instance?.setNegativeButton(content) { _, _ -> it() }
fun cancelButton(text: String = "取消", it: () -> Unit = {}) =
instance?.setNegativeButton(text) { _, _ -> it() }
/**
* 设置对话框第三个按钮
* @param content 按钮文本内容
* @param text 按钮文本内容
* @param it 点击事件
*/
fun addNeutralButton(content: String, it: () -> Unit = {}) =
instance?.setNeutralButton(content) { _, _ -> it() }
fun neutralButton(text: String = "更多", it: () -> Unit = {}) =
instance?.setNeutralButton(text) { _, _ -> it() }
/** 显示对话框 */
internal fun show() = instance?.create()?.apply {
window?.setBackgroundDrawable(GradientDrawable(
GradientDrawable.Orientation.TOP_BOTTOM,
intArrayOf(Color.WHITE, Color.WHITE)
if (isUseBlackTheme) intArrayOf(0xFF2D2D2D.toInt(), 0xFF2D2D2D.toInt())
else intArrayOf(Color.WHITE, Color.WHITE)
).apply {
shape = GradientDrawable.RECTANGLE
gradientType = GradientDrawable.LINEAR_GRADIENT

View File

@@ -21,7 +21,6 @@
package com.fankes.tsbattery.utils;
import android.content.Context;
import android.os.Environment;
import com.fankes.tsbattery.BuildConfig;
@@ -83,12 +82,4 @@ public class FileUtils {
public static File getDefaultPrefFile(Context context) {
return new File(getPrefDir(context), FILE_PREF_NAME);
}
public static File getBackupPrefsFile() {
return new File(getBackupDir(), FILE_PREF_NAME);
}
private static File getBackupDir() {
return new File(Environment.getExternalStorageDirectory(), "QQPurify");
}
}

View File

@@ -23,14 +23,24 @@
package com.fankes.tsbattery.utils
import android.content.Context
import android.content.Intent
import android.content.pm.PackageInfo
import android.content.pm.PackageManager
import android.net.Uri
import android.provider.Settings
import android.widget.Toast
import com.fankes.tsbattery.application.TSApplication.Companion.appContext
/** 得到安装包信息 */
/**
* 得到安装包信息
* @return [PackageInfo]
*/
val Context.packageInfo get() = packageManager?.getPackageInfo(packageName, 0) ?: PackageInfo()
/** 判断应用是否安装 */
/**
* 判断应用是否安装
* @return [Boolean]
*/
val String.isInstall
get() =
try {
@@ -43,18 +53,46 @@ val String.isInstall
false
}
/** 得到版本信息 */
/**
* 得到版本信息
* @return [String]
*/
val Context.versionName get() = packageInfo.versionName ?: ""
/** 得到版本号 */
/**
* 得到版本号
* @return [Int]
*/
val Context.versionCode get() = packageInfo.versionCode
/** dp 转换为 px */
/**
* dp 转换为 px
* @return [Int]
*/
val Number.dp get() = (toFloat() * appContext.resources.displayMetrics.density).toInt()
/**
* dp 转换为 px
* @param context 使用的实例
* @return [Float]
*/
fun Number.dp(context: Context) = toFloat() * context.resources.displayMetrics.density
/**
* 跳转 APP 自身设置界面
* @param packageName 包名
*/
fun Context.openSelfSetting(packageName: String) {
try {
if (packageName.isInstall)
startActivity(Intent().apply {
flags = Intent.FLAG_ACTIVITY_NEW_TASK
action = Settings.ACTION_APPLICATION_DETAILS_SETTINGS
data = Uri.fromParts("package", packageName, null)
})
else Toast.makeText(this, "你没有安装此应用", Toast.LENGTH_SHORT).show()
} catch (_: Exception) {
Toast.makeText(this, "启动 $packageName 应用信息失败", Toast.LENGTH_SHORT).show()
}
}

View File

@@ -0,0 +1,10 @@
<?xml version="1.0" encoding="utf-8"?>
<ripple xmlns:android="http://schemas.android.com/apk/res/android"
android:color="#777777">
<item>
<shape android:shape="rectangle">
<solid android:color="#66DAD9D9" />
<corners android:radius="15dp" />
</shape>
</item>
</ripple>

View File

@@ -6,7 +6,7 @@
android:layout_height="match_parent"
android:orientation="vertical"
tools:context=".ui.MainActivity"
tools:ignore="HardcodedText,UseCompoundDrawables,ContentDescription">
tools:ignore="HardcodedText,UseCompoundDrawables,ContentDescription,TooManyViews">
<LinearLayout
android:layout_width="match_parent"
@@ -266,7 +266,7 @@
android:layout_height="wrap_content"
android:alpha="0.6"
android:lineSpacingExtra="5dp"
android:text="上述列出的版本号为最佳兼容版本,你可以点击进行查看。\n这些标注的版本在适配范围内的 APP 都将有效,但可能不能达到最佳使用效果。\n如果当前版本失效请看下方的联系方式。"
android:text="上述列出的版本号为最佳兼容版本,你可以点击进行查看。\n没有标注的版本在适配范围内的 APP 适用性都将有效,但可能不能达到最佳使用效果。\n如果当前版本失效请看下方的联系方式。"
android:textColor="#FF323B42"
android:textSize="10sp"
tools:ignore="SmallSp" />
@@ -282,14 +282,41 @@
android:elevation="0dp"
android:gravity="center"
android:orientation="vertical"
android:paddingLeft="15dp"
android:paddingRight="15dp">
android:padding="15dp">
<com.fankes.tsbattery.view.MaterialSwitch
android:id="@+id/protect_mode_switch"
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="启用保守模式"
android:layout_marginBottom="5dp"
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/qqtim_protect_mode_switch"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="启用保守模式 [QQ]"
android:textColor="#FF323B42"
android:textSize="15sp" />
@@ -299,9 +326,177 @@
android:layout_marginBottom="10dp"
android:alpha="0.6"
android:lineSpacingExtra="6dp"
android:text="此选项默认关闭,默认情况下模块将会干掉 QQ 和 TIM 自身的电源锁控制类,开启后模块将只对系统电源锁生效,如果你的 QQ 或 TIM 视频通话等设置发生了故障,可以尝试开启这个功能,开启后请重启 QQ 或 TIM暂不支持微信。"
android:text="此选项默认关闭,默认情况下模块将会干掉 QQ 自身的电源锁控制类,开启后模块将只对系统电源锁生效,如果你的 QQ 视频通话等设置发生了故障,可以尝试开启这个功能,开启后请重启 QQ。"
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="5dp"
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>
<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/shot_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>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
android:id="@+id/quick_qq_button"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginEnd="5dp"
android:layout_weight="1"
android:background="@drawable/button_round"
android:gravity="center"
android:padding="10dp"
android:singleLine="true"
android:text="QQ"
android:textColor="#FF323B42"
android:textSize="15sp" />
<TextView
android:id="@+id/quick_tim_button"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginEnd="5dp"
android:layout_weight="1"
android:background="@drawable/button_round"
android:gravity="center"
android:padding="10dp"
android:singleLine="true"
android:text="TIM"
android:textColor="#FF323B42"
android:textSize="15sp" />
<TextView
android:id="@+id/quick_wechat_button"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:background="@drawable/button_round"
android:gravity="center"
android:padding="10dp"
android:singleLine="true"
android:text="微信"
android:textColor="#FF323B42"
android:textSize="15sp" />
</LinearLayout>
</LinearLayout>
<LinearLayout
@@ -444,6 +639,16 @@
android:textColor="#777777"
android:textSize="12sp" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="10dp"
android:alpha="0.8"
android:lineSpacingExtra="6dp"
android:text="Q.模块是否需要挂后台?\nA.模块完全不需要挂后台,模块只是一个控制和显示的工具,真正的任务交由 Hook 处理,若出现失效的情况请发送模块运行日志给我们而不是将模块挂后台。"
android:textColor="#777777"
android:textSize="12sp" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.0 KiB