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

Commit 64a54dc7 authored by William Xiao's avatar William Xiao Committed by Android (Google) Code Review
Browse files

Merge changes I6fa1ce10,Id50499d0 into main

* changes:
  Remove no-op Immediately communal transition key
  Apply new ktfmt formatting
parents 95b0e20b 234f6a5a
Loading
Loading
Loading
Loading
+9 −48
Original line number Diff line number Diff line
@@ -14,22 +14,6 @@
 * limitations under the License.
 */

/*
 * Copyright (C) 2024 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.android.systemui.keyguard.domain.interactor

import android.os.PowerManager
@@ -47,7 +31,6 @@ import com.android.systemui.communal.data.repository.FakeCommunalSceneRepository
import com.android.systemui.communal.data.repository.fakeCommunalSceneRepository
import com.android.systemui.communal.domain.interactor.setCommunalAvailable
import com.android.systemui.communal.shared.model.CommunalScenes
import com.android.systemui.communal.shared.model.CommunalTransitionKeys
import com.android.systemui.coroutines.collectLastValue
import com.android.systemui.keyguard.data.repository.FakeKeyguardTransitionRepository
import com.android.systemui.keyguard.data.repository.fakeKeyguardRepository
@@ -129,7 +112,7 @@ class FromDozingTransitionInteractorTest(flags: FlagsParameterization?) : SysuiT
            transitionRepository.sendTransitionSteps(
                from = KeyguardState.LOCKSCREEN,
                to = KeyguardState.DOZING,
                testScope
                testScope,
            )
            kosmos.fakeKeyguardRepository.setBiometricUnlockState(BiometricUnlockMode.NONE)
            reset(transitionRepository)
@@ -145,10 +128,7 @@ class FromDozingTransitionInteractorTest(flags: FlagsParameterization?) : SysuiT

            // Under default conditions, we should transition to LOCKSCREEN when waking up.
            assertThat(transitionRepository)
                .startedTransition(
                    from = KeyguardState.DOZING,
                    to = KeyguardState.LOCKSCREEN,
                )
                .startedTransition(from = KeyguardState.DOZING, to = KeyguardState.LOCKSCREEN)
        }

    @Test
@@ -166,10 +146,7 @@ class FromDozingTransitionInteractorTest(flags: FlagsParameterization?) : SysuiT
            // If dreaming is possible and communal is available, then we should transition to
            // GLANCEABLE_HUB when waking up due to power button press.
            assertThat(transitionRepository)
                .startedTransition(
                    from = KeyguardState.DOZING,
                    to = KeyguardState.GLANCEABLE_HUB,
                )
                .startedTransition(from = KeyguardState.DOZING, to = KeyguardState.GLANCEABLE_HUB)
        }

    @Test
@@ -186,8 +163,7 @@ class FromDozingTransitionInteractorTest(flags: FlagsParameterization?) : SysuiT

            // If dreaming is possible and communal is available, then we should transition to
            // GLANCEABLE_HUB when waking up due to power button press.
            verify(kosmos.fakeCommunalSceneRepository)
                .changeScene(CommunalScenes.Communal, CommunalTransitionKeys.Immediately)
            verify(kosmos.fakeCommunalSceneRepository).snapToScene(CommunalScenes.Communal)
        }

    @Test
@@ -204,10 +180,7 @@ class FromDozingTransitionInteractorTest(flags: FlagsParameterization?) : SysuiT
            // If dreaming is NOT possible but communal is available, then we should transition to
            // LOCKSCREEN when waking up due to power button press.
            assertThat(transitionRepository)
                .startedTransition(
                    from = KeyguardState.DOZING,
                    to = KeyguardState.LOCKSCREEN,
                )
                .startedTransition(from = KeyguardState.DOZING, to = KeyguardState.LOCKSCREEN)
        }

    @Test
@@ -224,10 +197,7 @@ class FromDozingTransitionInteractorTest(flags: FlagsParameterization?) : SysuiT
            // If dreaming is possible but communal is NOT available, then we should transition to
            // LOCKSCREEN when waking up due to power button press.
            assertThat(transitionRepository)
                .startedTransition(
                    from = KeyguardState.DOZING,
                    to = KeyguardState.LOCKSCREEN,
                )
                .startedTransition(from = KeyguardState.DOZING, to = KeyguardState.LOCKSCREEN)
        }

    @Test
@@ -245,10 +215,7 @@ class FromDozingTransitionInteractorTest(flags: FlagsParameterization?) : SysuiT

            // Under default conditions, we should transition to LOCKSCREEN when waking up.
            assertThat(transitionRepository)
                .startedTransition(
                    from = KeyguardState.DOZING,
                    to = KeyguardState.GLANCEABLE_HUB,
                )
                .startedTransition(from = KeyguardState.DOZING, to = KeyguardState.GLANCEABLE_HUB)
        }

    @Test
@@ -261,10 +228,7 @@ class FromDozingTransitionInteractorTest(flags: FlagsParameterization?) : SysuiT

            // Waking with a SHOW_WHEN_LOCKED activity on top should transition to OCCLUDED.
            assertThat(transitionRepository)
                .startedTransition(
                    from = KeyguardState.DOZING,
                    to = KeyguardState.OCCLUDED,
                )
                .startedTransition(from = KeyguardState.DOZING, to = KeyguardState.OCCLUDED)
        }

    @Test
@@ -282,10 +246,7 @@ class FromDozingTransitionInteractorTest(flags: FlagsParameterization?) : SysuiT

            // Waking with a SHOW_WHEN_LOCKED activity on top should transition to OCCLUDED.
            assertThat(transitionRepository)
                .startedTransition(
                    from = KeyguardState.DOZING,
                    to = KeyguardState.OCCLUDED,
                )
                .startedTransition(from = KeyguardState.DOZING, to = KeyguardState.OCCLUDED)
        }

    @Test
+5 −6
Original line number Diff line number Diff line
@@ -146,7 +146,7 @@ constructor(
                screenTimeout =
                    systemSettings.getInt(
                        Settings.System.SCREEN_OFF_TIMEOUT,
                        DEFAULT_SCREEN_TIMEOUT
                        DEFAULT_SCREEN_TIMEOUT,
                    )
            }
            .launchIn(bgScope)
@@ -160,7 +160,7 @@ constructor(
            combine(
                    communalSceneInteractor.currentScene,
                    // Emit a value on start so the combine starts.
                    communalInteractor.userActivity.emitOnStart()
                    communalInteractor.userActivity.emitOnStart(),
                ) { scene, _ ->
                    // Only timeout if we're on the hub is open.
                    scene == CommunalScenes.Communal
@@ -219,7 +219,7 @@ constructor(
    }

    private suspend fun determineSceneAfterTransition(
        lastStartedTransition: TransitionStep,
        lastStartedTransition: TransitionStep
    ): Pair<SceneKey, TransitionKey>? {
        val to = lastStartedTransition.to
        val from = lastStartedTransition.from
@@ -251,9 +251,8 @@ constructor(
                Pair(CommunalScenes.Blank, CommunalTransitionKeys.SimpleFade)
            }
            from == KeyguardState.DOZING && to == KeyguardState.GLANCEABLE_HUB -> {
                // Make sure the communal hub is showing (immediately, not fading in) when
                // transitioning from dozing to hub.
                Pair(CommunalScenes.Communal, CommunalTransitionKeys.Immediately)
                // Make sure the communal hub is showing when transitioning from dozing to hub.
                Pair(CommunalScenes.Communal, CommunalTransitionKeys.SimpleFade)
            }
            else -> null
        }
+0 −2
Original line number Diff line number Diff line
@@ -30,6 +30,4 @@ object CommunalTransitionKeys {
    val ToEditMode = TransitionKey("ToEditMode")
    /** Transition to the glanceable hub after exiting edit mode */
    val FromEditMode = TransitionKey("FromEditMode")
    /** Immediately transitions without any delay */
    val Immediately = TransitionKey("Immediately")
}
+6 −12
Original line number Diff line number Diff line
@@ -24,7 +24,6 @@ import com.android.systemui.Flags.communalSceneKtfRefactor
import com.android.systemui.communal.domain.interactor.CommunalInteractor
import com.android.systemui.communal.domain.interactor.CommunalSceneInteractor
import com.android.systemui.communal.shared.model.CommunalScenes
import com.android.systemui.communal.shared.model.CommunalTransitionKeys
import com.android.systemui.dagger.SysUISingleton
import com.android.systemui.dagger.qualifiers.Background
import com.android.systemui.dagger.qualifiers.Main
@@ -95,10 +94,7 @@ constructor(
        scope.launch {
            powerInteractor.isAwake
                .filterRelevantKeyguardStateAnd { isAwake -> isAwake }
                .sample(
                    keyguardInteractor.biometricUnlockState,
                    ::Pair,
                )
                .sample(keyguardInteractor.biometricUnlockState, ::Pair)
                .collect {
                    (
                        _,
@@ -203,21 +199,21 @@ constructor(
                            if (!SceneContainerFlag.isEnabled) {
                                startTransitionTo(
                                    KeyguardState.GONE,
                                    ownerReason = "waking from dozing"
                                    ownerReason = "waking from dozing",
                                )
                            }
                        } else if (primaryBouncerShowing) {
                            if (!SceneContainerFlag.isEnabled) {
                                startTransitionTo(
                                    KeyguardState.PRIMARY_BOUNCER,
                                    ownerReason = "waking from dozing"
                                    ownerReason = "waking from dozing",
                                )
                            }
                        } else if (isIdleOnCommunal && !communalSceneKtfRefactor()) {
                            if (!SceneContainerFlag.isEnabled) {
                                startTransitionTo(
                                    KeyguardState.GLANCEABLE_HUB,
                                    ownerReason = "waking from dozing"
                                    ownerReason = "waking from dozing",
                                )
                            }
                        } else if (isCommunalAvailable && dreamManager.canStartDreaming(true)) {
@@ -227,7 +223,7 @@ constructor(
                        } else {
                            startTransitionTo(
                                KeyguardState.LOCKSCREEN,
                                ownerReason = "waking from dozing"
                                ownerReason = "waking from dozing",
                            )
                        }
                    }
@@ -237,11 +233,9 @@ constructor(

    private suspend fun transitionToGlanceableHub() {
        if (communalSceneKtfRefactor()) {
            communalSceneInteractor.changeScene(
            communalSceneInteractor.snapToScene(
                newScene = CommunalScenes.Communal,
                loggingReason = "from dozing to hub",
                // Immediately show the hub when transitioning from dozing to hub.
                transitionKey = CommunalTransitionKeys.Immediately,
            )
        } else {
            startTransitionTo(KeyguardState.GLANCEABLE_HUB)
+5 −6
Original line number Diff line number Diff line
@@ -162,10 +162,9 @@ constructor(
                .filterRelevantKeyguardStateAnd { isAsleep -> isAsleep }
                .collect {
                    if (communalSceneKtfRefactor()) {
                        communalSceneInteractor.changeScene(
                        communalSceneInteractor.snapToScene(
                            newScene = CommunalScenes.Blank,
                            loggingReason = "hub to dozing",
                            transitionKey = CommunalTransitionKeys.Immediately,
                            keyguardState = KeyguardState.DOZING,
                        )
                    } else {
@@ -210,12 +209,12 @@ constructor(
                            // ends, to avoid transitioning to OCCLUDED erroneously when exiting
                            // the dream.
                            .debounce(100.milliseconds),
                        ::Pair
                        ::Pair,
                    )
                    .sampleFilter(
                        // When launching activities from widgets on the hub, we have a
                        // custom occlusion animation.
                        communalSceneInteractor.isLaunchingWidget,
                        communalSceneInteractor.isLaunchingWidget
                    ) { launchingWidget ->
                        !launchingWidget
                    }
@@ -253,7 +252,7 @@ constructor(
                        noneOf(
                            // When launching activities from widgets on the hub, we wait to change
                            // scenes until the activity launch is complete.
                            communalSceneInteractor.isLaunchingWidget,
                            communalSceneInteractor.isLaunchingWidget
                        ),
                    )
                    .filterRelevantKeyguardStateAnd { isKeyguardGoingAway -> isKeyguardGoingAway }
@@ -270,7 +269,7 @@ constructor(
                                newScene = CommunalScenes.Blank,
                                loggingReason = "hub to gone",
                                transitionKey = CommunalTransitionKeys.SimpleFade,
                                keyguardState = KeyguardState.GONE
                                keyguardState = KeyguardState.GONE,
                            )
                        }
                    }