From 5c64d007e898980fa51ec2add5bbcac139ffe73e Mon Sep 17 00:00:00 2001 From: Jeff DeCew Date: Tue, 9 Mar 2021 15:33:35 -0500 Subject: [PATCH] Do not increment the conversation unread count when FLAG_ONLY_ALERT_ONCE is set. Bug: 179417569 Test: manual testing with updated notify app. Change-Id: I4009146716fde91f24cdd69a72bf7b0048e2bc14 --- .../notification/ConversationNotifications.kt | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/ConversationNotifications.kt b/packages/SystemUI/src/com/android/systemui/statusbar/notification/ConversationNotifications.kt index 004cf9968a77d..b0d41f1557134 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/ConversationNotifications.kt +++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/ConversationNotifications.kt @@ -218,13 +218,18 @@ class ConversationNotificationManager @Inject constructor( }) } + private fun ConversationState.shouldIncrementUnread(newBuilder: Notification.Builder) = + if (notification.flags and Notification.FLAG_ONLY_ALERT_ONCE != 0) { + false + } else { + val oldBuilder = Notification.Builder.recoverBuilder(context, notification) + Notification.areStyledNotificationsVisiblyDifferent(oldBuilder, newBuilder) + } + fun getUnreadCount(entry: NotificationEntry, recoveredBuilder: Notification.Builder): Int = states.compute(entry.key) { _, state -> val newCount = state?.run { - val old = Notification.Builder.recoverBuilder(context, notification) - val increment = Notification - .areStyledNotificationsVisiblyDifferent(old, recoveredBuilder) - if (increment) unreadCount + 1 else unreadCount + if (shouldIncrementUnread(recoveredBuilder)) unreadCount + 1 else unreadCount } ?: 1 ConversationState(newCount, entry.sbn.notification) }!!.unreadCount