diff options
| author | 2025-02-27 15:43:45 +0000 | |
|---|---|---|
| committer | 2025-02-28 19:57:22 +0000 | |
| commit | 1d4e1ab19bd9816c047e7b15e835a373141c2383 (patch) | |
| tree | 42dbb7855a5737f0ce3424e4e9767bffaabe675f | |
| parent | bc85e45d67ee6f7a1e20666c5b5dfc6672c71bf7 (diff) | |
[SB] Rework chip visibility & notification icon visibility with HUNs.
I noticed a few problems:
- With StatusBarNoHunBehavior flag off, if you have a chip and then get
a HUN then we weren't showing the HUN's notification icon because
`isAnyChipVisible` was `true`.
- With StatusBarNoHunBehavior flag on, then tapping the chip to show
the HUN would hide the chip because there was a pinned HUN.
This reworks the flows to address both of these problems.
Bug: 364653005
Flag: com.android.systemui.status_bar_no_hun_behavior
Flag: com.android.systemui.status_bar_root_modernization
Test: NoHunBehavior off: Verify status bar updates to show HUN icon &
text if you have a chip AND if you don't have a chip
Test: NoHunBeahvior on: Verify status bar always shows clock & chip,
even if there's a chip HUN showing or a non-chip HUN showing
Test: atest HomeStatusBarViewModelTest
Change-Id: Ie58ebbc9ad021f9e33b1280c4cbbc4d146b31e23
2 files changed, 157 insertions, 17 deletions
diff --git a/packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/pipeline/shared/ui/viewmodel/HomeStatusBarViewModelImplTest.kt b/packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/pipeline/shared/ui/viewmodel/HomeStatusBarViewModelImplTest.kt index 7e8ee1b156df..de45b4887daa 100644 --- a/packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/pipeline/shared/ui/viewmodel/HomeStatusBarViewModelImplTest.kt +++ b/packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/pipeline/shared/ui/viewmodel/HomeStatusBarViewModelImplTest.kt @@ -716,7 +716,8 @@ class HomeStatusBarViewModelImplTest : SysuiTestCase() { } @Test - fun canShowOngoingActivityChips_statusBarNotHidden_noSecureCamera_hun_false() = + @DisableFlags(StatusBarNoHunBehavior.FLAG_NAME) + fun canShowOngoingActivityChips_statusBarNotHidden_noSecureCamera_hunBySystem_noHunFlagOff_false() = kosmos.runTest { val latest by collectLastValue(underTest.canShowOngoingActivityChips) @@ -725,7 +726,7 @@ class HomeStatusBarViewModelImplTest : SysuiTestCase() { headsUpNotificationRepository.setNotifications( UnconfinedFakeHeadsUpRowRepository( key = "key", - pinnedStatus = MutableStateFlow(PinnedStatus.PinnedByUser), + pinnedStatus = MutableStateFlow(PinnedStatus.PinnedBySystem), ) ) @@ -733,6 +734,60 @@ class HomeStatusBarViewModelImplTest : SysuiTestCase() { } @Test + @DisableFlags(StatusBarNoHunBehavior.FLAG_NAME) + fun canShowOngoingActivityChips_statusBarNotHidden_noSecureCamera_hunByUser_noHunFlagOff_true() = + kosmos.runTest { + val latest by collectLastValue(underTest.canShowOngoingActivityChips) + + transitionKeyguardToGone() + + headsUpNotificationRepository.setNotifications( + UnconfinedFakeHeadsUpRowRepository( + key = "key", + pinnedStatus = MutableStateFlow(PinnedStatus.PinnedByUser), + ) + ) + + assertThat(latest).isTrue() + } + + @Test + @EnableFlags(StatusBarNoHunBehavior.FLAG_NAME) + fun canShowOngoingActivityChips_statusBarNotHidden_noSecureCamera_hunBySystem_noHunFlagOn_true() = + kosmos.runTest { + val latest by collectLastValue(underTest.canShowOngoingActivityChips) + + transitionKeyguardToGone() + + headsUpNotificationRepository.setNotifications( + UnconfinedFakeHeadsUpRowRepository( + key = "key", + pinnedStatus = MutableStateFlow(PinnedStatus.PinnedBySystem), + ) + ) + + assertThat(latest).isTrue() + } + + @Test + @EnableFlags(StatusBarNoHunBehavior.FLAG_NAME) + fun canShowOngoingActivityChips_statusBarNotHidden_noSecureCamera_hunByUser_noHunFlagOn_true() = + kosmos.runTest { + val latest by collectLastValue(underTest.canShowOngoingActivityChips) + + transitionKeyguardToGone() + + headsUpNotificationRepository.setNotifications( + UnconfinedFakeHeadsUpRowRepository( + key = "key", + pinnedStatus = MutableStateFlow(PinnedStatus.PinnedByUser), + ) + ) + + assertThat(latest).isTrue() + } + + @Test fun isClockVisible_allowedByDisableFlags_visible() = kosmos.runTest { val latest by collectLastValue(underTest.isClockVisible) @@ -892,7 +947,7 @@ class HomeStatusBarViewModelImplTest : SysuiTestCase() { @Test @EnableChipsModernization - fun isNotificationIconContainerVisible_anyChipShowing_ChipsModernizationOn() = + fun isNotificationIconContainerVisible_anyChipShowing_chipsModernizationOn() = kosmos.runTest { val latest by collectLastValue(underTest.isNotificationIconContainerVisible) transitionKeyguardToGone() @@ -909,7 +964,7 @@ class HomeStatusBarViewModelImplTest : SysuiTestCase() { @Test @DisableFlags(StatusBarRootModernization.FLAG_NAME, StatusBarChipsModernization.FLAG_NAME) @EnableFlags(StatusBarNotifChips.FLAG_NAME) - fun isNotificationIconContainerVisible_anyChipShowing_PromotedNotifsOn() = + fun isNotificationIconContainerVisible_anyChipShowing_promotedNotifsOn() = kosmos.runTest { val latest by collectLastValue(underTest.isNotificationIconContainerVisible) transitionKeyguardToGone() @@ -929,7 +984,7 @@ class HomeStatusBarViewModelImplTest : SysuiTestCase() { StatusBarRootModernization.FLAG_NAME, StatusBarChipsModernization.FLAG_NAME, ) - fun isNotificationIconContainerVisible_anyChipShowing_ChipsModernizationAndPromotedNotifsOff() = + fun isNotificationIconContainerVisible_anyChipShowing_chipsModernizationAndPromotedNotifsOff() = kosmos.runTest { val latest by collectLastValue(underTest.isNotificationIconContainerVisible) transitionKeyguardToGone() @@ -943,6 +998,86 @@ class HomeStatusBarViewModelImplTest : SysuiTestCase() { assertThat(latest!!.visibility).isEqualTo(View.VISIBLE) } + @DisableFlags(StatusBarNoHunBehavior.FLAG_NAME) + fun isNotificationIconContainerVisible_hasChipButAlsoHun_hunBySystem_noHunFlagOff_visible() = + kosmos.runTest { + val latest by collectLastValue(underTest.isNotificationIconContainerVisible) + transitionKeyguardToGone() + + // Chip + kosmos.screenRecordRepository.screenRecordState.value = ScreenRecordModel.Recording + + // HUN, PinnedBySystem + headsUpNotificationRepository.setNotifications( + UnconfinedFakeHeadsUpRowRepository( + key = "key", + pinnedStatus = MutableStateFlow(PinnedStatus.PinnedBySystem), + ) + ) + + assertThat(latest!!.visibility).isEqualTo(View.VISIBLE) + } + + @DisableFlags(StatusBarNoHunBehavior.FLAG_NAME) + fun isNotificationIconContainerVisible_hasChipButAlsoHun_hunByUser_noHunFlagOff_gone() = + kosmos.runTest { + val latest by collectLastValue(underTest.isNotificationIconContainerVisible) + transitionKeyguardToGone() + + // Chip + kosmos.screenRecordRepository.screenRecordState.value = ScreenRecordModel.Recording + + // HUN, PinnedByUser + headsUpNotificationRepository.setNotifications( + UnconfinedFakeHeadsUpRowRepository( + key = "key", + pinnedStatus = MutableStateFlow(PinnedStatus.PinnedByUser), + ) + ) + + assertThat(latest!!.visibility).isEqualTo(View.GONE) + } + + @EnableFlags(StatusBarNoHunBehavior.FLAG_NAME) + fun isNotificationIconContainerVisible_hasChipButAlsoHun_hunBySystem_noHunFlagOn_gone() = + kosmos.runTest { + val latest by collectLastValue(underTest.isNotificationIconContainerVisible) + transitionKeyguardToGone() + + // Chip + kosmos.screenRecordRepository.screenRecordState.value = ScreenRecordModel.Recording + + // HUN, PinnedBySystem + headsUpNotificationRepository.setNotifications( + UnconfinedFakeHeadsUpRowRepository( + key = "key", + pinnedStatus = MutableStateFlow(PinnedStatus.PinnedBySystem), + ) + ) + + assertThat(latest!!.visibility).isEqualTo(View.GONE) + } + + @EnableFlags(StatusBarNoHunBehavior.FLAG_NAME) + fun isNotificationIconContainerVisible_hasChipButAlsoHun_hunByUser_noHunFlagOn_gone() = + kosmos.runTest { + val latest by collectLastValue(underTest.isNotificationIconContainerVisible) + transitionKeyguardToGone() + + // Chip + kosmos.screenRecordRepository.screenRecordState.value = ScreenRecordModel.Recording + + // HUN, PinnedByUser + headsUpNotificationRepository.setNotifications( + UnconfinedFakeHeadsUpRowRepository( + key = "key", + pinnedStatus = MutableStateFlow(PinnedStatus.PinnedByUser), + ) + ) + + assertThat(latest!!.visibility).isEqualTo(View.GONE) + } + @Test fun isSystemInfoVisible_allowedByDisableFlags_visible() = kosmos.runTest { diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/pipeline/shared/ui/viewmodel/HomeStatusBarViewModel.kt b/packages/SystemUI/src/com/android/systemui/statusbar/pipeline/shared/ui/viewmodel/HomeStatusBarViewModel.kt index 807e90567eb7..7a5e69c851e9 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/pipeline/shared/ui/viewmodel/HomeStatusBarViewModel.kt +++ b/packages/SystemUI/src/com/android/systemui/statusbar/pipeline/shared/ui/viewmodel/HomeStatusBarViewModel.kt @@ -369,15 +369,6 @@ constructor( ) .flowOn(bgDispatcher) - private val isAnyChipVisible = - if (StatusBarChipsModernization.isEnabled) { - ongoingActivityChips.map { it.active.any { chip -> !chip.isHidden } } - } else if (StatusBarNotifChips.isEnabled) { - ongoingActivityChipsLegacy.map { it.primary is OngoingActivityChipModel.Active } - } else { - primaryOngoingActivityChip.map { it is OngoingActivityChipModel.Active } - } - /** * True if we need to hide the usual start side content in order to show the heads up * notification info. @@ -419,9 +410,23 @@ constructor( combine( isHomeStatusBarAllowed, keyguardInteractor.isSecureCameraActive, - headsUpNotificationInteractor.statusBarHeadsUpStatus, - ) { isHomeStatusBarAllowed, isSecureCameraActive, headsUpState -> - isHomeStatusBarAllowed && !isSecureCameraActive && !headsUpState.isPinned + hideStartSideContentForHeadsUp, + ) { isHomeStatusBarAllowed, isSecureCameraActive, hideStartSideContentForHeadsUp -> + isHomeStatusBarAllowed && !isSecureCameraActive && !hideStartSideContentForHeadsUp + } + + private val hasOngoingActivityChips = + if (StatusBarChipsModernization.isEnabled) { + ongoingActivityChips.map { it.active.any { chip -> !chip.isHidden } } + } else if (StatusBarNotifChips.isEnabled) { + ongoingActivityChipsLegacy.map { it.primary is OngoingActivityChipModel.Active } + } else { + primaryOngoingActivityChip.map { it is OngoingActivityChipModel.Active } + } + + private val isAnyChipVisible = + combine(hasOngoingActivityChips, canShowOngoingActivityChips) { hasChips, canShowChips -> + hasChips && canShowChips } override val isClockVisible: Flow<VisibilityModel> = |