Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 5c64d007 authored by Jeff DeCew's avatar Jeff DeCew
Browse files

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
parent d6209d4e
Loading
Loading
Loading
Loading
+9 −4
Original line number Diff line number Diff line
@@ -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