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

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

Merge "[SB] Don't show home status bar on lockscreen, even for HUNs." into main

parents cf03673c 7d7ad022
Loading
Loading
Loading
Loading
+103 −0
Original line number Diff line number Diff line
@@ -36,6 +36,7 @@ import com.android.systemui.display.data.repository.displayRepository
import com.android.systemui.display.data.repository.fake
import com.android.systemui.flags.DisableSceneContainer
import com.android.systemui.flags.EnableSceneContainer
import com.android.systemui.keyguard.data.repository.fakeDeviceEntryFaceAuthRepository
import com.android.systemui.keyguard.data.repository.fakeKeyguardTransitionRepository
import com.android.systemui.keyguard.data.repository.keyguardOcclusionRepository
import com.android.systemui.keyguard.domain.interactor.keyguardInteractor
@@ -1014,6 +1015,108 @@ class HomeStatusBarViewModelImplTest : SysuiTestCase() {
            assertIsCallChip(underTest.ongoingActivityChips.chips.active[1], "call", context)
        }

    @Test
    @DisableSceneContainer
    @DisableFlags(StatusBarNoHunBehavior.FLAG_NAME)
    fun hunOnLockscreenWithBypass_sceneFlagOff_noHunFlagOff_everythingVisible() =
        kosmos.runTest {
            val latestNotifs by collectLastValue(underTest.isNotificationIconContainerVisible)
            val latestSystemInfo by collectLastValue(underTest.systemInfoCombinedVis)

            // WHEN on lockscreen with bypass enabled
            fakeKeyguardTransitionRepository.transitionTo(
                KeyguardState.GONE,
                KeyguardState.LOCKSCREEN,
            )
            fakeDeviceEntryFaceAuthRepository.isBypassEnabled.value = true
            // WHEN there's a HUN
            headsUpNotificationRepository.setNotifications(
                UnconfinedFakeHeadsUpRowRepository(
                    key = "key",
                    pinnedStatus = MutableStateFlow(PinnedStatus.PinnedBySystem),
                )
            )

            // THEN status bar content shows if StatusBarNoHunBehavior is off
            assertThat(latestNotifs!!.visibility).isEqualTo(View.VISIBLE)
            assertThat(latestSystemInfo!!.baseVisibility.visibility).isEqualTo(View.VISIBLE)
        }

    @Test
    @EnableSceneContainer
    @DisableFlags(StatusBarNoHunBehavior.FLAG_NAME)
    fun hunOnLockscreenWithBypass_sceneFlagOn_noHunFlagOff_everythingVisible() =
        kosmos.runTest {
            val latestNotifs by collectLastValue(underTest.isNotificationIconContainerVisible)
            val latestSystemInfo by collectLastValue(underTest.systemInfoCombinedVis)

            // WHEN on lockscreen with bypass enabled
            sceneContainerRepository.snapToScene(Scenes.Lockscreen)
            fakeDeviceEntryFaceAuthRepository.isBypassEnabled.value = true
            // WHEN there's a HUN
            headsUpNotificationRepository.setNotifications(
                UnconfinedFakeHeadsUpRowRepository(
                    key = "key",
                    pinnedStatus = MutableStateFlow(PinnedStatus.PinnedBySystem),
                )
            )

            // THEN status bar content shows if StatusBarNoHunBehavior is off
            assertThat(latestNotifs!!.visibility).isEqualTo(View.VISIBLE)
            assertThat(latestSystemInfo!!.baseVisibility.visibility).isEqualTo(View.VISIBLE)
        }

    @Test
    @DisableSceneContainer
    @EnableFlags(StatusBarNoHunBehavior.FLAG_NAME)
    fun hunOnLockscreenWithBypass_sceneFlagOff_noHunFlagOn_everythingHidden() =
        kosmos.runTest {
            val latestNotifs by collectLastValue(underTest.isNotificationIconContainerVisible)
            val latestSystemInfo by collectLastValue(underTest.systemInfoCombinedVis)

            // WHEN on lockscreen with bypass enabled
            fakeKeyguardTransitionRepository.transitionTo(
                KeyguardState.GONE,
                KeyguardState.LOCKSCREEN,
            )
            fakeDeviceEntryFaceAuthRepository.isBypassEnabled.value = true
            // WHEN there's a HUN
            headsUpNotificationRepository.setNotifications(
                UnconfinedFakeHeadsUpRowRepository(
                    key = "key",
                    pinnedStatus = MutableStateFlow(PinnedStatus.PinnedBySystem),
                )
            )

            // THEN status bar content still hides if StatusBarNoHunBehavior is on
            assertThat(latestNotifs!!.visibility).isEqualTo(View.GONE)
            assertThat(latestSystemInfo!!.baseVisibility.visibility).isEqualTo(View.GONE)
        }

    @Test
    @EnableSceneContainer
    @EnableFlags(StatusBarNoHunBehavior.FLAG_NAME)
    fun hunOnLockscreenWithBypass_sceneFlagOn_noHunFlagOn_everythingHidden() =
        kosmos.runTest {
            val latestNotifs by collectLastValue(underTest.isNotificationIconContainerVisible)
            val latestSystemInfo by collectLastValue(underTest.systemInfoCombinedVis)

            // WHEN on lockscreen with bypass enabled
            sceneContainerRepository.snapToScene(Scenes.Lockscreen)
            fakeDeviceEntryFaceAuthRepository.isBypassEnabled.value = true
            // WHEN there's a HUN
            headsUpNotificationRepository.setNotifications(
                UnconfinedFakeHeadsUpRowRepository(
                    key = "key",
                    pinnedStatus = MutableStateFlow(PinnedStatus.PinnedBySystem),
                )
            )

            // THEN status bar content still hides if StatusBarNoHunBehavior is on
            assertThat(latestNotifs!!.visibility).isEqualTo(View.GONE)
            assertThat(latestSystemInfo!!.baseVisibility.visibility).isEqualTo(View.GONE)
        }

    @Test
    fun isClockVisible_allowedByDisableFlags_visible() =
        kosmos.runTest {
+9 −1
Original line number Diff line number Diff line
@@ -400,6 +400,14 @@ constructor(
                keyguardInteractor.isSecureCameraActive,
                headsUpNotificationInteractor.statusBarHeadsUpStatus,
            ) { isHomeStatusBarAllowed, isSecureCameraActive, headsUpState ->
                val showForHeadsUp =
                    if (StatusBarNoHunBehavior.isEnabled) {
                        false
                    } else {
                        // HUNs can appear on lockscreen if face auth with bypass is enabled, in
                        // which case we need to show the HUN app name in the status bar
                        headsUpState.isPinned
                    }
                // When launching the camera over the lockscreen, the status icons would typically
                // become visible momentarily before animating out, since we're not yet aware that
                // the launching camera activity is fullscreen. Even once the activity finishes
@@ -407,7 +415,7 @@ constructor(
                // the icons and tells us to hide them. To ensure that this high-visibility
                // animation is smooth, keep the icons hidden during a camera launch. See
                // b/257292822.
                headsUpState.isPinned || (isHomeStatusBarAllowed && !isSecureCameraActive)
                showForHeadsUp || (isHomeStatusBarAllowed && !isSecureCameraActive)
            }
            .distinctUntilChanged()
            .logDiffsForTable(