mirror of
https://github.com/fankes/TSBattery.git
synced 2025-09-06 10:45:53 +08:00
Update YukiHookAPI
This commit is contained in:
@@ -72,8 +72,8 @@ tasks.whenTaskAdded {
|
|||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
compileOnly 'de.robv.android.xposed:api:82'
|
compileOnly 'de.robv.android.xposed:api:82'
|
||||||
implementation 'com.highcapable.yukihookapi:api:1.0.69'
|
implementation 'com.highcapable.yukihookapi:api:1.0.70'
|
||||||
ksp 'com.highcapable.yukihookapi:ksp-xposed:1.0.69'
|
ksp 'com.highcapable.yukihookapi:ksp-xposed:1.0.70'
|
||||||
implementation 'com.squareup.okhttp3:okhttp:4.9.3'
|
implementation 'com.squareup.okhttp3:okhttp:4.9.3'
|
||||||
implementation 'com.geyifeng.immersionbar:immersionbar:3.2.0'
|
implementation 'com.geyifeng.immersionbar:immersionbar:3.2.0'
|
||||||
implementation 'com.geyifeng.immersionbar:immersionbar-ktx:3.2.0'
|
implementation 'com.geyifeng.immersionbar:immersionbar-ktx:3.2.0'
|
||||||
|
@@ -269,21 +269,21 @@ class HookEntry : YukiHookXposedInitProxy {
|
|||||||
injectMember {
|
injectMember {
|
||||||
method { name = "startTempService" }
|
method { name = "startTempService" }
|
||||||
intercept()
|
intercept()
|
||||||
}
|
}.ignoredNoSuchMemberFailure()
|
||||||
injectMember {
|
injectMember {
|
||||||
method {
|
method {
|
||||||
name = "startCoreService"
|
name = "startCoreService"
|
||||||
param(BooleanType)
|
param(BooleanType)
|
||||||
}
|
}
|
||||||
intercept()
|
intercept()
|
||||||
}
|
}.ignoredNoSuchMemberFailure()
|
||||||
injectMember {
|
injectMember {
|
||||||
method {
|
method {
|
||||||
name = "onStartCommand"
|
name = "onStartCommand"
|
||||||
param(IntentClass, IntType, IntType)
|
param(IntentClass, IntType, IntType)
|
||||||
}
|
}
|
||||||
replaceTo(any = 2)
|
replaceTo(any = 2)
|
||||||
}
|
}.ignoredNoSuchMemberFailure()
|
||||||
}
|
}
|
||||||
injectMember {
|
injectMember {
|
||||||
method { name = "onCreate" }
|
method { name = "onCreate" }
|
||||||
@@ -315,7 +315,7 @@ class HookEntry : YukiHookXposedInitProxy {
|
|||||||
param(IntentClass, IntType, IntType)
|
param(IntentClass, IntType, IntType)
|
||||||
}
|
}
|
||||||
replaceTo(any = 2)
|
replaceTo(any = 2)
|
||||||
}
|
}.ignoredNoSuchMemberFailure()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -332,48 +332,28 @@ class HookEntry : YukiHookXposedInitProxy {
|
|||||||
afterHook {
|
afterHook {
|
||||||
/** 是否启用 Hook */
|
/** 是否启用 Hook */
|
||||||
if (prefs.get(DataConst.ENABLE_SETTING_TIP).not()) return@afterHook
|
if (prefs.get(DataConst.ENABLE_SETTING_TIP).not()) return@afterHook
|
||||||
|
|
||||||
/** 当前的顶级 Item 实例 */
|
/** 当前的顶级 Item 实例 */
|
||||||
var formItemRefRoot: View? = null
|
val formItemRefRoot = field {
|
||||||
|
type(FormSimpleItemClass).index(num = 1)
|
||||||
/**
|
}.ignoredError().get(instance).cast() ?: field {
|
||||||
* 使用循环筛选
|
type(FormCommonSingleLineItemClass).index(num = 1)
|
||||||
* @param target 目标变量名称
|
}.ignoredError().get(instance).cast<View?>()
|
||||||
* @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 } }
|
|
||||||
/** 创建一个新的 Item */
|
/** 创建一个新的 Item */
|
||||||
FormSimpleItemClass.clazz.constructor { param(ContextClass) }.get().newInstance<View>(instance)?.also {
|
FormSimpleItemClass.clazz.buildOf<View>(instance) { param(ContextClass) }?.current {
|
||||||
it.javaClass.apply {
|
method {
|
||||||
method {
|
name = "setLeftText"
|
||||||
name = "setLeftText"
|
param(CharSequenceType)
|
||||||
param(CharSequenceType)
|
}.call("TSBattery")
|
||||||
}.get(it).call("TSBattery")
|
method {
|
||||||
method {
|
name = "setRightText"
|
||||||
name = "setRightText"
|
param(CharSequenceType)
|
||||||
param(CharSequenceType)
|
}.call(prefs.get(DataConst.ENABLE_MODULE_VERSION))
|
||||||
}.get(it).call(prefs.get(DataConst.ENABLE_MODULE_VERSION))
|
method {
|
||||||
method {
|
name = "setBgType"
|
||||||
name = "setBgType"
|
param(IntType)
|
||||||
param(IntType)
|
}.call(if (isQQ) 0 else 2)
|
||||||
}.get(it).call(if (isQQ) 0 else 2)
|
}?.apply {
|
||||||
}
|
setOnClickListener {
|
||||||
it.setOnClickListener {
|
|
||||||
instance<Activity>().apply {
|
instance<Activity>().apply {
|
||||||
showDialog {
|
showDialog {
|
||||||
title = "TSBattery 守护中"
|
title = "TSBattery 守护中"
|
||||||
@@ -400,16 +380,16 @@ class HookEntry : YukiHookXposedInitProxy {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}?.apply {
|
}?.also { item ->
|
||||||
var listGroup = formItemRefRoot?.parent as? ViewGroup?
|
var listGroup = formItemRefRoot?.parent as? ViewGroup?
|
||||||
val lparam = (if (listGroup?.childCount == 1) {
|
val lparam = (if (listGroup?.childCount == 1) {
|
||||||
listGroup = listGroup.parent as? ViewGroup
|
listGroup = listGroup.parent as? ViewGroup
|
||||||
(formItemRefRoot?.parent as? View?)?.layoutParams
|
(formItemRefRoot?.parent as? View?)?.layoutParams
|
||||||
} else formItemRefRoot?.layoutParams) ?: ViewGroup.LayoutParams(MATCH_PARENT, WRAP_CONTENT)
|
} else formItemRefRoot?.layoutParams) ?: ViewGroup.LayoutParams(MATCH_PARENT, WRAP_CONTENT)
|
||||||
/** 设置圆角和间距 */
|
/** 设置圆角和间距 */
|
||||||
if (isQQ) (lparam as? MarginLayoutParams?)?.setMargins(0, 15.dp(context), 0, 0)
|
if (isQQ) (lparam as? MarginLayoutParams?)?.setMargins(0, 15.dp(item.context), 0, 0)
|
||||||
/** 将 Item 添加到设置界面 */
|
/** 将 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) }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -522,21 +502,21 @@ class HookEntry : YukiHookXposedInitProxy {
|
|||||||
injectMember {
|
injectMember {
|
||||||
method {
|
method {
|
||||||
name = "doReport"
|
name = "doReport"
|
||||||
param(("com.tencent.qapmsdk.qqbattery.monitor.WakeLockMonitor\$WakeLockEntity").clazz, IntType)
|
param("com.tencent.qapmsdk.qqbattery.monitor.WakeLockMonitor\$WakeLockEntity", IntType)
|
||||||
}
|
}
|
||||||
intercept()
|
intercept()
|
||||||
}
|
}
|
||||||
injectMember {
|
injectMember {
|
||||||
method {
|
method {
|
||||||
name = "afterHookedMethod"
|
name = "afterHookedMethod"
|
||||||
param(("com.tencent.qapmsdk.qqbattery.monitor.MethodHookParam").clazz)
|
param("com.tencent.qapmsdk.qqbattery.monitor.MethodHookParam")
|
||||||
}
|
}
|
||||||
intercept()
|
intercept()
|
||||||
}
|
}
|
||||||
injectMember {
|
injectMember {
|
||||||
method {
|
method {
|
||||||
name = "beforeHookedMethod"
|
name = "beforeHookedMethod"
|
||||||
param(("com.tencent.qapmsdk.qqbattery.monitor.MethodHookParam").clazz)
|
param("com.tencent.qapmsdk.qqbattery.monitor.MethodHookParam")
|
||||||
}
|
}
|
||||||
intercept()
|
intercept()
|
||||||
}
|
}
|
||||||
@@ -570,6 +550,7 @@ class HookEntry : YukiHookXposedInitProxy {
|
|||||||
/**
|
/**
|
||||||
* 这个是毒瘤核心操作类
|
* 这个是毒瘤核心操作类
|
||||||
* 功能同上、全部拦截
|
* 功能同上、全部拦截
|
||||||
|
* 👮🏻 经过排查 Play 版本也没这个类...... Emmmm 不想说啥了
|
||||||
*/
|
*/
|
||||||
findClass(name = "com.tencent.qapmsdk.qqbattery.QQBatteryMonitor").hook {
|
findClass(name = "com.tencent.qapmsdk.qqbattery.QQBatteryMonitor").hook {
|
||||||
injectMember {
|
injectMember {
|
||||||
|
@@ -37,7 +37,7 @@ import android.widget.TextView
|
|||||||
import androidx.appcompat.app.AppCompatActivity
|
import androidx.appcompat.app.AppCompatActivity
|
||||||
import androidx.viewbinding.ViewBinding
|
import androidx.viewbinding.ViewBinding
|
||||||
import com.google.android.material.dialog.MaterialAlertDialogBuilder
|
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.factory.method
|
||||||
import com.highcapable.yukihookapi.hook.type.android.LayoutInflaterClass
|
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 // 对话框实例
|
private var dialogInstance: Dialog? = null // 对话框实例
|
||||||
|
|
||||||
@DoNotUseField
|
@CauseProblemsApi
|
||||||
var customLayoutView: View? = null // 自定义布局
|
var customLayoutView: View? = null // 自定义布局
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Reference in New Issue
Block a user