diff --git a/packages/SystemUI/src/com/android/keyguard/KeyguardListenModel.kt b/packages/SystemUI/src/com/android/keyguard/KeyguardListenModel.kt index 36fe5ba1a8511..65412066651ed 100644 --- a/packages/SystemUI/src/com/android/keyguard/KeyguardListenModel.kt +++ b/packages/SystemUI/src/com/android/keyguard/KeyguardListenModel.kt @@ -21,7 +21,7 @@ data class KeyguardFingerprintListenModel( override val listening: Boolean, // keep sorted val biometricEnabledForUser: Boolean, - val bouncer: Boolean, + val bouncerIsOrWillShow: Boolean, val canSkipBouncer: Boolean, val credentialAttempted: Boolean, val deviceInteractive: Boolean, @@ -51,7 +51,7 @@ data class KeyguardFaceListenModel( val authInterruptActive: Boolean, val becauseCannotSkipBouncer: Boolean, val biometricSettingEnabledForUser: Boolean, - val bouncer: Boolean, + val bouncerFullyShown: Boolean, val faceAuthenticated: Boolean, val faceDisabled: Boolean, val keyguardAwake: Boolean, diff --git a/packages/SystemUI/src/com/android/keyguard/KeyguardUpdateMonitor.java b/packages/SystemUI/src/com/android/keyguard/KeyguardUpdateMonitor.java index 3b8a29bfe8c46..9ba5149248bed 100644 --- a/packages/SystemUI/src/com/android/keyguard/KeyguardUpdateMonitor.java +++ b/packages/SystemUI/src/com/android/keyguard/KeyguardUpdateMonitor.java @@ -275,7 +275,8 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener, Dumpab private boolean mCredentialAttempted; private boolean mKeyguardGoingAway; private boolean mGoingToSleep; - private boolean mBouncer; // true if bouncerIsOrWillBeShowing + private boolean mBouncerFullyShown; + private boolean mBouncerIsOrWillBeShowing; private boolean mAuthInterruptActive; private boolean mNeedsSlowUnlockTransition; private boolean mAssistantVisible; @@ -1865,7 +1866,7 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener, Dumpab handleKeyguardReset(); break; case MSG_KEYGUARD_BOUNCER_CHANGED: - handleKeyguardBouncerChanged(msg.arg1); + handleKeyguardBouncerChanged(msg.arg1, msg.arg2); break; case MSG_USER_INFO_CHANGED: handleUserInfoChanged(msg.arg1); @@ -2355,7 +2356,7 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener, Dumpab final boolean shouldListenKeyguardState = mKeyguardIsVisible || !mDeviceInteractive - || (mBouncer && !mKeyguardGoingAway) + || (mBouncerIsOrWillBeShowing && !mKeyguardGoingAway) || mGoingToSleep || shouldListenForFingerprintAssistant || (mKeyguardOccluded && mIsDreaming) @@ -2375,7 +2376,7 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener, Dumpab && biometricEnabledForUser; final boolean shouldListenBouncerState = - !(mFingerprintLockedOut && mBouncer && mCredentialAttempted); + !(mFingerprintLockedOut && mBouncerIsOrWillBeShowing && mCredentialAttempted); final boolean isEncryptedOrLockdownForUser = isEncryptedOrLockdown(user); final boolean shouldListenUdfpsState = !isUdfps @@ -2394,7 +2395,7 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener, Dumpab user, shouldListen, biometricEnabledForUser, - mBouncer, + mBouncerIsOrWillBeShowing, userCanSkipBouncer, mCredentialAttempted, mDeviceInteractive, @@ -2450,7 +2451,8 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener, Dumpab // Scan even when encrypted or timeout to show a preemptive bouncer when bypassing. // Lock-down mode shouldn't scan, since it is more explicit. - boolean strongAuthAllowsScanning = (!isEncryptedOrTimedOut || canBypass && !mBouncer); + boolean strongAuthAllowsScanning = (!isEncryptedOrTimedOut || canBypass + && !mBouncerFullyShown); // If the device supports face detection (without authentication), allow it to happen // if the device is in lockdown mode. Otherwise, prevent scanning. @@ -2469,8 +2471,8 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener, Dumpab // Only listen if this KeyguardUpdateMonitor belongs to the primary user. There is an // instance of KeyguardUpdateMonitor for each user but KeyguardUpdateMonitor is user-aware. final boolean shouldListen = - (mBouncer || mAuthInterruptActive || mOccludingAppRequestingFace || awakeKeyguard - || shouldListenForFaceAssistant) + (mBouncerFullyShown || mAuthInterruptActive || mOccludingAppRequestingFace + || awakeKeyguard || shouldListenForFaceAssistant) && !mSwitchingUser && !faceDisabledForUser && becauseCannotSkipBouncer && !mKeyguardGoingAway && biometricEnabledForUser && !mLockIconPressed && strongAuthAllowsScanning && mIsPrimaryUser @@ -2488,7 +2490,7 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener, Dumpab mAuthInterruptActive, becauseCannotSkipBouncer, biometricEnabledForUser, - mBouncer, + mBouncerFullyShown, faceAuthenticated, faceDisabledForUser, awakeKeyguard, @@ -3050,13 +3052,21 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener, Dumpab /** * Handle {@link #MSG_KEYGUARD_BOUNCER_CHANGED} * - * @see #sendKeyguardBouncerChanged(boolean) + * @see #sendKeyguardBouncerChanged(boolean, boolean) */ - private void handleKeyguardBouncerChanged(int bouncerVisible) { + private void handleKeyguardBouncerChanged(int bouncerIsOrWillBeShowing, int bouncerFullyShown) { Assert.isMainThread(); - if (DEBUG) Log.d(TAG, "handleKeyguardBouncerChanged(" + bouncerVisible + ")"); - mBouncer = bouncerVisible == 1; - if (mBouncer) { + final boolean wasBouncerIsOrWillBeShowing = mBouncerIsOrWillBeShowing; + final boolean wasBouncerFullyShown = mBouncerFullyShown; + mBouncerIsOrWillBeShowing = bouncerIsOrWillBeShowing == 1; + mBouncerFullyShown = bouncerFullyShown == 1; + if (DEBUG) { + Log.d(TAG, "handleKeyguardBouncerChanged" + + " bouncerIsOrWillBeShowing=" + mBouncerIsOrWillBeShowing + + " bouncerFullyShowing=" + mBouncerFullyShown); + } + + if (mBouncerFullyShown) { // If the bouncer is shown, always clear this flag. This can happen in the following // situations: 1) Default camera with SHOW_WHEN_LOCKED is not chosen yet. 2) Secure // camera requests dismiss keyguard (tapping on photos for example). When these happen, @@ -3066,13 +3076,25 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener, Dumpab mCredentialAttempted = false; } - for (int i = 0; i < mCallbacks.size(); i++) { - KeyguardUpdateMonitorCallback cb = mCallbacks.get(i).get(); - if (cb != null) { - cb.onKeyguardBouncerChanged(mBouncer); + if (wasBouncerIsOrWillBeShowing != mBouncerIsOrWillBeShowing) { + for (int i = 0; i < mCallbacks.size(); i++) { + KeyguardUpdateMonitorCallback cb = mCallbacks.get(i).get(); + if (cb != null) { + cb.onKeyguardBouncerStateChanged(mBouncerIsOrWillBeShowing); + } } + updateFingerprintListeningState(BIOMETRIC_ACTION_UPDATE); + } + + if (wasBouncerFullyShown != mBouncerFullyShown) { + for (int i = 0; i < mCallbacks.size(); i++) { + KeyguardUpdateMonitorCallback cb = mCallbacks.get(i).get(); + if (cb != null) { + cb.onKeyguardBouncerFullyShowingChanged(mBouncerFullyShown); + } + } + updateFaceListeningState(BIOMETRIC_ACTION_UPDATE); } - updateBiometricListeningState(BIOMETRIC_ACTION_UPDATE); } /** @@ -3219,12 +3241,18 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener, Dumpab } /** - * @see #handleKeyguardBouncerChanged(int) + * @see #handleKeyguardBouncerChanged(int, int) */ - public void sendKeyguardBouncerChanged(boolean bouncerIsOrWillBeShowing) { - if (DEBUG) Log.d(TAG, "sendKeyguardBouncerChanged(" + bouncerIsOrWillBeShowing + ")"); + public void sendKeyguardBouncerChanged(boolean bouncerIsOrWillBeShowing, + boolean bouncerFullyShown) { + if (DEBUG) { + Log.d(TAG, "sendKeyguardBouncerChanged" + + " bouncerIsOrWillBeShowing=" + bouncerIsOrWillBeShowing + + " bouncerFullyShown=" + bouncerFullyShown); + } Message message = mHandler.obtainMessage(MSG_KEYGUARD_BOUNCER_CHANGED); message.arg1 = bouncerIsOrWillBeShowing ? 1 : 0; + message.arg2 = bouncerFullyShown ? 1 : 0; message.sendToTarget(); } @@ -3561,7 +3589,7 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener, Dumpab if (isUdfpsSupported()) { pw.println(" udfpsEnrolled=" + isUdfpsEnrolled()); pw.println(" shouldListenForUdfps=" + shouldListenForFingerprint(true)); - pw.println(" bouncerVisible=" + mBouncer); + pw.println(" mBouncerIsOrWillBeShowing=" + mBouncerIsOrWillBeShowing); pw.println(" mStatusBarState=" + StatusBarState.toString(mStatusBarState)); } } @@ -3585,6 +3613,7 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener, Dumpab pw.println(" mFaceLockedOutPermanent=" + mFaceLockedOutPermanent); pw.println(" enabledByUser=" + mBiometricEnabledForUser.get(userId)); pw.println(" mSecureCameraLaunched=" + mSecureCameraLaunched); + pw.println(" mBouncerFullyShown=" + mBouncerFullyShown); } mListenModels.print(pw); diff --git a/packages/SystemUI/src/com/android/keyguard/KeyguardUpdateMonitorCallback.java b/packages/SystemUI/src/com/android/keyguard/KeyguardUpdateMonitorCallback.java index 9373ea8f459c6..2620195ae8c43 100644 --- a/packages/SystemUI/src/com/android/keyguard/KeyguardUpdateMonitorCallback.java +++ b/packages/SystemUI/src/com/android/keyguard/KeyguardUpdateMonitorCallback.java @@ -97,10 +97,16 @@ public class KeyguardUpdateMonitorCallback { /** * Called when the keyguard enters or leaves bouncer mode. - * @param bouncer if true, keyguard is showing the bouncer or transitioning from/to bouncer - * mode. + * @param bouncerIsOrWillBeShowing if true, keyguard is showing the bouncer or transitioning + * from/to bouncer mode. */ - public void onKeyguardBouncerChanged(boolean bouncer) { } + public void onKeyguardBouncerStateChanged(boolean bouncerIsOrWillBeShowing) { } + + /** + * Called when the keyguard fully transitions to the bouncer or is no longer the bouncer + * @param bouncerIsFullyShowing if true, keyguard is fully showing the bouncer + */ + public void onKeyguardBouncerFullyShowingChanged(boolean bouncerIsFullyShowing) { } /** * Called when visibility of lockscreen clock changes, such as when diff --git a/packages/SystemUI/src/com/android/keyguard/LockIconViewController.java b/packages/SystemUI/src/com/android/keyguard/LockIconViewController.java index ffded659c2acc..25f185c8a4ed4 100644 --- a/packages/SystemUI/src/com/android/keyguard/LockIconViewController.java +++ b/packages/SystemUI/src/com/android/keyguard/LockIconViewController.java @@ -468,7 +468,7 @@ public class LockIconViewController extends ViewController impleme } @Override - public void onKeyguardBouncerChanged(boolean bouncer) { + public void onKeyguardBouncerStateChanged(boolean bouncer) { mIsBouncerShowing = bouncer; updateVisibility(); } diff --git a/packages/SystemUI/src/com/android/systemui/biometrics/AuthRippleController.kt b/packages/SystemUI/src/com/android/systemui/biometrics/AuthRippleController.kt index 0cde745d2e128..33126b3887da7 100644 --- a/packages/SystemUI/src/com/android/systemui/biometrics/AuthRippleController.kt +++ b/packages/SystemUI/src/com/android/systemui/biometrics/AuthRippleController.kt @@ -280,7 +280,7 @@ class AuthRippleController @Inject constructor( } } - override fun onKeyguardBouncerChanged(bouncerIsOrWillBeShowing: Boolean) { + override fun onKeyguardBouncerStateChanged(bouncerIsOrWillBeShowing: Boolean) { if (bouncerIsOrWillBeShowing) { mView.fadeDwellRipple() } diff --git a/packages/SystemUI/src/com/android/systemui/doze/DozeLog.java b/packages/SystemUI/src/com/android/systemui/doze/DozeLog.java index 8e1d645d1e978..f05fc2bb202a7 100644 --- a/packages/SystemUI/src/com/android/systemui/doze/DozeLog.java +++ b/packages/SystemUI/src/com/android/systemui/doze/DozeLog.java @@ -396,8 +396,8 @@ public class DozeLog implements Dumpable { } @Override - public void onKeyguardBouncerChanged(boolean bouncer) { - traceKeyguardBouncerChanged(bouncer); + public void onKeyguardBouncerFullyShowingChanged(boolean fullyShowing) { + traceKeyguardBouncerChanged(fullyShowing); } @Override diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/KeyguardLiftController.kt b/packages/SystemUI/src/com/android/systemui/statusbar/phone/KeyguardLiftController.kt index 64b0b4e2909fa..280e75cc7381f 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/KeyguardLiftController.kt +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/KeyguardLiftController.kt @@ -77,7 +77,7 @@ class KeyguardLiftController @Inject constructor( } private val keyguardUpdateMonitorCallback = object : KeyguardUpdateMonitorCallback() { - override fun onKeyguardBouncerChanged(bouncer: Boolean) { + override fun onKeyguardBouncerFullyShowingChanged(bouncer: Boolean) { bouncerVisible = bouncer updateListeningState() } diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarKeyguardViewManager.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarKeyguardViewManager.java index a1cbba47e8227..84413445138c8 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarKeyguardViewManager.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarKeyguardViewManager.java @@ -1055,8 +1055,10 @@ public class StatusBarKeyguardViewManager implements RemoteInputController.Callb if ((showing && !occluded) != (mLastShowing && !mLastOccluded) || mFirstUpdate) { mKeyguardUpdateManager.onKeyguardVisibilityChanged(showing && !occluded); } - if (bouncerIsOrWillBeShowing != mLastBouncerIsOrWillBeShowing || mFirstUpdate) { - mKeyguardUpdateManager.sendKeyguardBouncerChanged(bouncerIsOrWillBeShowing); + if (bouncerIsOrWillBeShowing != mLastBouncerIsOrWillBeShowing || mFirstUpdate + || bouncerShowing != mLastBouncerShowing) { + mKeyguardUpdateManager.sendKeyguardBouncerChanged(bouncerIsOrWillBeShowing, + bouncerShowing); } mFirstUpdate = false; diff --git a/packages/SystemUI/tests/src/com/android/keyguard/KeyguardListenQueueTest.kt b/packages/SystemUI/tests/src/com/android/keyguard/KeyguardListenQueueTest.kt index 4bdab7658a068..4cca38a6e5a8a 100644 --- a/packages/SystemUI/tests/src/com/android/keyguard/KeyguardListenQueueTest.kt +++ b/packages/SystemUI/tests/src/com/android/keyguard/KeyguardListenQueueTest.kt @@ -58,7 +58,7 @@ private fun fingerprintModel(user: Int) = KeyguardFingerprintListenModel( userId = user, listening = false, biometricEnabledForUser = false, - bouncer = false, + bouncerIsOrWillShow = false, canSkipBouncer = false, credentialAttempted = false, deviceInteractive = false, @@ -85,7 +85,7 @@ private fun faceModel(user: Int) = KeyguardFaceListenModel( authInterruptActive = false, becauseCannotSkipBouncer = false, biometricSettingEnabledForUser = false, - bouncer = false, + bouncerFullyShown = false, faceAuthenticated = false, faceDisabled = false, keyguardAwake = false, diff --git a/packages/SystemUI/tests/src/com/android/keyguard/KeyguardUpdateMonitorTest.java b/packages/SystemUI/tests/src/com/android/keyguard/KeyguardUpdateMonitorTest.java index 42e15c4fb7d9d..87f5dc66ec53d 100644 --- a/packages/SystemUI/tests/src/com/android/keyguard/KeyguardUpdateMonitorTest.java +++ b/packages/SystemUI/tests/src/com/android/keyguard/KeyguardUpdateMonitorTest.java @@ -526,6 +526,15 @@ public class KeyguardUpdateMonitorTest extends SysuiTestCase { verify(mFaceManager).hasEnrolledTemplates(anyInt()); } + @Test + public void testNoStartAuthenticate_whenAboutToShowBouncer() { + mKeyguardUpdateMonitor.sendKeyguardBouncerChanged( + /* bouncerIsOrWillBeShowing */ true, /* bouncerFullyShown */ false); + + verify(mFaceManager, never()).authenticate(any(), any(), any(), any(), anyInt(), + anyBoolean()); + } + @Test public void testTriesToAuthenticate_whenKeyguard() { mKeyguardUpdateMonitor.dispatchStartedWakingUp(); @@ -649,7 +658,7 @@ public class KeyguardUpdateMonitorTest extends SysuiTestCase { // doesn't matter here mKeyguardUpdateMonitor.onFaceAuthenticated(KeyguardUpdateMonitor.getCurrentUser(), true /* isStrongBiometric */); - mKeyguardUpdateMonitor.sendKeyguardBouncerChanged(true); + setKeyguardBouncerVisibility(true); mTestableLooper.processAllMessages(); verify(mFaceManager, never()).authenticate(any(), any(), any(), any(), anyInt(), @@ -1064,7 +1073,7 @@ public class KeyguardUpdateMonitorTest extends SysuiTestCase { } private void setKeyguardBouncerVisibility(boolean isVisible) { - mKeyguardUpdateMonitor.sendKeyguardBouncerChanged(isVisible); + mKeyguardUpdateMonitor.sendKeyguardBouncerChanged(isVisible, isVisible); mTestableLooper.processAllMessages(); }