@@ -35,10 +35,14 @@ import android.graphics.drawable.Drawable
3535import android.graphics.drawable.Icon
3636import android.graphics.drawable.VectorDrawable
3737import android.service.notification.StatusBarNotification
38+ import android.util.ArrayMap
39+ import android.util.ArraySet
3840import android.view.View
41+ import android.view.ViewGroup
3942import android.view.ViewOutlineProvider
4043import android.widget.ImageView
4144import androidx.core.graphics.drawable.toBitmap
45+ import androidx.core.view.children
4246import com.fankes.coloros.notify.bean.IconDataBean
4347import com.fankes.coloros.notify.const.Const
4448import com.fankes.coloros.notify.data.DataConst
@@ -97,6 +101,12 @@ class SystemUIHooker : YukiBaseHooker() {
97101 /* * 原生存在的类 */
98102 private const val PluginManagerImplClass = " $SYSTEMUI_PACKAGE_NAME .shared.plugins.PluginManagerImpl"
99103
104+ /* * 根据多个版本存在不同的包名相同的类 */
105+ private val OplusNotificationIconAreaControllerClass = VariousClass (
106+ " com.oplusos.systemui.statusbar.phone.OplusNotificationIconAreaController" ,
107+ " com.coloros.systemui.statusbar.phone.ColorosNotificationIconAreaController"
108+ )
109+
100110 /* * 根据多个版本存在不同的包名相同的类 */
101111 private val SystemPromptControllerClass = VariousClass (
102112 " com.oplusos.systemui.statusbar.policy.SystemPromptController" ,
@@ -153,16 +163,16 @@ class SystemUIHooker : YukiBaseHooker() {
153163 }
154164
155165 /* * 缓存的彩色 APP 图标 */
156- private var appIcons = HashMap <String , Drawable >()
166+ private var appIcons = ArrayMap <String , Drawable >()
157167
158168 /* * 缓存的通知优化图标数组 */
159169 private var iconDatas = ArrayList <IconDataBean >()
160170
161- /* * 缓存的状态栏小图标实例 */
162- private var statusBarIconViews = HashSet < ImageView >()
171+ /* * 状态栏通知图标容器 */
172+ private var notificationIconContainer : ViewGroup ? = null
163173
164174 /* * 缓存的通知小图标包装纸实例 */
165- private var notificationViewWrappers = HashSet <Any >()
175+ private var notificationViewWrappers = ArraySet <Any >()
166176
167177 /* * 仅监听一次主题壁纸颜色变化 */
168178 private var isWallpaperColorListenerSetUp = false
@@ -290,7 +300,7 @@ class SystemUIHooker : YukiBaseHooker() {
290300 .get(RoundRectDrawableUtilClass .clazz.field { name = " Companion" }.get().self)
291301 /* * 启动一个线程防止卡顿 */
292302 Thread {
293- statusBarIconViews. takeIf { it.isNotEmpty() } ?.forEach {
303+ notificationIconContainer?.children ?.forEach {
294304 runInSafe {
295305 /* * 得到通知实例 */
296306 val nf = nfField.get(it).cast<StatusBarNotification >() ? : return @Thread
@@ -311,7 +321,7 @@ class SystemUIHooker : YukiBaseHooker() {
311321 /* * 得到缩放大小 */
312322 val sNfSize = sNfSizeField.get(it).int()
313323 /* * 在主线程设置图标 */
314- it.post { it .setImageDrawable(roundUtil.invoke(pair.first, sRadius, sNfSize, sNfSize, it.context)) }
324+ it.post { (it as ? ImageView ? )? .setImageDrawable(roundUtil.invoke(pair.first, sRadius, sNfSize, sNfSize, it.context)) }
315325 }
316326 }
317327 }
@@ -611,12 +621,20 @@ class SystemUIHooker : YukiBaseHooker() {
611621 registerWallpaperColorChanged(it)
612622 /* * 注册广播 */
613623 registerReceiver(it.context)
614- /* * 缓存实例 */
615- statusBarIconViews.add(it)
616624 }
617625 }
618626 }
619627 }
628+ /* * 注入状态栏通知图标容器实例 */
629+ OplusNotificationIconAreaControllerClass .hook {
630+ injectMember {
631+ method {
632+ name = " updateIconsForLayout"
633+ paramCount = 10
634+ }
635+ afterHook { notificationIconContainer = args(index = 1 ).cast() }
636+ }
637+ }
620638 /* * 替换通知图标和样式 */
621639 NotificationHeaderViewWrapperClass .hook {
622640 injectMember {
0 commit comments