From 9aae48c785d488f23458ff998fdf92567e8bbb92 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?YuSaki=E4=B8=B6Kanade?= <53483352+Nep-Timeline@users.noreply.github.com> Date: Mon, 21 Apr 2025 22:40:21 +0800 Subject: [PATCH] fix: coloros 15 removed updateIconsForLayout method (#76) --- .../notify/hook/entity/SystemUIHooker.kt | 23 ++++++++++++------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/app/src/main/java/com/fankes/coloros/notify/hook/entity/SystemUIHooker.kt b/app/src/main/java/com/fankes/coloros/notify/hook/entity/SystemUIHooker.kt index 70ddba5..a55a48e 100644 --- a/app/src/main/java/com/fankes/coloros/notify/hook/entity/SystemUIHooker.kt +++ b/app/src/main/java/com/fankes/coloros/notify/hook/entity/SystemUIHooker.kt @@ -749,7 +749,7 @@ object SystemUIHooker : YukiBaseHooker() { StatusBarNotificationPresenterClass.constructor().hookAll().after { notificationPresenter = instance } /** 注入状态栏通知图标容器实例 */ OplusNotificationIconAreaControllerClass.apply { - var isOldWay = false + var way = 0 method { name = "updateIconsForLayout" paramCount = 10 @@ -762,13 +762,20 @@ object SystemUIHooker : YukiBaseHooker() { method { name = "updateIconsForLayout" paramCount = 1 - }.onFind { isOldWay = true } + }.onFind { way = 1 } + method { + name = "updateStatusBarIcons" + }.onFind { way = 2 } }.hook().after { - if (isOldWay) { - notificationIconInstances.clear() - field { name = "mLastToShow" }.get(instance).list() - .takeIf { it.isNotEmpty() }?.forEach { notificationIconInstances.add(it) } - } else notificationIconContainer = args(index = 1).cast() + when (way) { + 1 -> notificationIconContainer = OplusNotificationIconAreaControllerClass.method { name = "getNotificationIcons" }.get(instance).invoke() + 2 -> { + notificationIconInstances.clear() + field { name = "mLastToShow" }.get(instance).list() + .takeIf { it.isNotEmpty() }?.forEach { notificationIconInstances.add(it) } + } + else -> notificationIconContainer = args(index = 1).cast() + } } /** 注入状态栏通知图标容器实例 */ NotificationIconAreaControllerClass.apply { @@ -896,4 +903,4 @@ object SystemUIHooker : YukiBaseHooker() { } } } -} \ No newline at end of file +}