Loading packages/SystemUI/multivalentTests/src/com/android/systemui/communal/CommunalDreamStartableTest.kt +0 −2 Original line number Diff line number Diff line Loading @@ -22,7 +22,6 @@ import androidx.test.ext.junit.runners.AndroidJUnit4 import androidx.test.filters.SmallTest import com.android.systemui.Flags import com.android.systemui.SysuiTestCase import com.android.systemui.communal.domain.interactor.communalInteractor import com.android.systemui.keyguard.data.repository.fakeKeyguardRepository import com.android.systemui.keyguard.data.repository.fakeKeyguardTransitionRepository import com.android.systemui.keyguard.data.repository.keyguardRepository Loading Loading @@ -66,7 +65,6 @@ class CommunalDreamStartableTest : SysuiTestCase() { powerInteractor = kosmos.powerInteractor, keyguardInteractor = kosmos.keyguardInteractor, keyguardTransitionInteractor = kosmos.keyguardTransitionInteractor, communalInteractor = kosmos.communalInteractor, dreamManager = dreamManager, bgScope = kosmos.applicationCoroutineScope, ) Loading packages/SystemUI/src/com/android/systemui/communal/CommunalDreamStartable.kt +22 −24 Original line number Diff line number Diff line Loading @@ -19,23 +19,25 @@ package com.android.systemui.communal import android.annotation.SuppressLint import android.app.DreamManager import com.android.systemui.CoreStartable import com.android.systemui.Flags.glanceableHubAllowKeyguardWhenDreaming import com.android.systemui.Flags.communalHub import com.android.systemui.Flags.glanceableHubAllowKeyguardWhenDreaming import com.android.systemui.Flags.restartDreamOnUnocclude import com.android.systemui.communal.domain.interactor.CommunalInteractor import com.android.systemui.dagger.SysUISingleton import com.android.systemui.dagger.qualifiers.Background import com.android.systemui.keyguard.domain.interactor.KeyguardInteractor import com.android.systemui.keyguard.domain.interactor.KeyguardTransitionInteractor import com.android.systemui.keyguard.shared.model.Edge import com.android.systemui.keyguard.shared.model.KeyguardState 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.util.kotlin.Utils.Companion.sample import com.android.systemui.util.kotlin.sample import com.android.systemui.scene.shared.model.Scenes 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.onEach import javax.inject.Inject /** * A [CoreStartable] responsible for automatically starting the dream when the communal hub is Loading @@ -48,7 +50,6 @@ constructor( private val powerInteractor: PowerInteractor, private val keyguardInteractor: KeyguardInteractor, private val keyguardTransitionInteractor: KeyguardTransitionInteractor, private val communalInteractor: CommunalInteractor, private val dreamManager: DreamManager, @Background private val bgScope: CoroutineScope, ) : CoreStartable { Loading @@ -60,31 +61,28 @@ constructor( // Return to dream from occluded when not already dreaming. if (restartDreamOnUnocclude()) { keyguardTransitionInteractor.startedKeyguardTransitionStep .sample(keyguardInteractor.isDreaming, ::Pair) .filter { (step, isDreaming) -> step.from == KeyguardState.OCCLUDED && step.to == KeyguardState.DREAMING && !isDreaming } keyguardTransitionInteractor .transition(Edge.create(from = KeyguardState.OCCLUDED, to = KeyguardState.DREAMING)) .filterState(TransitionState.STARTED) .sampleFilter(keyguardInteractor.isDreaming) { isDreaming -> !isDreaming } .onEach { dreamManager.startDream() } .launchIn(bgScope) } // Restart the dream underneath the hub in order to support the ability to swipe // away the hub to enter the dream. keyguardTransitionInteractor.finishedKeyguardState .sample(powerInteractor.isAwake, keyguardInteractor.isDreaming) .onEach { (finishedState, isAwake, dreaming) -> if ( finishedState == KeyguardState.GLANCEABLE_HUB && !dreaming && !glanceableHubAllowKeyguardWhenDreaming() && keyguardTransitionInteractor .transition( edge = Edge.create(to = Scenes.Communal), edgeWithoutSceneContainer = Edge.create(to = KeyguardState.GLANCEABLE_HUB) ) .filterState(TransitionState.FINISHED) .sampleFilter(powerInteractor.isAwake) { isAwake -> dreamManager.canStartDreaming(isAwake) ) { dreamManager.startDream() } } .sampleFilter(keyguardInteractor.isDreaming) { isDreaming -> !isDreaming } .filter { !glanceableHubAllowKeyguardWhenDreaming() } .onEach { dreamManager.startDream() } .launchIn(bgScope) } } packages/SystemUI/src/com/android/systemui/keyguard/domain/interactor/KeyguardTransitionInteractor.kt +0 −2 Original line number Diff line number Diff line Loading @@ -265,8 +265,6 @@ constructor( .map { step -> step.to } .shareIn(scope, SharingStarted.Eagerly, replay = 1) val currentTransitionInfo: StateFlow<TransitionInfo> = repository.currentTransitionInfoInternal /** The from state of the last [TransitionState.STARTED] transition. */ // TODO: is it performant to have several SharedFlows side by side instead of one? @SuppressLint("SharedFlowCreation") Loading packages/SystemUI/src/com/android/systemui/keyguard/domain/interactor/scenetransition/LockscreenSceneTransitionInteractor.kt +3 −3 Original line number Diff line number Diff line Loading @@ -131,7 +131,7 @@ constructor( val newTransition = TransitionInfo( ownerName = this::class.java.simpleName, from = transitionInteractor.currentTransitionInfo.value.to, from = transitionInteractor.currentTransitionInfoInternal.value.to, to = state, animator = null, modeOnCanceled = TransitionModeOnCanceled.REVERSE Loading @@ -150,7 +150,7 @@ constructor( private suspend fun handleTransition(transition: ObservableTransitionState.Transition) { if (transition.fromScene == Scenes.Lockscreen) { if (currentTransitionId != null) { val currentToState = transitionInteractor.currentTransitionInfo.value.to val currentToState = transitionInteractor.currentTransitionInfoInternal.value.to if (currentToState == UNDEFINED) { transitionKtfTo(transitionInteractor.getStartedFromState()) } Loading Loading @@ -201,7 +201,7 @@ constructor( } private suspend fun startTransitionFromLockscreen() { val currentState = transitionInteractor.currentTransitionInfo.value.to val currentState = transitionInteractor.currentTransitionInfoInternal.value.to val newTransition = TransitionInfo( ownerName = this::class.java.simpleName, Loading packages/SystemUI/src/com/android/systemui/keyguard/shared/model/TransitionStep.kt +6 −0 Original line number Diff line number Diff line Loading @@ -15,6 +15,9 @@ */ package com.android.systemui.keyguard.shared.model import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.filter /** This information will flow from the [KeyguardTransitionRepository] to control the UI layer */ data class TransitionStep @JvmOverloads Loading @@ -39,3 +42,6 @@ constructor( return to == state && transitionState == TransitionState.FINISHED } } fun Flow<TransitionStep>.filterState(transitionState: TransitionState) = this.filter { it.transitionState == transitionState } Loading
packages/SystemUI/multivalentTests/src/com/android/systemui/communal/CommunalDreamStartableTest.kt +0 −2 Original line number Diff line number Diff line Loading @@ -22,7 +22,6 @@ import androidx.test.ext.junit.runners.AndroidJUnit4 import androidx.test.filters.SmallTest import com.android.systemui.Flags import com.android.systemui.SysuiTestCase import com.android.systemui.communal.domain.interactor.communalInteractor import com.android.systemui.keyguard.data.repository.fakeKeyguardRepository import com.android.systemui.keyguard.data.repository.fakeKeyguardTransitionRepository import com.android.systemui.keyguard.data.repository.keyguardRepository Loading Loading @@ -66,7 +65,6 @@ class CommunalDreamStartableTest : SysuiTestCase() { powerInteractor = kosmos.powerInteractor, keyguardInteractor = kosmos.keyguardInteractor, keyguardTransitionInteractor = kosmos.keyguardTransitionInteractor, communalInteractor = kosmos.communalInteractor, dreamManager = dreamManager, bgScope = kosmos.applicationCoroutineScope, ) Loading
packages/SystemUI/src/com/android/systemui/communal/CommunalDreamStartable.kt +22 −24 Original line number Diff line number Diff line Loading @@ -19,23 +19,25 @@ package com.android.systemui.communal import android.annotation.SuppressLint import android.app.DreamManager import com.android.systemui.CoreStartable import com.android.systemui.Flags.glanceableHubAllowKeyguardWhenDreaming import com.android.systemui.Flags.communalHub import com.android.systemui.Flags.glanceableHubAllowKeyguardWhenDreaming import com.android.systemui.Flags.restartDreamOnUnocclude import com.android.systemui.communal.domain.interactor.CommunalInteractor import com.android.systemui.dagger.SysUISingleton import com.android.systemui.dagger.qualifiers.Background import com.android.systemui.keyguard.domain.interactor.KeyguardInteractor import com.android.systemui.keyguard.domain.interactor.KeyguardTransitionInteractor import com.android.systemui.keyguard.shared.model.Edge import com.android.systemui.keyguard.shared.model.KeyguardState 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.util.kotlin.Utils.Companion.sample import com.android.systemui.util.kotlin.sample import com.android.systemui.scene.shared.model.Scenes 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.onEach import javax.inject.Inject /** * A [CoreStartable] responsible for automatically starting the dream when the communal hub is Loading @@ -48,7 +50,6 @@ constructor( private val powerInteractor: PowerInteractor, private val keyguardInteractor: KeyguardInteractor, private val keyguardTransitionInteractor: KeyguardTransitionInteractor, private val communalInteractor: CommunalInteractor, private val dreamManager: DreamManager, @Background private val bgScope: CoroutineScope, ) : CoreStartable { Loading @@ -60,31 +61,28 @@ constructor( // Return to dream from occluded when not already dreaming. if (restartDreamOnUnocclude()) { keyguardTransitionInteractor.startedKeyguardTransitionStep .sample(keyguardInteractor.isDreaming, ::Pair) .filter { (step, isDreaming) -> step.from == KeyguardState.OCCLUDED && step.to == KeyguardState.DREAMING && !isDreaming } keyguardTransitionInteractor .transition(Edge.create(from = KeyguardState.OCCLUDED, to = KeyguardState.DREAMING)) .filterState(TransitionState.STARTED) .sampleFilter(keyguardInteractor.isDreaming) { isDreaming -> !isDreaming } .onEach { dreamManager.startDream() } .launchIn(bgScope) } // Restart the dream underneath the hub in order to support the ability to swipe // away the hub to enter the dream. keyguardTransitionInteractor.finishedKeyguardState .sample(powerInteractor.isAwake, keyguardInteractor.isDreaming) .onEach { (finishedState, isAwake, dreaming) -> if ( finishedState == KeyguardState.GLANCEABLE_HUB && !dreaming && !glanceableHubAllowKeyguardWhenDreaming() && keyguardTransitionInteractor .transition( edge = Edge.create(to = Scenes.Communal), edgeWithoutSceneContainer = Edge.create(to = KeyguardState.GLANCEABLE_HUB) ) .filterState(TransitionState.FINISHED) .sampleFilter(powerInteractor.isAwake) { isAwake -> dreamManager.canStartDreaming(isAwake) ) { dreamManager.startDream() } } .sampleFilter(keyguardInteractor.isDreaming) { isDreaming -> !isDreaming } .filter { !glanceableHubAllowKeyguardWhenDreaming() } .onEach { dreamManager.startDream() } .launchIn(bgScope) } }
packages/SystemUI/src/com/android/systemui/keyguard/domain/interactor/KeyguardTransitionInteractor.kt +0 −2 Original line number Diff line number Diff line Loading @@ -265,8 +265,6 @@ constructor( .map { step -> step.to } .shareIn(scope, SharingStarted.Eagerly, replay = 1) val currentTransitionInfo: StateFlow<TransitionInfo> = repository.currentTransitionInfoInternal /** The from state of the last [TransitionState.STARTED] transition. */ // TODO: is it performant to have several SharedFlows side by side instead of one? @SuppressLint("SharedFlowCreation") Loading
packages/SystemUI/src/com/android/systemui/keyguard/domain/interactor/scenetransition/LockscreenSceneTransitionInteractor.kt +3 −3 Original line number Diff line number Diff line Loading @@ -131,7 +131,7 @@ constructor( val newTransition = TransitionInfo( ownerName = this::class.java.simpleName, from = transitionInteractor.currentTransitionInfo.value.to, from = transitionInteractor.currentTransitionInfoInternal.value.to, to = state, animator = null, modeOnCanceled = TransitionModeOnCanceled.REVERSE Loading @@ -150,7 +150,7 @@ constructor( private suspend fun handleTransition(transition: ObservableTransitionState.Transition) { if (transition.fromScene == Scenes.Lockscreen) { if (currentTransitionId != null) { val currentToState = transitionInteractor.currentTransitionInfo.value.to val currentToState = transitionInteractor.currentTransitionInfoInternal.value.to if (currentToState == UNDEFINED) { transitionKtfTo(transitionInteractor.getStartedFromState()) } Loading Loading @@ -201,7 +201,7 @@ constructor( } private suspend fun startTransitionFromLockscreen() { val currentState = transitionInteractor.currentTransitionInfo.value.to val currentState = transitionInteractor.currentTransitionInfoInternal.value.to val newTransition = TransitionInfo( ownerName = this::class.java.simpleName, Loading
packages/SystemUI/src/com/android/systemui/keyguard/shared/model/TransitionStep.kt +6 −0 Original line number Diff line number Diff line Loading @@ -15,6 +15,9 @@ */ package com.android.systemui.keyguard.shared.model import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.filter /** This information will flow from the [KeyguardTransitionRepository] to control the UI layer */ data class TransitionStep @JvmOverloads Loading @@ -39,3 +42,6 @@ constructor( return to == state && transitionState == TransitionState.FINISHED } } fun Flow<TransitionStep>.filterState(transitionState: TransitionState) = this.filter { it.transitionState == transitionState }