Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit ab224625 authored by Andreas Miko's avatar Andreas Miko
Browse files

[Flexiglass] Fix KeyguardWakeDirectlyToGoneInteractor

Bug: 349784682
Flag: com.android.systemui.scene_container
Test: NONE
Change-Id: Ief3f9879df31e3cb7936403acda835c573edcef7
parent 4f76b942
Loading
Loading
Loading
Loading
+11 −0
Original line number Diff line number Diff line
@@ -464,6 +464,17 @@ constructor(
        return finishedKeyguardState.map { it == state }.distinctUntilChanged()
    }

    fun isCurrentlyIn(scene: SceneKey, stateWithoutSceneContainer: KeyguardState): Flow<Boolean> {
        return if (SceneContainerFlag.isEnabled) {
                // In STL there is no difference between finished/currentState
                isFinishedIn(scene, stateWithoutSceneContainer)
            } else {
                stateWithoutSceneContainer.checkValidState()
                currentKeyguardState.map { it == stateWithoutSceneContainer }
            }
            .distinctUntilChanged()
    }

    fun getCurrentState(): KeyguardState {
        return currentKeyguardState.replayCache.last()
    }
+10 −3
Original line number Diff line number Diff line
@@ -37,6 +37,7 @@ import com.android.systemui.keyguard.shared.model.KeyguardState.Companion.device
import com.android.systemui.keyguard.shared.model.KeyguardState.Companion.deviceIsAwakeInState
import com.android.systemui.power.domain.interactor.PowerInteractor
import com.android.systemui.power.shared.model.WakeSleepReason
import com.android.systemui.scene.shared.model.Scenes
import com.android.systemui.user.domain.interactor.SelectedUserInteractor
import com.android.systemui.util.kotlin.sample
import com.android.systemui.util.settings.SecureSettings
@@ -181,14 +182,20 @@ constructor(
        scope.launch {
            powerInteractor.detailedWakefulness
                .distinctUntilChangedBy { it.isAwake() }
                .sample(transitionInteractor.currentKeyguardState, ::Pair)
                .collect { (wakefulness, currentState) ->
                .sample(
                    transitionInteractor.isCurrentlyIn(
                        Scenes.Gone,
                        stateWithoutSceneContainer = KeyguardState.GONE
                    ),
                    ::Pair
                )
                .collect { (wakefulness, finishedInGone) ->
                    // Save isAwake for use in onDreamingStarted/onDreamingStopped.
                    this@KeyguardWakeDirectlyToGoneInteractor.isAwake = wakefulness.isAwake()

                    // If we're sleeping from GONE, check the timeout and lock instantly settings.
                    // These are not relevant if we're coming from non-GONE states.
                    if (!isAwake && currentState == KeyguardState.GONE) {
                    if (!isAwake && finishedInGone) {
                        val lockTimeoutDuration = getCanIgnoreAuthAndReturnToGoneDuration()

                        // If the screen timed out and went to sleep, and the lock timeout is > 0ms,