From 3061256eb91eb80410907fc8995926500cb7ea32 Mon Sep 17 00:00:00 2001 From: Alejandro Nijamkin Date: Thu, 31 Oct 2024 15:02:14 -0700 Subject: [flexiglass] Dismissible lockscreen shows when folded. On foldables, if "Continue using apps on fold" is set to "Swipe up to continue", the dismissible lockscreen should show when the unlocked/entered device is folded. This isn't working. By removing handleSurfaceBehindKeyguardVisibility, we eliminate the logic that was returning to the Gone scene from the Lockscreen scene when the surface behind was made visible. In addition, the change in WindowManagerLockscreenVisibilityInteractor was also necessary to make sure that the surface behind doesn't become visible prematurely. Fix: 376693347 Test: manually verified behaviour when folding using all three settings of "Continue using apps on fold" Flag: com.android.systemui.scene_container Change-Id: I8f23efa6128b9e7c58d6b994e5295be31edbfbf6 --- ...dowManagerLockscreenVisibilityInteractorTest.kt | 47 +++------------------- .../startable/SceneContainerStartableTest.kt | 34 ---------------- .../WindowManagerLockscreenVisibilityInteractor.kt | 9 +---- .../domain/startable/SceneContainerStartable.kt | 24 ----------- .../startable/SceneContainerStartableKosmos.kt | 2 - 5 files changed, 6 insertions(+), 110 deletions(-) diff --git a/packages/SystemUI/multivalentTests/src/com/android/systemui/keyguard/domain/interactor/WindowManagerLockscreenVisibilityInteractorTest.kt b/packages/SystemUI/multivalentTests/src/com/android/systemui/keyguard/domain/interactor/WindowManagerLockscreenVisibilityInteractorTest.kt index 7f313564e35a..2c12f8782ddc 100644 --- a/packages/SystemUI/multivalentTests/src/com/android/systemui/keyguard/domain/interactor/WindowManagerLockscreenVisibilityInteractorTest.kt +++ b/packages/SystemUI/multivalentTests/src/com/android/systemui/keyguard/domain/interactor/WindowManagerLockscreenVisibilityInteractorTest.kt @@ -193,7 +193,7 @@ class WindowManagerLockscreenVisibilityInteractorTest : SysuiTestCase() { @Test @EnableSceneContainer - fun surfaceBehindVisibility_fromLockscreenToGone_noUserInput_trueThroughout() = + fun surfaceBehindVisibility_fromLockscreenToGone_dependsOnDeviceEntry() = testScope.runTest { val isSurfaceBehindVisible by collectLastValue(underTest.value.surfaceBehindVisibility) val currentScene by collectLastValue(kosmos.sceneInteractor.currentScene) @@ -208,7 +208,7 @@ class WindowManagerLockscreenVisibilityInteractorTest : SysuiTestCase() { SuccessFingerprintAuthenticationStatus(0, true) ) - // Start the transition to Gone, the surface should become immediately visible. + // Start the transition to Gone, the surface should remain invisible. kosmos.setSceneTransition( ObservableTransitionState.Transition( fromScene = Scenes.Lockscreen, @@ -220,9 +220,9 @@ class WindowManagerLockscreenVisibilityInteractorTest : SysuiTestCase() { ) ) assertThat(currentScene).isEqualTo(Scenes.Lockscreen) - assertThat(isSurfaceBehindVisible).isTrue() + assertThat(isSurfaceBehindVisible).isFalse() - // Towards the end of the transition, the surface should continue to be visible. + // Towards the end of the transition, the surface should continue to remain invisible. kosmos.setSceneTransition( ObservableTransitionState.Transition( fromScene = Scenes.Lockscreen, @@ -234,7 +234,7 @@ class WindowManagerLockscreenVisibilityInteractorTest : SysuiTestCase() { ) ) assertThat(currentScene).isEqualTo(Scenes.Lockscreen) - assertThat(isSurfaceBehindVisible).isTrue() + assertThat(isSurfaceBehindVisible).isFalse() // After the transition, settles on Gone. Surface behind should stay visible now. kosmos.setSceneTransition(ObservableTransitionState.Idle(Scenes.Gone)) @@ -243,43 +243,6 @@ class WindowManagerLockscreenVisibilityInteractorTest : SysuiTestCase() { assertThat(isSurfaceBehindVisible).isTrue() } - @Test - @EnableSceneContainer - fun surfaceBehindVisibility_fromLockscreenToGone_withUserInput_falseUntilInputStops() = - testScope.runTest { - val isSurfaceBehindVisible by collectLastValue(underTest.value.surfaceBehindVisibility) - val currentScene by collectLastValue(kosmos.sceneInteractor.currentScene) - - // Before the transition, we start on Lockscreen so the surface should start invisible. - kosmos.setSceneTransition(ObservableTransitionState.Idle(Scenes.Lockscreen)) - assertThat(currentScene).isEqualTo(Scenes.Lockscreen) - assertThat(isSurfaceBehindVisible).isFalse() - - // Unlocked with fingerprint. - kosmos.deviceEntryFingerprintAuthRepository.setAuthenticationStatus( - SuccessFingerprintAuthenticationStatus(0, true) - ) - - // Start the transition to Gone, the surface should not be visible while - // isUserInputOngoing is true - val isUserInputOngoing = MutableStateFlow(true) - kosmos.setSceneTransition( - ObservableTransitionState.Transition( - fromScene = Scenes.Lockscreen, - toScene = Scenes.Gone, - isInitiatedByUserInput = true, - isUserInputOngoing = isUserInputOngoing, - progress = flowOf(0.51f), - currentScene = flowOf(Scenes.Gone), - ) - ) - assertThat(isSurfaceBehindVisible).isFalse() - - // When isUserInputOngoing becomes false, then the surface should become visible. - isUserInputOngoing.value = false - assertThat(isSurfaceBehindVisible).isTrue() - } - @Test @EnableSceneContainer fun surfaceBehindVisibility_fromBouncerToGone_becomesTrue() = diff --git a/packages/SystemUI/multivalentTests/src/com/android/systemui/scene/domain/startable/SceneContainerStartableTest.kt b/packages/SystemUI/multivalentTests/src/com/android/systemui/scene/domain/startable/SceneContainerStartableTest.kt index 2c8f7cf47723..55f88cc5b7a2 100644 --- a/packages/SystemUI/multivalentTests/src/com/android/systemui/scene/domain/startable/SceneContainerStartableTest.kt +++ b/packages/SystemUI/multivalentTests/src/com/android/systemui/scene/domain/startable/SceneContainerStartableTest.kt @@ -2118,40 +2118,6 @@ class SceneContainerStartableTest : SysuiTestCase() { assertThat(currentScene).isEqualTo(Scenes.Lockscreen) } - @Test - fun switchToGone_whenSurfaceBehindLockscreenVisibleMidTransition() = - testScope.runTest { - val currentScene by collectLastValue(sceneInteractor.currentScene) - val transitionStateFlow = - prepareState(authenticationMethod = AuthenticationMethodModel.None) - underTest.start() - assertThat(currentScene).isEqualTo(Scenes.Lockscreen) - // Swipe to Gone, more than halfway - transitionStateFlow.value = - ObservableTransitionState.Transition( - fromScene = Scenes.Lockscreen, - toScene = Scenes.Gone, - currentScene = flowOf(Scenes.Gone), - progress = flowOf(0.51f), - isInitiatedByUserInput = true, - isUserInputOngoing = flowOf(true), - ) - runCurrent() - // Lift finger - transitionStateFlow.value = - ObservableTransitionState.Transition( - fromScene = Scenes.Lockscreen, - toScene = Scenes.Gone, - currentScene = flowOf(Scenes.Gone), - progress = flowOf(0.51f), - isInitiatedByUserInput = true, - isUserInputOngoing = flowOf(false), - ) - runCurrent() - - assertThat(currentScene).isEqualTo(Scenes.Gone) - } - @Test fun switchToGone_extendUnlock() = testScope.runTest { diff --git a/packages/SystemUI/src/com/android/systemui/keyguard/domain/interactor/WindowManagerLockscreenVisibilityInteractor.kt b/packages/SystemUI/src/com/android/systemui/keyguard/domain/interactor/WindowManagerLockscreenVisibilityInteractor.kt index 2c9884a63990..f473a82138e6 100644 --- a/packages/SystemUI/src/com/android/systemui/keyguard/domain/interactor/WindowManagerLockscreenVisibilityInteractor.kt +++ b/packages/SystemUI/src/com/android/systemui/keyguard/domain/interactor/WindowManagerLockscreenVisibilityInteractor.kt @@ -126,14 +126,7 @@ constructor( sceneInteractor.get().transitionState.flatMapLatestConflated { state -> when { state.isTransitioning(from = Scenes.Lockscreen, to = Scenes.Gone) -> - (state as Transition).isUserInputOngoing.flatMapLatestConflated { - isUserInputOngoing -> - if (isUserInputOngoing) { - isDeviceEntered - } else { - flowOf(true) - } - } + isDeviceEntered state.isTransitioning(from = Scenes.Bouncer, to = Scenes.Gone) -> (state as Transition).progress.map { progress -> progress > diff --git a/packages/SystemUI/src/com/android/systemui/scene/domain/startable/SceneContainerStartable.kt b/packages/SystemUI/src/com/android/systemui/scene/domain/startable/SceneContainerStartable.kt index 1fbe8e2f21e5..580a51a3dc0a 100644 --- a/packages/SystemUI/src/com/android/systemui/scene/domain/startable/SceneContainerStartable.kt +++ b/packages/SystemUI/src/com/android/systemui/scene/domain/startable/SceneContainerStartable.kt @@ -46,7 +46,6 @@ import com.android.systemui.deviceentry.shared.model.DeviceUnlockSource import com.android.systemui.keyguard.DismissCallbackRegistry import com.android.systemui.keyguard.domain.interactor.KeyguardEnabledInteractor import com.android.systemui.keyguard.domain.interactor.KeyguardInteractor -import com.android.systemui.keyguard.domain.interactor.WindowManagerLockscreenVisibilityInteractor import com.android.systemui.model.SceneContainerPlugin import com.android.systemui.model.SysUiState import com.android.systemui.model.updateFlags @@ -97,7 +96,6 @@ import kotlinx.coroutines.flow.filter import kotlinx.coroutines.flow.filterIsInstance import kotlinx.coroutines.flow.filterNot import kotlinx.coroutines.flow.filterNotNull -import kotlinx.coroutines.flow.first import kotlinx.coroutines.flow.flatMapLatest import kotlinx.coroutines.flow.flowOf import kotlinx.coroutines.flow.map @@ -138,7 +136,6 @@ constructor( private val uiEventLogger: UiEventLogger, private val sceneBackInteractor: SceneBackInteractor, private val shadeSessionStorage: SessionStorage, - private val windowMgrLockscreenVisInteractor: WindowManagerLockscreenVisibilityInteractor, private val keyguardEnabledInteractor: KeyguardEnabledInteractor, private val dismissCallbackRegistry: DismissCallbackRegistry, private val statusBarStateController: SysuiStatusBarStateController, @@ -270,27 +267,6 @@ constructor( handleDeviceUnlockStatus() handlePowerState() handleShadeTouchability() - handleSurfaceBehindKeyguardVisibility() - } - - private fun handleSurfaceBehindKeyguardVisibility() { - applicationScope.launch { - sceneInteractor.currentScene.collectLatest { currentScene -> - if (currentScene == Scenes.Lockscreen) { - // Wait for the screen to be on - powerInteractor.isAwake.first { it } - // Wait for surface to become visible - windowMgrLockscreenVisInteractor.surfaceBehindVisibility.first { it } - // Make sure the device is actually unlocked before force-changing the scene - deviceUnlockedInteractor.deviceUnlockStatus.first { it.isUnlocked } - // Override the current transition, if any, by forcing the scene to Gone - sceneInteractor.changeScene( - toScene = Scenes.Gone, - loggingReason = "surface behind keyguard is visible", - ) - } - } - } } private fun handleBouncerImeVisibility() { diff --git a/packages/SystemUI/tests/utils/src/com/android/systemui/scene/domain/startable/SceneContainerStartableKosmos.kt b/packages/SystemUI/tests/utils/src/com/android/systemui/scene/domain/startable/SceneContainerStartableKosmos.kt index 4228c3c0b110..7e6a7271c561 100644 --- a/packages/SystemUI/tests/utils/src/com/android/systemui/scene/domain/startable/SceneContainerStartableKosmos.kt +++ b/packages/SystemUI/tests/utils/src/com/android/systemui/scene/domain/startable/SceneContainerStartableKosmos.kt @@ -32,7 +32,6 @@ import com.android.systemui.haptics.vibratorHelper import com.android.systemui.keyguard.dismissCallbackRegistry import com.android.systemui.keyguard.domain.interactor.keyguardEnabledInteractor import com.android.systemui.keyguard.domain.interactor.keyguardInteractor -import com.android.systemui.keyguard.domain.interactor.windowManagerLockscreenVisibilityInteractor import com.android.systemui.kosmos.Kosmos import com.android.systemui.kosmos.Kosmos.Fixture import com.android.systemui.kosmos.testScope @@ -78,7 +77,6 @@ val Kosmos.sceneContainerStartable by Fixture { uiEventLogger = uiEventLogger, sceneBackInteractor = sceneBackInteractor, shadeSessionStorage = shadeSessionStorage, - windowMgrLockscreenVisInteractor = windowManagerLockscreenVisibilityInteractor, keyguardEnabledInteractor = keyguardEnabledInteractor, dismissCallbackRegistry = dismissCallbackRegistry, statusBarStateController = sysuiStatusBarStateController, -- cgit v1.2.3-59-g8ed1b