diff options
| author | 2024-07-22 22:57:09 +0000 | |
|---|---|---|
| committer | 2024-07-22 22:57:09 +0000 | |
| commit | ad39ff3310cd87ea209fb40cae310a450b1ff98f (patch) | |
| tree | 3e40d81d652f78d4b5873e1ce774b21d79cab1ce | |
| parent | 3b6d41ecc4049f68087870080a6be23008f5085f (diff) | |
| parent | a9a31b3845b6ab1d45037907ed5c3bed70d86cd6 (diff) | |
Merge "Fix transitions when communal ktf refactor enabled" into main
12 files changed, 204 insertions, 41 deletions
diff --git a/packages/SystemUI/multivalentTests/src/com/android/systemui/communal/CommunalSceneStartableTest.kt b/packages/SystemUI/multivalentTests/src/com/android/systemui/communal/CommunalSceneStartableTest.kt index 4ad020f94c89..bbd2f6b0174a 100644 --- a/packages/SystemUI/multivalentTests/src/com/android/systemui/communal/CommunalSceneStartableTest.kt +++ b/packages/SystemUI/multivalentTests/src/com/android/systemui/communal/CommunalSceneStartableTest.kt @@ -16,11 +16,13 @@ package com.android.systemui.communal +import android.platform.test.annotations.DisableFlags import android.platform.test.annotations.EnableFlags import android.provider.Settings import androidx.test.ext.junit.runners.AndroidJUnit4 import androidx.test.filters.SmallTest import com.android.systemui.Flags.FLAG_COMMUNAL_HUB +import com.android.systemui.Flags.FLAG_COMMUNAL_SCENE_KTF_REFACTOR import com.android.systemui.SysuiTestCase import com.android.systemui.communal.domain.interactor.communalInteractor import com.android.systemui.communal.domain.interactor.communalSceneInteractor @@ -103,6 +105,7 @@ class CommunalSceneStartableTest : SysuiTestCase() { } @Test + @DisableFlags(FLAG_COMMUNAL_SCENE_KTF_REFACTOR) fun keyguardGoesAway_whenLaunchingWidget_doNotForceBlankScene() = with(kosmos) { testScope.runTest { @@ -123,6 +126,7 @@ class CommunalSceneStartableTest : SysuiTestCase() { } @Test + @DisableFlags(FLAG_COMMUNAL_SCENE_KTF_REFACTOR) fun keyguardGoesAway_whenNotLaunchingWidget_forceBlankScene() = with(kosmos) { testScope.runTest { @@ -143,6 +147,7 @@ class CommunalSceneStartableTest : SysuiTestCase() { } @Test + @DisableFlags(FLAG_COMMUNAL_SCENE_KTF_REFACTOR) fun keyguardGoesAway_whenInEditMode_doesNotChangeScene() = with(kosmos) { testScope.runTest { @@ -180,6 +185,7 @@ class CommunalSceneStartableTest : SysuiTestCase() { } @Test + @DisableFlags(FLAG_COMMUNAL_SCENE_KTF_REFACTOR) fun occluded_forceBlankScene() = with(kosmos) { testScope.runTest { @@ -199,6 +205,7 @@ class CommunalSceneStartableTest : SysuiTestCase() { } @Test + @DisableFlags(FLAG_COMMUNAL_SCENE_KTF_REFACTOR) fun occluded_doesNotForceBlankSceneIfLaunchingActivityOverLockscreen() = with(kosmos) { testScope.runTest { @@ -218,6 +225,7 @@ class CommunalSceneStartableTest : SysuiTestCase() { } @Test + @DisableFlags(FLAG_COMMUNAL_SCENE_KTF_REFACTOR) fun deviceDocked_doesNotForceCommunalIfTransitioningFromCommunal() = with(kosmos) { testScope.runTest { @@ -235,6 +243,7 @@ class CommunalSceneStartableTest : SysuiTestCase() { } @Test + @DisableFlags(FLAG_COMMUNAL_SCENE_KTF_REFACTOR) fun deviceAsleep_forceBlankSceneAfterTimeout() = with(kosmos) { testScope.runTest { @@ -256,6 +265,7 @@ class CommunalSceneStartableTest : SysuiTestCase() { } @Test + @DisableFlags(FLAG_COMMUNAL_SCENE_KTF_REFACTOR) fun deviceAsleep_wakesUpBeforeTimeout_noChangeInScene() = with(kosmos) { testScope.runTest { @@ -483,6 +493,7 @@ class CommunalSceneStartableTest : SysuiTestCase() { } @Test + @DisableFlags(FLAG_COMMUNAL_SCENE_KTF_REFACTOR) fun transitionFromDozingToGlanceableHub_forcesCommunal() = with(kosmos) { testScope.runTest { diff --git a/packages/SystemUI/multivalentTests/src/com/android/systemui/communal/domain/interactor/CommunalSceneTransitionInteractorTest.kt b/packages/SystemUI/multivalentTests/src/com/android/systemui/communal/domain/interactor/CommunalSceneTransitionInteractorTest.kt index f7f70c154ce6..ad7385344fac 100644 --- a/packages/SystemUI/multivalentTests/src/com/android/systemui/communal/domain/interactor/CommunalSceneTransitionInteractorTest.kt +++ b/packages/SystemUI/multivalentTests/src/com/android/systemui/communal/domain/interactor/CommunalSceneTransitionInteractorTest.kt @@ -34,8 +34,11 @@ import com.android.systemui.flags.fakeFeatureFlagsClassic import com.android.systemui.keyguard.data.repository.fakeKeyguardRepository import com.android.systemui.keyguard.data.repository.keyguardTransitionRepository import com.android.systemui.keyguard.data.repository.realKeyguardTransitionRepository +import com.android.systemui.keyguard.shared.model.DozeStateModel +import com.android.systemui.keyguard.shared.model.DozeTransitionModel import com.android.systemui.keyguard.shared.model.KeyguardState.DREAMING import com.android.systemui.keyguard.shared.model.KeyguardState.GLANCEABLE_HUB +import com.android.systemui.keyguard.shared.model.KeyguardState.GONE import com.android.systemui.keyguard.shared.model.KeyguardState.LOCKSCREEN import com.android.systemui.keyguard.shared.model.KeyguardState.OCCLUDED import com.android.systemui.keyguard.shared.model.TransitionInfo @@ -46,6 +49,8 @@ import com.android.systemui.keyguard.shared.model.TransitionState.RUNNING import com.android.systemui.keyguard.shared.model.TransitionState.STARTED import com.android.systemui.keyguard.shared.model.TransitionStep import com.android.systemui.kosmos.testScope +import com.android.systemui.power.domain.interactor.PowerInteractor.Companion.setAwakeForTest +import com.android.systemui.power.domain.interactor.powerInteractor import com.android.systemui.testKosmos import com.google.common.truth.Truth.assertThat import kotlinx.coroutines.ExperimentalCoroutinesApi @@ -53,6 +58,7 @@ import kotlinx.coroutines.flow.MutableSharedFlow import kotlinx.coroutines.flow.MutableStateFlow import kotlinx.coroutines.flow.flowOf import kotlinx.coroutines.launch +import kotlinx.coroutines.test.advanceTimeBy import kotlinx.coroutines.test.runCurrent import kotlinx.coroutines.test.runTest import org.junit.Before @@ -211,8 +217,15 @@ class CommunalSceneTransitionInteractorTest : SysuiTestCase() { @Test fun transition_from_hub_end_in_dream() = testScope.runTest { + // Device is dreaming and not dozing. + kosmos.powerInteractor.setAwakeForTest() + kosmos.fakeKeyguardRepository.setDozeTransitionModel( + DozeTransitionModel(from = DozeStateModel.DOZE, to = DozeStateModel.FINISH) + ) + kosmos.fakeKeyguardRepository.setKeyguardOccluded(true) kosmos.fakeKeyguardRepository.setDreaming(true) - runCurrent() + kosmos.fakeKeyguardRepository.setDreamingWithOverlay(true) + advanceTimeBy(100L) sceneTransitions.value = hubToBlank @@ -254,6 +267,100 @@ class CommunalSceneTransitionInteractorTest : SysuiTestCase() { ) } + /** Transition from hub to occluded. */ + @Test + fun transition_from_hub_end_in_occluded() = + testScope.runTest { + kosmos.fakeKeyguardRepository.setKeyguardOccluded(true) + runCurrent() + + sceneTransitions.value = hubToBlank + + val currentStep by collectLastValue(keyguardTransitionRepository.transitions) + + assertThat(currentStep) + .isEqualTo( + TransitionStep( + from = GLANCEABLE_HUB, + to = OCCLUDED, + transitionState = STARTED, + value = 0f, + ownerName = ownerName, + ) + ) + + progress.emit(0.4f) + assertThat(currentStep) + .isEqualTo( + TransitionStep( + from = GLANCEABLE_HUB, + to = OCCLUDED, + transitionState = RUNNING, + value = 0.4f, + ownerName = ownerName, + ) + ) + + sceneTransitions.value = Idle(CommunalScenes.Blank) + assertThat(currentStep) + .isEqualTo( + TransitionStep( + from = GLANCEABLE_HUB, + to = OCCLUDED, + transitionState = FINISHED, + value = 1f, + ownerName = ownerName, + ) + ) + } + + /** Transition from hub to gone. */ + @Test + fun transition_from_hub_end_in_gone() = + testScope.runTest { + kosmos.fakeKeyguardRepository.setKeyguardGoingAway(true) + runCurrent() + + sceneTransitions.value = hubToBlank + + val currentStep by collectLastValue(keyguardTransitionRepository.transitions) + + assertThat(currentStep) + .isEqualTo( + TransitionStep( + from = GLANCEABLE_HUB, + to = GONE, + transitionState = STARTED, + value = 0f, + ownerName = ownerName, + ) + ) + + progress.emit(0.4f) + assertThat(currentStep) + .isEqualTo( + TransitionStep( + from = GLANCEABLE_HUB, + to = GONE, + transitionState = RUNNING, + value = 0.4f, + ownerName = ownerName, + ) + ) + + sceneTransitions.value = Idle(CommunalScenes.Blank) + assertThat(currentStep) + .isEqualTo( + TransitionStep( + from = GLANCEABLE_HUB, + to = GONE, + transitionState = FINISHED, + value = 1f, + ownerName = ownerName, + ) + ) + } + /** Transition from blank to hub, then settle back in blank. */ @Test fun transition_from_blank_end_in_blank() = diff --git a/packages/SystemUI/multivalentTests/src/com/android/systemui/keyguard/domain/interactor/KeyguardTransitionScenariosTest.kt b/packages/SystemUI/multivalentTests/src/com/android/systemui/keyguard/domain/interactor/KeyguardTransitionScenariosTest.kt index 42cd5ec69466..3fd1c20c0560 100644 --- a/packages/SystemUI/multivalentTests/src/com/android/systemui/keyguard/domain/interactor/KeyguardTransitionScenariosTest.kt +++ b/packages/SystemUI/multivalentTests/src/com/android/systemui/keyguard/domain/interactor/KeyguardTransitionScenariosTest.kt @@ -2230,11 +2230,13 @@ class KeyguardTransitionScenariosTest(flags: FlagsParameterization?) : SysuiTest fun glanceableHubToDreaming_communalKtfRefactor() = testScope.runTest { // GIVEN that we are dreaming and not dozing + powerInteractor.setAwakeForTest() keyguardRepository.setDreaming(true) + keyguardRepository.setDreamingWithOverlay(true) keyguardRepository.setDozeTransitionModel( DozeTransitionModel(from = DozeStateModel.DOZE, to = DozeStateModel.FINISH) ) - runCurrent() + advanceTimeBy(100L) // GIVEN a prior transition has run to GLANCEABLE_HUB communalSceneInteractor.changeScene(CommunalScenes.Communal) diff --git a/packages/SystemUI/src/com/android/systemui/communal/CommunalSceneStartable.kt b/packages/SystemUI/src/com/android/systemui/communal/CommunalSceneStartable.kt index e9b23850627a..6b7712d9364e 100644 --- a/packages/SystemUI/src/com/android/systemui/communal/CommunalSceneStartable.kt +++ b/packages/SystemUI/src/com/android/systemui/communal/CommunalSceneStartable.kt @@ -20,6 +20,7 @@ import android.provider.Settings import com.android.compose.animation.scene.SceneKey import com.android.compose.animation.scene.TransitionKey import com.android.systemui.CoreStartable +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.domain.interactor.CommunalSettingsInteractor @@ -96,20 +97,22 @@ constructor( return } - // Handle automatically switching based on keyguard state. - keyguardTransitionInteractor.startedKeyguardTransitionStep - .mapLatest(::determineSceneAfterTransition) - .filterNotNull() - .onEach { (nextScene, nextTransition) -> - if (!communalSceneInteractor.isLaunchingWidget.value) { - // When launching a widget, we don't want to animate the scene change or the - // Communal Hub will reveal the wallpaper even though it shouldn't. Instead we - // snap to the new scene as part of the launch animation, once the activity - // launch is done, so we don't change scene here. - communalSceneInteractor.changeScene(nextScene, nextTransition) + if (!communalSceneKtfRefactor()) { + // Handle automatically switching based on keyguard state. + keyguardTransitionInteractor.startedKeyguardTransitionStep + .mapLatest(::determineSceneAfterTransition) + .filterNotNull() + .onEach { (nextScene, nextTransition) -> + if (!communalSceneInteractor.isLaunchingWidget.value) { + // When launching a widget, we don't want to animate the scene change or the + // Communal Hub will reveal the wallpaper even though it shouldn't. Instead + // we snap to the new scene as part of the launch animation, once the + // activity launch is done, so we don't change scene here. + communalSceneInteractor.changeScene(nextScene, nextTransition) + } } - } - .launchIn(applicationScope) + .launchIn(applicationScope) + } // TODO(b/322787129): re-enable once custom animations are in place // Handle automatically switching to communal when docked. diff --git a/packages/SystemUI/src/com/android/systemui/communal/domain/interactor/CommunalSceneInteractor.kt b/packages/SystemUI/src/com/android/systemui/communal/domain/interactor/CommunalSceneInteractor.kt index 45cfe3673f3d..e45a69599a68 100644 --- a/packages/SystemUI/src/com/android/systemui/communal/domain/interactor/CommunalSceneInteractor.kt +++ b/packages/SystemUI/src/com/android/systemui/communal/domain/interactor/CommunalSceneInteractor.kt @@ -28,6 +28,7 @@ import com.android.systemui.communal.shared.model.EditModeState import com.android.systemui.dagger.SysUISingleton import com.android.systemui.dagger.qualifiers.Application import com.android.systemui.keyguard.shared.model.KeyguardState +import com.android.systemui.util.kotlin.BooleanFlowOperators.allOf import javax.inject.Inject import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.ExperimentalCoroutinesApi @@ -184,6 +185,10 @@ constructor( initialValue = false, ) + /** This flow will be true when idle on the hub and not transitioning to edit mode. */ + val isIdleOnCommunalNotEditMode: Flow<Boolean> = + allOf(isIdleOnCommunal, editModeState.map { it == null }) + /** * Flow that emits a boolean if any portion of the communal UI is visible at all. * diff --git a/packages/SystemUI/src/com/android/systemui/communal/domain/interactor/CommunalSceneTransitionInteractor.kt b/packages/SystemUI/src/com/android/systemui/communal/domain/interactor/CommunalSceneTransitionInteractor.kt index 8351566fcae6..6a20610da3a6 100644 --- a/packages/SystemUI/src/com/android/systemui/communal/domain/interactor/CommunalSceneTransitionInteractor.kt +++ b/packages/SystemUI/src/com/android/systemui/communal/domain/interactor/CommunalSceneTransitionInteractor.kt @@ -85,16 +85,16 @@ constructor( */ private val nextKeyguardStateInternal = combine( - keyguardInteractor.isDreaming, + keyguardInteractor.isAbleToDream, keyguardInteractor.isKeyguardOccluded, keyguardInteractor.isKeyguardGoingAway, ) { dreaming, occluded, keyguardGoingAway -> if (keyguardGoingAway) { KeyguardState.GONE + } else if (occluded && !dreaming) { + KeyguardState.OCCLUDED } else if (dreaming) { KeyguardState.DREAMING - } else if (occluded) { - KeyguardState.OCCLUDED } else { KeyguardState.LOCKSCREEN } @@ -162,10 +162,13 @@ constructor( // We may receive an Idle event without a corresponding Transition // event, such as when snapping to a scene without an animation. val targetState = - if (idle.currentScene == CommunalScenes.Blank) { + if (idle.currentScene == CommunalScenes.Communal) { + KeyguardState.GLANCEABLE_HUB + } else if (currentToState == KeyguardState.GLANCEABLE_HUB) { nextKeyguardState.value } else { - KeyguardState.GLANCEABLE_HUB + // Do nothing as we are no longer in the hub state. + return } transitionKtfTo(targetState) repository.nextLockscreenTargetState.value = null @@ -188,7 +191,7 @@ constructor( from = internalTransitionInteractor.currentTransitionInfoInternal.value.to, to = state, animator = null, - modeOnCanceled = TransitionModeOnCanceled.REVERSE + modeOnCanceled = TransitionModeOnCanceled.REVERSE, ) currentTransitionId = internalTransitionInteractor.startTransition(newTransition) internalTransitionInteractor.updateTransition( diff --git a/packages/SystemUI/src/com/android/systemui/communal/widgets/EditWidgetsActivity.kt b/packages/SystemUI/src/com/android/systemui/communal/widgets/EditWidgetsActivity.kt index 08fe42ede5d3..398576935eed 100644 --- a/packages/SystemUI/src/com/android/systemui/communal/widgets/EditWidgetsActivity.kt +++ b/packages/SystemUI/src/com/android/systemui/communal/widgets/EditWidgetsActivity.kt @@ -41,6 +41,7 @@ import com.android.systemui.communal.shared.model.EditModeState import com.android.systemui.communal.ui.compose.CommunalHub import com.android.systemui.communal.ui.viewmodel.CommunalEditModeViewModel import com.android.systemui.communal.util.WidgetPickerIntentUtils.getWidgetExtraFromIntent +import com.android.systemui.keyguard.shared.model.KeyguardState import com.android.systemui.log.LogBuffer import com.android.systemui.log.core.Logger import com.android.systemui.log.dagger.CommunalLog @@ -146,7 +147,8 @@ constructor( communalViewModel.canShowEditMode.collect { communalViewModel.changeScene( CommunalScenes.Blank, - CommunalTransitionKeys.ToEditMode + CommunalTransitionKeys.ToEditMode, + KeyguardState.GONE, ) // wait till transitioned to Blank scene, then animate in communal content in // edit mode diff --git a/packages/SystemUI/src/com/android/systemui/keyguard/domain/interactor/FromGlanceableHubTransitionInteractor.kt b/packages/SystemUI/src/com/android/systemui/keyguard/domain/interactor/FromGlanceableHubTransitionInteractor.kt index d81195060071..6b1be93c988a 100644 --- a/packages/SystemUI/src/com/android/systemui/keyguard/domain/interactor/FromGlanceableHubTransitionInteractor.kt +++ b/packages/SystemUI/src/com/android/systemui/keyguard/domain/interactor/FromGlanceableHubTransitionInteractor.kt @@ -24,6 +24,7 @@ import com.android.systemui.communal.domain.interactor.CommunalSceneInteractor import com.android.systemui.communal.domain.interactor.CommunalSettingsInteractor import com.android.systemui.communal.shared.model.CommunalScenes import com.android.systemui.communal.shared.model.CommunalTransitionKeys +import com.android.systemui.communal.shared.model.EditModeState import com.android.systemui.dagger.SysUISingleton import com.android.systemui.dagger.qualifiers.Background import com.android.systemui.dagger.qualifiers.Main @@ -36,6 +37,7 @@ import com.android.systemui.scene.shared.flag.SceneContainerFlag import com.android.systemui.util.kotlin.BooleanFlowOperators.allOf import com.android.systemui.util.kotlin.BooleanFlowOperators.noneOf import com.android.systemui.util.kotlin.BooleanFlowOperators.not +import com.android.systemui.util.kotlin.sample import javax.inject.Inject import kotlin.time.Duration.Companion.milliseconds import kotlin.time.Duration.Companion.seconds @@ -240,12 +242,21 @@ constructor( ), ) .filterRelevantKeyguardStateAnd { isKeyguardGoingAway -> isKeyguardGoingAway } - .collect { - communalSceneInteractor.changeScene( - newScene = CommunalScenes.Blank, - transitionKey = CommunalTransitionKeys.SimpleFade, - keyguardState = KeyguardState.GONE - ) + .sample(communalSceneInteractor.editModeState, ::Pair) + .collect { (_, editModeState) -> + if ( + editModeState == EditModeState.STARTING || + editModeState == EditModeState.SHOWING + ) { + // Don't change scenes here as that is handled by the edit activity. + startTransitionTo(KeyguardState.GONE) + } else { + communalSceneInteractor.changeScene( + newScene = CommunalScenes.Blank, + transitionKey = CommunalTransitionKeys.SimpleFade, + keyguardState = KeyguardState.GONE + ) + } } } } else { diff --git a/packages/SystemUI/src/com/android/systemui/keyguard/domain/interactor/FromGoneTransitionInteractor.kt b/packages/SystemUI/src/com/android/systemui/keyguard/domain/interactor/FromGoneTransitionInteractor.kt index b084824cd348..ef76f3837889 100644 --- a/packages/SystemUI/src/com/android/systemui/keyguard/domain/interactor/FromGoneTransitionInteractor.kt +++ b/packages/SystemUI/src/com/android/systemui/keyguard/domain/interactor/FromGoneTransitionInteractor.kt @@ -19,7 +19,7 @@ package com.android.systemui.keyguard.domain.interactor import android.animation.ValueAnimator import com.android.app.animation.Interpolators import com.android.app.tracing.coroutines.launch -import com.android.systemui.communal.domain.interactor.CommunalInteractor +import com.android.systemui.communal.domain.interactor.CommunalSceneInteractor import com.android.systemui.dagger.SysUISingleton import com.android.systemui.dagger.qualifiers.Background import com.android.systemui.dagger.qualifiers.Main @@ -52,7 +52,7 @@ constructor( @Main mainDispatcher: CoroutineDispatcher, keyguardInteractor: KeyguardInteractor, powerInteractor: PowerInteractor, - private val communalInteractor: CommunalInteractor, + private val communalSceneInteractor: CommunalSceneInteractor, keyguardOcclusionInteractor: KeyguardOcclusionInteractor, private val biometricSettingsRepository: BiometricSettingsRepository, private val keyguardRepository: KeyguardRepository, @@ -88,7 +88,7 @@ constructor( biometricSettingsRepository.isCurrentUserInLockdown .distinctUntilChanged() .filterRelevantKeyguardStateAnd { inLockdown -> inLockdown } - .sample(communalInteractor.isIdleOnCommunal, ::Pair) + .sample(communalSceneInteractor.isIdleOnCommunalNotEditMode, ::Pair) .collect { (_, isIdleOnCommunal) -> val to = if (isIdleOnCommunal) { @@ -120,7 +120,7 @@ constructor( scope.launch("$TAG#listenForGoneToLockscreenOrHub") { keyguardInteractor.isKeyguardShowing .filterRelevantKeyguardStateAnd { isKeyguardShowing -> isKeyguardShowing } - .sample(communalInteractor.isIdleOnCommunal, ::Pair) + .sample(communalSceneInteractor.isIdleOnCommunalNotEditMode, ::Pair) .collect { (_, isIdleOnCommunal) -> val to = if (isIdleOnCommunal) { diff --git a/packages/SystemUI/src/com/android/systemui/keyguard/domain/interactor/FromPrimaryBouncerTransitionInteractor.kt b/packages/SystemUI/src/com/android/systemui/keyguard/domain/interactor/FromPrimaryBouncerTransitionInteractor.kt index 6c89ce055470..9adcaa229ae2 100644 --- a/packages/SystemUI/src/com/android/systemui/keyguard/domain/interactor/FromPrimaryBouncerTransitionInteractor.kt +++ b/packages/SystemUI/src/com/android/systemui/keyguard/domain/interactor/FromPrimaryBouncerTransitionInteractor.kt @@ -18,7 +18,9 @@ package com.android.systemui.keyguard.domain.interactor import android.animation.ValueAnimator import com.android.keyguard.KeyguardSecurityModel -import com.android.systemui.communal.domain.interactor.CommunalInteractor +import com.android.systemui.Flags.communalSceneKtfRefactor +import com.android.systemui.communal.domain.interactor.CommunalSceneInteractor +import com.android.systemui.communal.shared.model.CommunalScenes import com.android.systemui.dagger.SysUISingleton import com.android.systemui.dagger.qualifiers.Background import com.android.systemui.dagger.qualifiers.Main @@ -55,7 +57,7 @@ constructor( @Background bgDispatcher: CoroutineDispatcher, @Main mainDispatcher: CoroutineDispatcher, keyguardInteractor: KeyguardInteractor, - private val communalInteractor: CommunalInteractor, + private val communalSceneInteractor: CommunalSceneInteractor, private val keyguardSecurityModel: KeyguardSecurityModel, private val selectedUserInteractor: SelectedUserInteractor, powerInteractor: PowerInteractor, @@ -94,7 +96,10 @@ constructor( .distinctUntilChanged() fun dismissPrimaryBouncer() { - scope.launch { startTransitionTo(KeyguardState.GONE) } + scope.launch { + startTransitionTo(KeyguardState.GONE) + closeHubImmediatelyIfNeeded() + } } private fun listenForPrimaryBouncerToLockscreenHubOrOccluded() { @@ -106,7 +111,7 @@ constructor( .sample( powerInteractor.isAwake, keyguardInteractor.isActiveDreamLockscreenHosted, - communalInteractor.isIdleOnCommunal + communalSceneInteractor.isIdleOnCommunal ) .filterRelevantKeyguardState() .collect { @@ -135,7 +140,7 @@ constructor( keyguardInteractor.isKeyguardOccluded, keyguardInteractor.isDreaming, keyguardInteractor.isActiveDreamLockscreenHosted, - communalInteractor.isIdleOnCommunal, + communalSceneInteractor.isIdleOnCommunal, ) .filterRelevantKeyguardStateAnd { (isBouncerShowing, isAwake, _, _, isActiveDreamLockscreenHosted, _) -> @@ -158,6 +163,19 @@ constructor( } } + private fun closeHubImmediatelyIfNeeded() { + // If the hub is showing, and we are not animating a widget launch nor transitioning to + // edit mode, then close the hub immediately. + if ( + communalSceneKtfRefactor() && + communalSceneInteractor.isIdleOnCommunal.value && + !communalSceneInteractor.isLaunchingWidget.value && + communalSceneInteractor.editModeState.value == null + ) { + communalSceneInteractor.snapToScene(CommunalScenes.Blank) + } + } + private fun listenForPrimaryBouncerToAsleep() { // TODO(b/336576536): Check if adaptation for scene framework is needed if (SceneContainerFlag.isEnabled) return @@ -212,6 +230,7 @@ constructor( }, modeOnCanceled = TransitionModeOnCanceled.RESET, ) + closeHubImmediatelyIfNeeded() } } } diff --git a/packages/SystemUI/tests/utils/src/com/android/systemui/keyguard/domain/interactor/FromGoneTransitionInteractorKosmos.kt b/packages/SystemUI/tests/utils/src/com/android/systemui/keyguard/domain/interactor/FromGoneTransitionInteractorKosmos.kt index 317294f3c884..c694114a0f47 100644 --- a/packages/SystemUI/tests/utils/src/com/android/systemui/keyguard/domain/interactor/FromGoneTransitionInteractorKosmos.kt +++ b/packages/SystemUI/tests/utils/src/com/android/systemui/keyguard/domain/interactor/FromGoneTransitionInteractorKosmos.kt @@ -16,7 +16,7 @@ package com.android.systemui.keyguard.domain.interactor -import com.android.systemui.communal.domain.interactor.communalInteractor +import com.android.systemui.communal.domain.interactor.communalSceneInteractor import com.android.systemui.keyguard.data.repository.biometricSettingsRepository import com.android.systemui.keyguard.data.repository.fakeKeyguardTransitionRepository import com.android.systemui.keyguard.data.repository.keyguardRepository @@ -37,7 +37,7 @@ val Kosmos.fromGoneTransitionInteractor by mainDispatcher = testDispatcher, keyguardInteractor = keyguardInteractor, powerInteractor = powerInteractor, - communalInteractor = communalInteractor, + communalSceneInteractor = communalSceneInteractor, keyguardOcclusionInteractor = keyguardOcclusionInteractor, biometricSettingsRepository = biometricSettingsRepository, keyguardRepository = keyguardRepository, diff --git a/packages/SystemUI/tests/utils/src/com/android/systemui/keyguard/domain/interactor/FromPrimaryBouncerTransitionInteractorKosmos.kt b/packages/SystemUI/tests/utils/src/com/android/systemui/keyguard/domain/interactor/FromPrimaryBouncerTransitionInteractorKosmos.kt index 42ee15216590..3c369d7d954f 100644 --- a/packages/SystemUI/tests/utils/src/com/android/systemui/keyguard/domain/interactor/FromPrimaryBouncerTransitionInteractorKosmos.kt +++ b/packages/SystemUI/tests/utils/src/com/android/systemui/keyguard/domain/interactor/FromPrimaryBouncerTransitionInteractorKosmos.kt @@ -17,7 +17,7 @@ package com.android.systemui.keyguard.domain.interactor import com.android.keyguard.keyguardSecurityModel -import com.android.systemui.communal.domain.interactor.communalInteractor +import com.android.systemui.communal.domain.interactor.communalSceneInteractor import com.android.systemui.keyguard.data.repository.keyguardTransitionRepository import com.android.systemui.kosmos.Kosmos import com.android.systemui.kosmos.applicationCoroutineScope @@ -36,7 +36,7 @@ var Kosmos.fromPrimaryBouncerTransitionInteractor by bgDispatcher = testDispatcher, mainDispatcher = testDispatcher, keyguardInteractor = keyguardInteractor, - communalInteractor = communalInteractor, + communalSceneInteractor = communalSceneInteractor, keyguardSecurityModel = keyguardSecurityModel, selectedUserInteractor = selectedUserInteractor, powerInteractor = powerInteractor, |