Loading packages/SystemUI/src/com/android/keyguard/ClockEventController.kt +4 −4 Original line number Diff line number Diff line Loading @@ -228,7 +228,7 @@ open class ClockEventController @Inject constructor( listenForDozing(this) if (featureFlags.isEnabled(DOZING_MIGRATION_1)) { listenForDozeAmountTransition(this) listenForGoneToAodTransition(this) listenForAnyStateToAodTransition(this) } else { listenForDozeAmount(this) } Loading Loading @@ -286,10 +286,10 @@ open class ClockEventController @Inject constructor( * dozing. */ @VisibleForTesting internal fun listenForGoneToAodTransition(scope: CoroutineScope): Job { internal fun listenForAnyStateToAodTransition(scope: CoroutineScope): Job { return scope.launch { keyguardTransitionInteractor.goneToAodTransition.filter { it.transitionState == TransitionState.STARTED keyguardTransitionInteractor.anyStateToAodTransition.filter { it.transitionState == TransitionState.FINISHED }.collect { dozeAmount = 1f clock?.animations?.doze(dozeAmount) Loading packages/SystemUI/src/com/android/keyguard/KeyguardSecurityContainer.java +9 −2 Original line number Diff line number Diff line Loading @@ -106,8 +106,9 @@ public class KeyguardSecurityContainer extends ConstraintLayout { static final int USER_TYPE_WORK_PROFILE = 2; static final int USER_TYPE_SECONDARY_USER = 3; @IntDef({MODE_DEFAULT, MODE_ONE_HANDED, MODE_USER_SWITCHER}) @IntDef({MODE_UNINITIALIZED, MODE_DEFAULT, MODE_ONE_HANDED, MODE_USER_SWITCHER}) public @interface Mode {} static final int MODE_UNINITIALIZED = -1; static final int MODE_DEFAULT = 0; static final int MODE_ONE_HANDED = 1; static final int MODE_USER_SWITCHER = 2; Loading Loading @@ -154,7 +155,11 @@ public class KeyguardSecurityContainer extends ConstraintLayout { private boolean mDisappearAnimRunning; private SwipeListener mSwipeListener; private ViewMode mViewMode = new DefaultViewMode(); private @Mode int mCurrentMode = MODE_DEFAULT; /* * Using MODE_UNINITIALIZED to mean the view mode is set to DefaultViewMode, but init() has not * yet been called on it. This will happen when the ViewController is initialized. */ private @Mode int mCurrentMode = MODE_UNINITIALIZED; private int mWidth = -1; private final WindowInsetsAnimation.Callback mWindowInsetsAnimationCallback = Loading Loading @@ -347,6 +352,8 @@ public class KeyguardSecurityContainer extends ConstraintLayout { private String modeToString(@Mode int mode) { switch (mode) { case MODE_UNINITIALIZED: return "Uninitialized"; case MODE_DEFAULT: return "Default"; case MODE_ONE_HANDED: Loading packages/SystemUI/src/com/android/keyguard/KeyguardSecurityContainerController.java +1 −0 Original line number Diff line number Diff line Loading @@ -318,6 +318,7 @@ public class KeyguardSecurityContainerController extends ViewController<Keyguard @Override public void onInit() { mSecurityViewFlipperController.init(); configureMode(); } @Override Loading packages/SystemUI/src/com/android/systemui/keyguard/data/repository/KeyguardRepository.kt +65 −0 Original line number Diff line number Diff line Loading @@ -23,9 +23,12 @@ import com.android.systemui.dagger.SysUISingleton import com.android.systemui.doze.DozeHost import com.android.systemui.keyguard.WakefulnessLifecycle import com.android.systemui.keyguard.WakefulnessLifecycle.Wakefulness import com.android.systemui.keyguard.shared.model.BiometricUnlockModel import com.android.systemui.keyguard.shared.model.StatusBarState import com.android.systemui.keyguard.shared.model.WakefulnessModel import com.android.systemui.plugins.statusbar.StatusBarStateController import com.android.systemui.statusbar.phone.BiometricUnlockController import com.android.systemui.statusbar.phone.BiometricUnlockController.WakeAndUnlockMode import com.android.systemui.statusbar.policy.KeyguardStateController import javax.inject.Inject import kotlinx.coroutines.channels.awaitClose Loading Loading @@ -65,6 +68,9 @@ interface KeyguardRepository { */ val isKeyguardShowing: Flow<Boolean> /** Observable for whether the bouncer is showing. */ val isBouncerShowing: Flow<Boolean> /** * Observable for whether we are in doze state. * Loading Loading @@ -95,6 +101,9 @@ interface KeyguardRepository { /** Observable for device wake/sleep state */ val wakefulnessState: Flow<WakefulnessModel> /** Observable for biometric unlock modes */ val biometricUnlockState: Flow<BiometricUnlockModel> /** * Returns `true` if the keyguard is showing; `false` otherwise. * Loading Loading @@ -125,6 +134,7 @@ constructor( private val keyguardStateController: KeyguardStateController, dozeHost: DozeHost, wakefulnessLifecycle: WakefulnessLifecycle, biometricUnlockController: BiometricUnlockController, ) : KeyguardRepository { private val _animateBottomAreaDozingTransitions = MutableStateFlow(false) override val animateBottomAreaDozingTransitions = Loading Loading @@ -159,6 +169,29 @@ constructor( awaitClose { keyguardStateController.removeCallback(callback) } } override val isBouncerShowing: Flow<Boolean> = conflatedCallbackFlow { val callback = object : KeyguardStateController.Callback { override fun onBouncerShowingChanged() { trySendWithFailureLogging( keyguardStateController.isBouncerShowing, TAG, "updated isBouncerShowing" ) } } keyguardStateController.addCallback(callback) // Adding the callback does not send an initial update. trySendWithFailureLogging( keyguardStateController.isBouncerShowing, TAG, "initial isBouncerShowing" ) awaitClose { keyguardStateController.removeCallback(callback) } } override val isDozing: Flow<Boolean> = conflatedCallbackFlow { val callback = Loading Loading @@ -248,6 +281,24 @@ constructor( awaitClose { wakefulnessLifecycle.removeObserver(callback) } } override val biometricUnlockState: Flow<BiometricUnlockModel> = conflatedCallbackFlow { val callback = object : BiometricUnlockController.BiometricModeListener { override fun onModeChanged(@WakeAndUnlockMode mode: Int) { trySendWithFailureLogging(biometricModeIntToObject(mode), TAG, "biometric mode") } } biometricUnlockController.addBiometricModeListener(callback) trySendWithFailureLogging( biometricModeIntToObject(biometricUnlockController.getMode()), TAG, "initial biometric mode" ) awaitClose { biometricUnlockController.removeBiometricModeListener(callback) } } override fun setAnimateDozingTransitions(animate: Boolean) { _animateBottomAreaDozingTransitions.value = animate } Loading Loading @@ -279,6 +330,20 @@ constructor( } } private fun biometricModeIntToObject(@WakeAndUnlockMode value: Int): BiometricUnlockModel { return when (value) { 0 -> BiometricUnlockModel.NONE 1 -> BiometricUnlockModel.WAKE_AND_UNLOCK 2 -> BiometricUnlockModel.WAKE_AND_UNLOCK_PULSING 3 -> BiometricUnlockModel.SHOW_BOUNCER 4 -> BiometricUnlockModel.ONLY_WAKE 5 -> BiometricUnlockModel.UNLOCK_COLLAPSING 6 -> BiometricUnlockModel.WAKE_AND_UNLOCK_FROM_DREAM 7 -> BiometricUnlockModel.DISMISS_BOUNCER else -> throw IllegalArgumentException("Invalid BiometricUnlockModel value: $value") } } companion object { private const val TAG = "KeyguardRepositoryImpl" } Loading packages/SystemUI/src/com/android/systemui/keyguard/domain/interactor/AodToGoneTransitionInteractor.kt 0 → 100644 +81 −0 Original line number Diff line number Diff line /* * 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.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.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.launch @SysUISingleton class AodToGoneTransitionInteractor @Inject constructor( @Application private val scope: CoroutineScope, private val keyguardInteractor: KeyguardInteractor, private val keyguardTransitionRepository: KeyguardTransitionRepository, private val keyguardTransitionInteractor: KeyguardTransitionInteractor, ) : TransitionInteractor("AOD->GONE") { private val wakeAndUnlockModes = setOf(WAKE_AND_UNLOCK, WAKE_AND_UNLOCK_FROM_DREAM, WAKE_AND_UNLOCK_PULSING) override fun start() { scope.launch { keyguardInteractor.biometricUnlockState .sample(keyguardTransitionInteractor.finishedKeyguardState, { a, b -> Pair(a, b) }) .collect { pair -> val (biometricUnlockState, keyguardState) = pair if ( keyguardState == KeyguardState.AOD && wakeAndUnlockModes.contains(biometricUnlockState) ) { keyguardTransitionRepository.startTransition( TransitionInfo( name, KeyguardState.AOD, KeyguardState.GONE, getAnimator(), ) ) } } } } private fun getAnimator(): ValueAnimator { return ValueAnimator().apply { setInterpolator(Interpolators.LINEAR) setDuration(TRANSITION_DURATION_MS) } } companion object { private const val TRANSITION_DURATION_MS = 500L } } Loading
packages/SystemUI/src/com/android/keyguard/ClockEventController.kt +4 −4 Original line number Diff line number Diff line Loading @@ -228,7 +228,7 @@ open class ClockEventController @Inject constructor( listenForDozing(this) if (featureFlags.isEnabled(DOZING_MIGRATION_1)) { listenForDozeAmountTransition(this) listenForGoneToAodTransition(this) listenForAnyStateToAodTransition(this) } else { listenForDozeAmount(this) } Loading Loading @@ -286,10 +286,10 @@ open class ClockEventController @Inject constructor( * dozing. */ @VisibleForTesting internal fun listenForGoneToAodTransition(scope: CoroutineScope): Job { internal fun listenForAnyStateToAodTransition(scope: CoroutineScope): Job { return scope.launch { keyguardTransitionInteractor.goneToAodTransition.filter { it.transitionState == TransitionState.STARTED keyguardTransitionInteractor.anyStateToAodTransition.filter { it.transitionState == TransitionState.FINISHED }.collect { dozeAmount = 1f clock?.animations?.doze(dozeAmount) Loading
packages/SystemUI/src/com/android/keyguard/KeyguardSecurityContainer.java +9 −2 Original line number Diff line number Diff line Loading @@ -106,8 +106,9 @@ public class KeyguardSecurityContainer extends ConstraintLayout { static final int USER_TYPE_WORK_PROFILE = 2; static final int USER_TYPE_SECONDARY_USER = 3; @IntDef({MODE_DEFAULT, MODE_ONE_HANDED, MODE_USER_SWITCHER}) @IntDef({MODE_UNINITIALIZED, MODE_DEFAULT, MODE_ONE_HANDED, MODE_USER_SWITCHER}) public @interface Mode {} static final int MODE_UNINITIALIZED = -1; static final int MODE_DEFAULT = 0; static final int MODE_ONE_HANDED = 1; static final int MODE_USER_SWITCHER = 2; Loading Loading @@ -154,7 +155,11 @@ public class KeyguardSecurityContainer extends ConstraintLayout { private boolean mDisappearAnimRunning; private SwipeListener mSwipeListener; private ViewMode mViewMode = new DefaultViewMode(); private @Mode int mCurrentMode = MODE_DEFAULT; /* * Using MODE_UNINITIALIZED to mean the view mode is set to DefaultViewMode, but init() has not * yet been called on it. This will happen when the ViewController is initialized. */ private @Mode int mCurrentMode = MODE_UNINITIALIZED; private int mWidth = -1; private final WindowInsetsAnimation.Callback mWindowInsetsAnimationCallback = Loading Loading @@ -347,6 +352,8 @@ public class KeyguardSecurityContainer extends ConstraintLayout { private String modeToString(@Mode int mode) { switch (mode) { case MODE_UNINITIALIZED: return "Uninitialized"; case MODE_DEFAULT: return "Default"; case MODE_ONE_HANDED: Loading
packages/SystemUI/src/com/android/keyguard/KeyguardSecurityContainerController.java +1 −0 Original line number Diff line number Diff line Loading @@ -318,6 +318,7 @@ public class KeyguardSecurityContainerController extends ViewController<Keyguard @Override public void onInit() { mSecurityViewFlipperController.init(); configureMode(); } @Override Loading
packages/SystemUI/src/com/android/systemui/keyguard/data/repository/KeyguardRepository.kt +65 −0 Original line number Diff line number Diff line Loading @@ -23,9 +23,12 @@ import com.android.systemui.dagger.SysUISingleton import com.android.systemui.doze.DozeHost import com.android.systemui.keyguard.WakefulnessLifecycle import com.android.systemui.keyguard.WakefulnessLifecycle.Wakefulness import com.android.systemui.keyguard.shared.model.BiometricUnlockModel import com.android.systemui.keyguard.shared.model.StatusBarState import com.android.systemui.keyguard.shared.model.WakefulnessModel import com.android.systemui.plugins.statusbar.StatusBarStateController import com.android.systemui.statusbar.phone.BiometricUnlockController import com.android.systemui.statusbar.phone.BiometricUnlockController.WakeAndUnlockMode import com.android.systemui.statusbar.policy.KeyguardStateController import javax.inject.Inject import kotlinx.coroutines.channels.awaitClose Loading Loading @@ -65,6 +68,9 @@ interface KeyguardRepository { */ val isKeyguardShowing: Flow<Boolean> /** Observable for whether the bouncer is showing. */ val isBouncerShowing: Flow<Boolean> /** * Observable for whether we are in doze state. * Loading Loading @@ -95,6 +101,9 @@ interface KeyguardRepository { /** Observable for device wake/sleep state */ val wakefulnessState: Flow<WakefulnessModel> /** Observable for biometric unlock modes */ val biometricUnlockState: Flow<BiometricUnlockModel> /** * Returns `true` if the keyguard is showing; `false` otherwise. * Loading Loading @@ -125,6 +134,7 @@ constructor( private val keyguardStateController: KeyguardStateController, dozeHost: DozeHost, wakefulnessLifecycle: WakefulnessLifecycle, biometricUnlockController: BiometricUnlockController, ) : KeyguardRepository { private val _animateBottomAreaDozingTransitions = MutableStateFlow(false) override val animateBottomAreaDozingTransitions = Loading Loading @@ -159,6 +169,29 @@ constructor( awaitClose { keyguardStateController.removeCallback(callback) } } override val isBouncerShowing: Flow<Boolean> = conflatedCallbackFlow { val callback = object : KeyguardStateController.Callback { override fun onBouncerShowingChanged() { trySendWithFailureLogging( keyguardStateController.isBouncerShowing, TAG, "updated isBouncerShowing" ) } } keyguardStateController.addCallback(callback) // Adding the callback does not send an initial update. trySendWithFailureLogging( keyguardStateController.isBouncerShowing, TAG, "initial isBouncerShowing" ) awaitClose { keyguardStateController.removeCallback(callback) } } override val isDozing: Flow<Boolean> = conflatedCallbackFlow { val callback = Loading Loading @@ -248,6 +281,24 @@ constructor( awaitClose { wakefulnessLifecycle.removeObserver(callback) } } override val biometricUnlockState: Flow<BiometricUnlockModel> = conflatedCallbackFlow { val callback = object : BiometricUnlockController.BiometricModeListener { override fun onModeChanged(@WakeAndUnlockMode mode: Int) { trySendWithFailureLogging(biometricModeIntToObject(mode), TAG, "biometric mode") } } biometricUnlockController.addBiometricModeListener(callback) trySendWithFailureLogging( biometricModeIntToObject(biometricUnlockController.getMode()), TAG, "initial biometric mode" ) awaitClose { biometricUnlockController.removeBiometricModeListener(callback) } } override fun setAnimateDozingTransitions(animate: Boolean) { _animateBottomAreaDozingTransitions.value = animate } Loading Loading @@ -279,6 +330,20 @@ constructor( } } private fun biometricModeIntToObject(@WakeAndUnlockMode value: Int): BiometricUnlockModel { return when (value) { 0 -> BiometricUnlockModel.NONE 1 -> BiometricUnlockModel.WAKE_AND_UNLOCK 2 -> BiometricUnlockModel.WAKE_AND_UNLOCK_PULSING 3 -> BiometricUnlockModel.SHOW_BOUNCER 4 -> BiometricUnlockModel.ONLY_WAKE 5 -> BiometricUnlockModel.UNLOCK_COLLAPSING 6 -> BiometricUnlockModel.WAKE_AND_UNLOCK_FROM_DREAM 7 -> BiometricUnlockModel.DISMISS_BOUNCER else -> throw IllegalArgumentException("Invalid BiometricUnlockModel value: $value") } } companion object { private const val TAG = "KeyguardRepositoryImpl" } Loading
packages/SystemUI/src/com/android/systemui/keyguard/domain/interactor/AodToGoneTransitionInteractor.kt 0 → 100644 +81 −0 Original line number Diff line number Diff line /* * 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.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.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.launch @SysUISingleton class AodToGoneTransitionInteractor @Inject constructor( @Application private val scope: CoroutineScope, private val keyguardInteractor: KeyguardInteractor, private val keyguardTransitionRepository: KeyguardTransitionRepository, private val keyguardTransitionInteractor: KeyguardTransitionInteractor, ) : TransitionInteractor("AOD->GONE") { private val wakeAndUnlockModes = setOf(WAKE_AND_UNLOCK, WAKE_AND_UNLOCK_FROM_DREAM, WAKE_AND_UNLOCK_PULSING) override fun start() { scope.launch { keyguardInteractor.biometricUnlockState .sample(keyguardTransitionInteractor.finishedKeyguardState, { a, b -> Pair(a, b) }) .collect { pair -> val (biometricUnlockState, keyguardState) = pair if ( keyguardState == KeyguardState.AOD && wakeAndUnlockModes.contains(biometricUnlockState) ) { keyguardTransitionRepository.startTransition( TransitionInfo( name, KeyguardState.AOD, KeyguardState.GONE, getAnimator(), ) ) } } } } private fun getAnimator(): ValueAnimator { return ValueAnimator().apply { setInterpolator(Interpolators.LINEAR) setDuration(TRANSITION_DURATION_MS) } } companion object { private const val TRANSITION_DURATION_MS = 500L } }