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

Commit 0fb96d50 authored by Andreas Miko's avatar Andreas Miko
Browse files

[Scene container] Transform KeyguardOcclusionInteractor

Bug: 349784682
Flag: com.android.systemui.scene_container
Test: refactor / added unit tests
Change-Id: I185151b0e339c143f181419acd0ba7fd27309d73
parent 8aee0382
Loading
Loading
Loading
Loading
+41 −0
Original line number Diff line number Diff line
@@ -41,6 +41,7 @@ import com.android.systemui.authentication.data.repository.fakeAuthenticationRep
import com.android.systemui.authentication.shared.model.AuthenticationMethodModel
import com.android.systemui.coroutines.collectLastValue
import com.android.systemui.coroutines.collectValues
import com.android.systemui.flags.DisableSceneContainer
import com.android.systemui.flags.EnableSceneContainer
import com.android.systemui.keyguard.data.repository.FakeKeyguardTransitionRepository
import com.android.systemui.keyguard.data.repository.deviceEntryFingerprintAuthRepository
@@ -54,6 +55,9 @@ import com.android.systemui.power.domain.interactor.PowerInteractor
import com.android.systemui.power.domain.interactor.PowerInteractor.Companion.setAsleepForTest
import com.android.systemui.power.domain.interactor.PowerInteractor.Companion.setAwakeForTest
import com.android.systemui.power.domain.interactor.powerInteractor
import com.android.systemui.scene.data.repository.Transition
import com.android.systemui.scene.data.repository.setSceneTransition
import com.android.systemui.scene.shared.model.Scenes
import com.android.systemui.statusbar.domain.interactor.keyguardOcclusionInteractor
import com.android.systemui.testKosmos
import com.google.common.truth.Truth.assertThat
@@ -208,6 +212,7 @@ class KeyguardOcclusionInteractorTest : SysuiTestCase() {
        }

    @Test
    @DisableSceneContainer
    fun showWhenLockedActivityLaunchedFromPowerGesture_falseIfReturningToGone() =
        testScope.runTest {
            val values by collectValues(underTest.showWhenLockedActivityLaunchedFromPowerGesture)
@@ -243,6 +248,42 @@ class KeyguardOcclusionInteractorTest : SysuiTestCase() {
                )
        }

    @Test
    @EnableSceneContainer
    fun showWhenLockedActivityLaunchedFromPowerGesture_falseIfReturningToGone_scene_container() =
        testScope.runTest {
            val values by collectValues(underTest.showWhenLockedActivityLaunchedFromPowerGesture)
            powerInteractor.setAwakeForTest()
            kosmos.setSceneTransition(Transition(Scenes.Lockscreen, Scenes.Gone))

            powerInteractor.setAsleepForTest()

            kosmos.setSceneTransition(Transition(Scenes.Gone, Scenes.Lockscreen))
            transitionRepository.sendTransitionSteps(
                from = KeyguardState.UNDEFINED,
                to = KeyguardState.AOD,
                testScope = testScope,
                throughTransitionState = TransitionState.RUNNING
            )

            powerInteractor.onCameraLaunchGestureDetected()
            kosmos.keyguardOcclusionRepository.setShowWhenLockedActivityInfo(true)
            powerInteractor.setAwakeForTest()
            runCurrent()

            kosmos.setSceneTransition(Transition(Scenes.Lockscreen, Scenes.Gone))
            transitionRepository.sendTransitionSteps(
                from = KeyguardState.AOD,
                to = KeyguardState.UNDEFINED,
                testScope = testScope,
            )

            assertThat(values)
                .containsExactly(
                    false,
                )
        }

    @Test
    @EnableSceneContainer
    fun occludingActivityWillDismissKeyguard() =
+10 −4
Original line number Diff line number Diff line
@@ -24,6 +24,7 @@ import com.android.systemui.keyguard.data.repository.KeyguardOcclusionRepository
import com.android.systemui.keyguard.shared.model.KeyguardState
import com.android.systemui.power.domain.interactor.PowerInteractor
import com.android.systemui.scene.shared.flag.SceneContainerFlag
import com.android.systemui.scene.shared.model.Scenes
import com.android.systemui.util.kotlin.sample
import dagger.Lazy
import javax.inject.Inject
@@ -94,10 +95,15 @@ constructor(
                // currently
                // GONE, in which case we're going back to GONE and launching the insecure camera).
                powerInteractor.detailedWakefulness
                    .sample(transitionInteractor.currentKeyguardState, ::Pair)
                    .map { (wakefulness, currentKeyguardState) ->
                        wakefulness.powerButtonLaunchGestureTriggered &&
                            currentKeyguardState != KeyguardState.GONE
                    .sample(
                        transitionInteractor.isFinishedIn(
                            Scenes.Gone,
                            stateWithoutSceneContainer = KeyguardState.GONE
                        ),
                        ::Pair
                    )
                    .map { (wakefulness, isOnGone) ->
                        wakefulness.powerButtonLaunchGestureTriggered && !isOnGone
                    },
                // Emit false once that activity goes away.
                isShowWhenLockedActivityOnTop.filter { !it }.map { false }