diff --git a/app/build.gradle b/app/build.gradle index a16ad40..3519878 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -58,8 +58,8 @@ tasks.whenTaskAdded { dependencies { implementation "com.github.topjohnwu.libsu:core:3.1.2" compileOnly 'de.robv.android.xposed:api:82' - implementation 'com.highcapable.yukihookapi:api:1.0' - ksp 'com.highcapable.yukihookapi:ksp-xposed:1.0' + implementation 'com.highcapable.yukihookapi:api:1.0.1' + ksp 'com.highcapable.yukihookapi:ksp-xposed:1.0.1' implementation 'com.geyifeng.immersionbar:immersionbar:3.2.0' implementation 'com.geyifeng.immersionbar:immersionbar-ktx:3.2.0' implementation 'androidx.core:core-ktx:1.7.0' diff --git a/app/src/main/java/com/fankes/miui/notify/hook/HookEntry.kt b/app/src/main/java/com/fankes/miui/notify/hook/HookEntry.kt index 647754e..4862f3e 100644 --- a/app/src/main/java/com/fankes/miui/notify/hook/HookEntry.kt +++ b/app/src/main/java/com/fankes/miui/notify/hook/HookEntry.kt @@ -42,7 +42,6 @@ import com.fankes.miui.notify.hook.factory.isAppNotifyHookAllOf import com.fankes.miui.notify.hook.factory.isAppNotifyHookOf import com.fankes.miui.notify.params.IconPackParams import com.fankes.miui.notify.utils.* -import com.highcapable.yukihookapi.YukiHookAPI.configs import com.highcapable.yukihookapi.annotation.xposed.InjectYukiHookWithXposed import com.highcapable.yukihookapi.hook.bean.VariousClass import com.highcapable.yukihookapi.hook.factory.* @@ -106,8 +105,8 @@ class HookEntry : YukiHookXposedInitProxy { */ private fun PackageParam.isGrayscaleIcon(context: Context, drawable: Drawable) = safeOfFalse { ContrastColorUtilClass.clazz.let { - it.obtainMethod(name = "isGrayscaleIcon", DrawableClass) - ?.invokeAny(it.obtainMethod(name = "getInstance", ContextClass)?.invokeStatic(context), drawable) ?: false + it.method(name = "isGrayscaleIcon", DrawableClass) + ?.call(it.method(name = "getInstance", ContextClass)?.callStatic(context), drawable) ?: false } } @@ -116,7 +115,7 @@ class HookEntry : YukiHookXposedInitProxy { * @return [Boolean] */ private fun PackageParam.isShowMiuiStyle() = safeOfFalse { - NotificationUtilClass.clazz.obtainMethod(name = "showMiuiStyle")?.invokeStatic() ?: false + NotificationUtilClass.clazz.method(name = "showMiuiStyle")?.callStatic() ?: false } /** @@ -135,7 +134,7 @@ class HookEntry : YukiHookXposedInitProxy { * @return [String] */ private fun PackageParam.findAppName(instance: Any?) = safeOf(default = "") { - ExpandedNotificationClass.clazz.obtainMethod(name = "getAppName")?.invokeAny(instance) ?: "" + ExpandedNotificationClass.clazz.method(name = "getAppName")?.call(instance) ?: "" } /** @@ -150,7 +149,7 @@ class HookEntry : YukiHookXposedInitProxy { */ private val PackageParam.globalContext get() = safeOfNull { - SystemUIApplicationClass.clazz.obtainMethod(name = "getContext")?.invokeStatic() + SystemUIApplicationClass.clazz.method(name = "getContext")?.callStatic() } /** @@ -337,7 +336,7 @@ class HookEntry : YukiHookXposedInitProxy { !prefs.getBoolean(ENABLE_MODULE, default = true) -> loggerW(msg = "Aborted Hook -> Hook Closed") /** 开始 Hook */ else -> { - findClass(NotificationUtilClass).hook { + NotificationUtilClass.hook { /** 强制回写系统的状态栏图标样式为原生 */ injectMember { method { @@ -402,7 +401,7 @@ class HookEntry : YukiHookXposedInitProxy { val iconImageView = instance() ?: return@afterHook /** 获取通知实例 */ - val expandedNf = thisClass.obtainFieldAny(instance, name = "mNotification") + val expandedNf = field { name = "mNotification" }.of(instance) /** * 强制设置图标 - 防止 MIPUSH 不生效 @@ -468,14 +467,19 @@ class HookEntry : YukiHookXposedInitProxy { /** 对于之前没有通知图标色彩判断功能的版本判断是 MIUI 样式就停止 Hook */ if (!hasIgnoreStatusBarIconColor() && isShowMiuiStyle()) return@afterHook /** 获取小图标 */ - val iconImageView = NotificationHeaderViewWrapperClass.clazz - .obtainFieldAny(any = instance, name = "mIcon") ?: return@afterHook + val iconImageView = field { + classSet = NotificationHeaderViewWrapperClass.clazz + name = "mIcon" + }.of(instance) ?: return@afterHook /** 从父类中得到 mRow 变量 - [ExpandableNotificationRowClass] */ - NotificationViewWrapperClass.clazz.obtainFieldAny(instance, name = "mRow").apply { + field { + classSet = NotificationViewWrapperClass.clazz + name = "mRow" + }.get(instance).apply { /** 获取其中的得到通知方法 */ val expandedNf = - ExpandableNotificationRowClass.clazz.obtainMethod(name = "getStatusBarNotification") - ?.invokeAny(any = this) + ExpandableNotificationRowClass.clazz.method(name = "getStatusBarNotification") + ?.call(instance = self) /** 执行 Hook */ hookNotifyIconOnSet(iconImageView.context, expandedNf, iconImageView) } diff --git a/app/src/main/java/com/fankes/miui/notify/utils/Utils.kt b/app/src/main/java/com/fankes/miui/notify/utils/Utils.kt index 2d4009f..7cf82eb 100644 --- a/app/src/main/java/com/fankes/miui/notify/utils/Utils.kt +++ b/app/src/main/java/com/fankes/miui/notify/utils/Utils.kt @@ -35,10 +35,10 @@ import android.provider.Settings import android.service.notification.StatusBarNotification import android.util.Base64 import com.fankes.miui.notify.application.MNNApplication.Companion.appContext +import com.highcapable.yukihookapi.hook.factory.callStatic import com.highcapable.yukihookapi.hook.factory.classOf import com.highcapable.yukihookapi.hook.factory.hasClass -import com.highcapable.yukihookapi.hook.factory.invokeStatic -import com.highcapable.yukihookapi.hook.factory.obtainMethod +import com.highcapable.yukihookapi.hook.factory.method import com.highcapable.yukihookapi.hook.log.loggerE import com.highcapable.yukihookapi.hook.type.java.StringType import com.topjohnwu.superuser.Shell @@ -245,9 +245,9 @@ fun Bitmap.round(radius: Float): Bitmap = * @return [String] */ fun findPropString(key: String, default: String = "") = safeOf(default) { - (classOf(name = "android.os.SystemProperties").obtainMethod( + (classOf(name = "android.os.SystemProperties").method( name = "get", StringType, StringType - )?.invokeStatic(key, default)) ?: default + )?.callStatic(key, default)) ?: default } /**