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 {