diff options
| author | 2024-05-10 20:07:11 +0000 | |
|---|---|---|
| committer | 2024-05-10 20:07:11 +0000 | |
| commit | fac6c127d2b4c47e393ae76be1ddfa8017d15a7a (patch) | |
| tree | 738d33b0f75d58d516ab15ff7f254beb678402e2 | |
| parent | daaa567555b76a89f50b10703f26afb56cb7cb93 (diff) | |
Revert "Fix WindowManagerLockscreenVisibility"
Revert submission 27057737
Reason for revert: Droid-monitor created revert due to breakages in b/339822929. Will be verifying through ABTD before submission.
Reverted changes: /q/submissionid:27057737
Change-Id: I6563fdc760e86b10bf48af3e8f02100b1c3591df
5 files changed, 45 insertions, 226 deletions
diff --git a/packages/SystemUI/compose/scene/src/com/android/compose/animation/scene/ObservableTransitionState.kt b/packages/SystemUI/compose/scene/src/com/android/compose/animation/scene/ObservableTransitionState.kt index 92d5c26148e4..d924d88d1e59 100644 --- a/packages/SystemUI/compose/scene/src/com/android/compose/animation/scene/ObservableTransitionState.kt +++ b/packages/SystemUI/compose/scene/src/com/android/compose/animation/scene/ObservableTransitionState.kt @@ -74,16 +74,6 @@ sealed interface ObservableTransitionState { */ val isUserInputOngoing: Flow<Boolean>, ) : ObservableTransitionState - - fun isIdle(scene: SceneKey?): Boolean { - return this is Idle && (scene == null || this.currentScene == scene) - } - - fun isTransitioning(from: SceneKey? = null, to: SceneKey? = null): Boolean { - return this is Transition && - (from == null || this.fromScene == from) && - (to == null || this.toScene == to) - } } /** 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 dc35e4311d25..bb2eeb77969d 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 @@ -16,16 +16,11 @@ package com.android.systemui.keyguard.domain.interactor -import com.android.compose.animation.scene.ObservableTransitionState import com.android.systemui.dagger.SysUISingleton import com.android.systemui.keyguard.shared.model.BiometricUnlockMode import com.android.systemui.keyguard.shared.model.KeyguardState import com.android.systemui.keyguard.shared.model.TransitionState -import com.android.systemui.scene.domain.interactor.SceneInteractor -import com.android.systemui.scene.shared.flag.SceneContainerFlag -import com.android.systemui.scene.shared.model.Scenes import com.android.systemui.statusbar.notification.domain.interactor.NotificationLaunchAnimationInteractor -import com.android.systemui.util.kotlin.pairwise import com.android.systemui.util.kotlin.sample import javax.inject.Inject import kotlinx.coroutines.ExperimentalCoroutinesApi @@ -47,7 +42,6 @@ constructor( fromBouncerInteractor: FromPrimaryBouncerTransitionInteractor, fromAlternateBouncerInteractor: FromAlternateBouncerTransitionInteractor, notificationLaunchAnimationInteractor: NotificationLaunchAnimationInteractor, - sceneInteractor: SceneInteractor, ) { private val defaultSurfaceBehindVisibility = transitionInteractor.finishedKeyguardState.map(::isSurfaceVisible) @@ -109,42 +103,21 @@ constructor( * animation. This is used to keep the RemoteAnimationTarget alive until we're done using it. */ val usingKeyguardGoingAwayAnimation: Flow<Boolean> = - if (SceneContainerFlag.isEnabled) { - combine( - sceneInteractor.transitionState, - surfaceBehindInteractor.isAnimatingSurface, - notificationLaunchAnimationInteractor.isLaunchAnimationRunning, - ) { transition, isAnimatingSurface, isLaunchAnimationRunning -> - // Using the animation if we're animating it directly, or if the - // ActivityLaunchAnimator is in the process of animating it. - val isAnyAnimationRunning = isAnimatingSurface || isLaunchAnimationRunning - // We may still be animating the surface after the keyguard is fully GONE, since - // some animations (like the translation spring) are not tied directly to the - // transition step amount. - transition.isTransitioning(to = Scenes.Gone) || - (isAnyAnimationRunning && - (transition.isIdle(Scenes.Gone) || - transition.isTransitioning(from = Scenes.Gone))) - } - .distinctUntilChanged() - } else { - combine( - transitionInteractor.isInTransitionToState(KeyguardState.GONE), - transitionInteractor.finishedKeyguardState, - surfaceBehindInteractor.isAnimatingSurface, - notificationLaunchAnimationInteractor.isLaunchAnimationRunning, - ) { isInTransitionToGone, finishedState, isAnimatingSurface, notifLaunchRunning -> - // Using the animation if we're animating it directly, or if the - // ActivityLaunchAnimator is in the process of animating it. - val animationsRunning = isAnimatingSurface || notifLaunchRunning - // We may still be animating the surface after the keyguard is fully GONE, since - // some animations (like the translation spring) are not tied directly to the - // transition step amount. - isInTransitionToGone || - (finishedState == KeyguardState.GONE && animationsRunning) - } - .distinctUntilChanged() - } + combine( + transitionInteractor.isInTransitionToState(KeyguardState.GONE), + transitionInteractor.finishedKeyguardState, + surfaceBehindInteractor.isAnimatingSurface, + notificationLaunchAnimationInteractor.isLaunchAnimationRunning, + ) { isInTransitionToGone, finishedState, isAnimatingSurface, notifLaunchRunning -> + // Using the animation if we're animating it directly, or if the + // ActivityLaunchAnimator is in the process of animating it. + val animationsRunning = isAnimatingSurface || notifLaunchRunning + // We may still be animating the surface after the keyguard is fully GONE, since + // some animations (like the translation spring) are not tied directly to the + // transition step amount. + isInTransitionToGone || (finishedState == KeyguardState.GONE && animationsRunning) + } + .distinctUntilChanged() /** * Whether the lockscreen is visible, from the Window Manager (WM) perspective. @@ -154,44 +127,28 @@ constructor( * want to know if the AOD/clock/notifs/etc. are visible. */ val lockscreenVisibility: Flow<Boolean> = - if (SceneContainerFlag.isEnabled) { - sceneInteractor.transitionState - .pairwise(ObservableTransitionState.Idle(Scenes.Lockscreen)) - .map { (prevTransitionState, transitionState) -> - val isReturningToGoneAfterCancellation = - prevTransitionState.isTransitioning(from = Scenes.Gone) && - transitionState.isTransitioning(to = Scenes.Gone) - val isNotOnGone = - !transitionState.isTransitioning(from = Scenes.Gone) && - !transitionState.isIdle(Scenes.Gone) + transitionInteractor.currentKeyguardState + .sample(transitionInteractor.startedStepWithPrecedingStep, ::Pair) + .map { (currentState, startedWithPrev) -> + val startedFromStep = startedWithPrev?.previousValue + val startedStep = startedWithPrev?.newValue + val returningToGoneAfterCancellation = + startedStep?.to == KeyguardState.GONE && + startedFromStep?.transitionState == TransitionState.CANCELED && + startedFromStep.from == KeyguardState.GONE - isNotOnGone && !isReturningToGoneAfterCancellation - } - .distinctUntilChanged() - } else { - transitionInteractor.currentKeyguardState - .sample(transitionInteractor.startedStepWithPrecedingStep, ::Pair) - .map { (currentState, startedWithPrev) -> - val startedFromStep = startedWithPrev?.previousValue - val startedStep = startedWithPrev?.newValue - val returningToGoneAfterCancellation = - startedStep?.to == KeyguardState.GONE && - startedFromStep?.transitionState == TransitionState.CANCELED && - startedFromStep.from == KeyguardState.GONE - - if (!returningToGoneAfterCancellation) { - // By default, apply the lockscreen visibility of the current state. - KeyguardState.lockscreenVisibleInState(currentState) - } else { - // If we're transitioning to GONE after a prior canceled transition from - // GONE, then this is the camera launch transition from an asleep state back - // to GONE. We don't want to show the lockscreen since we're aborting the - // lock and going back to GONE. - KeyguardState.lockscreenVisibleInState(KeyguardState.GONE) - } + if (!returningToGoneAfterCancellation) { + // By default, apply the lockscreen visibility of the current state. + KeyguardState.lockscreenVisibleInState(currentState) + } else { + // If we're transitioning to GONE after a prior canceled transition from GONE, + // then this is the camera launch transition from an asleep state back to GONE. + // We don't want to show the lockscreen since we're aborting the lock and going + // back to GONE. + KeyguardState.lockscreenVisibleInState(KeyguardState.GONE) } - .distinctUntilChanged() - } + } + .distinctUntilChanged() /** * Whether always-on-display (AOD) is visible when the lockscreen is visible, from window diff --git a/packages/SystemUI/tests/src/com/android/systemui/keyguard/domain/interactor/WindowManagerLockscreenVisibilityInteractorTest.kt b/packages/SystemUI/tests/src/com/android/systemui/keyguard/domain/interactor/WindowManagerLockscreenVisibilityInteractorTest.kt index a77169e74de5..b1a8dd1d3fdc 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/keyguard/domain/interactor/WindowManagerLockscreenVisibilityInteractorTest.kt +++ b/packages/SystemUI/tests/src/com/android/systemui/keyguard/domain/interactor/WindowManagerLockscreenVisibilityInteractorTest.kt @@ -18,29 +18,20 @@ package com.android.systemui.keyguard.domain.interactor import androidx.test.ext.junit.runners.AndroidJUnit4 import androidx.test.filters.SmallTest -import com.android.compose.animation.scene.ObservableTransitionState import com.android.systemui.SysuiTestCase -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.shared.model.KeyguardState import com.android.systemui.keyguard.shared.model.TransitionState import com.android.systemui.keyguard.shared.model.TransitionStep import com.android.systemui.kosmos.testScope -import com.android.systemui.scene.data.repository.sceneContainerRepository -import com.android.systemui.scene.shared.model.Scenes import com.android.systemui.testKosmos import com.android.systemui.util.mockito.mock import com.android.systemui.util.mockito.whenever -import com.google.common.truth.Truth.assertThat import junit.framework.Assert.assertEquals import kotlinx.coroutines.flow.MutableStateFlow -import kotlinx.coroutines.flow.flowOf import kotlinx.coroutines.test.runCurrent import kotlinx.coroutines.test.runTest -import org.junit.Before import org.junit.Test import org.junit.runner.RunWith @@ -66,22 +57,14 @@ class WindowManagerLockscreenVisibilityInteractorTest : SysuiTestCase() { .thenReturn(surfaceBehindIsAnimatingFlow) } - private val underTest = lazy { kosmos.windowManagerLockscreenVisibilityInteractor } + private val underTest = kosmos.windowManagerLockscreenVisibilityInteractor private val testScope = kosmos.testScope private val transitionRepository = kosmos.fakeKeyguardTransitionRepository - @Before - fun setUp() { - // lazy value needs to be called here otherwise flow collection misbehaves - underTest.value - kosmos.sceneContainerRepository.setTransitionState(sceneTransitions) - } - @Test - @DisableSceneContainer fun surfaceBehindVisibility_switchesToCorrectFlow() = testScope.runTest { - val values by collectValues(underTest.value.surfaceBehindVisibility) + val values by collectValues(underTest.surfaceBehindVisibility) // Start on LOCKSCREEN. transitionRepository.sendTransitionStep( @@ -187,10 +170,9 @@ class WindowManagerLockscreenVisibilityInteractorTest : SysuiTestCase() { } @Test - @DisableSceneContainer fun testUsingGoingAwayAnimation_duringTransitionToGone() = testScope.runTest { - val values by collectValues(underTest.value.usingKeyguardGoingAwayAnimation) + val values by collectValues(underTest.usingKeyguardGoingAwayAnimation) // Start on LOCKSCREEN. transitionRepository.sendTransitionStep( @@ -248,10 +230,9 @@ class WindowManagerLockscreenVisibilityInteractorTest : SysuiTestCase() { } @Test - @DisableSceneContainer fun testNotUsingGoingAwayAnimation_evenWhenAnimating_ifStateIsNotGone() = testScope.runTest { - val values by collectValues(underTest.value.usingKeyguardGoingAwayAnimation) + val values by collectValues(underTest.usingKeyguardGoingAwayAnimation) // Start on LOCKSCREEN. transitionRepository.sendTransitionStep( @@ -338,10 +319,9 @@ class WindowManagerLockscreenVisibilityInteractorTest : SysuiTestCase() { } @Test - @DisableSceneContainer fun lockscreenVisibility_visibleWhenGone() = testScope.runTest { - val values by collectValues(underTest.value.lockscreenVisibility) + val values by collectValues(underTest.lockscreenVisibility) // Start on LOCKSCREEN. transitionRepository.sendTransitionStep( @@ -405,10 +385,9 @@ class WindowManagerLockscreenVisibilityInteractorTest : SysuiTestCase() { } @Test - @DisableSceneContainer fun testLockscreenVisibility_usesFromState_ifCanceled() = testScope.runTest { - val values by collectValues(underTest.value.lockscreenVisibility) + val values by collectValues(underTest.lockscreenVisibility) transitionRepository.sendTransitionSteps( from = KeyguardState.LOCKSCREEN, @@ -507,10 +486,9 @@ class WindowManagerLockscreenVisibilityInteractorTest : SysuiTestCase() { * state during the AOD/isAsleep -> GONE transition is AOD (where lockscreen visibility = true). */ @Test - @DisableSceneContainer fun testLockscreenVisibility_falseDuringTransitionToGone_fromCanceledGone() = testScope.runTest { - val values by collectValues(underTest.value.lockscreenVisibility) + val values by collectValues(underTest.lockscreenVisibility) transitionRepository.sendTransitionSteps( from = KeyguardState.LOCKSCREEN, @@ -609,11 +587,11 @@ class WindowManagerLockscreenVisibilityInteractorTest : SysuiTestCase() { ) } + /** */ @Test - @DisableSceneContainer fun testLockscreenVisibility_trueDuringTransitionToGone_fromNotCanceledGone() = testScope.runTest { - val values by collectValues(underTest.value.lockscreenVisibility) + val values by collectValues(underTest.lockscreenVisibility) transitionRepository.sendTransitionSteps( from = KeyguardState.LOCKSCREEN, @@ -724,109 +702,4 @@ class WindowManagerLockscreenVisibilityInteractorTest : SysuiTestCase() { values ) } - - @Test - @EnableSceneContainer - fun sceneContainer_lockscreenVisibility_visibleWhenNotGone() = - testScope.runTest { - val lockscreenVisibility by collectLastValue(underTest.value.lockscreenVisibility) - - sceneTransitions.value = lsToGone - assertThat(lockscreenVisibility).isTrue() - - sceneTransitions.value = ObservableTransitionState.Idle(Scenes.Gone) - assertThat(lockscreenVisibility).isFalse() - - sceneTransitions.value = goneToLs - assertThat(lockscreenVisibility).isFalse() - - sceneTransitions.value = ObservableTransitionState.Idle(Scenes.Lockscreen) - assertThat(lockscreenVisibility).isTrue() - } - - @Test - @EnableSceneContainer - fun sceneContainer_lockscreenVisibility_notVisibleWhenReturningToGone() = - testScope.runTest { - val lockscreenVisibility by collectLastValue(underTest.value.lockscreenVisibility) - - sceneTransitions.value = goneToLs - assertThat(lockscreenVisibility).isFalse() - - sceneTransitions.value = lsToGone - assertThat(lockscreenVisibility).isFalse() - - sceneTransitions.value = ObservableTransitionState.Idle(Scenes.Gone) - assertThat(lockscreenVisibility).isFalse() - - sceneTransitions.value = goneToLs - assertThat(lockscreenVisibility).isFalse() - - sceneTransitions.value = ObservableTransitionState.Idle(Scenes.Lockscreen) - assertThat(lockscreenVisibility).isTrue() - } - - @Test - @EnableSceneContainer - fun sceneContainer_usingGoingAwayAnimation_duringTransitionToGone() = - testScope.runTest { - val usingKeyguardGoingAwayAnimation by - collectLastValue(underTest.value.usingKeyguardGoingAwayAnimation) - - sceneTransitions.value = lsToGone - assertThat(usingKeyguardGoingAwayAnimation).isTrue() - - sceneTransitions.value = ObservableTransitionState.Idle(Scenes.Gone) - assertThat(usingKeyguardGoingAwayAnimation).isFalse() - } - - @Test - @EnableSceneContainer - fun sceneContainer_usingGoingAwayAnimation_surfaceBehindIsAnimating() = - testScope.runTest { - val usingKeyguardGoingAwayAnimation by - collectLastValue(underTest.value.usingKeyguardGoingAwayAnimation) - - sceneTransitions.value = lsToGone - surfaceBehindIsAnimatingFlow.emit(true) - assertThat(usingKeyguardGoingAwayAnimation).isTrue() - - sceneTransitions.value = ObservableTransitionState.Idle(Scenes.Gone) - assertThat(usingKeyguardGoingAwayAnimation).isTrue() - - sceneTransitions.value = goneToLs - assertThat(usingKeyguardGoingAwayAnimation).isTrue() - - surfaceBehindIsAnimatingFlow.emit(false) - assertThat(usingKeyguardGoingAwayAnimation).isFalse() - } - - companion object { - private val progress = MutableStateFlow(0f) - - private val sceneTransitions = - MutableStateFlow<ObservableTransitionState>( - ObservableTransitionState.Idle(Scenes.Lockscreen) - ) - - private val lsToGone = - ObservableTransitionState.Transition( - Scenes.Lockscreen, - Scenes.Gone, - flowOf(Scenes.Lockscreen), - progress, - false, - flowOf(false) - ) - - private val goneToLs = - ObservableTransitionState.Transition( - Scenes.Gone, - Scenes.Lockscreen, - flowOf(Scenes.Lockscreen), - progress, - false, - flowOf(false) - ) - } } diff --git a/packages/SystemUI/tests/src/com/android/systemui/wmshell/BubblesTest.java b/packages/SystemUI/tests/src/com/android/systemui/wmshell/BubblesTest.java index aac36405e9b6..56e5e293c799 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/wmshell/BubblesTest.java +++ b/packages/SystemUI/tests/src/com/android/systemui/wmshell/BubblesTest.java @@ -138,6 +138,7 @@ import com.android.systemui.statusbar.notification.row.ExpandableNotificationRow import com.android.systemui.statusbar.notification.row.NotificationTestHelper; import com.android.systemui.statusbar.phone.DozeParameters; import com.android.systemui.statusbar.phone.KeyguardBypassController; +import com.android.systemui.statusbar.phone.ScreenOffAnimationController; import com.android.systemui.statusbar.policy.BatteryController; import com.android.systemui.statusbar.policy.ConfigurationController; import com.android.systemui.statusbar.policy.DeviceProvisionedController; diff --git a/packages/SystemUI/tests/utils/src/com/android/systemui/keyguard/domain/interactor/WindowManagerLockscreenVisibilityInteractorKosmos.kt b/packages/SystemUI/tests/utils/src/com/android/systemui/keyguard/domain/interactor/WindowManagerLockscreenVisibilityInteractorKosmos.kt index b38acc8a46dc..29167d64d1f1 100644 --- a/packages/SystemUI/tests/utils/src/com/android/systemui/keyguard/domain/interactor/WindowManagerLockscreenVisibilityInteractorKosmos.kt +++ b/packages/SystemUI/tests/utils/src/com/android/systemui/keyguard/domain/interactor/WindowManagerLockscreenVisibilityInteractorKosmos.kt @@ -17,7 +17,6 @@ package com.android.systemui.keyguard.domain.interactor import com.android.systemui.kosmos.Kosmos -import com.android.systemui.scene.domain.interactor.sceneInteractor import com.android.systemui.statusbar.notification.domain.interactor.notificationLaunchAnimationInteractor val Kosmos.windowManagerLockscreenVisibilityInteractor by @@ -30,6 +29,5 @@ val Kosmos.windowManagerLockscreenVisibilityInteractor by fromBouncerInteractor = fromPrimaryBouncerTransitionInteractor, fromAlternateBouncerInteractor = fromAlternateBouncerTransitionInteractor, notificationLaunchAnimationInteractor = notificationLaunchAnimationInteractor, - sceneInteractor = sceneInteractor, ) } |