diff options
2 files changed, 51 insertions, 4 deletions
diff --git a/packages/SystemUI/multivalentTests/src/com/android/systemui/keyguard/domain/interactor/KeyguardOcclusionInteractorTest.kt b/packages/SystemUI/multivalentTests/src/com/android/systemui/keyguard/domain/interactor/KeyguardOcclusionInteractorTest.kt index 0f5e45814608..8914c80cdd5e 100644 --- a/packages/SystemUI/multivalentTests/src/com/android/systemui/keyguard/domain/interactor/KeyguardOcclusionInteractorTest.kt +++ b/packages/SystemUI/multivalentTests/src/com/android/systemui/keyguard/domain/interactor/KeyguardOcclusionInteractorTest.kt @@ -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) @@ -245,6 +250,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() = testScope.runTest { val occludingActivityWillDismissKeyguard by diff --git a/packages/SystemUI/src/com/android/systemui/keyguard/domain/interactor/KeyguardOcclusionInteractor.kt b/packages/SystemUI/src/com/android/systemui/keyguard/domain/interactor/KeyguardOcclusionInteractor.kt index 41ccea735f5f..5af38ba49b85 100644 --- a/packages/SystemUI/src/com/android/systemui/keyguard/domain/interactor/KeyguardOcclusionInteractor.kt +++ b/packages/SystemUI/src/com/android/systemui/keyguard/domain/interactor/KeyguardOcclusionInteractor.kt @@ -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 } |