diff options
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> = |