Skip to content

Commit 3cfbae8

Browse files
authored
fix: The refreshNotificationIcons does not work on ColorOS 16 (#89)
* fix: The refreshNotificationIcons does not work on ColorOS 16 * optimize field position Removed duplicate declaration of ViewConfigCoordinatorClass.
1 parent d2299c4 commit 3cfbae8

1 file changed

Lines changed: 16 additions & 3 deletions

File tree

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

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,9 @@ object SystemUIHooker : YukiBaseHooker() {
115115

116116
/** 原生存在的类 */
117117
private val MediaDataClass by lazyClassOrNull("${PackageName.SYSTEMUI}.media.MediaData")
118+
119+
/** 原生存在的类 */
120+
private val ViewConfigCoordinatorClass by lazyClassOrNull("${PackageName.SYSTEMUI}.statusbar.notification.collection.coordinator.ViewConfigCoordinator")
118121

119122
/** 原生存在的类 - 旧版本不存在 */
120123
private val LegacyNotificationIconAreaControllerImpl by lazyClassOrNull("${PackageName.SYSTEMUI}.statusbar.phone.LegacyNotificationIconAreaControllerImpl")
@@ -142,7 +145,7 @@ object SystemUIHooker : YukiBaseHooker() {
142145

143146
/** ColorOS 存在的类 - 旧版本不存在 */
144147
private val OplusNotificationGroupTemplateWrapperClass by lazyClassOrNull("com.oplus.systemui.notification.row.oplusgroup.OplusNotificationGroupTemplateWrapper")
145-
148+
146149
/** 根据多个版本存在不同的包名相同的类 */
147150
private val OplusNotificationIconAreaControllerClass by lazyClass(
148151
VariousClass(
@@ -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)