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

Commit 785e5042 authored by Caitlin Shkuratov's avatar Caitlin Shkuratov Committed by Android (Google) Code Review
Browse files

Merge changes from topic "caitlinshk-callchipflag-removal" into main

* changes:
  [SB] Remove status_bar_call_chip_notification_icon flag.
  [SB] Remove status_bar_use_repos_for_call_chip flag.
  [SB][Notif] Only hide text in chip that was actually tapped.
  [SB][Notif] Re-tapping notif chip hides the HUN.
parents 991ac06a 3efa0fcd
Loading
Loading
Loading
Loading
+0 −18
Original line number Diff line number Diff line
@@ -423,24 +423,6 @@ flag {
    }
}

flag {
    name: "status_bar_use_repos_for_call_chip"
    namespace: "systemui"
    description: "Use repositories as the source of truth for call notifications shown as a chip in"
        "the status bar"
    bug: "328584859"
    metadata {
        purpose: PURPOSE_BUGFIX
    }
}

flag {
    name: "status_bar_call_chip_notification_icon"
    namespace: "systemui"
    description: "Use the small icon set on the notification for the status bar call chip"
    bug: "354930838"
}

flag {
   name: "status_bar_signal_policy_refactor"
   namespace: "systemui"
+6 −86
Original line number Diff line number Diff line
@@ -22,7 +22,6 @@ import android.platform.test.annotations.EnableFlags
import android.view.View
import androidx.test.ext.junit.runners.AndroidJUnit4
import androidx.test.filters.SmallTest
import com.android.systemui.Flags.FLAG_STATUS_BAR_CALL_CHIP_NOTIFICATION_ICON
import com.android.systemui.SysuiTestCase
import com.android.systemui.common.shared.model.Icon
import com.android.systemui.coroutines.collectLastValue
@@ -126,65 +125,8 @@ class CallChipViewModelTest : SysuiTestCase() {
        }

    @Test
    @DisableFlags(FLAG_STATUS_BAR_CALL_CHIP_NOTIFICATION_ICON)
    fun chip_positiveStartTime_notifIconFlagOff_iconIsPhone() =
        testScope.runTest {
            val latest by collectLastValue(underTest.chip)

            repo.setOngoingCallState(
                inCallModel(startTimeMs = 1000, notificationIcon = createStatusBarIconViewOrNull())
            )

            assertThat((latest as OngoingActivityChipModel.Shown).icon)
                .isInstanceOf(OngoingActivityChipModel.ChipIcon.SingleColorIcon::class.java)
            val icon =
                (((latest as OngoingActivityChipModel.Shown).icon)
                        as OngoingActivityChipModel.ChipIcon.SingleColorIcon)
                    .impl as Icon.Resource
            assertThat(icon.res).isEqualTo(com.android.internal.R.drawable.ic_phone)
            assertThat(icon.contentDescription).isNotNull()
        }

    @Test
    @EnableFlags(FLAG_STATUS_BAR_CALL_CHIP_NOTIFICATION_ICON)
    @DisableFlags(StatusBarConnectedDisplays.FLAG_NAME)
    fun chip_positiveStartTime_notifIconFlagOn_iconIsNotifIcon() =
        testScope.runTest {
            val latest by collectLastValue(underTest.chip)

            val notifIcon = createStatusBarIconViewOrNull()
            repo.setOngoingCallState(inCallModel(startTimeMs = 1000, notificationIcon = notifIcon))

            assertThat((latest as OngoingActivityChipModel.Shown).icon)
                .isInstanceOf(OngoingActivityChipModel.ChipIcon.StatusBarView::class.java)
            val actualIcon =
                (((latest as OngoingActivityChipModel.Shown).icon)
                        as OngoingActivityChipModel.ChipIcon.StatusBarView)
                    .impl
            assertThat(actualIcon).isEqualTo(notifIcon)
        }

    @Test
    @EnableFlags(FLAG_STATUS_BAR_CALL_CHIP_NOTIFICATION_ICON, StatusBarConnectedDisplays.FLAG_NAME)
    fun chip_positiveStartTime_notifIconFlagOn_cdFlagOn_iconIsNotifKeyIcon() =
        testScope.runTest {
            val latest by collectLastValue(underTest.chip)

            repo.setOngoingCallState(
                inCallModel(
                    startTimeMs = 1000,
                    notificationIcon = createStatusBarIconViewOrNull(),
                    notificationKey = "notifKey",
                )
            )

            assertThat((latest as OngoingActivityChipModel.Shown).icon)
                .isEqualTo(OngoingActivityChipModel.ChipIcon.StatusBarNotificationIcon("notifKey"))
        }

    @Test
    @EnableFlags(FLAG_STATUS_BAR_CALL_CHIP_NOTIFICATION_ICON, StatusBarConnectedDisplays.FLAG_NAME)
    fun chip_positiveStartTime_notifIconAndConnectedDisplaysFlagOn_iconIsNotifIcon() =
    @EnableFlags(StatusBarConnectedDisplays.FLAG_NAME)
    fun chip_positiveStartTime_connectedDisplaysFlagOn_iconIsNotifIcon() =
        testScope.runTest {
            val latest by collectLastValue(underTest.chip)

@@ -205,29 +147,8 @@ class CallChipViewModelTest : SysuiTestCase() {
        }

    @Test
    @DisableFlags(FLAG_STATUS_BAR_CALL_CHIP_NOTIFICATION_ICON)
    fun chip_zeroStartTime_notifIconFlagOff_iconIsPhone() =
        testScope.runTest {
            val latest by collectLastValue(underTest.chip)

            repo.setOngoingCallState(
                inCallModel(startTimeMs = 0, notificationIcon = createStatusBarIconViewOrNull())
            )

            assertThat((latest as OngoingActivityChipModel.Shown).icon)
                .isInstanceOf(OngoingActivityChipModel.ChipIcon.SingleColorIcon::class.java)
            val icon =
                (((latest as OngoingActivityChipModel.Shown).icon)
                        as OngoingActivityChipModel.ChipIcon.SingleColorIcon)
                    .impl as Icon.Resource
            assertThat(icon.res).isEqualTo(com.android.internal.R.drawable.ic_phone)
            assertThat(icon.contentDescription).isNotNull()
        }

    @Test
    @EnableFlags(FLAG_STATUS_BAR_CALL_CHIP_NOTIFICATION_ICON)
    @DisableFlags(StatusBarConnectedDisplays.FLAG_NAME)
    fun chip_zeroStartTime_notifIconFlagOn_cdFlagOff_iconIsNotifIcon() =
    fun chip_zeroStartTime_cdFlagOff_iconIsNotifIcon() =
        testScope.runTest {
            val latest by collectLastValue(underTest.chip)

@@ -244,8 +165,8 @@ class CallChipViewModelTest : SysuiTestCase() {
        }

    @Test
    @EnableFlags(FLAG_STATUS_BAR_CALL_CHIP_NOTIFICATION_ICON, StatusBarConnectedDisplays.FLAG_NAME)
    fun chip_zeroStartTime_notifIconFlagOn_cdFlagOn_iconIsNotifKeyIcon() =
    @EnableFlags(StatusBarConnectedDisplays.FLAG_NAME)
    fun chip_zeroStartTime_cdFlagOn_iconIsNotifKeyIcon() =
        testScope.runTest {
            val latest by collectLastValue(underTest.chip)

@@ -262,7 +183,6 @@ class CallChipViewModelTest : SysuiTestCase() {
        }

    @Test
    @EnableFlags(FLAG_STATUS_BAR_CALL_CHIP_NOTIFICATION_ICON)
    @DisableFlags(StatusBarConnectedDisplays.FLAG_NAME)
    fun chip_notifIconFlagOn_butNullNotifIcon_cdFlagOff_iconIsPhone() =
        testScope.runTest {
@@ -281,7 +201,7 @@ class CallChipViewModelTest : SysuiTestCase() {
        }

    @Test
    @EnableFlags(FLAG_STATUS_BAR_CALL_CHIP_NOTIFICATION_ICON, StatusBarConnectedDisplays.FLAG_NAME)
    @EnableFlags(StatusBarConnectedDisplays.FLAG_NAME)
    fun chip_notifIconFlagOn_butNullNotifIcon_iconNotifKey() =
        testScope.runTest {
            val latest by collectLastValue(underTest.chip)
+95 −2
Original line number Diff line number Diff line
@@ -501,7 +501,7 @@ class NotifChipsViewModelTest : SysuiTestCase() {

    @Test
    @DisableFlags(FLAG_PROMOTE_NOTIFICATIONS_AUTOMATICALLY)
    fun chips_hasHeadsUpByUser_onlyShowsIcon() =
    fun chips_hasHeadsUpBySystem_showsTime() =
        kosmos.runTest {
            val latest by collectLastValue(underTest.chips)

@@ -523,7 +523,99 @@ class NotifChipsViewModelTest : SysuiTestCase() {
                )
            )

            // WHEN there's a HUN pinned by a user
            // WHEN there's a HUN pinned by the system
            kosmos.headsUpNotificationRepository.setNotifications(
                UnconfinedFakeHeadsUpRowRepository(
                    key = "notif",
                    pinnedStatus = MutableStateFlow(PinnedStatus.PinnedBySystem),
                )
            )

            // THEN the chip keeps showing time
            // (In real life the chip won't show at all, but that's handled in a different part of
            // the system. What we know here is that the chip shouldn't shrink to icon only.)
            assertThat(latest!![0])
                .isInstanceOf(OngoingActivityChipModel.Shown.ShortTimeDelta::class.java)
        }

    @Test
    @DisableFlags(FLAG_PROMOTE_NOTIFICATIONS_AUTOMATICALLY)
    fun chips_hasHeadsUpByUser_forOtherNotif_showsTime() =
        kosmos.runTest {
            val latest by collectLastValue(underTest.chips)

            val promotedContentBuilder =
                PromotedNotificationContentModel.Builder("notif").apply {
                    this.time =
                        PromotedNotificationContentModel.When(
                            time = 6543L,
                            mode = PromotedNotificationContentModel.When.Mode.BasicTime,
                        )
                }
            val otherPromotedContentBuilder =
                PromotedNotificationContentModel.Builder("other notif").apply {
                    this.time =
                        PromotedNotificationContentModel.When(
                            time = 654321L,
                            mode = PromotedNotificationContentModel.When.Mode.BasicTime,
                        )
                }
            val icon = createStatusBarIconViewOrNull()
            val otherIcon = createStatusBarIconViewOrNull()
            setNotifs(
                listOf(
                    activeNotificationModel(
                        key = "notif",
                        statusBarChipIcon = icon,
                        promotedContent = promotedContentBuilder.build(),
                    ),
                    activeNotificationModel(
                        key = "other notif",
                        statusBarChipIcon = otherIcon,
                        promotedContent = otherPromotedContentBuilder.build(),
                    ),
                )
            )

            // WHEN there's a HUN pinned for the "other notif" chip
            kosmos.headsUpNotificationRepository.setNotifications(
                UnconfinedFakeHeadsUpRowRepository(
                    key = "other notif",
                    pinnedStatus = MutableStateFlow(PinnedStatus.PinnedByUser),
                )
            )

            // THEN the "notif" chip keeps showing time
            val chip = latest!![0]
            assertThat(chip).isInstanceOf(OngoingActivityChipModel.Shown.ShortTimeDelta::class.java)
            assertIsNotifChip(chip, icon, "notif")
        }

    @Test
    @DisableFlags(FLAG_PROMOTE_NOTIFICATIONS_AUTOMATICALLY)
    fun chips_hasHeadsUpByUser_forThisNotif_onlyShowsIcon() =
        kosmos.runTest {
            val latest by collectLastValue(underTest.chips)

            val promotedContentBuilder =
                PromotedNotificationContentModel.Builder("notif").apply {
                    this.time =
                        PromotedNotificationContentModel.When(
                            time = 6543L,
                            mode = PromotedNotificationContentModel.When.Mode.BasicTime,
                        )
                }
            setNotifs(
                listOf(
                    activeNotificationModel(
                        key = "notif",
                        statusBarChipIcon = mock<StatusBarIconView>(),
                        promotedContent = promotedContentBuilder.build(),
                    )
                )
            )

            // WHEN this notification is pinned by the user
            kosmos.headsUpNotificationRepository.setNotifications(
                UnconfinedFakeHeadsUpRowRepository(
                    key = "notif",
@@ -531,6 +623,7 @@ class NotifChipsViewModelTest : SysuiTestCase() {
                )
            )

            // THEN the chip shrinks to icon only
            assertThat(latest!![0])
                .isInstanceOf(OngoingActivityChipModel.Shown.IconOnly::class.java)
        }
+31 −4
Original line number Diff line number Diff line
@@ -458,7 +458,7 @@ class HeadsUpCoordinatorTest : SysuiTestCase() {

    @Test
    @EnableFlags(StatusBarNotifChips.FLAG_NAME)
    fun showPromotedNotification_hasNotifEntry_shownAsHUN() =
    fun onPromotedNotificationChipTapped_hasNotifEntry_shownAsHUN() =
        testScope.runTest {
            whenever(notifCollection.getEntry(entry.key)).thenReturn(entry)

@@ -473,7 +473,7 @@ class HeadsUpCoordinatorTest : SysuiTestCase() {

    @Test
    @EnableFlags(StatusBarNotifChips.FLAG_NAME)
    fun showPromotedNotification_noNotifEntry_noHUN() =
    fun onPromotedNotificationChipTapped_noNotifEntry_noHUN() =
        testScope.runTest {
            whenever(notifCollection.getEntry(entry.key)).thenReturn(null)

@@ -488,7 +488,7 @@ class HeadsUpCoordinatorTest : SysuiTestCase() {

    @Test
    @EnableFlags(StatusBarNotifChips.FLAG_NAME)
    fun showPromotedNotification_shownAsHUNEvenIfEntryShouldNot() =
    fun onPromotedNotificationChipTapped_shownAsHUNEvenIfEntryShouldNot() =
        testScope.runTest {
            whenever(notifCollection.getEntry(entry.key)).thenReturn(entry)

@@ -511,7 +511,7 @@ class HeadsUpCoordinatorTest : SysuiTestCase() {

    @Test
    @EnableFlags(StatusBarNotifChips.FLAG_NAME)
    fun showPromotedNotification_atSameTimeAsOnAdded_promotedShownAsHUN() =
    fun onPromotedNotificationChipTapped_atSameTimeAsOnAdded_promotedShownAsHUN() =
        testScope.runTest {
            // First, the promoted notification appears as not heads up
            val promotedEntry = NotificationEntryBuilder().setPkg("promotedPackage").build()
@@ -547,6 +547,33 @@ class HeadsUpCoordinatorTest : SysuiTestCase() {
            verify(headsUpManager, never()).showNotification(eq(entry), any())
        }

    @Test
    @EnableFlags(StatusBarNotifChips.FLAG_NAME)
    fun onPromotedNotificationChipTapped_chipTappedTwice_hunHiddenOnSecondTap() =
        testScope.runTest {
            whenever(notifCollection.getEntry(entry.key)).thenReturn(entry)

            // WHEN chip tapped first
            statusBarNotificationChipsInteractor.onPromotedNotificationChipTapped(entry.key)
            executor.advanceClockToLast()
            executor.runAllReady()
            beforeFinalizeFilterListener.onBeforeFinalizeFilter(listOf(entry))

            // THEN HUN is shown
            finishBind(entry)
            verify(headsUpManager).showNotification(entry, isPinnedByUser = true)
            addHUN(entry)

            // WHEN chip is tapped again
            statusBarNotificationChipsInteractor.onPromotedNotificationChipTapped(entry.key)
            executor.advanceClockToLast()
            executor.runAllReady()
            beforeFinalizeFilterListener.onBeforeFinalizeFilter(listOf(entry))

            // THEN HUN is hidden
            verify(headsUpManager).removeNotification(eq(entry.key), eq(false), any())
        }

    @Test
    fun testTransferIsolatedChildAlert_withGroupAlertSummary() {
        setShouldHeadsUp(groupSummary)
+33 −16
Original line number Diff line number Diff line
@@ -32,6 +32,7 @@ import com.android.systemui.shade.data.repository.fakeShadeRepository
import com.android.systemui.shade.shadeTestUtil
import com.android.systemui.statusbar.notification.data.repository.FakeHeadsUpRowRepository
import com.android.systemui.statusbar.notification.data.repository.notificationsKeyguardViewStateRepository
import com.android.systemui.statusbar.notification.domain.model.TopPinnedState
import com.android.systemui.statusbar.notification.headsup.PinnedStatus
import com.android.systemui.statusbar.notification.stack.data.repository.headsUpNotificationRepository
import com.android.systemui.statusbar.notification.stack.domain.interactor.headsUpNotificationInteractor
@@ -412,46 +413,53 @@ class HeadsUpNotificationInteractorTest : SysuiTestCase() {
    @Test
    fun statusBarHeadsUpState_pinnedBySystem() =
        testScope.runTest {
            val statusBarHeadsUpState by collectLastValue(underTest.statusBarHeadsUpState)
            val state by collectLastValue(underTest.statusBarHeadsUpState)
            val status by collectLastValue(underTest.statusBarHeadsUpStatus)

            headsUpRepository.setNotifications(
                FakeHeadsUpRowRepository(key = "key 0", pinnedStatus = PinnedStatus.PinnedBySystem)
            )
            runCurrent()

            assertThat(statusBarHeadsUpState).isEqualTo(PinnedStatus.PinnedBySystem)
            assertThat(state).isEqualTo(TopPinnedState.Pinned("key 0", PinnedStatus.PinnedBySystem))
            assertThat(status).isEqualTo(PinnedStatus.PinnedBySystem)
        }

    @Test
    fun statusBarHeadsUpState_pinnedByUser() =
        testScope.runTest {
            val statusBarHeadsUpState by collectLastValue(underTest.statusBarHeadsUpState)
            val state by collectLastValue(underTest.statusBarHeadsUpState)
            val status by collectLastValue(underTest.statusBarHeadsUpStatus)

            headsUpRepository.setNotifications(
                FakeHeadsUpRowRepository(key = "key 0", pinnedStatus = PinnedStatus.PinnedByUser)
            )
            runCurrent()

            assertThat(statusBarHeadsUpState).isEqualTo(PinnedStatus.PinnedByUser)
            assertThat(state).isEqualTo(TopPinnedState.Pinned("key 0", PinnedStatus.PinnedByUser))
            assertThat(status).isEqualTo(PinnedStatus.PinnedByUser)
        }

    @Test
    fun statusBarHeadsUpState_withoutPinnedNotifications_notPinned() =
        testScope.runTest {
            val statusBarHeadsUpState by collectLastValue(underTest.statusBarHeadsUpState)
            val state by collectLastValue(underTest.statusBarHeadsUpState)
            val status by collectLastValue(underTest.statusBarHeadsUpStatus)

            headsUpRepository.setNotifications(
                FakeHeadsUpRowRepository(key = "key 0", PinnedStatus.NotPinned)
            )
            runCurrent()

            assertThat(statusBarHeadsUpState).isEqualTo(PinnedStatus.NotPinned)
            assertThat(state).isEqualTo(TopPinnedState.NothingPinned)
            assertThat(status).isEqualTo(PinnedStatus.NotPinned)
        }

    @Test
    fun statusBarHeadsUpState_whenShadeExpanded_false() =
        testScope.runTest {
            val statusBarHeadsUpState by collectLastValue(underTest.statusBarHeadsUpState)
            val state by collectLastValue(underTest.statusBarHeadsUpState)
            val status by collectLastValue(underTest.statusBarHeadsUpStatus)

            // WHEN a row is pinned
            headsUpRepository.setNotifications(fakeHeadsUpRowRepository("key 0", isPinned = true))
@@ -463,13 +471,15 @@ class HeadsUpNotificationInteractorTest : SysuiTestCase() {
            // should emit `false`.
            kosmos.fakeShadeRepository.setLegacyShadeExpansion(1.0f)

            assertThat(statusBarHeadsUpState!!.isPinned).isFalse()
            assertThat(state).isEqualTo(TopPinnedState.NothingPinned)
            assertThat(status!!.isPinned).isFalse()
        }

    @Test
    fun statusBarHeadsUpState_notificationsAreHidden_false() =
        testScope.runTest {
            val statusBarHeadsUpState by collectLastValue(underTest.statusBarHeadsUpState)
            val state by collectLastValue(underTest.statusBarHeadsUpState)
            val status by collectLastValue(underTest.statusBarHeadsUpStatus)

            // WHEN a row is pinned
            headsUpRepository.setNotifications(fakeHeadsUpRowRepository("key 0", isPinned = true))
@@ -477,13 +487,15 @@ class HeadsUpNotificationInteractorTest : SysuiTestCase() {
            // AND the notifications are hidden
            keyguardViewStateRepository.areNotificationsFullyHidden.value = true

            assertThat(statusBarHeadsUpState!!.isPinned).isFalse()
            assertThat(state).isEqualTo(TopPinnedState.NothingPinned)
            assertThat(status!!.isPinned).isFalse()
        }

    @Test
    fun statusBarHeadsUpState_onLockScreen_false() =
        testScope.runTest {
            val statusBarHeadsUpState by collectLastValue(underTest.statusBarHeadsUpState)
            val state by collectLastValue(underTest.statusBarHeadsUpState)
            val status by collectLastValue(underTest.statusBarHeadsUpStatus)

            // WHEN a row is pinned
            headsUpRepository.setNotifications(fakeHeadsUpRowRepository("key 0", isPinned = true))
@@ -494,13 +506,15 @@ class HeadsUpNotificationInteractorTest : SysuiTestCase() {
                testSetup = true,
            )

            assertThat(statusBarHeadsUpState!!.isPinned).isFalse()
            assertThat(state).isEqualTo(TopPinnedState.NothingPinned)
            assertThat(status!!.isPinned).isFalse()
        }

    @Test
    fun statusBarHeadsUpState_onByPassLockScreen_true() =
        testScope.runTest {
            val statusBarHeadsUpState by collectLastValue(underTest.statusBarHeadsUpState)
            val state by collectLastValue(underTest.statusBarHeadsUpState)
            val status by collectLastValue(underTest.statusBarHeadsUpStatus)

            // WHEN a row is pinned
            headsUpRepository.setNotifications(fakeHeadsUpRowRepository("key 0", isPinned = true))
@@ -513,13 +527,15 @@ class HeadsUpNotificationInteractorTest : SysuiTestCase() {
            // AND bypass is enabled
            faceAuthRepository.isBypassEnabled.value = true

            assertThat(statusBarHeadsUpState!!.isPinned).isTrue()
            assertThat(state).isInstanceOf(TopPinnedState.Pinned::class.java)
            assertThat(status!!.isPinned).isTrue()
        }

    @Test
    fun statusBarHeadsUpState_onByPassLockScreen_withoutNotifications_false() =
        testScope.runTest {
            val statusBarHeadsUpState by collectLastValue(underTest.statusBarHeadsUpState)
            val state by collectLastValue(underTest.statusBarHeadsUpState)
            val status by collectLastValue(underTest.statusBarHeadsUpStatus)

            // WHEN no pinned rows
            // AND the lock screen is shown
@@ -530,7 +546,8 @@ class HeadsUpNotificationInteractorTest : SysuiTestCase() {
            // AND bypass is enabled
            faceAuthRepository.isBypassEnabled.value = true

            assertThat(statusBarHeadsUpState!!.isPinned).isFalse()
            assertThat(state).isEqualTo(TopPinnedState.NothingPinned)
            assertThat(status!!.isPinned).isFalse()
        }

    private fun fakeHeadsUpRowRepository(key: String, isPinned: Boolean = false) =
Loading