From 51e3eb878451571aedee3456c34f65f5086f35dd Mon Sep 17 00:00:00 2001 From: Fankesyooni Date: Mon, 7 Feb 2022 21:31:25 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E4=B8=80=E4=B8=AA=20Hook=20?= =?UTF-8?q?=E5=BC=82=E5=B8=B8=E7=96=91=E4=BC=BC=E7=B3=BB=E7=BB=9F=E7=95=8C?= =?UTF-8?q?=E9=9D=A2=E5=B4=A9=E6=BA=83=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/fankes/miui/notify/hook/HookMain.kt | 38 ++++++++++--------- 1 file changed, 21 insertions(+), 17 deletions(-) diff --git a/app/src/main/java/com/fankes/miui/notify/hook/HookMain.kt b/app/src/main/java/com/fankes/miui/notify/hook/HookMain.kt index 18fb411..6c61ebf 100644 --- a/app/src/main/java/com/fankes/miui/notify/hook/HookMain.kt +++ b/app/src/main/java/com/fankes/miui/notify/hook/HookMain.kt @@ -675,10 +675,12 @@ class HookMain : IXposedHookLoadPackage { override fun afterHookedMethod(param: MethodHookParam) { /** 对于之前没有通知图标色彩判断功能的版本判断是 MIUI 样式就停止 Hook */ if (!lpparam.hasIgnoreStatusBarIconColor() && lpparam.isShowMiuiStyle()) return - lpparam.hookSmallIconOnSet( - context = lpparam.globalContext ?: param.args[0] as Context, - param.args?.get(if (isTooOld) 1 else 0) as? StatusBarNotification?, param - ) + runWithoutError(error = "GetSmallIconDoing") { + lpparam.hookSmallIconOnSet( + context = lpparam.globalContext ?: param.args[0] as Context, + param.args?.get(if (isTooOld) 1 else 0) as? StatusBarNotification?, param + ) + } } }) } @@ -708,19 +710,21 @@ class HookMain : IXposedHookLoadPackage { }.also { XposedBridge.hookMethod(it, object : XC_MethodReplacement() { override fun replaceHookedMethod(param: MethodHookParam): Any? { - if (isNewWay) - lpparam.hookNotifyIconOnSet( - context = param.args?.get(0) as? Context ?: lpparam.globalContext - ?: error("GlobalContext got null"), - param.args?.get(2) as? StatusBarNotification?, - param.args?.get(1) as ImageView - ) - else - lpparam.hookNotifyIconOnSet( - context = lpparam.globalContext ?: error("GlobalContext got null"), - param.args?.get(1) as? StatusBarNotification?, - param.args?.get(0) as ImageView - ) + runWithoutError(error = "AutoSetAppIconDoing") { + if (isNewWay) + lpparam.hookNotifyIconOnSet( + context = param.args?.get(0) as? Context ?: lpparam.globalContext + ?: error("GlobalContext got null"), + param.args?.get(2) as? StatusBarNotification?, + param.args?.get(1) as ImageView + ) + else + lpparam.hookNotifyIconOnSet( + context = lpparam.globalContext ?: error("GlobalContext got null"), + param.args?.get(1) as? StatusBarNotification?, + param.args?.get(0) as ImageView + ) + } return null } })