diff options
| author | 2024-09-10 12:03:17 +0000 | |
|---|---|---|
| committer | 2024-09-10 12:03:17 +0000 | |
| commit | 2e13098ff073f74282ceb13464908a0af73e613d (patch) | |
| tree | d9d544026b9b89c573ed34391370ed3aa4faea0c | |
| parent | bd6b44949c3060e69e7e1f9638dcc945cdd35b3e (diff) | |
| parent | aa185919f72b8d33749954d27c3ccb645c2ecd7d (diff) | |
Merge "[bc25] Replace references to deprecated shade scenes in ScrimStartable." into main
| -rw-r--r-- | packages/SystemUI/src/com/android/systemui/scene/domain/startable/ScrimStartable.kt | 70 |
1 files changed, 39 insertions, 31 deletions
diff --git a/packages/SystemUI/src/com/android/systemui/scene/domain/startable/ScrimStartable.kt b/packages/SystemUI/src/com/android/systemui/scene/domain/startable/ScrimStartable.kt index d1629c799732..e352bfe938f6 100644 --- a/packages/SystemUI/src/com/android/systemui/scene/domain/startable/ScrimStartable.kt +++ b/packages/SystemUI/src/com/android/systemui/scene/domain/startable/ScrimStartable.kt @@ -19,7 +19,9 @@ package com.android.systemui.scene.domain.startable import androidx.annotation.VisibleForTesting +import com.android.compose.animation.scene.ContentKey import com.android.compose.animation.scene.ObservableTransitionState +import com.android.compose.animation.scene.OverlayKey import com.android.compose.animation.scene.SceneKey import com.android.systemui.CoreStartable import com.android.systemui.bouncer.domain.interactor.AlternateBouncerInteractor @@ -33,6 +35,7 @@ import com.android.systemui.keyguard.shared.model.BiometricUnlockModel import com.android.systemui.scene.domain.interactor.SceneContainerOcclusionInteractor import com.android.systemui.scene.domain.interactor.SceneInteractor import com.android.systemui.scene.shared.flag.SceneContainerFlag +import com.android.systemui.scene.shared.model.Overlays import com.android.systemui.scene.shared.model.Scenes import com.android.systemui.settings.brightness.domain.interactor.BrightnessMirrorShowingInteractor import com.android.systemui.statusbar.phone.DozeServiceHost @@ -74,6 +77,7 @@ constructor( deviceEntryInteractor.isDeviceEntered, occlusionInteractor.invisibleDueToOcclusion, sceneInteractor.currentScene, + sceneInteractor.currentOverlays, sceneInteractor.transitionState, keyguardInteractor.isDozing, keyguardInteractor.isDreaming, @@ -95,34 +99,29 @@ constructor( val isDeviceEntered = flowValues[0] as Boolean val isOccluded = flowValues[1] as Boolean val currentScene = flowValues[2] as SceneKey - val transitionState = flowValues[3] as ObservableTransitionState - val isDozing = flowValues[4] as Boolean - val isDreaming = flowValues[5] as Boolean - val biometricUnlockState = flowValues[6] as BiometricUnlockModel - val isBrightnessMirrorVisible = flowValues[7] as Boolean - val isPulsing = flowValues[8] as Boolean - val hasPendingScreenOffCallback = flowValues[9] as Boolean + val currentOverlays = flowValues[3] as Set<OverlayKey> + val transitionState = flowValues[4] as ObservableTransitionState + val isDozing = flowValues[5] as Boolean + val isDreaming = flowValues[6] as Boolean + val biometricUnlockState = flowValues[7] as BiometricUnlockModel + val isBrightnessMirrorVisible = flowValues[8] as Boolean + val isPulsing = flowValues[9] as Boolean + val hasPendingScreenOffCallback = flowValues[10] as Boolean // This is true when the lockscreen scene is either the current scene or somewhere - // in the - // navigation back stack of scenes. + // in the navigation back stack of scenes. val isOnKeyguard = !isDeviceEntered val isCurrentSceneBouncer = currentScene == Scenes.Bouncer // This is true when moving away from one of the keyguard scenes to the gone scene. - // It - // happens only when unlocking or when dismissing a dismissible lockscreen. + // It happens only when unlocking or when dismissing a dismissible lockscreen. val isTransitioningAwayFromKeyguard = transitionState is ObservableTransitionState.Transition.ChangeScene && transitionState.fromScene.isKeyguard() && transitionState.toScene == Scenes.Gone - // This is true when any of the shade scenes is the current scene. - val isCurrentSceneShade = currentScene.isShade() - // This is true when moving into one of the shade scenes when a non-shade scene. - val isTransitioningToShade = - transitionState is ObservableTransitionState.Transition.ChangeScene && - !transitionState.fromScene.isShade() && - transitionState.toScene.isShade() + // This is true when any of the shade scenes or overlays is the current content. + val isCurrentContentShade = + currentScene.isShade() || currentOverlays.any { it.isShade() } // This is true after completing a transition to communal. val isIdleOnCommunal = transitionState.isIdle(Scenes.Communal) @@ -137,10 +136,10 @@ constructor( if (alternateBouncerInteractor.isVisibleState()) { // This will cancel the keyguardFadingAway animation if it is running. We need - // to do - // this as otherwise it can remain pending and leave keyguard in a weird state. + // to do this as otherwise it can remain pending and leave keyguard in a weird + // state. onKeyguardFadedAway(isTransitioningAwayFromKeyguard) - if (!isTransitioningToShade) { + if (!transitionState.isTransitioningToShade()) { // Safeguard which prevents the scrim from being stuck in the wrong // state Model(scrimState = ScrimState.KEYGUARD, unlocking = unlocking) @@ -163,7 +162,7 @@ constructor( ) } else if (isBrightnessMirrorVisible) { Model(scrimState = ScrimState.BRIGHTNESS_MIRROR, unlocking = unlocking) - } else if (isCurrentSceneShade && !isDeviceEntered) { + } else if (isCurrentContentShade && !isDeviceEntered) { Model(scrimState = ScrimState.SHADE_LOCKED, unlocking = unlocking) } else if (isPulsing) { Model(scrimState = ScrimState.PULSING, unlocking = unlocking) @@ -171,8 +170,8 @@ constructor( Model(scrimState = ScrimState.OFF, unlocking = unlocking) } else if (isDozing && !unlocking) { // This will cancel the keyguardFadingAway animation if it is running. We need - // to do - // this as otherwise it can remain pending and leave keyguard in a weird state. + // to do this as otherwise it can remain pending and leave keyguard in a weird + // state. onKeyguardFadedAway(isTransitioningAwayFromKeyguard) Model(scrimState = ScrimState.AOD, unlocking = false) } else if (isIdleOnCommunal) { @@ -222,15 +221,24 @@ constructor( return this == Scenes.Lockscreen || this == Scenes.Bouncer } - private fun SceneKey.isShade(): Boolean { + private fun ContentKey.isShade(): Boolean { return this == Scenes.Shade || this == Scenes.QuickSettings || - this == Scenes.NotificationsShade || - this == Scenes.QuickSettingsShade + this == Overlays.NotificationsShade || + this == Overlays.QuickSettingsShade + } + + private fun ObservableTransitionState.isTransitioningToShade(): Boolean { + return when (this) { + is ObservableTransitionState.Idle -> false + is ObservableTransitionState.Transition.ChangeScene -> + !fromScene.isShade() && toScene.isShade() + is ObservableTransitionState.Transition.ReplaceOverlay -> + !fromOverlay.isShade() && toOverlay.isShade() + is ObservableTransitionState.Transition.ShowOrHideOverlay -> + !fromContent.isShade() && toContent.isShade() + } } - private data class Model( - val scrimState: ScrimState, - val unlocking: Boolean, - ) + private data class Model(val scrimState: ScrimState, val unlocking: Boolean) } |