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

Commit 60f2ca97 authored by burakov's avatar burakov
Browse files

[Dual Shade] Run face auth when the overlay shade opens.

Fix: 420435065
Test: Updated unit tests.
Flag: com.android.systemui.scene_container
Change-Id: I17540714b2cd5edb4525d4130fd95479816eddb7
parent 958116b9
Loading
Loading
Loading
Loading
+78 −1
Original line number Diff line number Diff line
@@ -65,6 +65,7 @@ import com.android.systemui.scene.data.repository.setSceneTransition
import com.android.systemui.scene.domain.interactor.sceneInteractor
import com.android.systemui.scene.shared.model.Overlays
import com.android.systemui.scene.shared.model.Scenes
import com.android.systemui.shade.domain.interactor.enableDualShade
import com.android.systemui.shade.domain.interactor.enableSingleShade
import com.android.systemui.testKosmos
import com.android.systemui.user.data.model.SelectionStatus
@@ -519,7 +520,7 @@ class DeviceEntryFaceAuthInteractorTest : SysuiTestCase() {

    @Test
    @EnableSceneContainer
    fun faceAuthIsRequestedWhenShadeExpansionIsStarted() =
    fun faceAuthIsRequestedWhenSingleShadeExpansionIsStarted() =
        kosmos.runTest {
            enableSingleShade()
            runCurrent()
@@ -593,6 +594,82 @@ class DeviceEntryFaceAuthInteractorTest : SysuiTestCase() {
            assertThat(faceAuthRepository.runningAuthRequest.value).isNull()
        }

    @Test
    @EnableSceneContainer
    fun faceAuthIsRequestedWhenDualShadeExpansionIsStarted() =
        kosmos.runTest {
            enableDualShade()
            runCurrent()
            underTest.start()
            faceAuthRepository.canRunFaceAuth.value = true
            sceneInteractor.snapToScene(toScene = Scenes.Lockscreen, "for-test")
            runCurrent()

            sceneInteractor.showOverlay(Overlays.NotificationsShade, loggingReason = "for-test")
            sceneInteractor.setTransitionState(
                flowOf(
                    ObservableTransitionState.Transition.showOverlay(
                        overlay = Overlays.NotificationsShade,
                        fromScene = Scenes.Lockscreen,
                        currentOverlays = flowOf(emptySet()),
                        progress = flowOf(0.2f),
                        isInitiatedByUserInput = true,
                        isUserInputOngoing = flowOf(false),
                    )
                )
            )

            runCurrent()
            assertThat(faceAuthRepository.runningAuthRequest.value)
                .isEqualTo(Pair(FaceAuthUiEvent.FACE_AUTH_TRIGGERED_QS_EXPANDED, false))
        }

    @Test
    @EnableSceneContainer
    fun faceAuthIsRequestedOnlyOnceWhenDualShadeExpansionStarts() =
        kosmos.runTest {
            enableDualShade()
            underTest.start()
            faceAuthRepository.canRunFaceAuth.value = true
            sceneInteractor.snapToScene(toScene = Scenes.Lockscreen, "for-test")
            runCurrent()

            sceneInteractor.showOverlay(Overlays.NotificationsShade, loggingReason = "for-test")
            sceneInteractor.setTransitionState(
                flowOf(
                    ObservableTransitionState.Transition.showOverlay(
                        overlay = Overlays.NotificationsShade,
                        fromScene = Scenes.Lockscreen,
                        currentOverlays = flowOf(emptySet()),
                        progress = flowOf(0.2f),
                        isInitiatedByUserInput = true,
                        isUserInputOngoing = flowOf(false),
                    )
                )
            )

            runCurrent()
            assertThat(faceAuthRepository.runningAuthRequest.value)
                .isEqualTo(Pair(FaceAuthUiEvent.FACE_AUTH_TRIGGERED_QS_EXPANDED, false))
            faceAuthRepository.runningAuthRequest.value = null

            // expansion progress shouldn't trigger face auth again
            sceneInteractor.setTransitionState(
                flowOf(
                    ObservableTransitionState.Transition.showOverlay(
                        overlay = Overlays.NotificationsShade,
                        fromScene = Scenes.Lockscreen,
                        currentOverlays = flowOf(emptySet()),
                        progress = flowOf(0.5f),
                        isInitiatedByUserInput = true,
                        isUserInputOngoing = flowOf(false),
                    )
                )
            )

            assertThat(faceAuthRepository.runningAuthRequest.value).isNull()
        }

    @Test
    fun faceAuthIsRequestedWhenNotificationPanelClicked() =
        kosmos.runTest {
+7 −1
Original line number Diff line number Diff line
@@ -263,7 +263,13 @@ constructor(
            sceneInteractor
                .get()
                .transitionState
                .filter { it.isTransitioning(from = Scenes.Lockscreen, to = Scenes.Shade) }
                .filter {
                    it.isTransitioning(from = Scenes.Lockscreen, to = Scenes.Shade) ||
                        it.isTransitioning(
                            from = Scenes.Lockscreen,
                            to = Overlays.NotificationsShade,
                        )
                }
                .distinctUntilChanged()
                .onEach { onShadeExpansionStarted() }
                .launchIn(applicationScope)