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

Commit 6cdcd6b8 authored by lyn's avatar lyn
Browse files

Always show app icons in bundle header

Fixes: 433950639
Test: BundleInteractorTest
Test: open/close bundle and shade
      => app icons persist
Flag: com.android.systemui.notification_bundle_ui
Change-Id: Ic48a5b06682d055c480ead51715864fb255dd5e3
parent a2e45a11
Loading
Loading
Loading
Loading
+17 −26
Original line number Diff line number Diff line
@@ -182,7 +182,7 @@ class BundleInteractorTest : SysuiTestCase() {
        }

    @Test
    fun previewIcons_collapseTimeNonZero_filterBytime() =
    fun previewIcons_collapseTimeNonZero_stillFetchesAllIcons() =
        testScope.runTest {
            // Arrange
            val collapseTime = 100L
@@ -196,22 +196,12 @@ class BundleInteractorTest : SysuiTestCase() {
                    on { packageName }.thenReturn("new_app")
                    on { timeAddedToBundle }.thenReturn(150L) // Newer than collapseTime
                }
            val appDataAtCollapse =
                mock<AppData> {
                    on { packageName }.thenReturn("at_collapse_app")
                    on { timeAddedToBundle }
                        .thenReturn(collapseTime) // Equal to collapseTime (should be filtered out)
                }
            val appDataList = listOf(appDataOld, appDataNew, appDataAtCollapse)
            val appDataList = listOf(appDataOld, appDataNew)

            whenever(
                    kosmos.mockAppIconProvider.getOrFetchAppIcon(
                        eq("new_app"),
                        any<UserHandle>(),
                        any<String>(),
                    )
                )
                .thenReturn(drawable3)
            whenever(kosmos.mockAppIconProvider.getOrFetchAppIcon(eq("old_app"), any(), any()))
                .thenReturn(drawable1)
            whenever(kosmos.mockAppIconProvider.getOrFetchAppIcon(eq("new_app"), any(), any()))
                .thenReturn(drawable2)

            testBundleRepository.lastCollapseTime = collapseTime
            testBundleRepository.appDataList.value = appDataList
@@ -221,17 +211,15 @@ class BundleInteractorTest : SysuiTestCase() {
            val result = underTest.previewIcons.first()

            // Assert
            assertThat(result).containsExactly(drawable3)
            verify(kosmos.mockAppIconProvider, times(0))
                .getOrFetchAppIcon(eq("old_app"), any<UserHandle>(), any<String>())
            verify(kosmos.mockAppIconProvider, times(0))
                .getOrFetchAppIcon(eq("at_collapse_app"), any<UserHandle>(), any<String>())
            verify(kosmos.mockAppIconProvider)
                .getOrFetchAppIcon(eq("new_app"), any<UserHandle>(), any<String>())
            assertThat(result).hasSize(2)
            assertThat(result).containsExactly(drawable1, drawable2).inOrder()

            verify(kosmos.mockAppIconProvider).getOrFetchAppIcon(eq("old_app"), any(), any())
            verify(kosmos.mockAppIconProvider).getOrFetchAppIcon(eq("new_app"), any(), any())
        }

    @Test
    fun previewIcons_allAppDataOlderThanCollapseTime_emitsEmptyList() =
    fun previewIcons_allAppDataOlderThanCollapseTime_emitsFullList() =
        testScope.runTest {
            // Arrange
            val collapseTime = 200L
@@ -243,6 +231,9 @@ class BundleInteractorTest : SysuiTestCase() {
                    }
                }

            whenever(kosmos.mockAppIconProvider.getOrFetchAppIcon(anyString(), any(), any()))
                .thenReturn(drawable1, drawable2, drawable3)

            testBundleRepository.lastCollapseTime = collapseTime
            testBundleRepository.appDataList.value = appDataList
            runCurrent()
@@ -251,8 +242,8 @@ class BundleInteractorTest : SysuiTestCase() {
            val result = underTest.previewIcons.first()

            // Assert
            assertThat(result).isEmpty()
            verify(kosmos.mockAppIconProvider, times(0))
            assertThat(result).hasSize(3)
            verify(kosmos.mockAppIconProvider, times(3))
                .getOrFetchAppIcon(anyString(), any<UserHandle>(), any<String>())
        }

+3 −9
Original line number Diff line number Diff line
@@ -104,15 +104,9 @@ constructor(
        rawAppDataList: List<AppData>,
        collapseTime: Long,
    ): List<AppData> {
        return if (collapseTime == 0L) {
            rawAppDataList
        } else {
            rawAppDataList.filter { appData ->
                val addedTime = appData.timeAddedToBundle
                val shouldKeep = addedTime > collapseTime
                shouldKeep
            }
        }
        // Always show app icons in bundle header
        // and keep filtering infra for now
        return rawAppDataList
    }

    /** Converts a list of AppData to a list of Drawables by fetching icons */