Loading packages/SystemUI/src/com/android/systemui/keyguard/domain/interactor/FromDreamingTransitionInteractor.kt +4 −1 Original line number Diff line number Diff line Loading @@ -54,7 +54,10 @@ constructor( fun startToLockscreenTransition() { scope.launch { if (transitionInteractor.startedKeyguardState.value == KeyguardState.DREAMING) { if ( transitionInteractor.startedKeyguardState.replayCache.last() == KeyguardState.DREAMING ) { startTransitionTo(KeyguardState.LOCKSCREEN) } } Loading packages/SystemUI/src/com/android/systemui/keyguard/domain/interactor/KeyguardSurfaceBehindInteractor.kt +13 −10 Original line number Diff line number Diff line Loading @@ -24,6 +24,7 @@ import javax.inject.Inject import kotlinx.coroutines.ExperimentalCoroutinesApi import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.combine import kotlinx.coroutines.flow.distinctUntilChanged import kotlinx.coroutines.flow.flatMapLatest import kotlinx.coroutines.flow.flowOf import kotlinx.coroutines.flow.map Loading @@ -40,7 +41,8 @@ constructor( @OptIn(ExperimentalCoroutinesApi::class) val viewParams: Flow<KeyguardSurfaceBehindModel> = transitionInteractor.isInTransitionToAnyState.flatMapLatest { isInTransition -> transitionInteractor.isInTransitionToAnyState .flatMapLatest { isInTransition -> if (!isInTransition) { defaultParams } else { Loading @@ -52,6 +54,7 @@ constructor( } } } .distinctUntilChanged() val isAnimatingSurface = repository.isAnimatingSurface Loading packages/SystemUI/src/com/android/systemui/keyguard/domain/interactor/KeyguardTransitionInteractor.kt +8 −9 Original line number Diff line number Diff line Loading @@ -37,14 +37,14 @@ import com.android.systemui.keyguard.shared.model.TransitionStep import javax.inject.Inject import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.SharedFlow import kotlinx.coroutines.flow.SharingStarted import kotlinx.coroutines.flow.StateFlow import kotlinx.coroutines.flow.combine import kotlinx.coroutines.flow.distinctUntilChanged import kotlinx.coroutines.flow.filter import kotlinx.coroutines.flow.map import kotlinx.coroutines.flow.merge import kotlinx.coroutines.flow.stateIn import kotlinx.coroutines.flow.shareIn /** Encapsulates business-logic related to the keyguard transitions. */ @SysUISingleton Loading Loading @@ -171,16 +171,16 @@ constructor( repository.transitions.filter { step -> step.transitionState == TransitionState.FINISHED } /** The destination state of the last started transition. */ val startedKeyguardState: StateFlow<KeyguardState> = val startedKeyguardState: SharedFlow<KeyguardState> = startedKeyguardTransitionStep .map { step -> step.to } .stateIn(scope, SharingStarted.Eagerly, OFF) .shareIn(scope, SharingStarted.Eagerly, replay = 1) /** The last completed [KeyguardState] transition */ val finishedKeyguardState: StateFlow<KeyguardState> = val finishedKeyguardState: SharedFlow<KeyguardState> = finishedKeyguardTransitionStep .map { step -> step.to } .stateIn(scope, SharingStarted.Eagerly, LOCKSCREEN) .shareIn(scope, SharingStarted.Eagerly, replay = 1) /** * Whether we're currently in a transition to a new [KeyguardState] and haven't yet completed Loading Loading @@ -227,14 +227,13 @@ constructor( * state. */ fun startDismissKeyguardTransition() { when (startedKeyguardState.value) { when (val startedState = startedKeyguardState.replayCache.last()) { LOCKSCREEN -> fromLockscreenTransitionInteractor.get().dismissKeyguard() PRIMARY_BOUNCER -> fromPrimaryBouncerTransitionInteractor.get().dismissPrimaryBouncer() else -> Log.e( "KeyguardTransitionInteractor", "We don't know how to dismiss keyguard from state " + "${startedKeyguardState.value}" "We don't know how to dismiss keyguard from state $startedState." ) } } Loading packages/SystemUI/src/com/android/systemui/keyguard/domain/interactor/TransitionInteractor.kt +4 −4 Original line number Diff line number Diff line Loading @@ -53,16 +53,16 @@ sealed class TransitionInteractor( modeOnCanceled: TransitionModeOnCanceled = TransitionModeOnCanceled.LAST_VALUE ): UUID? { if ( fromState != transitionInteractor.startedKeyguardState.value && fromState != transitionInteractor.finishedKeyguardState.value fromState != transitionInteractor.startedKeyguardState.replayCache.last() && fromState != transitionInteractor.finishedKeyguardState.replayCache.last() ) { Log.e( name, "startTransition: We were asked to transition from " + "$fromState to $toState, however we last finished a transition to " + "${transitionInteractor.finishedKeyguardState.value}, " + "${transitionInteractor.finishedKeyguardState.replayCache.last()}, " + "and last started a transition to " + "${transitionInteractor.startedKeyguardState.value}. " + "${transitionInteractor.startedKeyguardState.replayCache.last()}. " + "Ignoring startTransition, but this should never happen." ) return null Loading packages/SystemUI/tests/src/com/android/systemui/keyguard/domain/interactor/InWindowLauncherUnlockAnimationInteractorTest.kt +7 −0 Original line number Diff line number Diff line Loading @@ -411,6 +411,13 @@ class InWindowLauncherUnlockAnimationInteractorTest : SysuiTestCase() { to = KeyguardState.GONE, ) ) transitionRepository.sendTransitionStep( TransitionStep( transitionState = TransitionState.CANCELED, from = KeyguardState.LOCKSCREEN, to = KeyguardState.GONE, ) ) transitionRepository.sendTransitionStep( TransitionStep( transitionState = TransitionState.STARTED, Loading Loading
packages/SystemUI/src/com/android/systemui/keyguard/domain/interactor/FromDreamingTransitionInteractor.kt +4 −1 Original line number Diff line number Diff line Loading @@ -54,7 +54,10 @@ constructor( fun startToLockscreenTransition() { scope.launch { if (transitionInteractor.startedKeyguardState.value == KeyguardState.DREAMING) { if ( transitionInteractor.startedKeyguardState.replayCache.last() == KeyguardState.DREAMING ) { startTransitionTo(KeyguardState.LOCKSCREEN) } } Loading
packages/SystemUI/src/com/android/systemui/keyguard/domain/interactor/KeyguardSurfaceBehindInteractor.kt +13 −10 Original line number Diff line number Diff line Loading @@ -24,6 +24,7 @@ import javax.inject.Inject import kotlinx.coroutines.ExperimentalCoroutinesApi import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.combine import kotlinx.coroutines.flow.distinctUntilChanged import kotlinx.coroutines.flow.flatMapLatest import kotlinx.coroutines.flow.flowOf import kotlinx.coroutines.flow.map Loading @@ -40,7 +41,8 @@ constructor( @OptIn(ExperimentalCoroutinesApi::class) val viewParams: Flow<KeyguardSurfaceBehindModel> = transitionInteractor.isInTransitionToAnyState.flatMapLatest { isInTransition -> transitionInteractor.isInTransitionToAnyState .flatMapLatest { isInTransition -> if (!isInTransition) { defaultParams } else { Loading @@ -52,6 +54,7 @@ constructor( } } } .distinctUntilChanged() val isAnimatingSurface = repository.isAnimatingSurface Loading
packages/SystemUI/src/com/android/systemui/keyguard/domain/interactor/KeyguardTransitionInteractor.kt +8 −9 Original line number Diff line number Diff line Loading @@ -37,14 +37,14 @@ import com.android.systemui.keyguard.shared.model.TransitionStep import javax.inject.Inject import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.SharedFlow import kotlinx.coroutines.flow.SharingStarted import kotlinx.coroutines.flow.StateFlow import kotlinx.coroutines.flow.combine import kotlinx.coroutines.flow.distinctUntilChanged import kotlinx.coroutines.flow.filter import kotlinx.coroutines.flow.map import kotlinx.coroutines.flow.merge import kotlinx.coroutines.flow.stateIn import kotlinx.coroutines.flow.shareIn /** Encapsulates business-logic related to the keyguard transitions. */ @SysUISingleton Loading Loading @@ -171,16 +171,16 @@ constructor( repository.transitions.filter { step -> step.transitionState == TransitionState.FINISHED } /** The destination state of the last started transition. */ val startedKeyguardState: StateFlow<KeyguardState> = val startedKeyguardState: SharedFlow<KeyguardState> = startedKeyguardTransitionStep .map { step -> step.to } .stateIn(scope, SharingStarted.Eagerly, OFF) .shareIn(scope, SharingStarted.Eagerly, replay = 1) /** The last completed [KeyguardState] transition */ val finishedKeyguardState: StateFlow<KeyguardState> = val finishedKeyguardState: SharedFlow<KeyguardState> = finishedKeyguardTransitionStep .map { step -> step.to } .stateIn(scope, SharingStarted.Eagerly, LOCKSCREEN) .shareIn(scope, SharingStarted.Eagerly, replay = 1) /** * Whether we're currently in a transition to a new [KeyguardState] and haven't yet completed Loading Loading @@ -227,14 +227,13 @@ constructor( * state. */ fun startDismissKeyguardTransition() { when (startedKeyguardState.value) { when (val startedState = startedKeyguardState.replayCache.last()) { LOCKSCREEN -> fromLockscreenTransitionInteractor.get().dismissKeyguard() PRIMARY_BOUNCER -> fromPrimaryBouncerTransitionInteractor.get().dismissPrimaryBouncer() else -> Log.e( "KeyguardTransitionInteractor", "We don't know how to dismiss keyguard from state " + "${startedKeyguardState.value}" "We don't know how to dismiss keyguard from state $startedState." ) } } Loading
packages/SystemUI/src/com/android/systemui/keyguard/domain/interactor/TransitionInteractor.kt +4 −4 Original line number Diff line number Diff line Loading @@ -53,16 +53,16 @@ sealed class TransitionInteractor( modeOnCanceled: TransitionModeOnCanceled = TransitionModeOnCanceled.LAST_VALUE ): UUID? { if ( fromState != transitionInteractor.startedKeyguardState.value && fromState != transitionInteractor.finishedKeyguardState.value fromState != transitionInteractor.startedKeyguardState.replayCache.last() && fromState != transitionInteractor.finishedKeyguardState.replayCache.last() ) { Log.e( name, "startTransition: We were asked to transition from " + "$fromState to $toState, however we last finished a transition to " + "${transitionInteractor.finishedKeyguardState.value}, " + "${transitionInteractor.finishedKeyguardState.replayCache.last()}, " + "and last started a transition to " + "${transitionInteractor.startedKeyguardState.value}. " + "${transitionInteractor.startedKeyguardState.replayCache.last()}. " + "Ignoring startTransition, but this should never happen." ) return null Loading
packages/SystemUI/tests/src/com/android/systemui/keyguard/domain/interactor/InWindowLauncherUnlockAnimationInteractorTest.kt +7 −0 Original line number Diff line number Diff line Loading @@ -411,6 +411,13 @@ class InWindowLauncherUnlockAnimationInteractorTest : SysuiTestCase() { to = KeyguardState.GONE, ) ) transitionRepository.sendTransitionStep( TransitionStep( transitionState = TransitionState.CANCELED, from = KeyguardState.LOCKSCREEN, to = KeyguardState.GONE, ) ) transitionRepository.sendTransitionStep( TransitionStep( transitionState = TransitionState.STARTED, Loading