mirror of
https://github.com/fankes/TSBattery.git
synced 2025-09-04 09:45:41 +08:00
Compare commits
19 Commits
Author | SHA1 | Date | |
---|---|---|---|
8043457a6e | |||
d4a1536d70 | |||
5c784f65f8 | |||
1c6c6e6480 | |||
4712d0063b | |||
583c72470b | |||
8cf945b670 | |||
6fba93e1fa | |||
288563ef68 | |||
d1e4c17817 | |||
c8ec50cb29 | |||
b6e042b9d0 | |||
3c4789d9a0 | |||
46ff5f4bcf | |||
09eeeeab5f | |||
f285e6f96d | |||
fb90d4051b | |||
911eb042a6 | |||
9d48732140 |
@@ -35,7 +35,7 @@ fun a(test: String) {
|
||||
val a = "" // 变量注释
|
||||
```
|
||||
|
||||
- ⚠️注意:只允许两个 // 后方要有空格
|
||||
- ⚠️ 注意:只允许两个 // 后方要有空格
|
||||
|
||||
## 项目要求
|
||||
|
||||
|
25
README.md
25
README.md
@@ -2,40 +2,46 @@
|
||||
|
||||
[](https://github.com/fankes/TSBattery)
|
||||
[](https://github.com/fankes/TSBattery/blob/master/LICENSE)
|
||||
[](https://github.com/fankes/TSBattery/releases)
|
||||
[](https://github.com/fankes/TSBattery/releases)
|
||||
[](https://github.com/fankes/TSBattery/releases)
|
||||
[](https://github.com/Xposed-Modules-Repo/com.fankes.tsbattery/releases)
|
||||
[](https://t.me/XiaofangInternet)
|
||||
[](https://t.me/XiaofangInternet)
|
||||
<br/><br/>
|
||||
<br/>
|
||||
A new way to save your battery avoid cancer apps hacker it.<br/>
|
||||
A new way to save your battery avoid cancer apps hacker it.
|
||||
|
||||
TSBattery 是一个旨在使 QQ、TIM、微信 变得更省电的开源 Xposed 模块。
|
||||
|
||||
# Developer
|
||||
## Developer
|
||||
|
||||
[酷安 @星夜不荟](http://www.coolapk.com/u/876977)
|
||||
|
||||
# 适配说明
|
||||
## 适配说明
|
||||
|
||||
- 支持并建议使用 <b>LSPosed</b>(若作用域没有自动出现推荐请勾选 QQ、TIM、微信)
|
||||
|
||||
- 可以使用 <b>~~EdXposed~~</b>,但随时停止支持
|
||||
|
||||
- <b>太极无极 · 阴</b> 支持性不是很好,建议使用 <b>太极无极 · 阳</b>
|
||||
|
||||
- 支持 <b>Pine</b>(梦境模块) 但是部分功能有限制
|
||||
|
||||
- 请不要使用 <b>~~应用转生~~</b>,发生封号情况后果自负
|
||||
|
||||
# 请勿用于非法用途
|
||||
## 请勿用于非法用途
|
||||
|
||||
- 本模块完全开源免费,如果好用你可以打赏支持开发,但是请不要用于非法用途。
|
||||
|
||||
- 本模块发布地址仅有 [Xposed-Modules-Repo](https://github.com/Xposed-Modules-Repo/com.fankes.tsbattery/releases)、
|
||||
[Release](https://github.com/fankes/TSBattery/releases) 及 [蓝奏云](https://fankes.lanzouy.com/b02zfz3sj),从其他非正规渠道下载到的版本或对您造成任何影响均与我们无关。
|
||||
|
||||
# 开始贡献
|
||||
## 开始贡献
|
||||
|
||||
欢迎为此项目进行新版本的适配代码贡献!<br/>
|
||||
|
||||
- [CONTRIBUTING](https://github.com/fankes/TSBattery/blob/master/CONTRIBUTING.md)
|
||||
|
||||
# 许可证
|
||||
## 许可证
|
||||
|
||||
- [AGPL-3.0](https://www.gnu.org/licenses/agpl-3.0.html)
|
||||
|
||||
@@ -56,5 +62,6 @@ You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
```
|
||||
|
||||
Powered by [YukiHookAPI](https://github.com/fankes/YukiHookAPI)<br/><br/>
|
||||
Powered by [YukiHookAPI](https://github.com/fankes/YukiHookAPI)
|
||||
|
||||
版权所有 © 2019-2022 Fankes Studio(qzmmcn@163.com)
|
@@ -1,7 +1,7 @@
|
||||
plugins {
|
||||
id 'com.android.application'
|
||||
id 'kotlin-android'
|
||||
id 'com.google.devtools.ksp' version '1.6.10-1.0.4'
|
||||
id 'com.google.devtools.ksp' version '1.6.20-1.0.5'
|
||||
}
|
||||
|
||||
android {
|
||||
@@ -25,20 +25,12 @@ android {
|
||||
versionCode rootProject.ext.appVersionCode
|
||||
versionName rootProject.ext.appVersionName
|
||||
|
||||
kotlinOptions {
|
||||
freeCompilerArgs = [
|
||||
'-Xno-param-assertions',
|
||||
'-Xno-call-assertions',
|
||||
'-Xno-receiver-assertions'
|
||||
]
|
||||
}
|
||||
|
||||
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
||||
}
|
||||
|
||||
buildTypes {
|
||||
release {
|
||||
minifyEnabled true
|
||||
minifyEnabled rootProject.ext.enableR8
|
||||
signingConfig signingConfigs.debug
|
||||
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
|
||||
}
|
||||
@@ -49,6 +41,11 @@ android {
|
||||
}
|
||||
kotlinOptions {
|
||||
jvmTarget = '11'
|
||||
freeCompilerArgs = [
|
||||
'-Xno-param-assertions',
|
||||
'-Xno-call-assertions',
|
||||
'-Xno-receiver-assertions'
|
||||
]
|
||||
}
|
||||
buildFeatures {
|
||||
viewBinding true
|
||||
@@ -72,8 +69,8 @@ tasks.whenTaskAdded {
|
||||
|
||||
dependencies {
|
||||
compileOnly 'de.robv.android.xposed:api:82'
|
||||
implementation 'com.highcapable.yukihookapi:api:1.0.69'
|
||||
ksp 'com.highcapable.yukihookapi:ksp-xposed:1.0.69'
|
||||
implementation 'com.highcapable.yukihookapi:api:1.0.80'
|
||||
ksp 'com.highcapable.yukihookapi:ksp-xposed:1.0.80'
|
||||
implementation 'com.squareup.okhttp3:okhttp:4.9.3'
|
||||
implementation 'com.geyifeng.immersionbar:immersionbar:3.2.0'
|
||||
implementation 'com.geyifeng.immersionbar:immersionbar-ktx:3.2.0'
|
||||
|
8
app/proguard-rules.pro
vendored
8
app/proguard-rules.pro
vendored
@@ -20,7 +20,6 @@
|
||||
# hide the original source file name.
|
||||
#-renamesourcefileattribute SourceFile
|
||||
|
||||
-dontwarn
|
||||
-ignorewarnings
|
||||
-optimizationpasses 10
|
||||
-dontusemixedcaseclassnames
|
||||
@@ -35,13 +34,6 @@
|
||||
-renamesourcefileattribute P
|
||||
-keepattributes SourceFile,LineNumberTable
|
||||
|
||||
-keep public class * extends android.app.Activity
|
||||
-keep public class * extends android.app.Application
|
||||
-keep public class * extends android.app.Service
|
||||
-keep public class * extends android.content.ContentProvider
|
||||
-keep public class * extends android.app.backup.BackupAgentHelper
|
||||
-keep public class * extends android.preference.Preference
|
||||
|
||||
-assumenosideeffects class kotlin.jvm.internal.Intrinsics {
|
||||
public static *** throwUninitializedProperty(...);
|
||||
public static *** throwUninitializedPropertyAccessException(...);
|
||||
|
@@ -19,31 +19,15 @@
|
||||
*
|
||||
* This file is Created by fankes on 2021/11/9.
|
||||
*/
|
||||
@file:Suppress("unused")
|
||||
|
||||
package com.fankes.tsbattery.application
|
||||
|
||||
import android.app.Application
|
||||
import androidx.appcompat.app.AppCompatDelegate
|
||||
import com.highcapable.yukihookapi.hook.xposed.application.ModuleApplication
|
||||
|
||||
class TSApplication : Application() {
|
||||
|
||||
companion object {
|
||||
|
||||
/** 全局静态实例 */
|
||||
private var context: TSApplication? = null
|
||||
|
||||
/**
|
||||
* 调用全局静态实例
|
||||
* @return [TSApplication]
|
||||
*/
|
||||
val appContext get() = context ?: error("App is death")
|
||||
}
|
||||
class TSApplication : ModuleApplication() {
|
||||
|
||||
override fun onCreate() {
|
||||
super.onCreate()
|
||||
/** 设置静态实例 */
|
||||
context = this
|
||||
/** 跟随系统夜间模式 */
|
||||
AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_FOLLOW_SYSTEM)
|
||||
}
|
||||
|
@@ -32,6 +32,7 @@ import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import android.view.ViewGroup.LayoutParams.MATCH_PARENT
|
||||
import android.view.ViewGroup.LayoutParams.WRAP_CONTENT
|
||||
import android.view.ViewGroup.MarginLayoutParams
|
||||
import android.widget.Toast
|
||||
import com.fankes.tsbattery.BuildConfig
|
||||
import com.fankes.tsbattery.data.DataConst
|
||||
@@ -39,6 +40,7 @@ import com.fankes.tsbattery.hook.HookConst.QQ_PACKAGE_NAME
|
||||
import com.fankes.tsbattery.hook.HookConst.TIM_PACKAGE_NAME
|
||||
import com.fankes.tsbattery.hook.HookConst.WECHAT_PACKAGE_NAME
|
||||
import com.fankes.tsbattery.ui.activity.MainActivity
|
||||
import com.fankes.tsbattery.utils.factory.dp
|
||||
import com.fankes.tsbattery.utils.factory.showDialog
|
||||
import com.fankes.tsbattery.utils.factory.versionCode
|
||||
import com.fankes.tsbattery.utils.factory.versionName
|
||||
@@ -50,10 +52,10 @@ import com.highcapable.yukihookapi.hook.log.loggerE
|
||||
import com.highcapable.yukihookapi.hook.param.PackageParam
|
||||
import com.highcapable.yukihookapi.hook.type.android.*
|
||||
import com.highcapable.yukihookapi.hook.type.java.*
|
||||
import com.highcapable.yukihookapi.hook.xposed.proxy.YukiHookXposedInitProxy
|
||||
import com.highcapable.yukihookapi.hook.xposed.proxy.IYukiHookXposedInit
|
||||
|
||||
@InjectYukiHookWithXposed
|
||||
class HookEntry : YukiHookXposedInitProxy {
|
||||
class HookEntry : IYukiHookXposedInit {
|
||||
|
||||
companion object {
|
||||
|
||||
@@ -128,7 +130,7 @@ class HookEntry : YukiHookXposedInitProxy {
|
||||
interceptBaseChatPie(methodName = "bk")
|
||||
interceptBaseChatPie(methodName = "bl")
|
||||
}
|
||||
"8.8.83", "8.8.85" -> {
|
||||
"8.8.83", "8.8.85", "8.8.88" -> {
|
||||
interceptBaseChatPie(methodName = "bl")
|
||||
interceptBaseChatPie(methodName = "bm")
|
||||
}
|
||||
@@ -173,11 +175,11 @@ class HookEntry : YukiHookXposedInitProxy {
|
||||
}
|
||||
beforeHook {
|
||||
if (prefs.get(DataConst.ENABLE_NOTIFY_TIP))
|
||||
when (firstArgs<CharSequence>()) {
|
||||
when (args().first().cast<CharSequence>()) {
|
||||
"QQ正在后台运行" ->
|
||||
args().set("QQ正在后台运行 - TSBattery 守护中")
|
||||
args().first().set("QQ正在后台运行 - TSBattery 守护中")
|
||||
"TIM正在后台运行" ->
|
||||
args().set("TIM正在后台运行 - TSBattery 守护中")
|
||||
args().first().set("TIM正在后台运行 - TSBattery 守护中")
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -267,21 +269,21 @@ class HookEntry : YukiHookXposedInitProxy {
|
||||
injectMember {
|
||||
method { name = "startTempService" }
|
||||
intercept()
|
||||
}
|
||||
}.ignoredNoSuchMemberFailure()
|
||||
injectMember {
|
||||
method {
|
||||
name = "startCoreService"
|
||||
param(BooleanType)
|
||||
}
|
||||
intercept()
|
||||
}
|
||||
}.ignoredNoSuchMemberFailure()
|
||||
injectMember {
|
||||
method {
|
||||
name = "onStartCommand"
|
||||
param(IntentClass, IntType, IntType)
|
||||
}
|
||||
replaceTo(any = 2)
|
||||
}
|
||||
}.ignoredNoSuchMemberFailure()
|
||||
}
|
||||
injectMember {
|
||||
method { name = "onCreate" }
|
||||
@@ -313,7 +315,7 @@ class HookEntry : YukiHookXposedInitProxy {
|
||||
param(IntentClass, IntType, IntType)
|
||||
}
|
||||
replaceTo(any = 2)
|
||||
}
|
||||
}.ignoredNoSuchMemberFailure()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -330,48 +332,28 @@ class HookEntry : YukiHookXposedInitProxy {
|
||||
afterHook {
|
||||
/** 是否启用 Hook */
|
||||
if (prefs.get(DataConst.ENABLE_SETTING_TIP).not()) return@afterHook
|
||||
|
||||
/** 当前的顶级 Item 实例 */
|
||||
var formItemRefRoot: View? = null
|
||||
|
||||
/**
|
||||
* 使用循环筛选
|
||||
* @param target 目标变量名称
|
||||
* @return [View] or null
|
||||
*/
|
||||
fun match(target: String) = runCatching {
|
||||
field {
|
||||
name = target
|
||||
type = FormSimpleItemClass.clazz
|
||||
}.ignoredError().get(instance).cast() ?: field {
|
||||
name = target
|
||||
type = FormCommonSingleLineItemClass.clazz
|
||||
}.ignoredError().get(instance).cast<View?>()
|
||||
}.getOrNull()
|
||||
/** 循环出当前设置界面存在的顶级 Item */
|
||||
arrayOf(
|
||||
"a", "b", "c", "d", "e", "f", "g",
|
||||
"h", "i", "j", "k", "l", "m", "n",
|
||||
"o", "p", "q", "r", "s", "t", "u",
|
||||
"v", "w", "x", "y", "z", "A", "B"
|
||||
).forEach { match(it)?.also { e -> formItemRefRoot = e } }
|
||||
val formItemRefRoot = field {
|
||||
type(FormSimpleItemClass).index(num = 1)
|
||||
}.ignoredError().get(instance).cast() ?: field {
|
||||
type(FormCommonSingleLineItemClass).index(num = 1)
|
||||
}.ignoredError().get(instance).cast<View?>()
|
||||
/** 创建一个新的 Item */
|
||||
FormSimpleItemClass.clazz.constructor { param(ContextClass) }.get().newInstance<View>(instance)?.also {
|
||||
it.javaClass.apply {
|
||||
method {
|
||||
name = "setLeftText"
|
||||
param(CharSequenceType)
|
||||
}.get(it).call("TSBattery")
|
||||
method {
|
||||
name = "setRightText"
|
||||
param(CharSequenceType)
|
||||
}.get(it).call(prefs.get(DataConst.ENABLE_MODULE_VERSION))
|
||||
method {
|
||||
name = "setBgType"
|
||||
param(IntType)
|
||||
}.get(it).call(2)
|
||||
}
|
||||
it.setOnClickListener {
|
||||
FormSimpleItemClass.clazz.buildOf<View>(instance) { param(ContextClass) }?.current {
|
||||
method {
|
||||
name = "setLeftText"
|
||||
param(CharSequenceType)
|
||||
}.call("TSBattery")
|
||||
method {
|
||||
name = "setRightText"
|
||||
param(CharSequenceType)
|
||||
}.call(prefs.get(DataConst.ENABLE_MODULE_VERSION))
|
||||
method {
|
||||
name = "setBgType"
|
||||
param(IntType)
|
||||
}.call(if (isQQ) 0 else 2)
|
||||
}?.apply {
|
||||
setOnClickListener {
|
||||
instance<Activity>().apply {
|
||||
showDialog {
|
||||
title = "TSBattery 守护中"
|
||||
@@ -398,14 +380,16 @@ class HookEntry : YukiHookXposedInitProxy {
|
||||
}
|
||||
}
|
||||
}
|
||||
}.apply {
|
||||
}?.also { item ->
|
||||
var listGroup = formItemRefRoot?.parent as? ViewGroup?
|
||||
val lparam = (if (listGroup?.childCount == 1) {
|
||||
listGroup = listGroup.parent as? ViewGroup
|
||||
(formItemRefRoot?.parent as? View?)?.layoutParams
|
||||
} else formItemRefRoot?.layoutParams) ?: ViewGroup.LayoutParams(MATCH_PARENT, WRAP_CONTENT)
|
||||
/** 设置圆角和间距 */
|
||||
if (isQQ) (lparam as? MarginLayoutParams?)?.setMargins(0, 15.dp(item.context), 0, 0)
|
||||
/** 将 Item 添加到设置界面 */
|
||||
listGroup?.also { if (isQQ) it.addView(this, lparam) else it.addView(this, 0, lparam) }
|
||||
listGroup?.also { if (isQQ) it.addView(item, lparam) else it.addView(item, 0, lparam) }
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -518,21 +502,21 @@ class HookEntry : YukiHookXposedInitProxy {
|
||||
injectMember {
|
||||
method {
|
||||
name = "doReport"
|
||||
param(("com.tencent.qapmsdk.qqbattery.monitor.WakeLockMonitor\$WakeLockEntity").clazz, IntType)
|
||||
param("com.tencent.qapmsdk.qqbattery.monitor.WakeLockMonitor\$WakeLockEntity", IntType)
|
||||
}
|
||||
intercept()
|
||||
}
|
||||
injectMember {
|
||||
method {
|
||||
name = "afterHookedMethod"
|
||||
param(("com.tencent.qapmsdk.qqbattery.monitor.MethodHookParam").clazz)
|
||||
param("com.tencent.qapmsdk.qqbattery.monitor.MethodHookParam")
|
||||
}
|
||||
intercept()
|
||||
}
|
||||
injectMember {
|
||||
method {
|
||||
name = "beforeHookedMethod"
|
||||
param(("com.tencent.qapmsdk.qqbattery.monitor.MethodHookParam").clazz)
|
||||
param("com.tencent.qapmsdk.qqbattery.monitor.MethodHookParam")
|
||||
}
|
||||
intercept()
|
||||
}
|
||||
@@ -566,6 +550,7 @@ class HookEntry : YukiHookXposedInitProxy {
|
||||
/**
|
||||
* 这个是毒瘤核心操作类
|
||||
* 功能同上、全部拦截
|
||||
* 👮🏻 经过排查 Play 版本也没这个类...... Emmmm 不想说啥了
|
||||
*/
|
||||
findClass(name = "com.tencent.qapmsdk.qqbattery.QQBatteryMonitor").hook {
|
||||
injectMember {
|
||||
|
@@ -48,7 +48,7 @@ class MainActivity : BaseActivity<ActivityMainBinding>() {
|
||||
|
||||
private const val moduleVersion = BuildConfig.VERSION_NAME
|
||||
private const val qqSupportVersion =
|
||||
"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.8.80、8.8.83、8.8.85 (8.2.11、8.5.5~8.8.85)"
|
||||
"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.8.80、8.8.83、8.8.85、8.8.88 (8.2.11、8.5.5~8.8.88)"
|
||||
private const val timSupportVersion = "2+、3+ (并未完全测试每个版本)"
|
||||
private const val wechatSupportVersion = "全版本仅支持基础省电,更多功能依然画饼"
|
||||
|
||||
|
@@ -37,7 +37,7 @@ import android.widget.TextView
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
import androidx.viewbinding.ViewBinding
|
||||
import com.google.android.material.dialog.MaterialAlertDialogBuilder
|
||||
import com.highcapable.yukihookapi.annotation.DoNotUseField
|
||||
import com.highcapable.yukihookapi.annotation.CauseProblemsApi
|
||||
import com.highcapable.yukihookapi.hook.factory.method
|
||||
import com.highcapable.yukihookapi.hook.type.android.LayoutInflaterClass
|
||||
|
||||
@@ -61,7 +61,7 @@ class DialogBuilder(val context: Context, private val isUseBlackTheme: Boolean)
|
||||
|
||||
private var dialogInstance: Dialog? = null // 对话框实例
|
||||
|
||||
@DoNotUseField
|
||||
@CauseProblemsApi
|
||||
var customLayoutView: View? = null // 自定义布局
|
||||
|
||||
/**
|
||||
|
@@ -35,8 +35,8 @@ import android.net.Uri
|
||||
import android.provider.Settings
|
||||
import android.widget.Toast
|
||||
import androidx.core.content.getSystemService
|
||||
import com.fankes.tsbattery.application.TSApplication.Companion.appContext
|
||||
import com.google.android.material.snackbar.Snackbar
|
||||
import com.highcapable.yukihookapi.hook.xposed.application.ModuleApplication.Companion.appContext
|
||||
|
||||
/**
|
||||
* 系统深色模式是否开启
|
||||
|
11
build.gradle
11
build.gradle
@@ -1,12 +1,13 @@
|
||||
plugins {
|
||||
id 'com.android.application' version '7.1.2' apply false
|
||||
id 'com.android.library' version '7.1.2' apply false
|
||||
id 'org.jetbrains.kotlin.android' version '1.6.10' apply false
|
||||
id 'com.android.application' version '7.1.3' apply false
|
||||
id 'com.android.library' version '7.1.3' apply false
|
||||
id 'org.jetbrains.kotlin.android' version '1.6.20' apply false
|
||||
}
|
||||
|
||||
ext {
|
||||
appVersionName = "3.6"
|
||||
appVersionCode = 14
|
||||
appVersionName = "3.8"
|
||||
appVersionCode = 16
|
||||
enableR8 = true
|
||||
}
|
||||
|
||||
task clean(type: Delete) {
|
||||
|
Reference in New Issue
Block a user