diff options
Diffstat (limited to 'packages/SystemUI/src')
13 files changed, 144 insertions, 123 deletions
diff --git a/packages/SystemUI/src/com/android/systemui/communal/data/repository/CommunalSceneRepository.kt b/packages/SystemUI/src/com/android/systemui/communal/data/repository/CommunalSceneRepository.kt index 2b8cf008c0c7..100e21d34c42 100644 --- a/packages/SystemUI/src/com/android/systemui/communal/data/repository/CommunalSceneRepository.kt +++ b/packages/SystemUI/src/com/android/systemui/communal/data/repository/CommunalSceneRepository.kt @@ -19,16 +19,13 @@ package com.android.systemui.communal.data.repository import android.content.res.Configuration import com.android.app.tracing.coroutines.launchTraced as launch import com.android.compose.animation.scene.ObservableTransitionState -import com.android.compose.animation.scene.OverlayKey import com.android.compose.animation.scene.SceneKey import com.android.compose.animation.scene.TransitionKey import com.android.systemui.communal.dagger.Communal import com.android.systemui.communal.shared.model.CommunalScenes import com.android.systemui.dagger.SysUISingleton -import com.android.systemui.dagger.qualifiers.Application import com.android.systemui.dagger.qualifiers.Background import com.android.systemui.scene.shared.model.SceneDataSource -import com.android.systemui.scene.shared.model.SceneDataSourceDelegator import javax.inject.Inject import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.flow.Flow @@ -59,9 +56,6 @@ interface CommunalSceneRepository { /** Immediately snaps to the desired scene. */ fun snapToScene(toScene: SceneKey) - /** Shows the hub from a power button press. */ - suspend fun showHubFromPowerButton() - /** * Updates the transition state of the hub [SceneTransitionLayout]. * @@ -77,10 +71,8 @@ interface CommunalSceneRepository { class CommunalSceneRepositoryImpl @Inject constructor( - @Application private val applicationScope: CoroutineScope, @Background backgroundScope: CoroutineScope, @Communal private val sceneDataSource: SceneDataSource, - @Communal private val delegator: SceneDataSourceDelegator, ) : CommunalSceneRepository { override val currentScene: StateFlow<SceneKey> = sceneDataSource.currentScene @@ -102,37 +94,17 @@ constructor( _communalContainerOrientation.asStateFlow() override fun changeScene(toScene: SceneKey, transitionKey: TransitionKey?) { - applicationScope.launch { - // SceneTransitionLayout state updates must be triggered on the thread the STL was - // created on. - sceneDataSource.changeScene(toScene, transitionKey) - } + sceneDataSource.changeScene(toScene, transitionKey) } override fun snapToScene(toScene: SceneKey) { - applicationScope.launch { - // SceneTransitionLayout state updates must be triggered on the thread the STL was - // created on. - sceneDataSource.snapToScene(toScene) - } + sceneDataSource.snapToScene(toScene) } override fun setCommunalContainerOrientation(orientation: Int) { _communalContainerOrientation.value = orientation } - override suspend fun showHubFromPowerButton() { - // If keyguard is not showing yet, the hub view is not ready and the - // [SceneDataSourceDelegator] will still be using the default [NoOpSceneDataSource] - // and initial key, which is Blank. This means that when the hub container loads, it - // will default to not showing the hub. Attempting to set the scene in this state - // is simply ignored by the [NoOpSceneDataSource]. Instead, we temporarily override - // it with a new one that defaults to Communal. This delegate will be overwritten - // once the [CommunalContainer] loads. - // TODO(b/392969914): show the hub first instead of forcing the scene. - delegator.setDelegate(NoOpSceneDataSource(CommunalScenes.Communal)) - } - /** * Updates the transition state of the hub [SceneTransitionLayout]. * @@ -141,33 +113,4 @@ constructor( override fun setTransitionState(transitionState: Flow<ObservableTransitionState>?) { _transitionState.value = transitionState } - - /** Noop implementation of a scene data source that always returns the initial [SceneKey]. */ - private class NoOpSceneDataSource(initialSceneKey: SceneKey) : SceneDataSource { - override val currentScene: StateFlow<SceneKey> = - MutableStateFlow(initialSceneKey).asStateFlow() - - override val currentOverlays: StateFlow<Set<OverlayKey>> = - MutableStateFlow(emptySet<OverlayKey>()).asStateFlow() - - override fun changeScene(toScene: SceneKey, transitionKey: TransitionKey?) = Unit - - override fun snapToScene(toScene: SceneKey) = Unit - - override fun showOverlay(overlay: OverlayKey, transitionKey: TransitionKey?) = Unit - - override fun hideOverlay(overlay: OverlayKey, transitionKey: TransitionKey?) = Unit - - override fun replaceOverlay( - from: OverlayKey, - to: OverlayKey, - transitionKey: TransitionKey?, - ) = Unit - - override fun instantlyShowOverlay(overlay: OverlayKey) = Unit - - override fun instantlyHideOverlay(overlay: OverlayKey) = Unit - - override fun freezeAndAnimateToCurrentState() = Unit - } } diff --git a/packages/SystemUI/src/com/android/systemui/communal/domain/interactor/CommunalInteractor.kt b/packages/SystemUI/src/com/android/systemui/communal/domain/interactor/CommunalInteractor.kt index 684c52ad45f3..272439e68f71 100644 --- a/packages/SystemUI/src/com/android/systemui/communal/domain/interactor/CommunalInteractor.kt +++ b/packages/SystemUI/src/com/android/systemui/communal/domain/interactor/CommunalInteractor.kt @@ -149,9 +149,18 @@ constructor( val isCommunalEnabled: StateFlow<Boolean> = communalSettingsInteractor.isCommunalEnabled /** Whether communal features are enabled and available. */ - val isCommunalAvailable: Flow<Boolean> = - allOf(communalSettingsInteractor.isCommunalEnabled, keyguardInteractor.isKeyguardShowing) - .distinctUntilChanged() + @Deprecated("Use isCommunalEnabled instead", replaceWith = ReplaceWith("isCommunalEnabled")) + val isCommunalAvailable: Flow<Boolean> by lazy { + val availableFlow = + if (communalSettingsInteractor.isV2FlagEnabled()) { + communalSettingsInteractor.isCommunalEnabled + } else { + allOf( + communalSettingsInteractor.isCommunalEnabled, + keyguardInteractor.isKeyguardShowing, + ) + } + availableFlow .onEach { available -> logger.i({ "Communal is ${if (bool1) "" else "un"}available" }) { bool1 = available @@ -167,6 +176,7 @@ constructor( started = SharingStarted.WhileSubscribed(), replay = 1, ) + } private val _isDisclaimerDismissed = MutableStateFlow(false) val isDisclaimerDismissed: Flow<Boolean> = _isDisclaimerDismissed.asStateFlow() @@ -467,6 +477,7 @@ constructor( size = CommunalContentSize.toSize(widget.spanY), ) } + is CommunalWidgetContentModel.Pending -> { WidgetContent.PendingWidget( appWidgetId = widget.appWidgetId, @@ -493,6 +504,7 @@ constructor( when (model) { is CommunalWidgetContentModel.Available -> model.providerInfo.profile.identifier + is CommunalWidgetContentModel.Pending -> model.user.identifier } uid != disallowedByDevicePolicyUser.id @@ -576,6 +588,7 @@ constructor( when (widget) { is CommunalWidgetContentModel.Available -> currentUserIds.contains(widget.providerInfo.profile?.identifier) + is CommunalWidgetContentModel.Pending -> true } } 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 a112dd25e006..80222299177b 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 @@ -29,6 +29,7 @@ import com.android.systemui.communal.shared.model.CommunalScenes.toSceneContaine 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.dagger.qualifiers.Main import com.android.systemui.keyguard.shared.model.KeyguardState import com.android.systemui.scene.domain.interactor.SceneInteractor import com.android.systemui.scene.shared.flag.SceneContainerFlag @@ -37,6 +38,7 @@ import com.android.systemui.statusbar.policy.KeyguardStateController import com.android.systemui.util.kotlin.BooleanFlowOperators.allOf import com.android.systemui.util.kotlin.pairwiseBy import javax.inject.Inject +import kotlinx.coroutines.CoroutineDispatcher import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.delay import kotlinx.coroutines.flow.Flow @@ -57,6 +59,7 @@ class CommunalSceneInteractor @Inject constructor( @Application private val applicationScope: CoroutineScope, + @Main private val mainImmediateDispatcher: CoroutineDispatcher, private val repository: CommunalSceneRepository, private val logger: CommunalSceneLogger, private val sceneInteractor: SceneInteractor, @@ -113,6 +116,12 @@ constructor( onSceneAboutToChangeListener.add(processor) } + /** Unregisters a previously registered listener. */ + fun unregisterSceneStateProcessor(processor: OnSceneAboutToChangeListener) { + SceneContainerFlag.assertInLegacyMode() + onSceneAboutToChangeListener.remove(processor) + } + /** * Asks for an asynchronous scene witch to [newScene], which will use the corresponding * installed transition or the one specified by [transitionKey], if provided. @@ -123,7 +132,7 @@ constructor( transitionKey: TransitionKey? = null, keyguardState: KeyguardState? = null, ) { - applicationScope.launch("$TAG#changeScene") { + applicationScope.launch("$TAG#changeScene", mainImmediateDispatcher) { if (SceneContainerFlag.isEnabled) { sceneInteractor.changeScene( toScene = newScene.toSceneContainerSceneKey(), @@ -175,29 +184,6 @@ constructor( } } - fun showHubFromPowerButton() { - val loggingReason = "showing hub from power button" - applicationScope.launch("$TAG#showHubFromPowerButton") { - if (SceneContainerFlag.isEnabled) { - sceneInteractor.changeScene( - toScene = CommunalScenes.Communal.toSceneContainerSceneKey(), - loggingReason = loggingReason, - ) - return@launch - } - - if (currentScene.value == CommunalScenes.Communal) return@launch - logger.logSceneChangeRequested( - from = currentScene.value, - to = CommunalScenes.Communal, - reason = loggingReason, - isInstant = true, - ) - notifyListeners(CommunalScenes.Communal, null) - repository.showHubFromPowerButton() - } - } - private fun notifyListeners(newScene: SceneKey, keyguardState: KeyguardState?) { onSceneAboutToChangeListener.forEach { it.onSceneAboutToChange(newScene, keyguardState) } } 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 477b87119563..89d738ef3bcc 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 @@ -25,6 +25,7 @@ import com.android.systemui.communal.data.repository.CommunalSceneTransitionRepo import com.android.systemui.communal.shared.model.CommunalScenes import com.android.systemui.dagger.SysUISingleton import com.android.systemui.dagger.qualifiers.Application +import com.android.systemui.dagger.qualifiers.Main import com.android.systemui.keyguard.domain.interactor.InternalKeyguardTransitionInteractor import com.android.systemui.keyguard.domain.interactor.KeyguardInteractor import com.android.systemui.keyguard.domain.interactor.KeyguardTransitionInteractor @@ -37,6 +38,7 @@ import com.android.systemui.scene.shared.flag.SceneContainerFlag import com.android.systemui.util.kotlin.pairwise import java.util.UUID import javax.inject.Inject +import kotlinx.coroutines.CoroutineDispatcher import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.Job import kotlinx.coroutines.flow.SharingStarted @@ -64,6 +66,7 @@ constructor( val internalTransitionInteractor: InternalKeyguardTransitionInteractor, private val settingsInteractor: CommunalSettingsInteractor, @Application private val applicationScope: CoroutineScope, + @Main private val mainImmediateDispatcher: CoroutineDispatcher, private val sceneInteractor: CommunalSceneInteractor, private val repository: CommunalSceneTransitionRepository, private val powerInteractor: PowerInteractor, @@ -143,7 +146,7 @@ constructor( /** Monitors [SceneTransitionLayout] state and updates KTF state accordingly. */ private fun listenForSceneTransitionProgress() { - applicationScope.launch { + applicationScope.launch("$TAG#listenForSceneTransitionProgress", mainImmediateDispatcher) { sceneInteractor.transitionState .pairwise(ObservableTransitionState.Idle(CommunalScenes.Blank)) .collect { (prevTransition, transition) -> @@ -256,7 +259,10 @@ constructor( private fun collectProgress(transition: ObservableTransitionState.Transition) { progressJob?.cancel() - progressJob = applicationScope.launch { transition.progress.collect { updateProgress(it) } } + progressJob = + applicationScope.launch("$TAG#collectProgress", mainImmediateDispatcher) { + transition.progress.collect { updateProgress(it) } + } } private suspend fun startTransitionFromGlanceableHub() { @@ -300,4 +306,8 @@ constructor( TransitionState.RUNNING, ) } + + private companion object { + const val TAG = "CommunalSceneTransitionInteractor" + } } diff --git a/packages/SystemUI/src/com/android/systemui/communal/widgets/CommunalAppWidgetHostStartable.kt b/packages/SystemUI/src/com/android/systemui/communal/widgets/CommunalAppWidgetHostStartable.kt index 440c3001a2f9..701aa5c8d2c5 100644 --- a/packages/SystemUI/src/com/android/systemui/communal/widgets/CommunalAppWidgetHostStartable.kt +++ b/packages/SystemUI/src/com/android/systemui/communal/widgets/CommunalAppWidgetHostStartable.kt @@ -92,7 +92,17 @@ constructor( !glanceableHubMultiUserHelper.glanceableHubHsumFlagEnabled || !glanceableHubMultiUserHelper.isHeadlessSystemUserMode() ) { - anyOf(communalInteractor.isCommunalAvailable, communalInteractor.editModeOpen) + val isAvailable = + if (communalSettingsInteractor.isV2FlagEnabled()) { + allOf( + communalInteractor.isCommunalEnabled, + keyguardInteractor.isKeyguardShowing, + ) + } else { + communalInteractor.isCommunalAvailable + } + + anyOf(isAvailable, communalInteractor.editModeOpen) // Only trigger updates on state changes, ignoring the initial false value. .pairwise(false) .filter { (previous, new) -> previous != new } @@ -153,6 +163,7 @@ constructor( is CommunalWidgetContentModel.Available -> widget.providerInfo.widgetCategory and AppWidgetProviderInfo.WIDGET_CATEGORY_NOT_KEYGUARD != 0 + else -> false } } @@ -171,6 +182,7 @@ constructor( when (widget) { is CommunalWidgetContentModel.Available -> widget.providerInfo.profile?.identifier + is CommunalWidgetContentModel.Pending -> widget.user.identifier } !currentUserIds.contains(uid) diff --git a/packages/SystemUI/src/com/android/systemui/keyguard/KeyguardViewMediator.java b/packages/SystemUI/src/com/android/systemui/keyguard/KeyguardViewMediator.java index 099a7f067482..170966b45618 100644 --- a/packages/SystemUI/src/com/android/systemui/keyguard/KeyguardViewMediator.java +++ b/packages/SystemUI/src/com/android/systemui/keyguard/KeyguardViewMediator.java @@ -2433,11 +2433,7 @@ public class KeyguardViewMediator implements CoreStartable, private void doKeyguardLocked(Bundle options) { // If the power button behavior requests to open the glanceable hub. if (options != null && options.getBoolean(EXTRA_TRIGGER_HUB)) { - if (mCommunalSettingsInteractor.get().getAutoOpenEnabled().getValue()) { - // Set the hub to show immediately when the SysUI window shows, then continue to - // lock the device. - mCommunalSceneInteractor.get().showHubFromPowerButton(); - } else { + if (!mKeyguardInteractor.showGlanceableHub()) { // If the hub is not available, go to sleep instead of locking. This can happen // because the power button behavior does not check all possible reasons the hub // might be disabled. diff --git a/packages/SystemUI/src/com/android/systemui/keyguard/domain/interactor/FromAodTransitionInteractor.kt b/packages/SystemUI/src/com/android/systemui/keyguard/domain/interactor/FromAodTransitionInteractor.kt index f53421d539fe..4fca453a184c 100644 --- a/packages/SystemUI/src/com/android/systemui/keyguard/domain/interactor/FromAodTransitionInteractor.kt +++ b/packages/SystemUI/src/com/android/systemui/keyguard/domain/interactor/FromAodTransitionInteractor.kt @@ -93,8 +93,8 @@ constructor( // transition. scope.launch("$TAG#listenForAodToAwake") { powerInteractor.detailedWakefulness - .filterRelevantKeyguardStateAnd { wakefulness -> wakefulness.isAwake() } .debounce(50L) + .filterRelevantKeyguardStateAnd { wakefulness -> wakefulness.isAwake() } .sample( transitionInteractor.startedKeyguardTransitionStep, wakeToGoneInteractor.canWakeDirectlyToGone, @@ -140,7 +140,8 @@ constructor( val shouldTransitionToCommunal = communalSettingsInteractor.isV2FlagEnabled() && autoOpenCommunal && - !detailedWakefulness.isAwakeFromMotionOrLift() + !detailedWakefulness.isAwakeFromMotionOrLift() && + !isKeyguardOccludedLegacy if (shouldTransitionToGone) { // TODO(b/360368320): Adapt for scene framework diff --git a/packages/SystemUI/src/com/android/systemui/keyguard/domain/interactor/FromDozingTransitionInteractor.kt b/packages/SystemUI/src/com/android/systemui/keyguard/domain/interactor/FromDozingTransitionInteractor.kt index 4aaa1fab4c65..d673f22386b7 100644 --- a/packages/SystemUI/src/com/android/systemui/keyguard/domain/interactor/FromDozingTransitionInteractor.kt +++ b/packages/SystemUI/src/com/android/systemui/keyguard/domain/interactor/FromDozingTransitionInteractor.kt @@ -125,7 +125,9 @@ constructor( wakefulness: WakefulnessModel, ) = if (communalSettingsInteractor.isV2FlagEnabled()) { - shouldShowCommunal && !wakefulness.isAwakeFromMotionOrLift() + shouldShowCommunal && + !wakefulness.isAwakeFromMotionOrLift() && + !keyguardInteractor.isKeyguardOccluded.value } else { isCommunalAvailable && dreamManager.canStartDreaming(false) } 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 ca6a7907a8eb..cc5ec79a1060 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 @@ -20,6 +20,8 @@ import android.animation.ValueAnimator import com.android.app.animation.Interpolators import com.android.app.tracing.coroutines.launchTraced as launch 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.dagger.SysUISingleton import com.android.systemui.dagger.qualifiers.Background import com.android.systemui.dagger.qualifiers.Main @@ -48,6 +50,7 @@ constructor( keyguardInteractor: KeyguardInteractor, powerInteractor: PowerInteractor, private val communalSceneInteractor: CommunalSceneInteractor, + private val communalSettingsInteractor: CommunalSettingsInteractor, keyguardOcclusionInteractor: KeyguardOcclusionInteractor, private val keyguardShowWhileAwakeInteractor: KeyguardShowWhileAwakeInteractor, ) : @@ -77,6 +80,26 @@ constructor( } /** + * Attempt to show the glanceable hub from the gone state (eg due to power button press). + * + * This will return whether the hub was successfully shown or not. + */ + fun showGlanceableHub(): Boolean { + val isRelevantKeyguardState = + transitionInteractor.startedKeyguardTransitionStep.value.to == KeyguardState.GONE + val showGlanceableHub = + isRelevantKeyguardState && + communalSettingsInteractor.isV2FlagEnabled() && + communalSettingsInteractor.autoOpenEnabled.value && + !keyguardInteractor.isKeyguardOccluded.value + if (showGlanceableHub) { + communalSceneInteractor.snapToScene(CommunalScenes.Communal, "showGlanceableHub()") + return true + } + return false + } + + /** * A special case supported on foldables, where folding the device may put the device on an * unlocked lockscreen, but if an occluding app is already showing (like a active phone call), * then go directly to OCCLUDED. @@ -100,28 +123,36 @@ constructor( scope.launch { keyguardShowWhileAwakeInteractor.showWhileAwakeEvents .filterRelevantKeyguardState() - .sample(communalSceneInteractor.isIdleOnCommunalNotEditMode, ::Pair) - .collect { (lockReason, idleOnCommunal) -> - val to = - if (idleOnCommunal) { - KeyguardState.GLANCEABLE_HUB - } else { - KeyguardState.LOCKSCREEN - } - startTransitionTo(to, ownerReason = "lockWhileAwake: $lockReason") + .sample(communalSettingsInteractor.autoOpenEnabled, ::Pair) + .collect { (lockReason, autoOpenHub) -> + if (autoOpenHub) { + communalSceneInteractor.changeScene( + CommunalScenes.Communal, + "lockWhileAwake: $lockReason", + ) + } else { + startTransitionTo( + KeyguardState.LOCKSCREEN, + ownerReason = "lockWhileAwake: $lockReason", + ) + } } } } else { - scope.launch("$TAG#listenForGoneToLockscreenOrHubOrOccluded") { + scope.launch("$TAG#listenForGoneToLockscreenOrHubOrOccluded", mainDispatcher) { keyguardInteractor.isKeyguardShowing .filterRelevantKeyguardStateAnd { isKeyguardShowing -> isKeyguardShowing } - .sample(communalSceneInteractor.isIdleOnCommunalNotEditMode, ::Pair) - .collect { (_, isIdleOnCommunal) -> + .sample(communalSettingsInteractor.autoOpenEnabled, ::Pair) + .collect { (_, autoOpenHub) -> val to = - if (isIdleOnCommunal) { - KeyguardState.GLANCEABLE_HUB - } else if (keyguardInteractor.isKeyguardOccluded.value) { + if (keyguardInteractor.isKeyguardOccluded.value) { KeyguardState.OCCLUDED + } else if (autoOpenHub) { + communalSceneInteractor.changeScene( + CommunalScenes.Communal, + "keyguard interactor says keyguard is showing", + ) + return@collect } else { KeyguardState.LOCKSCREEN } diff --git a/packages/SystemUI/src/com/android/systemui/keyguard/domain/interactor/KeyguardInteractor.kt b/packages/SystemUI/src/com/android/systemui/keyguard/domain/interactor/KeyguardInteractor.kt index 2d5ff61a5015..e625fd72e159 100644 --- a/packages/SystemUI/src/com/android/systemui/keyguard/domain/interactor/KeyguardInteractor.kt +++ b/packages/SystemUI/src/com/android/systemui/keyguard/domain/interactor/KeyguardInteractor.kt @@ -507,6 +507,11 @@ constructor( } /** Temporary shim, until [KeyguardWmStateRefactor] is enabled */ + fun showGlanceableHub(): Boolean { + return fromGoneTransitionInteractor.get().showGlanceableHub() + } + + /** Temporary shim, until [KeyguardWmStateRefactor] is enabled */ fun dismissKeyguard() { when (keyguardTransitionInteractor.transitionState.value.to) { LOCKSCREEN -> fromLockscreenTransitionInteractor.get().dismissKeyguard() diff --git a/packages/SystemUI/src/com/android/systemui/keyguard/ui/viewmodel/GoneToGlanceableHubTransitionViewModel.kt b/packages/SystemUI/src/com/android/systemui/keyguard/ui/viewmodel/GoneToGlanceableHubTransitionViewModel.kt index 6d95ade59211..4bc722bc6695 100644 --- a/packages/SystemUI/src/com/android/systemui/keyguard/ui/viewmodel/GoneToGlanceableHubTransitionViewModel.kt +++ b/packages/SystemUI/src/com/android/systemui/keyguard/ui/viewmodel/GoneToGlanceableHubTransitionViewModel.kt @@ -30,15 +30,15 @@ import kotlinx.coroutines.flow.Flow @SysUISingleton class GoneToGlanceableHubTransitionViewModel @Inject -constructor( - animationFlow: KeyguardTransitionAnimationFlow, -) : DeviceEntryIconTransition { +constructor(animationFlow: KeyguardTransitionAnimationFlow) : DeviceEntryIconTransition { private val transitionAnimation = animationFlow .setup(duration = TO_GLANCEABLE_HUB_DURATION, edge = Edge.INVALID) .setupWithoutSceneContainer(edge = Edge.create(GONE, GLANCEABLE_HUB)) + val keyguardAlpha = transitionAnimation.immediatelyTransitionTo(0f) + override val deviceEntryParentViewAlpha: Flow<Float> = transitionAnimation.sharedFlow( duration = 167.milliseconds, diff --git a/packages/SystemUI/src/com/android/systemui/keyguard/ui/viewmodel/KeyguardRootViewModel.kt b/packages/SystemUI/src/com/android/systemui/keyguard/ui/viewmodel/KeyguardRootViewModel.kt index 830afeac7b96..a5051657c2f0 100644 --- a/packages/SystemUI/src/com/android/systemui/keyguard/ui/viewmodel/KeyguardRootViewModel.kt +++ b/packages/SystemUI/src/com/android/systemui/keyguard/ui/viewmodel/KeyguardRootViewModel.kt @@ -116,6 +116,7 @@ constructor( private val goneToDozingTransitionViewModel: GoneToDozingTransitionViewModel, private val goneToDreamingTransitionViewModel: GoneToDreamingTransitionViewModel, private val goneToLockscreenTransitionViewModel: GoneToLockscreenTransitionViewModel, + private val goneToGlanceableHubTransitionViewModel: GoneToGlanceableHubTransitionViewModel, private val lockscreenToAodTransitionViewModel: LockscreenToAodTransitionViewModel, private val lockscreenToDozingTransitionViewModel: LockscreenToDozingTransitionViewModel, private val lockscreenToDreamingTransitionViewModel: LockscreenToDreamingTransitionViewModel, @@ -277,6 +278,7 @@ constructor( primaryBouncerToAodTransitionViewModel.lockscreenAlpha, primaryBouncerToGoneTransitionViewModel.lockscreenAlpha, primaryBouncerToLockscreenTransitionViewModel.lockscreenAlpha(viewState), + goneToGlanceableHubTransitionViewModel.keyguardAlpha, ) .onStart { emit(0f) }, ) { hideKeyguard, alpha -> diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/ui/viewmodel/SharedNotificationContainerViewModel.kt b/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/ui/viewmodel/SharedNotificationContainerViewModel.kt index 0ea9509f0c13..e3c2fb5b6e59 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/ui/viewmodel/SharedNotificationContainerViewModel.kt +++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/ui/viewmodel/SharedNotificationContainerViewModel.kt @@ -25,9 +25,11 @@ import com.android.systemui.bouncer.domain.interactor.BouncerInteractor import com.android.systemui.common.shared.model.NotificationContainerBounds import com.android.systemui.common.ui.domain.interactor.ConfigurationInteractor 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.Application import com.android.systemui.dump.DumpManager +import com.android.systemui.kairos.awaitClose import com.android.systemui.keyguard.domain.interactor.KeyguardInteractor import com.android.systemui.keyguard.domain.interactor.KeyguardTransitionInteractor import com.android.systemui.keyguard.shared.model.Edge @@ -95,6 +97,7 @@ import com.android.systemui.util.kotlin.BooleanFlowOperators.not import com.android.systemui.util.kotlin.FlowDumperImpl import com.android.systemui.util.kotlin.Utils.Companion.sample as sampleCombine import com.android.systemui.util.kotlin.sample +import com.android.systemui.utils.coroutines.flow.conflatedCallbackFlow import dagger.Lazy import javax.inject.Inject import kotlinx.coroutines.CoroutineScope @@ -357,14 +360,31 @@ constructor( ) .dumpValue("isOnLockscreenWithoutShade") + private val aboutToTransitionToHub: Flow<Unit> = + if (SceneContainerFlag.isEnabled) { + emptyFlow() + } else { + conflatedCallbackFlow { + val callback = + CommunalSceneInteractor.OnSceneAboutToChangeListener { toScene, _ -> + if (toScene == CommunalScenes.Communal) { + trySend(Unit) + } + } + communalSceneInteractor.registerSceneStateProcessor(callback) + awaitClose { communalSceneInteractor.unregisterSceneStateProcessor(callback) } + } + } + /** If the user is visually on the glanceable hub or transitioning to/from it */ private val isOnGlanceableHub: Flow<Boolean> = - combine( - keyguardTransitionInteractor.isFinishedIn( - content = Scenes.Communal, - stateWithoutSceneContainer = GLANCEABLE_HUB, - ), + merge( + aboutToTransitionToHub.map { true }, anyOf( + keyguardTransitionInteractor.isFinishedIn( + content = Scenes.Communal, + stateWithoutSceneContainer = GLANCEABLE_HUB, + ), keyguardTransitionInteractor.isInTransition( edge = Edge.create(to = Scenes.Communal), edgeWithoutSceneContainer = Edge.create(to = GLANCEABLE_HUB), @@ -374,9 +394,7 @@ constructor( edgeWithoutSceneContainer = Edge.create(from = GLANCEABLE_HUB), ), ), - ) { isOnGlanceableHub, transitioningToOrFromHub -> - isOnGlanceableHub || transitioningToOrFromHub - } + ) .distinctUntilChanged() .dumpWhileCollecting("isOnGlanceableHub") @@ -532,6 +550,7 @@ constructor( emit(1f - qsExpansion) } } + Split -> combineTransform(isAnyExpanded, bouncerInteractor.bouncerExpansion) { isAnyExpanded, @@ -544,6 +563,7 @@ constructor( emit(1f) } } + Dual -> combineTransform( shadeModeInteractor.isShadeLayoutWide, |