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
This commit is contained in:
Jeff DeCew
2021-03-09 15:33:35 -05:00
parent d6209d4e18
commit 5c64d007e8

View File

@@ -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