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

Commit de045224 authored by Treehugger Robot's avatar Treehugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Prevent dream starting on top of edit mode" into main

parents 9dc301d3 a2bb7b0f
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -81,6 +81,7 @@ class CommunalDreamStartableTest : SysuiTestCase() {
    @Test
    fun startDreamWhenTransitioningToHub() =
        testScope.runTest {
            keyguardRepository.setKeyguardShowing(true)
            keyguardRepository.setDreaming(false)
            powerRepository.setScreenPowerState(ScreenPowerState.SCREEN_ON)
            whenever(dreamManager.canStartDreaming(/* isScreenOn= */ true)).thenReturn(true)
+17 −9
Original line number Diff line number Diff line
@@ -32,11 +32,14 @@ import com.android.systemui.keyguard.shared.model.TransitionState
import com.android.systemui.keyguard.shared.model.filterState
import com.android.systemui.power.domain.interactor.PowerInteractor
import com.android.systemui.scene.shared.model.Scenes
import com.android.systemui.util.kotlin.BooleanFlowOperators.allOf
import com.android.systemui.util.kotlin.BooleanFlowOperators.not
import com.android.systemui.util.kotlin.Utils.Companion.sampleFilter
import javax.inject.Inject
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.flow.filter
import kotlinx.coroutines.flow.launchIn
import kotlinx.coroutines.flow.map
import kotlinx.coroutines.flow.onEach

/**
@@ -54,6 +57,18 @@ constructor(
    private val dreamManager: DreamManager,
    @Background private val bgScope: CoroutineScope,
) : CoreStartable {
    /** Flow that emits when the dream should be started underneath the glanceable hub. */
    val startDream =
        allOf(
                keyguardTransitionInteractor
                    .transitionValue(Scenes.Communal, KeyguardState.GLANCEABLE_HUB)
                    .map { it == 1f },
                not(keyguardInteractor.isDreaming),
                // TODO(b/362830856): Remove this workaround.
                keyguardInteractor.isKeyguardShowing,
            )
            .filter { it }

    @SuppressLint("MissingPermission")
    override fun start() {
        if (!communalSettingsInteractor.isCommunalFlagEnabled()) {
@@ -72,17 +87,10 @@ constructor(

        // Restart the dream underneath the hub in order to support the ability to swipe
        // away the hub to enter the dream.
        keyguardTransitionInteractor
            .transition(
                edge = Edge.create(to = Scenes.Communal),
                edgeWithoutSceneContainer = Edge.create(to = KeyguardState.GLANCEABLE_HUB)
            )
            .filterState(TransitionState.FINISHED)
        startDream
            .sampleFilter(powerInteractor.isAwake) { isAwake ->
                dreamManager.canStartDreaming(isAwake)
                !glanceableHubAllowKeyguardWhenDreaming() && dreamManager.canStartDreaming(isAwake)
            }
            .sampleFilter(keyguardInteractor.isDreaming) { isDreaming -> !isDreaming }
            .filter { !glanceableHubAllowKeyguardWhenDreaming() }
            .onEach { dreamManager.startDream() }
            .launchIn(bgScope)
    }
+1 −0
Original line number Diff line number Diff line
@@ -182,6 +182,7 @@ constructor(
    }

    private suspend fun finishCurrentTransition() {
        if (currentTransitionId == null) return
        internalTransitionInteractor.updateTransition(
            currentTransitionId!!,
            1f,