From d1dc64108ae02e92cfe6606486efc37e651b1fe7 Mon Sep 17 00:00:00 2001 From: fankesyooni Date: Mon, 6 Nov 2023 11:20:53 +0800 Subject: [PATCH] fix: some problem in MIUI 14 (14.0.4) Android 14 --- .../miui/notify/hook/entity/SystemUIHooker.kt | 52 ++++++++++--------- 1 file changed, 28 insertions(+), 24 deletions(-) diff --git a/app/src/main/java/com/fankes/miui/notify/hook/entity/SystemUIHooker.kt b/app/src/main/java/com/fankes/miui/notify/hook/entity/SystemUIHooker.kt index 3572bff5..2868f131 100644 --- a/app/src/main/java/com/fankes/miui/notify/hook/entity/SystemUIHooker.kt +++ b/app/src/main/java/com/fankes/miui/notify/hook/entity/SystemUIHooker.kt @@ -732,9 +732,9 @@ object SystemUIHooker : YukiBaseHooker() { */ private fun Any?.getSbn() = ExpandableNotificationRowClass - .method { name = "getEntry" } - .get(this).call() - ?.current(ignored = true) + .field { name = "mEntry" } + .get(this) + .current(ignored = true) ?.field { name = "mSbn" } ?.cast() ?: ExpandableNotificationRowClass @@ -843,30 +843,34 @@ object SystemUIHooker : YukiBaseHooker() { param { it[0] extends StatusBarNotificationClass } }.hookAll().replaceToFalse() var isUseLegacy = false - /** 强制回写系统的状态栏图标样式为原生 */ - method { - name = "getSmallIcon" - param { it[0] extends StatusBarNotificationClass && it[1] == IntType } - }.remedys { - method { - name = "getSmallIcon" - param(ExpandedNotificationClass) - } + /** + * 强制回写系统的状态栏图标样式为原生 + * 部分系统没有 "getSmallIcon" 这个方法 - 所以直接忽略 + */ + if (hasMethod { name = "getSmallIcon" }) method { name = "getSmallIcon" - param(ContextClass, ExpandedNotificationClass) - }.onFind { isUseLegacy = true } - }.hook().after { - (globalContext ?: args().first().cast())?.also { context -> - val expandedNf = args(if (isUseLegacy) 1 else 0).cast() - /** Hook 状态栏小图标 */ - compatStatusIcon( - context = context, - nf = expandedNf, - iconDrawable = result()?.loadDrawable(context) - ).also { pair -> if (pair.second) result = Icon.createWithBitmap(pair.first?.toBitmap()) } + param { it[0] extends StatusBarNotificationClass && it[1] == IntType } + }.remedys { + method { + name = "getSmallIcon" + param(ExpandedNotificationClass) + } + method { + name = "getSmallIcon" + param(ContextClass, ExpandedNotificationClass) + }.onFind { isUseLegacy = true } + }.hook().after { + (globalContext ?: args().first().cast())?.also { context -> + val expandedNf = args(if (isUseLegacy) 1 else 0).cast() + /** Hook 状态栏小图标 */ + compatStatusIcon( + context = context, + nf = expandedNf, + iconDrawable = result()?.loadDrawable(context) + ).also { pair -> if (pair.second) result = Icon.createWithBitmap(pair.first?.toBitmap()) } + } } - } } /** 注入状态栏通知图标实例 */ StatusBarIconViewClass.method {