From 3cc2787a8865278dc687c5605cf29cccf1237cba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E5=A4=AA=E7=99=BD?= <36808766+ghhccghk@users.noreply.github.com> Date: Thu, 5 Dec 2024 22:42:15 +0800 Subject: [PATCH] =?UTF-8?q?=E5=BC=BA=E5=88=B6=E4=BF=AE=E6=94=B9=20getCusto?= =?UTF-8?q?mAppIcon=20=E8=8E=B7=E5=8F=96=E7=9A=84=E5=9B=BE=E6=A0=87?= =?UTF-8?q?=E4=B8=BA=20smallIcon,=E5=90=8C=E6=97=B6=E6=B8=85=E7=90=86?= =?UTF-8?q?=E9=94=99=E8=AF=AF=E6=8F=90=E4=BA=A4=E7=9A=84=E4=BB=A3=E7=A0=81?= =?UTF-8?q?=20(#216)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * 强制修改 getCustomAppIcon 获取的图标为 smallIcon,同时清理错误提交的代码 * Resources.getSystem 换成 ct.resources --- .../miui/notify/hook/entity/SystemUIHooker.kt | 28 +++++++++++++++---- 1 file changed, 23 insertions(+), 5 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 d858c36..3f9e485 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 @@ -886,11 +886,32 @@ object SystemUIHooker : YukiBaseHooker() { param { it[0] extends StatusBarNotificationClass } }.hookAll().replaceToFalse() var isUseLegacy = false + /** + * 强制修改 getCustomAppIcon 获取的图标为 smallIcon + * 部分系统没有 "getCustomAppIcon" 这个方法 - 所以直接忽略 + */ + if (hasMethod { name = "getCustomAppIcon" }){ + method{ + name = "getCustomAppIcon" + param(NotificationClass, ContextClass) + }.hook().after { + val nf = args(0).cast() + val ct = args(1).cast() + val smail = nf?.smallIcon?.loadDrawable(ct)?.toBitmap() + if (smail != null && !smail.isRecycled) { + if (ct != null) { + result = BitmapDrawable(ct.resources, smail) + } + } else { + result = null + } + } + } /** * 强制回写系统的状态栏图标样式为原生 * 部分系统没有 "getSmallIcon" 这个方法 - 所以直接忽略 */ - if (hasMethod { name = "getSmallIcon" }) + if (hasMethod { name = "getSmallIcon" }){ method { name = "getSmallIcon" param { it[0] extends StatusBarNotificationClass && it[1] == IntType } @@ -899,10 +920,6 @@ object SystemUIHooker : YukiBaseHooker() { name = "getSmallIcon" param(ExpandedNotificationClass) } - method { - name = "getSmallIcon" - param { it[0] == ContextClass && it[1] extends SystemUIApplicationClass && it[2] == IntType && it[3] == BooleanType } - } method { name = "getSmallIcon" param { it[0] == ContextClass && it[1] extends StatusBarNotificationClass } @@ -918,6 +935,7 @@ object SystemUIHooker : YukiBaseHooker() { ).also { pair -> if (pair.second) result = Icon.createWithBitmap(pair.first?.toBitmap()) } } } + } } /** 去他妈的焦点通知彩色图标 */ FocusUtils?.apply {