mirror of
https://github.com/fankes/MIUINativeNotifyIcon.git
synced 2025-09-04 01:35:26 +08:00
强制修改 getCustomAppIcon 获取的图标为 smallIcon,同时清理错误提交的代码 (#216)
* 强制修改 getCustomAppIcon 获取的图标为 smallIcon,同时清理错误提交的代码 * Resources.getSystem 换成 ct.resources
This commit is contained in:
@@ -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<Notification>()
|
||||
val ct = args(1).cast<Context>()
|
||||
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 {
|
||||
|
Reference in New Issue
Block a user