diff --git a/packages/SystemUI/src/com/android/systemui/keyguard/data/repository/KeyguardTransitionRepository.kt b/packages/SystemUI/src/com/android/systemui/keyguard/data/repository/KeyguardTransitionRepository.kt index bce7d92cd8fb9..5bb586e489e55 100644 --- a/packages/SystemUI/src/com/android/systemui/keyguard/data/repository/KeyguardTransitionRepository.kt +++ b/packages/SystemUI/src/com/android/systemui/keyguard/data/repository/KeyguardTransitionRepository.kt @@ -116,6 +116,7 @@ class KeyguardTransitionRepositoryImpl @Inject constructor() : KeyguardTransitio KeyguardState.LOCKSCREEN, 0f, TransitionState.STARTED, + KeyguardTransitionRepositoryImpl::class.simpleName!!, ) ) emitTransition( @@ -124,6 +125,7 @@ class KeyguardTransitionRepositoryImpl @Inject constructor() : KeyguardTransitio KeyguardState.LOCKSCREEN, 1f, TransitionState.FINISHED, + KeyguardTransitionRepositoryImpl::class.simpleName!!, ) ) } diff --git a/packages/SystemUI/src/com/android/systemui/keyguard/domain/interactor/AodLockscreenTransitionInteractor.kt b/packages/SystemUI/src/com/android/systemui/keyguard/domain/interactor/AodLockscreenTransitionInteractor.kt index 9b193533805ef..f3d2905121bba 100644 --- a/packages/SystemUI/src/com/android/systemui/keyguard/domain/interactor/AodLockscreenTransitionInteractor.kt +++ b/packages/SystemUI/src/com/android/systemui/keyguard/domain/interactor/AodLockscreenTransitionInteractor.kt @@ -41,17 +41,14 @@ constructor( override fun start() { listenForTransitionToAodFromLockscreen() - listenForTransitionToLockscreenFromAod() + listenForTransitionToLockscreenFromDozeStates() } private fun listenForTransitionToAodFromLockscreen() { scope.launch { keyguardInteractor .dozeTransitionTo(DozeStateModel.DOZE_AOD) - .sample( - keyguardTransitionInteractor.startedKeyguardTransitionStep, - { a, b -> Pair(a, b) } - ) + .sample(keyguardTransitionInteractor.startedKeyguardTransitionStep, ::Pair) .collect { pair -> val (dozeToAod, lastStartedStep) = pair if (lastStartedStep.to == KeyguardState.LOCKSCREEN) { @@ -68,21 +65,19 @@ constructor( } } - private fun listenForTransitionToLockscreenFromAod() { + private fun listenForTransitionToLockscreenFromDozeStates() { + val canGoToLockscreen = setOf(KeyguardState.AOD, KeyguardState.DOZING) scope.launch { keyguardInteractor .dozeTransitionTo(DozeStateModel.FINISH) - .sample( - keyguardTransitionInteractor.startedKeyguardTransitionStep, - { a, b -> Pair(a, b) } - ) + .sample(keyguardTransitionInteractor.startedKeyguardTransitionStep, ::Pair) .collect { pair -> val (dozeToAod, lastStartedStep) = pair - if (lastStartedStep.to == KeyguardState.AOD) { + if (canGoToLockscreen.contains(lastStartedStep.to)) { keyguardTransitionRepository.startTransition( TransitionInfo( name, - KeyguardState.AOD, + lastStartedStep.to, KeyguardState.LOCKSCREEN, getAnimator(), ) diff --git a/packages/SystemUI/src/com/android/systemui/keyguard/domain/interactor/AodToGoneTransitionInteractor.kt b/packages/SystemUI/src/com/android/systemui/keyguard/domain/interactor/AodToGoneTransitionInteractor.kt index 2a220fcd75a65..dad166f2b5e04 100644 --- a/packages/SystemUI/src/com/android/systemui/keyguard/domain/interactor/AodToGoneTransitionInteractor.kt +++ b/packages/SystemUI/src/com/android/systemui/keyguard/domain/interactor/AodToGoneTransitionInteractor.kt @@ -21,9 +21,7 @@ import com.android.systemui.animation.Interpolators import com.android.systemui.dagger.SysUISingleton import com.android.systemui.dagger.qualifiers.Application import com.android.systemui.keyguard.data.repository.KeyguardTransitionRepository -import com.android.systemui.keyguard.shared.model.BiometricUnlockModel.WAKE_AND_UNLOCK -import com.android.systemui.keyguard.shared.model.BiometricUnlockModel.WAKE_AND_UNLOCK_FROM_DREAM -import com.android.systemui.keyguard.shared.model.BiometricUnlockModel.WAKE_AND_UNLOCK_PULSING +import com.android.systemui.keyguard.shared.model.BiometricUnlockModel.Companion.isWakeAndUnlock import com.android.systemui.keyguard.shared.model.KeyguardState import com.android.systemui.keyguard.shared.model.TransitionInfo import com.android.systemui.util.kotlin.sample @@ -42,9 +40,6 @@ constructor( private val keyguardTransitionInteractor: KeyguardTransitionInteractor, ) : TransitionInteractor(AodToGoneTransitionInteractor::class.simpleName!!) { - private val wakeAndUnlockModes = - setOf(WAKE_AND_UNLOCK, WAKE_AND_UNLOCK_FROM_DREAM, WAKE_AND_UNLOCK_PULSING) - override fun start() { scope.launch { keyguardInteractor.biometricUnlockState @@ -52,8 +47,7 @@ constructor( .collect { pair -> val (biometricUnlockState, keyguardState) = pair if ( - keyguardState == KeyguardState.AOD && - wakeAndUnlockModes.contains(biometricUnlockState) + keyguardState == KeyguardState.AOD && isWakeAndUnlock(biometricUnlockState) ) { keyguardTransitionRepository.startTransition( TransitionInfo( diff --git a/packages/SystemUI/src/com/android/systemui/keyguard/domain/interactor/DreamingLockscreenTransitionInteractor.kt b/packages/SystemUI/src/com/android/systemui/keyguard/domain/interactor/DreamingLockscreenTransitionInteractor.kt deleted file mode 100644 index 9cbf9eac686ac..0000000000000 --- a/packages/SystemUI/src/com/android/systemui/keyguard/domain/interactor/DreamingLockscreenTransitionInteractor.kt +++ /dev/null @@ -1,94 +0,0 @@ -/* - * Copyright (C) 2022 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License - */ - -package com.android.systemui.keyguard.domain.interactor - -import android.animation.ValueAnimator -import com.android.systemui.animation.Interpolators -import com.android.systemui.dagger.SysUISingleton -import com.android.systemui.dagger.qualifiers.Application -import com.android.systemui.keyguard.data.repository.KeyguardTransitionRepository -import com.android.systemui.keyguard.shared.model.DozeStateModel -import com.android.systemui.keyguard.shared.model.KeyguardState -import com.android.systemui.keyguard.shared.model.TransitionInfo -import com.android.systemui.util.kotlin.sample -import javax.inject.Inject -import kotlinx.coroutines.CoroutineScope -import kotlinx.coroutines.flow.collect -import kotlinx.coroutines.flow.combine -import kotlinx.coroutines.launch - -@SysUISingleton -class DreamingLockscreenTransitionInteractor -@Inject -constructor( - @Application private val scope: CoroutineScope, - private val keyguardInteractor: KeyguardInteractor, - private val keyguardTransitionRepository: KeyguardTransitionRepository, - private val keyguardTransitionInteractor: KeyguardTransitionInteractor, -) : TransitionInteractor(DreamingLockscreenTransitionInteractor::class.simpleName!!) { - - override fun start() { - scope.launch { - keyguardInteractor.isDreaming - .sample( - combine( - keyguardInteractor.dozeTransitionModel, - keyguardTransitionInteractor.finishedKeyguardState - ) { a, b -> Pair(a, b) }, - { a, bc -> Triple(a, bc.first, bc.second) } - ) - .collect { triple -> - val (isDreaming, dozeTransitionModel, keyguardState) = triple - // Dozing/AOD and dreaming have overlapping events. If the state remains in - // FINISH, it means that doze mode is not running and DREAMING is ok to - // commence. - if (dozeTransitionModel.to == DozeStateModel.FINISH) { - if (isDreaming && keyguardState == KeyguardState.LOCKSCREEN) { - keyguardTransitionRepository.startTransition( - TransitionInfo( - name, - KeyguardState.LOCKSCREEN, - KeyguardState.DREAMING, - getAnimator(), - ) - ) - } else if (!isDreaming && keyguardState == KeyguardState.DREAMING) { - keyguardTransitionRepository.startTransition( - TransitionInfo( - name, - KeyguardState.DREAMING, - KeyguardState.LOCKSCREEN, - getAnimator(), - ) - ) - } - } - } - } - } - - private fun getAnimator(): ValueAnimator { - return ValueAnimator().apply { - setInterpolator(Interpolators.LINEAR) - setDuration(TRANSITION_DURATION_MS) - } - } - - companion object { - private const val TRANSITION_DURATION_MS = 500L - } -} diff --git a/packages/SystemUI/src/com/android/systemui/keyguard/domain/interactor/DreamingToAodTransitionInteractor.kt b/packages/SystemUI/src/com/android/systemui/keyguard/domain/interactor/DreamingToAodTransitionInteractor.kt deleted file mode 100644 index e34981eabcac0..0000000000000 --- a/packages/SystemUI/src/com/android/systemui/keyguard/domain/interactor/DreamingToAodTransitionInteractor.kt +++ /dev/null @@ -1,76 +0,0 @@ -/* - * Copyright (C) 2022 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License - */ - -package com.android.systemui.keyguard.domain.interactor - -import android.animation.ValueAnimator -import com.android.systemui.animation.Interpolators -import com.android.systemui.dagger.SysUISingleton -import com.android.systemui.dagger.qualifiers.Application -import com.android.systemui.keyguard.data.repository.KeyguardTransitionRepository -import com.android.systemui.keyguard.shared.model.KeyguardState -import com.android.systemui.keyguard.shared.model.TransitionInfo -import com.android.systemui.keyguard.shared.model.WakefulnessModel.Companion.isSleepingOrStartingToSleep -import com.android.systemui.util.kotlin.sample -import javax.inject.Inject -import kotlinx.coroutines.CoroutineScope -import kotlinx.coroutines.flow.collect -import kotlinx.coroutines.launch - -@SysUISingleton -class DreamingToAodTransitionInteractor -@Inject -constructor( - @Application private val scope: CoroutineScope, - private val keyguardInteractor: KeyguardInteractor, - private val keyguardTransitionRepository: KeyguardTransitionRepository, - private val keyguardTransitionInteractor: KeyguardTransitionInteractor, -) : TransitionInteractor("DREAMING->AOD") { - - override fun start() { - scope.launch { - keyguardInteractor.wakefulnessModel - .sample(keyguardTransitionInteractor.finishedKeyguardState, { a, b -> Pair(a, b) }) - .collect { pair -> - val (wakefulnessState, keyguardState) = pair - if ( - isSleepingOrStartingToSleep(wakefulnessState) && - keyguardState == KeyguardState.DREAMING - ) { - keyguardTransitionRepository.startTransition( - TransitionInfo( - name, - KeyguardState.DREAMING, - KeyguardState.AOD, - getAnimator(), - ) - ) - } - } - } - } - - private fun getAnimator(): ValueAnimator { - return ValueAnimator().apply { - setInterpolator(Interpolators.LINEAR) - setDuration(TRANSITION_DURATION_MS) - } - } - - companion object { - private const val TRANSITION_DURATION_MS = 300L - } -} diff --git a/packages/SystemUI/src/com/android/systemui/keyguard/domain/interactor/DreamingTransitionInteractor.kt b/packages/SystemUI/src/com/android/systemui/keyguard/domain/interactor/DreamingTransitionInteractor.kt new file mode 100644 index 0000000000000..b73ce9e5689c9 --- /dev/null +++ b/packages/SystemUI/src/com/android/systemui/keyguard/domain/interactor/DreamingTransitionInteractor.kt @@ -0,0 +1,180 @@ +/* + * Copyright (C) 2022 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License + */ + +package com.android.systemui.keyguard.domain.interactor + +import android.animation.ValueAnimator +import com.android.systemui.animation.Interpolators +import com.android.systemui.dagger.SysUISingleton +import com.android.systemui.dagger.qualifiers.Application +import com.android.systemui.keyguard.data.repository.KeyguardTransitionRepository +import com.android.systemui.keyguard.shared.model.BiometricUnlockModel.Companion.isWakeAndUnlock +import com.android.systemui.keyguard.shared.model.DozeStateModel +import com.android.systemui.keyguard.shared.model.DozeStateModel.Companion.isDozeOff +import com.android.systemui.keyguard.shared.model.KeyguardState +import com.android.systemui.keyguard.shared.model.TransitionInfo +import com.android.systemui.util.kotlin.sample +import javax.inject.Inject +import kotlinx.coroutines.CoroutineScope +import kotlinx.coroutines.flow.collect +import kotlinx.coroutines.flow.combine +import kotlinx.coroutines.launch + +@SysUISingleton +class DreamingTransitionInteractor +@Inject +constructor( + @Application private val scope: CoroutineScope, + private val keyguardInteractor: KeyguardInteractor, + private val keyguardTransitionRepository: KeyguardTransitionRepository, + private val keyguardTransitionInteractor: KeyguardTransitionInteractor, +) : TransitionInteractor(DreamingTransitionInteractor::class.simpleName!!) { + + private val canDreamFrom = + setOf(KeyguardState.LOCKSCREEN, KeyguardState.GONE, KeyguardState.DOZING) + + override fun start() { + listenForEntryToDreaming() + listenForDreamingToLockscreen() + listenForDreamingToGone() + listenForDreamingToDozing() + } + + private fun listenForEntryToDreaming() { + scope.launch { + keyguardInteractor.isDreaming + .sample( + combine( + keyguardInteractor.dozeTransitionModel, + keyguardTransitionInteractor.finishedKeyguardState, + ::Pair + ), + ::toTriple + ) + .collect { triple -> + val (isDreaming, dozeTransitionModel, keyguardState) = triple + // Dozing/AOD and dreaming have overlapping events. If the state remains in + // FINISH, it means that doze mode is not running and DREAMING is ok to + // commence. + if ( + isDozeOff(dozeTransitionModel.to) && + isDreaming && + canDreamFrom.contains(keyguardState) + ) { + keyguardTransitionRepository.startTransition( + TransitionInfo( + name, + keyguardState, + KeyguardState.DREAMING, + getAnimator(), + ) + ) + } + } + } + } + + private fun listenForDreamingToLockscreen() { + scope.launch { + keyguardInteractor.isDreaming + .sample( + combine( + keyguardInteractor.dozeTransitionModel, + keyguardTransitionInteractor.startedKeyguardTransitionStep, + ::Pair, + ), + ::toTriple + ) + .collect { triple -> + val (isDreaming, dozeTransitionModel, lastStartedTransition) = triple + if ( + isDozeOff(dozeTransitionModel.to) && + !isDreaming && + lastStartedTransition.to == KeyguardState.DREAMING + ) { + keyguardTransitionRepository.startTransition( + TransitionInfo( + name, + KeyguardState.DREAMING, + KeyguardState.LOCKSCREEN, + getAnimator(), + ) + ) + } + } + } + } + + private fun listenForDreamingToGone() { + scope.launch { + keyguardInteractor.biometricUnlockState + .sample(keyguardTransitionInteractor.finishedKeyguardState, ::Pair) + .collect { pair -> + val (biometricUnlockState, keyguardState) = pair + if ( + keyguardState == KeyguardState.DREAMING && + isWakeAndUnlock(biometricUnlockState) + ) { + keyguardTransitionRepository.startTransition( + TransitionInfo( + name, + KeyguardState.DREAMING, + KeyguardState.GONE, + getAnimator(), + ) + ) + } + } + } + } + + private fun listenForDreamingToDozing() { + scope.launch { + combine( + keyguardInteractor.dozeTransitionModel, + keyguardTransitionInteractor.finishedKeyguardState, + ::Pair + ) + .collect { pair -> + val (dozeTransitionModel, keyguardState) = pair + if ( + dozeTransitionModel.to == DozeStateModel.DOZE && + keyguardState == KeyguardState.DREAMING + ) { + keyguardTransitionRepository.startTransition( + TransitionInfo( + name, + KeyguardState.DREAMING, + KeyguardState.DOZING, + getAnimator(), + ) + ) + } + } + } + } + + private fun getAnimator(): ValueAnimator { + return ValueAnimator().apply { + setInterpolator(Interpolators.LINEAR) + setDuration(TRANSITION_DURATION_MS) + } + } + + companion object { + private const val TRANSITION_DURATION_MS = 500L + } +} diff --git a/packages/SystemUI/src/com/android/systemui/keyguard/domain/interactor/GoneAodTransitionInteractor.kt b/packages/SystemUI/src/com/android/systemui/keyguard/domain/interactor/GoneAodTransitionInteractor.kt index 483041a1b2365..a50e75909dd89 100644 --- a/packages/SystemUI/src/com/android/systemui/keyguard/domain/interactor/GoneAodTransitionInteractor.kt +++ b/packages/SystemUI/src/com/android/systemui/keyguard/domain/interactor/GoneAodTransitionInteractor.kt @@ -37,7 +37,7 @@ constructor( private val keyguardInteractor: KeyguardInteractor, private val keyguardTransitionRepository: KeyguardTransitionRepository, private val keyguardTransitionInteractor: KeyguardTransitionInteractor, -) : TransitionInteractor("GONE->AOD") { +) : TransitionInteractor(GoneAodTransitionInteractor::class.simpleName!!) { override fun start() { scope.launch { diff --git a/packages/SystemUI/src/com/android/systemui/keyguard/domain/interactor/KeyguardTransitionAuditLogger.kt b/packages/SystemUI/src/com/android/systemui/keyguard/domain/interactor/KeyguardTransitionAuditLogger.kt index e30e7f6ece110..a2661d76d90d9 100644 --- a/packages/SystemUI/src/com/android/systemui/keyguard/domain/interactor/KeyguardTransitionAuditLogger.kt +++ b/packages/SystemUI/src/com/android/systemui/keyguard/domain/interactor/KeyguardTransitionAuditLogger.kt @@ -46,6 +46,8 @@ constructor( scope.launch { keyguardInteractor.isDozing.collect { logger.v("isDozing", it) } } + scope.launch { keyguardInteractor.isDreaming.collect { logger.v("isDreaming", it) } } + scope.launch { interactor.finishedKeyguardTransitionStep.collect { logger.i("Finished transition", it) @@ -61,5 +63,9 @@ constructor( scope.launch { interactor.startedKeyguardTransitionStep.collect { logger.i("Started transition", it) } } + + scope.launch { + keyguardInteractor.dozeTransitionModel.collect { logger.i("Doze transition", it) } + } } } diff --git a/packages/SystemUI/src/com/android/systemui/keyguard/domain/interactor/KeyguardTransitionCoreStartable.kt b/packages/SystemUI/src/com/android/systemui/keyguard/domain/interactor/KeyguardTransitionCoreStartable.kt index 43dd358e4808a..bb8b79a3aa6b3 100644 --- a/packages/SystemUI/src/com/android/systemui/keyguard/domain/interactor/KeyguardTransitionCoreStartable.kt +++ b/packages/SystemUI/src/com/android/systemui/keyguard/domain/interactor/KeyguardTransitionCoreStartable.kt @@ -43,8 +43,7 @@ constructor( is LockscreenGoneTransitionInteractor -> Log.d(TAG, "Started $it") is AodToGoneTransitionInteractor -> Log.d(TAG, "Started $it") is BouncerToGoneTransitionInteractor -> Log.d(TAG, "Started $it") - is DreamingLockscreenTransitionInteractor -> Log.d(TAG, "Started $it") - is DreamingToAodTransitionInteractor -> Log.d(TAG, "Started $it") + is DreamingTransitionInteractor -> Log.d(TAG, "Started $it") } it.start() } diff --git a/packages/SystemUI/src/com/android/systemui/keyguard/domain/interactor/LockscreenGoneTransitionInteractor.kt b/packages/SystemUI/src/com/android/systemui/keyguard/domain/interactor/LockscreenGoneTransitionInteractor.kt index 4100f7a8413a0..95d96025cf4ac 100644 --- a/packages/SystemUI/src/com/android/systemui/keyguard/domain/interactor/LockscreenGoneTransitionInteractor.kt +++ b/packages/SystemUI/src/com/android/systemui/keyguard/domain/interactor/LockscreenGoneTransitionInteractor.kt @@ -37,15 +37,15 @@ constructor( private val keyguardInteractor: KeyguardInteractor, private val keyguardTransitionInteractor: KeyguardTransitionInteractor, private val keyguardTransitionRepository: KeyguardTransitionRepository, -) : TransitionInteractor("LOCKSCREEN->GONE") { +) : TransitionInteractor(LockscreenGoneTransitionInteractor::class.simpleName!!) { override fun start() { scope.launch { keyguardInteractor.isKeyguardGoingAway - .sample(keyguardTransitionInteractor.finishedKeyguardState, { a, b -> Pair(a, b) }) + .sample(keyguardTransitionInteractor.startedKeyguardTransitionStep, ::Pair) .collect { pair -> - val (isKeyguardGoingAway, keyguardState) = pair - if (!isKeyguardGoingAway && keyguardState == KeyguardState.LOCKSCREEN) { + val (isKeyguardGoingAway, lastStartedStep) = pair + if (isKeyguardGoingAway && lastStartedStep.to == KeyguardState.LOCKSCREEN) { keyguardTransitionRepository.startTransition( TransitionInfo( name, diff --git a/packages/SystemUI/src/com/android/systemui/keyguard/domain/interactor/StartKeyguardTransitionModule.kt b/packages/SystemUI/src/com/android/systemui/keyguard/domain/interactor/StartKeyguardTransitionModule.kt index dbffeab436a4b..5f63ae7658543 100644 --- a/packages/SystemUI/src/com/android/systemui/keyguard/domain/interactor/StartKeyguardTransitionModule.kt +++ b/packages/SystemUI/src/com/android/systemui/keyguard/domain/interactor/StartKeyguardTransitionModule.kt @@ -52,13 +52,5 @@ abstract class StartKeyguardTransitionModule { @IntoSet abstract fun lockscreenGone(impl: LockscreenGoneTransitionInteractor): TransitionInteractor - @Binds - @IntoSet - abstract fun dreamingLockscreen( - impl: DreamingLockscreenTransitionInteractor - ): TransitionInteractor - - @Binds - @IntoSet - abstract fun dreamingToAod(impl: DreamingToAodTransitionInteractor): TransitionInteractor + @Binds @IntoSet abstract fun dreaming(impl: DreamingTransitionInteractor): TransitionInteractor } diff --git a/packages/SystemUI/src/com/android/systemui/keyguard/domain/interactor/TransitionInteractor.kt b/packages/SystemUI/src/com/android/systemui/keyguard/domain/interactor/TransitionInteractor.kt index a2a46d9e3a71c..08ad3d5bdbf65 100644 --- a/packages/SystemUI/src/com/android/systemui/keyguard/domain/interactor/TransitionInteractor.kt +++ b/packages/SystemUI/src/com/android/systemui/keyguard/domain/interactor/TransitionInteractor.kt @@ -29,4 +29,6 @@ package com.android.systemui.keyguard.domain.interactor sealed class TransitionInteractor(val name: String) { abstract fun start() + + fun toTriple(a: A, bc: Pair) = Triple(a, bc.first, bc.second) } diff --git a/packages/SystemUI/src/com/android/systemui/keyguard/shared/model/BiometricUnlockModel.kt b/packages/SystemUI/src/com/android/systemui/keyguard/shared/model/BiometricUnlockModel.kt index db709b476c5d3..8fe6309fc0052 100644 --- a/packages/SystemUI/src/com/android/systemui/keyguard/shared/model/BiometricUnlockModel.kt +++ b/packages/SystemUI/src/com/android/systemui/keyguard/shared/model/BiometricUnlockModel.kt @@ -46,5 +46,14 @@ enum class BiometricUnlockModel { /** When bouncer is visible and will be dismissed. */ DISMISS_BOUNCER, /** Mode in which fingerprint wakes and unlocks the device from a dream. */ - WAKE_AND_UNLOCK_FROM_DREAM, + WAKE_AND_UNLOCK_FROM_DREAM; + + companion object { + private val wakeAndUnlockModes = + setOf(WAKE_AND_UNLOCK, WAKE_AND_UNLOCK_FROM_DREAM, WAKE_AND_UNLOCK_PULSING) + + fun isWakeAndUnlock(model: BiometricUnlockModel): Boolean { + return wakeAndUnlockModes.contains(model) + } + } } diff --git a/packages/SystemUI/src/com/android/systemui/keyguard/shared/model/DozeStateModel.kt b/packages/SystemUI/src/com/android/systemui/keyguard/shared/model/DozeStateModel.kt index 7039188d9e964..65b7cf732f9d5 100644 --- a/packages/SystemUI/src/com/android/systemui/keyguard/shared/model/DozeStateModel.kt +++ b/packages/SystemUI/src/com/android/systemui/keyguard/shared/model/DozeStateModel.kt @@ -42,5 +42,11 @@ enum class DozeStateModel { /** AOD, prox is near, transitions to DOZE_AOD_PAUSED after a timeout. */ DOZE_AOD_PAUSING, /** Always-on doze. Device is awake, showing docking UI and listening for pulse triggers. */ - DOZE_AOD_DOCKED + DOZE_AOD_DOCKED; + + companion object { + fun isDozeOff(model: DozeStateModel): Boolean { + return model == UNINITIALIZED || model == FINISH + } + } } diff --git a/packages/SystemUI/tests/src/com/android/systemui/keyguard/data/repository/KeyguardTransitionRepositoryTest.kt b/packages/SystemUI/tests/src/com/android/systemui/keyguard/data/repository/KeyguardTransitionRepositoryTest.kt index 2b03722f9f311..ce9c1da422f5f 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/keyguard/data/repository/KeyguardTransitionRepositoryTest.kt +++ b/packages/SystemUI/tests/src/com/android/systemui/keyguard/data/repository/KeyguardTransitionRepositoryTest.kt @@ -22,6 +22,7 @@ import android.util.Log import android.util.Log.TerribleFailure import android.util.Log.TerribleFailureHandler import android.view.Choreographer.FrameCallback +import androidx.test.filters.FlakyTest import androidx.test.filters.SmallTest import com.android.systemui.SysuiTestCase import com.android.systemui.animation.Interpolators @@ -97,6 +98,7 @@ class KeyguardTransitionRepositoryTest : SysuiTestCase() { } @Test + @FlakyTest(bugId = 260213291) fun `starting second transition will cancel the first transition`() { runBlocking(IMMEDIATE) { val (animator, provider) = setupAnimator(this) diff --git a/services/core/java/com/android/server/policy/keyguard/KeyguardServiceDelegate.java b/services/core/java/com/android/server/policy/keyguard/KeyguardServiceDelegate.java index 97a57e066fc78..3baaa9d440195 100644 --- a/services/core/java/com/android/server/policy/keyguard/KeyguardServiceDelegate.java +++ b/services/core/java/com/android/server/policy/keyguard/KeyguardServiceDelegate.java @@ -202,6 +202,9 @@ public class KeyguardServiceDelegate { if (!mKeyguardState.enabled) { mKeyguardService.setKeyguardEnabled(mKeyguardState.enabled); } + if (mKeyguardState.dreaming) { + mKeyguardService.onDreamingStarted(); + } } @Override