fix: getStatusBarTickerIcon/getStatusBarTickerDarkIcon lost state color in SystemUIHooker

This commit is contained in:
2024-12-13 17:39:03 +08:00
parent 8b6d35fa01
commit f00f6efcf3

View File

@@ -87,6 +87,7 @@ import com.highcapable.yukihookapi.hook.factory.hasMethod
import com.highcapable.yukihookapi.hook.factory.injectModuleAppResources import com.highcapable.yukihookapi.hook.factory.injectModuleAppResources
import com.highcapable.yukihookapi.hook.factory.method import com.highcapable.yukihookapi.hook.factory.method
import com.highcapable.yukihookapi.hook.log.YLog import com.highcapable.yukihookapi.hook.log.YLog
import com.highcapable.yukihookapi.hook.param.HookParam
import com.highcapable.yukihookapi.hook.type.android.ContextClass import com.highcapable.yukihookapi.hook.type.android.ContextClass
import com.highcapable.yukihookapi.hook.type.android.DrawableClass import com.highcapable.yukihookapi.hook.type.android.DrawableClass
import com.highcapable.yukihookapi.hook.type.android.ImageViewClass import com.highcapable.yukihookapi.hook.type.android.ImageViewClass
@@ -982,10 +983,8 @@ object SystemUIHooker : YukiBaseHooker() {
} }
} }
/** 去他妈的焦点通知彩色图标 */ /** 去他妈的焦点通知彩色图标 */
FocusUtilsClass?.method { FocusUtilsClass?.apply {
name { it == "getStatusBarTickerDarkIcon" || it == "getStatusBarTickerIcon" } fun HookParam.hookTickerDarkIcon(isDark: Boolean) {
param { (it[0] == StatusBarNotificationClass || it[0] == ExpandedNotificationClass) && it.size == 1 }
}?.hookAll()?.after {
(globalContext ?: args().first().cast())?.also { context -> (globalContext ?: args().first().cast())?.also { context ->
val expandedNf = args().first().cast<StatusBarNotification?>() val expandedNf = args().first().cast<StatusBarNotification?>()
val small = expandedNf?.notification?.smallIcon val small = expandedNf?.notification?.smallIcon
@@ -997,10 +996,29 @@ object SystemUIHooker : YukiBaseHooker() {
).also { pair -> ).also { pair ->
val originalBitmap = pair.first?.toBitmap() val originalBitmap = pair.first?.toBitmap()
val bitmap = originalBitmap?.let { Bitmap.createScaledBitmap(it, 50, 50, true) } val bitmap = originalBitmap?.let { Bitmap.createScaledBitmap(it, 50, 50, true) }
result = Icon.createWithBitmap(bitmap).apply { setTint(Color.BLACK) } result = Icon.createWithBitmap(bitmap).apply { setTint(if (isDark) Color.BLACK else Color.WHITE) }
} }
} }
} }
method {
name = "getStatusBarTickerDarkIcon"
param(StatusBarNotificationClass)
}.remedys {
method {
name = "getStatusBarTickerDarkIcon"
param(ExpandedNotificationClass)
}
}.hook().after { hookTickerDarkIcon(isDark = true) }
method {
name = "getStatusBarTickerIcon"
param(StatusBarNotificationClass)
}.remedys {
method {
name = "getStatusBarTickerIcon"
param(ExpandedNotificationClass)
}
}.hook().after { hookTickerDarkIcon(isDark = false) }
}
/** 注入状态栏通知图标实例 */ /** 注入状态栏通知图标实例 */
StatusBarIconViewClass.method { StatusBarIconViewClass.method {
name = "updateIconColor" name = "updateIconColor"