@@ -582,6 +582,37 @@ object SystemUIHooker : YukiBaseHooker() {
582582 }
583583 }
584584
585+ /* *
586+ * Hook 原生通知包装纸实例内容
587+ * @param wrapper 通知包装纸实例
588+ */
589+ private fun hookNotificationViewWrapper (wrapper : Any ) {
590+ /* * 忽略较旧版本 - 在没有 MIUI 通知栏样式的时候可能出现奇怪的问题 */
591+ if (isNotHasAbsoluteMiuiStyle && isShowMiuiStyle) return
592+
593+ /* * 获取小图标 */
594+ val iconImageView = NotificationHeaderViewWrapperClass .toClassOrNull()
595+ ?.field { name = " mIcon" }?.get(wrapper)?.cast<ImageView >() ? : return
596+
597+ /* * 获取 [ExpandableNotificationRowClass] */
598+ val rowPair = wrapper.getRowPair()
599+
600+ /* * 获取 [StatusBarNotification] */
601+ val expandedNf = rowPair.second.getSbn()
602+
603+ /* * 通知是否展开 */
604+ var isExpanded = rowPair.first
605+
606+ /* * 获取优先级 */
607+ val importance =
608+ (iconImageView.context.getSystemService(Context .NOTIFICATION_SERVICE ) as ? NotificationManager ? )
609+ ?.getNotificationChannel(expandedNf?.notification?.channelId)?.importance ? : 0
610+ /* * 非最小化优先级的通知全部设置为展开状态 */
611+ if (importance != 1 ) isExpanded = true
612+ /* * 执行 Hook */
613+ compatNotifyIcon(iconImageView.context, expandedNf, iconImageView, isExpanded)
614+ }
615+
585616 /* *
586617 * 从 [NotificationViewWrapperClass] 中获取 [ExpandableNotificationRowClass]
587618 * @return [Pair] - ([Boolean] 通知是否展开,[Any] 通知 Row 实例)
@@ -871,35 +902,13 @@ object SystemUIHooker : YukiBaseHooker() {
871902 }
872903 /* * 注入原生通知包装纸实例 */
873904 NotificationHeaderViewWrapperClass .hook {
874- /* * 修复下拉通知图标自动设置回 APP 图标的方法 */
875905 injectMember {
876906 method { name { it == " resolveHeaderViews" || it == " handleHeaderViews" || it == " resolveViews" } }
877- afterHook {
878- /* * 忽略较旧版本 - 在没有 MIUI 通知栏样式的时候可能出现奇怪的问题 */
879- if (isNotHasAbsoluteMiuiStyle && isShowMiuiStyle) return @afterHook
880-
881- /* * 获取小图标 */
882- val iconImageView = NotificationHeaderViewWrapperClass .toClassOrNull()
883- ?.field { name = " mIcon" }?.get(instance)?.cast<ImageView >() ? : return @afterHook
884-
885- /* * 获取 [ExpandableNotificationRowClass] */
886- val rowPair = instance.getRowPair()
887-
888- /* * 获取 [StatusBarNotification] */
889- val expandedNf = rowPair.second.getSbn()
890-
891- /* * 通知是否展开 */
892- var isExpanded = rowPair.first
893-
894- /* * 获取优先级 */
895- val importance =
896- (iconImageView.context.getSystemService(Context .NOTIFICATION_SERVICE ) as ? NotificationManager ? )
897- ?.getNotificationChannel(expandedNf?.notification?.channelId)?.importance ? : 0
898- /* * 非最小化优先级的通知全部设置为展开状态 */
899- if (importance != 1 ) isExpanded = true
900- /* * 执行 Hook */
901- compatNotifyIcon(iconImageView.context, expandedNf, iconImageView, isExpanded)
902- }
907+ afterHook { hookNotificationViewWrapper(instance) }
908+ }
909+ injectMember {
910+ method { name = " onContentUpdated" }
911+ afterHook { hookNotificationViewWrapper(instance) }
903912 }
904913 }
905914 /* * 修改 MIUI 风格通知栏的通知图标 */
0 commit comments