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

Commit 76f5e947 authored by Julia Reynolds's avatar Julia Reynolds
Browse files

Fix bundle notifcation count

Which was not including notifications in groups that exceed the
group limit

Test: BundleCoordinatorTest
Fixes: 424360473
Flag: com.android.systemui.notification_bundle_ui
Change-Id: Ib8d0fba014c3d52de558c92d5886c9752100467a
parent c797432f
Loading
Loading
Loading
Loading
+10 −10
Original line number Diff line number Diff line
@@ -498,7 +498,7 @@ class BundleCoordinatorTest : SysuiTestCase() {
        val bundle = BundleEntry(TEST_BUNDLE_SPEC)
        bundle.addChild(NotificationEntryBuilder().build())

        coordinator.bundleCountUpdater.onBeforeRenderList(listOf(bundle))
        coordinator.bundleCountUpdater.onBeforeFinalizeFilter(listOf(bundle))
        assertThat(bundle.bundleRepository.numberOfChildren).isEqualTo(1)
    }

@@ -510,7 +510,7 @@ class BundleCoordinatorTest : SysuiTestCase() {
        groupEntry.rawChildren.add(NotificationEntryBuilder().build())
        bundle.addChild(groupEntry)

        coordinator.bundleCountUpdater.onBeforeRenderList(listOf(bundle))
        coordinator.bundleCountUpdater.onBeforeFinalizeFilter(listOf(bundle))
        assertThat(bundle.bundleRepository.numberOfChildren).isEqualTo(2)
    }

@@ -527,7 +527,7 @@ class BundleCoordinatorTest : SysuiTestCase() {
        groupEntry2.rawChildren.add(NotificationEntryBuilder().build())
        bundle.addChild(groupEntry2)

        coordinator.bundleCountUpdater.onBeforeRenderList(listOf(bundle))
        coordinator.bundleCountUpdater.onBeforeFinalizeFilter(listOf(bundle))
        assertThat(bundle.bundleRepository.numberOfChildren).isEqualTo(3)
    }

@@ -540,7 +540,7 @@ class BundleCoordinatorTest : SysuiTestCase() {
        bundle.addChild(groupEntry1)
        bundle.addChild(NotificationEntryBuilder().build())

        coordinator.bundleCountUpdater.onBeforeRenderList(listOf(bundle))
        coordinator.bundleCountUpdater.onBeforeFinalizeFilter(listOf(bundle))
        assertThat(bundle.bundleRepository.numberOfChildren).isEqualTo(2)
    }

@@ -555,12 +555,12 @@ class BundleCoordinatorTest : SysuiTestCase() {
        groupEntry1.rawChildren.add(NotificationEntryBuilder().build())
        bundle.addChild(groupEntry1)

        coordinator.bundleCountUpdater.onBeforeRenderList(listOf(bundle))
        coordinator.bundleCountUpdater.onBeforeFinalizeFilter(listOf(bundle))
        assertThat(bundle.bundleRepository.numberOfChildren).isEqualTo(2)

        bundle.removeChild(directNotifChild)

        coordinator.bundleCountUpdater.onBeforeRenderList(listOf(bundle))
        coordinator.bundleCountUpdater.onBeforeFinalizeFilter(listOf(bundle))
        assertThat(bundle.bundleRepository.numberOfChildren).isEqualTo(1)
    }

@@ -572,11 +572,11 @@ class BundleCoordinatorTest : SysuiTestCase() {
        bundle.addChild(groupEntry1)
        bundle.addChild(NotificationEntryBuilder().build())

        coordinator.bundleCountUpdater.onBeforeRenderList(listOf(bundle))
        coordinator.bundleCountUpdater.onBeforeFinalizeFilter(listOf(bundle))
        assertThat(bundle.bundleRepository.numberOfChildren).isEqualTo(2)

        groupEntry1.rawChildren.clear()
        coordinator.bundleCountUpdater.onBeforeRenderList(listOf(bundle))
        coordinator.bundleCountUpdater.onBeforeFinalizeFilter(listOf(bundle))
        assertThat(bundle.bundleRepository.numberOfChildren).isEqualTo(1)
    }

@@ -588,12 +588,12 @@ class BundleCoordinatorTest : SysuiTestCase() {
        bundle.addChild(groupEntry1)
        bundle.addChild(NotificationEntryBuilder().build())

        coordinator.bundleCountUpdater.onBeforeRenderList(listOf(bundle))
        coordinator.bundleCountUpdater.onBeforeFinalizeFilter(listOf(bundle))
        assertThat(bundle.bundleRepository.numberOfChildren).isEqualTo(2)

        bundle.clearChildren()

        coordinator.bundleCountUpdater.onBeforeRenderList(listOf(bundle))
        coordinator.bundleCountUpdater.onBeforeFinalizeFilter(listOf(bundle))
        assertThat(bundle.bundleRepository.numberOfChildren).isEqualTo(0)
    }

+9 −9
Original line number Diff line number Diff line
@@ -36,6 +36,7 @@ import com.android.systemui.statusbar.notification.collection.NotifPipeline
import com.android.systemui.statusbar.notification.collection.NotificationEntry
import com.android.systemui.statusbar.notification.collection.PipelineEntry
import com.android.systemui.statusbar.notification.collection.coordinator.dagger.CoordinatorScope
import com.android.systemui.statusbar.notification.collection.listbuilder.OnBeforeFinalizeFilterListener
import com.android.systemui.statusbar.notification.collection.listbuilder.OnBeforeRenderListListener
import com.android.systemui.statusbar.notification.collection.listbuilder.pluggable.Invalidator
import com.android.systemui.statusbar.notification.collection.listbuilder.pluggable.NotifBundler
@@ -190,18 +191,17 @@ constructor(
     * counted.
     */
    @get:VisibleForTesting
    val bundleCountUpdater = OnBeforeRenderListListener { entries ->
    val bundleCountUpdater = OnBeforeFinalizeFilterListener { entries ->
        entries.forEachBundleEntry { bundleEntry ->
            val notifEntrySet = mutableSetOf<NotificationEntry>()
            fun collectNotifEntry(listEntries: List<ListEntry>) {
            fun countNotifications(listEntries: List<ListEntry>): Int {
                var count = 0
                for (entry in listEntries) {
                    when (entry) {
                        is NotificationEntry -> {
                            notifEntrySet.add(entry)
                            count++
                        }
                        is GroupEntry -> {
                            // Do not count group summary NotifEntry
                            collectNotifEntry(entry.children)
                            count += entry.children.size
                        }
                        else -> {
                            error(
@@ -212,9 +212,9 @@ constructor(
                        }
                    }
                }
                return count
            }
            collectNotifEntry(bundleEntry.children)
            bundleEntry.bundleRepository.numberOfChildren = notifEntrySet.size
            bundleEntry.bundleRepository.numberOfChildren = countNotifications(bundleEntry.children)
        }
    }

@@ -311,8 +311,8 @@ constructor(
        if (NotificationBundleUi.isEnabled) {
            pipeline.setNotifBundler(bundler)
            pipeline.addOnBeforeFinalizeFilterListener(this::inflateAllBundleEntries)
            pipeline.addOnBeforeFinalizeFilterListener(bundleCountUpdater)
            pipeline.addFinalizeFilter(bundleFilter)
            pipeline.addOnBeforeRenderListListener(bundleCountUpdater)
            pipeline.addOnBeforeRenderListListener(bundleMembershipUpdater)
            pipeline.addOnBeforeRenderListListener(bundleAppDataUpdater)
            bindOnboardingAffordanceInvalidator(pipeline)