Loading packages/SystemUI/multivalentTests/src/com/android/systemui/communal/CommunalDreamStartableTest.kt +1 −0 Original line number Diff line number Diff line Loading @@ -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) Loading packages/SystemUI/src/com/android/systemui/communal/CommunalDreamStartable.kt +17 −9 Original line number Diff line number Diff line Loading @@ -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 /** Loading @@ -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()) { Loading @@ -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) } Loading packages/SystemUI/src/com/android/systemui/communal/domain/interactor/CommunalSceneTransitionInteractor.kt +1 −0 Original line number Diff line number Diff line Loading @@ -182,6 +182,7 @@ constructor( } private suspend fun finishCurrentTransition() { if (currentTransitionId == null) return internalTransitionInteractor.updateTransition( currentTransitionId!!, 1f, Loading Loading
packages/SystemUI/multivalentTests/src/com/android/systemui/communal/CommunalDreamStartableTest.kt +1 −0 Original line number Diff line number Diff line Loading @@ -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) Loading
packages/SystemUI/src/com/android/systemui/communal/CommunalDreamStartable.kt +17 −9 Original line number Diff line number Diff line Loading @@ -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 /** Loading @@ -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()) { Loading @@ -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) } Loading
packages/SystemUI/src/com/android/systemui/communal/domain/interactor/CommunalSceneTransitionInteractor.kt +1 −0 Original line number Diff line number Diff line Loading @@ -182,6 +182,7 @@ constructor( } private suspend fun finishCurrentTransition() { if (currentTransitionId == null) return internalTransitionInteractor.updateTransition( currentTransitionId!!, 1f, Loading