Loading packages/SystemUI/src/com/android/systemui/scene/domain/startable/ScrimStartable.kt +39 −31 Original line number Diff line number Diff line Loading @@ -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 Loading @@ -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 Loading Loading @@ -74,6 +77,7 @@ constructor( deviceEntryInteractor.isDeviceEntered, occlusionInteractor.invisibleDueToOcclusion, sceneInteractor.currentScene, sceneInteractor.currentOverlays, sceneInteractor.transitionState, keyguardInteractor.isDozing, keyguardInteractor.isDreaming, Loading @@ -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) Loading @@ -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) Loading @@ -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) Loading @@ -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) { Loading Loading @@ -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 data class Model( val scrimState: ScrimState, val unlocking: Boolean, ) 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) } Loading
packages/SystemUI/src/com/android/systemui/scene/domain/startable/ScrimStartable.kt +39 −31 Original line number Diff line number Diff line Loading @@ -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 Loading @@ -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 Loading Loading @@ -74,6 +77,7 @@ constructor( deviceEntryInteractor.isDeviceEntered, occlusionInteractor.invisibleDueToOcclusion, sceneInteractor.currentScene, sceneInteractor.currentOverlays, sceneInteractor.transitionState, keyguardInteractor.isDozing, keyguardInteractor.isDreaming, Loading @@ -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) Loading @@ -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) Loading @@ -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) Loading @@ -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) { Loading Loading @@ -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 data class Model( val scrimState: ScrimState, val unlocking: Boolean, ) 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) }