Skip to content

Commit 7490247

Browse files
authored
fix: The refreshNotificationIcons does not work on ColorOS 16
1 parent d2299c4 commit 7490247

1 file changed

Lines changed: 15 additions & 2 deletions

File tree

app/src/main/java/com/fankes/coloros/notify/hook/entity/SystemUIHooker.kt

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,9 @@ object SystemUIHooker : YukiBaseHooker() {
142142

143143
/** ColorOS 存在的类 - 旧版本不存在 */
144144
private val OplusNotificationGroupTemplateWrapperClass by lazyClassOrNull("com.oplus.systemui.notification.row.oplusgroup.OplusNotificationGroupTemplateWrapper")
145+
146+
/** 原生存在的类 */
147+
private val ViewConfigCoordinatorClass by lazyClassOrNull("${PackageName.SYSTEMUI}.statusbar.notification.collection.coordinator.ViewConfigCoordinator")
145148

146149
/** 根据多个版本存在不同的包名相同的类 */
147150
private val OplusNotificationIconAreaControllerClass by lazyClass(
@@ -293,6 +296,13 @@ object SystemUIHooker : YukiBaseHooker() {
293296
name = "proxyOnContentUpdated"
294297
parameterCount = 1
295298
} != null
299+
300+
private val isNotificationPresenter
301+
get() = StatusBarNotificationPresenterClass.resolve().optional(silent = true)
302+
.firstMethodOrNull {
303+
name = "updateNotificationsOnDensityOrFontScaleChanged"
304+
emptyParameters()
305+
} != null
296306

297307
/**
298308
* 打印日志
@@ -785,7 +795,10 @@ object SystemUIHooker : YukiBaseHooker() {
785795
if (args().first().any() != null) instance<ImageView>().also { registerWallpaperColorChanged(it) }
786796
}
787797
/** 注入通知控制器实例 */
788-
StatusBarNotificationPresenterClass.resolve().optional().constructor {}.hookAll().after { notificationPresenter = instance }
798+
if (isNotificationPresenter)
799+
StatusBarNotificationPresenterClass.resolve().optional().constructor {}.hookAll().after { notificationPresenter = instance }
800+
else
801+
ViewConfigCoordinatorClass?.resolve()?.optional()?.constructor {}?.hookAll()?.after { notificationPresenter = instance }
789802
/** 替换通知面板背景 - 新版本 */
790803
if (!isOldNotificationBackground)
791804
OplusNotificationBackgroundViewClass?.resolve()?.optional()?.apply {
@@ -1023,4 +1036,4 @@ object SystemUIHooker : YukiBaseHooker() {
10231036
}
10241037
}
10251038
}
1026-
}
1039+
}

0 commit comments

Comments
 (0)