From d2dfe82bd8f4953184938e0e73a263e6535b6af7 Mon Sep 17 00:00:00 2001 From: Beverly Date: Wed, 21 Sep 2022 20:49:12 +0000 Subject: Eval KG showing, occluded and visibility together Keyguard visibility is based on the keyguard showing and occluded states, but the KUM state changes were previously separated so that KG would respond to a occlusion change but not have the newest visibility, so it would inaccurately update its fingerprint listening state. To avoid this race condition, this CL consolidates KG showing, occlusion and visibility changes to a single setKeyguardShowing(showing, occluded) method. The method updates the KUM state and then sends the change out to listeners. This CL also updates some of the vocab used. In the future, keyguardVisibility from a KUM perspective means that the keyguard is showing and NOT occluded. Test: atest SystemUITests Test: enable a screensaver and successfully authenticate from the screensaver with a non UDFPS fp sensor Test: double press power button to the camera (occluded state), and see that rear FP will stop running. Can still auth when accessing the photo gallery. Test: double press power button to the camera (occluded state), and see that UDFPS affordance isn't available. Can still auth when accessing the photo gallery. Test: Setup a timer to go off, see that going to/from the occluded activity updates the occluded & keyguard visibility state correctly Bug: 248089638 Fixes: 247580913 Change-Id: I3478be2d304a42beebdb6a4baaf2e571d74e61b1 --- .../com/android/keyguard/ClockEventController.kt | 10 +-- .../keyguard/KeyguardStatusViewController.java | 6 +- .../android/keyguard/KeyguardUpdateMonitor.java | 80 +++++++++++++--------- .../keyguard/KeyguardUpdateMonitorCallback.java | 26 ++----- .../android/keyguard/LockIconViewController.java | 13 ++-- .../logging/KeyguardUpdateMonitorLogger.kt | 10 ++- .../AccessibilityFloatingMenuController.java | 4 +- .../systemui/biometrics/AuthRippleController.kt | 2 +- .../src/com/android/systemui/doze/DozeLog.java | 4 +- .../src/com/android/systemui/doze/DozeLogger.kt | 6 +- .../systemui/keyguard/KeyguardViewMediator.java | 5 +- .../systemui/statusbar/phone/DozeParameters.java | 10 +-- .../statusbar/phone/KeyguardLiftController.kt | 2 +- .../phone/KeyguardStatusBarViewController.java | 4 +- .../systemui/statusbar/phone/ScrimController.java | 2 +- .../phone/StatusBarKeyguardViewManager.java | 4 +- .../policy/KeyguardStateControllerImpl.java | 2 +- .../policy/KeyguardUserSwitcherController.java | 6 +- .../keyguard/KeyguardUpdateMonitorTest.java | 45 ++++++------ .../biometrics/AuthRippleControllerTest.kt | 49 ++++--------- 20 files changed, 133 insertions(+), 157 deletions(-) diff --git a/packages/SystemUI/src/com/android/keyguard/ClockEventController.kt b/packages/SystemUI/src/com/android/keyguard/ClockEventController.kt index b444f4c1110b..fd386618977c 100644 --- a/packages/SystemUI/src/com/android/keyguard/ClockEventController.kt +++ b/packages/SystemUI/src/com/android/keyguard/ClockEventController.kt @@ -69,7 +69,7 @@ open class ClockEventController @Inject constructor( private var isCharging = false private var dozeAmount = 0f - private var isKeyguardShowing = false + private var isKeyguardVisible = false private val regionSamplingEnabled = featureFlags.isEnabled(com.android.systemui.flags.Flags.REGION_SAMPLING) @@ -145,7 +145,7 @@ open class ClockEventController @Inject constructor( private val batteryCallback = object : BatteryStateChangeCallback { override fun onBatteryLevelChanged(level: Int, pluggedIn: Boolean, charging: Boolean) { - if (isKeyguardShowing && !isCharging && charging) { + if (isKeyguardVisible && !isCharging && charging) { clock?.animations?.charge() } isCharging = charging @@ -168,9 +168,9 @@ open class ClockEventController @Inject constructor( } private val keyguardUpdateMonitorCallback = object : KeyguardUpdateMonitorCallback() { - override fun onKeyguardVisibilityChanged(showing: Boolean) { - isKeyguardShowing = showing - if (!isKeyguardShowing) { + override fun onKeyguardVisibilityChanged(visible: Boolean) { + isKeyguardVisible = visible + if (!isKeyguardVisible) { clock?.animations?.doze(if (isDozing) 1f else 0f) } } diff --git a/packages/SystemUI/src/com/android/keyguard/KeyguardStatusViewController.java b/packages/SystemUI/src/com/android/keyguard/KeyguardStatusViewController.java index c715a4eaef2b..e9f06eddf261 100644 --- a/packages/SystemUI/src/com/android/keyguard/KeyguardStatusViewController.java +++ b/packages/SystemUI/src/com/android/keyguard/KeyguardStatusViewController.java @@ -212,9 +212,9 @@ public class KeyguardStatusViewController extends ViewController mServiceStates = new HashMap<>(); private int mPhoneState; - private boolean mKeyguardIsVisible; + private boolean mKeyguardShowing; + private boolean mKeyguardOccluded; private boolean mCredentialAttempted; private boolean mKeyguardGoingAway; private boolean mGoingToSleep; @@ -318,7 +319,6 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener, Dumpab private boolean mAuthInterruptActive; private boolean mNeedsSlowUnlockTransition; private boolean mAssistantVisible; - private boolean mKeyguardOccluded; private boolean mOccludingAppRequestingFp; private boolean mOccludingAppRequestingFace; private boolean mSecureCameraLaunched; @@ -681,14 +681,42 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener, Dumpab } /** - * Updates KeyguardUpdateMonitor's internal state to know if keyguard is occluded + * Updates KeyguardUpdateMonitor's internal state to know if keyguard is showing and if + * its occluded. The keyguard is considered visible if its showing and NOT occluded. */ - public void setKeyguardOccluded(boolean occluded) { + public void setKeyguardShowing(boolean showing, boolean occluded) { + final boolean occlusionChanged = mKeyguardOccluded != occluded; + final boolean showingChanged = mKeyguardShowing != showing; + if (!occlusionChanged && !showingChanged) { + return; + } + + final boolean wasKeyguardVisible = isKeyguardVisible(); + mKeyguardShowing = showing; mKeyguardOccluded = occluded; - updateBiometricListeningState(BIOMETRIC_ACTION_UPDATE, - FACE_AUTH_UPDATED_KEYGUARD_OCCLUSION_CHANGED); - } + final boolean isKeyguardVisible = isKeyguardVisible(); + mLogger.logKeyguardShowingChanged(showing, occluded, isKeyguardVisible); + if (isKeyguardVisible != wasKeyguardVisible) { + if (isKeyguardVisible) { + mSecureCameraLaunched = false; + } + for (int i = 0; i < mCallbacks.size(); i++) { + KeyguardUpdateMonitorCallback cb = mCallbacks.get(i).get(); + if (cb != null) { + cb.onKeyguardVisibilityChanged(isKeyguardVisible); + } + } + } + + if (occlusionChanged) { + updateBiometricListeningState(BIOMETRIC_ACTION_UPDATE, + FACE_AUTH_UPDATED_KEYGUARD_OCCLUSION_CHANGED); + } else if (showingChanged) { + updateBiometricListeningState(BIOMETRIC_ACTION_UPDATE, + FACE_AUTH_UPDATED_KEYGUARD_VISIBILITY_CHANGED); + } + } /** * Request to listen for face authentication when an app is occluding keyguard. @@ -2442,7 +2470,7 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener, Dumpab // Triggers: final boolean triggerActiveUnlockForAssistant = shouldTriggerActiveUnlockForAssistant(); final boolean awakeKeyguard = mBouncerFullyShown || mUdfpsBouncerShowing - || (mKeyguardIsVisible && !mGoingToSleep + || (isKeyguardVisible() && !mGoingToSleep && mStatusBarState != StatusBarState.SHADE_LOCKED); // Gates: @@ -2518,7 +2546,7 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener, Dumpab final boolean userDoesNotHaveTrust = !getUserHasTrust(user); final boolean shouldListenForFingerprintAssistant = shouldListenForFingerprintAssistant(); final boolean shouldListenKeyguardState = - mKeyguardIsVisible + isKeyguardVisible() || !mDeviceInteractive || (mBouncerIsOrWillBeShowing && !mKeyguardGoingAway) || mGoingToSleep @@ -2567,7 +2595,7 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener, Dumpab mFingerprintLockedOut, mGoingToSleep, mKeyguardGoingAway, - mKeyguardIsVisible, + isKeyguardVisible(), mKeyguardOccluded, mOccludingAppRequestingFp, mIsPrimaryUser, @@ -2589,7 +2617,7 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener, Dumpab } final boolean statusBarShadeLocked = mStatusBarState == StatusBarState.SHADE_LOCKED; - final boolean awakeKeyguard = mKeyguardIsVisible && mDeviceInteractive + final boolean awakeKeyguard = isKeyguardVisible() && mDeviceInteractive && !statusBarShadeLocked; final int user = getCurrentUser(); final int strongAuth = mStrongAuthTracker.getStrongAuthForUser(user); @@ -3146,32 +3174,18 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener, Dumpab callbacksRefreshCarrierInfo(); } + /** + * Whether the keyguard is showing and not occluded. + */ public boolean isKeyguardVisible() { - return mKeyguardIsVisible; + return isKeyguardShowing() && !mKeyguardOccluded; } /** - * Notifies that the visibility state of Keyguard has changed. - * - *

Needs to be called from the main thread. + * Whether the keyguard is showing. It may still be occluded and not visible. */ - public void onKeyguardVisibilityChanged(boolean showing) { - Assert.isMainThread(); - mLogger.logKeyguardVisibilityChanged(showing); - mKeyguardIsVisible = showing; - - if (showing) { - mSecureCameraLaunched = false; - } - - for (int i = 0; i < mCallbacks.size(); i++) { - KeyguardUpdateMonitorCallback cb = mCallbacks.get(i).get(); - if (cb != null) { - cb.onKeyguardVisibilityChangedRaw(showing); - } - } - updateBiometricListeningState(BIOMETRIC_ACTION_UPDATE, - FACE_AUTH_UPDATED_KEYGUARD_VISIBILITY_CHANGED); + public boolean isKeyguardShowing() { + return mKeyguardShowing; } /** @@ -3380,7 +3394,7 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener, Dumpab callback.onTimeChanged(); callback.onPhoneStateChanged(mPhoneState); callback.onRefreshCarrierInfo(); - callback.onKeyguardVisibilityChangedRaw(mKeyguardIsVisible); + callback.onKeyguardVisibilityChanged(isKeyguardVisible()); callback.onTelephonyCapable(mTelephonyCapable); for (Entry data : mSimDatas.entrySet()) { diff --git a/packages/SystemUI/src/com/android/keyguard/KeyguardUpdateMonitorCallback.java b/packages/SystemUI/src/com/android/keyguard/KeyguardUpdateMonitorCallback.java index 7a42803859b5..bc5ab88b586b 100644 --- a/packages/SystemUI/src/com/android/keyguard/KeyguardUpdateMonitorCallback.java +++ b/packages/SystemUI/src/com/android/keyguard/KeyguardUpdateMonitorCallback.java @@ -16,7 +16,6 @@ package com.android.keyguard; import android.hardware.biometrics.BiometricSourceType; -import android.os.SystemClock; import android.telephony.TelephonyManager; import android.view.WindowManagerPolicyConstants; @@ -32,10 +31,6 @@ import java.util.TimeZone; */ public class KeyguardUpdateMonitorCallback { - private static final long VISIBILITY_CHANGED_COLLAPSE_MS = 1000; - private long mVisibilityChangedCalled; - private boolean mShowing; - /** * Called when the battery status changes, e.g. when plugged in or unplugged, charge * level, etc. changes. @@ -74,21 +69,6 @@ public class KeyguardUpdateMonitorCallback { */ public void onPhoneStateChanged(int phoneState) { } - /** - * Called when the visibility of the keyguard changes. - * @param showing Indicates if the keyguard is now visible. - */ - public void onKeyguardVisibilityChanged(boolean showing) { } - - public void onKeyguardVisibilityChangedRaw(boolean showing) { - final long now = SystemClock.elapsedRealtime(); - if (showing == mShowing - && (now - mVisibilityChangedCalled) < VISIBILITY_CHANGED_COLLAPSE_MS) return; - onKeyguardVisibilityChanged(showing); - mVisibilityChangedCalled = now; - mShowing = showing; - } - /** * Called when the keyguard enters or leaves bouncer mode. * @param bouncerIsOrWillBeShowing if true, keyguard is showing the bouncer or transitioning @@ -96,6 +76,12 @@ public class KeyguardUpdateMonitorCallback { */ public void onKeyguardBouncerStateChanged(boolean bouncerIsOrWillBeShowing) { } + /** + * Called when the keyguard visibility changes. + * @param visible whether the keyguard is showing and is NOT occluded + */ + public void onKeyguardVisibilityChanged(boolean visible) { } + /** * 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 diff --git a/packages/SystemUI/src/com/android/keyguard/LockIconViewController.java b/packages/SystemUI/src/com/android/keyguard/LockIconViewController.java index 2a3667610f9c..c41b7522ce93 100644 --- a/packages/SystemUI/src/com/android/keyguard/LockIconViewController.java +++ b/packages/SystemUI/src/com/android/keyguard/LockIconViewController.java @@ -446,14 +446,6 @@ public class LockIconViewController extends ViewController impleme private final KeyguardUpdateMonitorCallback mKeyguardUpdateMonitorCallback = new KeyguardUpdateMonitorCallback() { - @Override - public void onKeyguardVisibilityChanged(boolean showing) { - // reset mIsBouncerShowing state in case it was preemptively set - // onLongPress - mIsBouncerShowing = mKeyguardViewController.isBouncerShowing(); - updateVisibility(); - } - @Override public void onKeyguardBouncerStateChanged(boolean bouncer) { mIsBouncerShowing = bouncer; @@ -507,6 +499,11 @@ public class LockIconViewController extends ViewController impleme // If biometrics were removed, local vars mCanDismissLockScreen and // mUserUnlockedWithBiometric may not be updated. mCanDismissLockScreen = mKeyguardStateController.canDismissLockScreen(); + + // reset mIsBouncerShowing state in case it was preemptively set + // onLongPress + mIsBouncerShowing = mKeyguardViewController.isBouncerShowing(); + updateKeyguardShowing(); if (mIsKeyguardShowing) { mUserUnlockedWithBiometric = diff --git a/packages/SystemUI/src/com/android/keyguard/logging/KeyguardUpdateMonitorLogger.kt b/packages/SystemUI/src/com/android/keyguard/logging/KeyguardUpdateMonitorLogger.kt index bf9f4c88bde3..54cec7132bfa 100644 --- a/packages/SystemUI/src/com/android/keyguard/logging/KeyguardUpdateMonitorLogger.kt +++ b/packages/SystemUI/src/com/android/keyguard/logging/KeyguardUpdateMonitorLogger.kt @@ -170,8 +170,14 @@ class KeyguardUpdateMonitorLogger @Inject constructor( logBuffer.log(TAG, VERBOSE, { str1 = "$model" }, { str1!! }) } - fun logKeyguardVisibilityChanged(showing: Boolean) { - logBuffer.log(TAG, DEBUG, { bool1 = showing }, { "onKeyguardVisibilityChanged($bool1)" }) + fun logKeyguardShowingChanged(showing: Boolean, occluded: Boolean, visible: Boolean) { + logBuffer.log(TAG, DEBUG, { + bool1 = showing + bool2 = occluded + bool3 = visible + }, { + "keyguardShowingChanged(showing=$bool1 occluded=$bool2 visible=$bool3)" + }) } fun logMissingSupervisorAppError(userId: Int) { diff --git a/packages/SystemUI/src/com/android/systemui/accessibility/floatingmenu/AccessibilityFloatingMenuController.java b/packages/SystemUI/src/com/android/systemui/accessibility/floatingmenu/AccessibilityFloatingMenuController.java index 11353f67a799..403941f8e639 100644 --- a/packages/SystemUI/src/com/android/systemui/accessibility/floatingmenu/AccessibilityFloatingMenuController.java +++ b/packages/SystemUI/src/com/android/systemui/accessibility/floatingmenu/AccessibilityFloatingMenuController.java @@ -61,8 +61,8 @@ public class AccessibilityFloatingMenuController implements } @Override - public void onKeyguardVisibilityChanged(boolean showing) { - mIsKeyguardVisible = showing; + public void onKeyguardVisibilityChanged(boolean visible) { + mIsKeyguardVisible = visible; handleFloatingMenuVisibility(mIsKeyguardVisible, mBtnMode, mBtnTargets); } diff --git a/packages/SystemUI/src/com/android/systemui/biometrics/AuthRippleController.kt b/packages/SystemUI/src/com/android/systemui/biometrics/AuthRippleController.kt index 4fee0837a52c..4363b88bf21e 100644 --- a/packages/SystemUI/src/com/android/systemui/biometrics/AuthRippleController.kt +++ b/packages/SystemUI/src/com/android/systemui/biometrics/AuthRippleController.kt @@ -117,7 +117,7 @@ class AuthRippleController @Inject constructor( } fun showUnlockRipple(biometricSourceType: BiometricSourceType?) { - if (!(keyguardUpdateMonitor.isKeyguardVisible || keyguardUpdateMonitor.isDreaming) || + if (!keyguardStateController.isShowing || keyguardUpdateMonitor.userNeedsStrongAuth()) { return } diff --git a/packages/SystemUI/src/com/android/systemui/doze/DozeLog.java b/packages/SystemUI/src/com/android/systemui/doze/DozeLog.java index 8ae305b1f329..2e51b51d2836 100644 --- a/packages/SystemUI/src/com/android/systemui/doze/DozeLog.java +++ b/packages/SystemUI/src/com/android/systemui/doze/DozeLog.java @@ -431,8 +431,8 @@ public class DozeLog implements Dumpable { } @Override - public void onKeyguardVisibilityChanged(boolean showing) { - traceKeyguard(showing); + public void onKeyguardVisibilityChanged(boolean visible) { + traceKeyguard(visible); } }; diff --git a/packages/SystemUI/src/com/android/systemui/doze/DozeLogger.kt b/packages/SystemUI/src/com/android/systemui/doze/DozeLogger.kt index 21a2c3b57f82..cc5766210406 100644 --- a/packages/SystemUI/src/com/android/systemui/doze/DozeLogger.kt +++ b/packages/SystemUI/src/com/android/systemui/doze/DozeLogger.kt @@ -155,11 +155,11 @@ class DozeLogger @Inject constructor( }) } - fun logKeyguardVisibilityChange(isShowing: Boolean) { + fun logKeyguardVisibilityChange(isVisible: Boolean) { buffer.log(TAG, INFO, { - bool1 = isShowing + bool1 = isVisible }, { - "Keyguard visibility change, isShowing=$bool1" + "Keyguard visibility change, isVisible=$bool1" }) } diff --git a/packages/SystemUI/src/com/android/systemui/keyguard/KeyguardViewMediator.java b/packages/SystemUI/src/com/android/systemui/keyguard/KeyguardViewMediator.java index 38b98eb45aec..0eb69f08bfc2 100644 --- a/packages/SystemUI/src/com/android/systemui/keyguard/KeyguardViewMediator.java +++ b/packages/SystemUI/src/com/android/systemui/keyguard/KeyguardViewMediator.java @@ -512,9 +512,9 @@ public class KeyguardViewMediator extends CoreStartable implements Dumpable, KeyguardUpdateMonitorCallback mUpdateCallback = new KeyguardUpdateMonitorCallback() { @Override - public void onKeyguardVisibilityChanged(boolean showing) { + public void onKeyguardVisibilityChanged(boolean visible) { synchronized (KeyguardViewMediator.this) { - if (!showing && mPendingPinLock) { + if (!visible && mPendingPinLock) { Log.i(TAG, "PIN lock requested, starting keyguard"); // Bring the keyguard back in order to show the PIN lock @@ -1808,7 +1808,6 @@ public class KeyguardViewMediator extends CoreStartable implements Dumpable, if (mOccluded != isOccluded) { mOccluded = isOccluded; - mUpdateMonitor.setKeyguardOccluded(isOccluded); mKeyguardViewControllerLazy.get().setOccluded(isOccluded, animate && mDeviceInteractive); adjustStatusBarLocked(); diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/DozeParameters.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/DozeParameters.java index 54d39fd673f6..de7b152adaab 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/DozeParameters.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/DozeParameters.java @@ -93,13 +93,13 @@ public class DozeParameters implements private boolean mControlScreenOffAnimation; private boolean mIsQuickPickupEnabled; - private boolean mKeyguardShowing; + private boolean mKeyguardVisible; @VisibleForTesting final KeyguardUpdateMonitorCallback mKeyguardVisibilityCallback = new KeyguardUpdateMonitorCallback() { @Override - public void onKeyguardVisibilityChanged(boolean showing) { - mKeyguardShowing = showing; + public void onKeyguardVisibilityChanged(boolean visible) { + mKeyguardVisible = visible; updateControlScreenOff(); } @@ -293,7 +293,7 @@ public class DozeParameters implements public void updateControlScreenOff() { if (!getDisplayNeedsBlanking()) { final boolean controlScreenOff = - getAlwaysOn() && (mKeyguardShowing || shouldControlUnlockedScreenOff()); + getAlwaysOn() && (mKeyguardVisible || shouldControlUnlockedScreenOff()); setControlScreenOffAnimation(controlScreenOff); } } @@ -348,7 +348,7 @@ public class DozeParameters implements } private boolean willAnimateFromLockScreenToAod() { - return getAlwaysOn() && mKeyguardShowing; + return getAlwaysOn() && mKeyguardVisible; } private boolean getBoolean(String propName, int resId) { 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 b58dbe263eff..e3e85728ff83 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/KeyguardLiftController.kt +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/KeyguardLiftController.kt @@ -88,7 +88,7 @@ class KeyguardLiftController @Inject constructor( updateListeningState() } - override fun onKeyguardVisibilityChanged(showing: Boolean) { + override fun onKeyguardVisibilityChanged(visible: Boolean) { updateListeningState() } } diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/KeyguardStatusBarViewController.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/KeyguardStatusBarViewController.java index 054bd28e003d..14cebf4b9f4b 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/KeyguardStatusBarViewController.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/KeyguardStatusBarViewController.java @@ -187,8 +187,8 @@ public class KeyguardStatusBarViewController extends ViewController()); - mKeyguardUpdateMonitor.onKeyguardVisibilityChanged(true); + keyguardIsVisible(); verify(mFaceManager).authenticate(any(), any(), any(), any(), anyInt(), anyBoolean()); } @@ -693,7 +693,7 @@ public class KeyguardUpdateMonitorTest extends SysuiTestCase { mTestableLooper.processAllMessages(); mKeyguardUpdateMonitor.onTrustChanged(true /* enabled */, KeyguardUpdateMonitor.getCurrentUser(), 0 /* flags */, new ArrayList<>()); - mKeyguardUpdateMonitor.onKeyguardVisibilityChanged(true); + keyguardIsVisible(); verify(mFaceManager, never()).authenticate(any(), any(), any(), any(), anyInt(), anyBoolean()); } @@ -705,7 +705,7 @@ public class KeyguardUpdateMonitorTest extends SysuiTestCase { when(mStrongAuthTracker.getStrongAuthForUser(anyInt())).thenReturn( KeyguardUpdateMonitor.StrongAuthTracker.STRONG_AUTH_REQUIRED_AFTER_USER_LOCKDOWN); - mKeyguardUpdateMonitor.onKeyguardVisibilityChanged(true); + keyguardIsVisible(); verify(mFaceManager, never()).authenticate(any(), any(), any(), any(), anyInt(), anyBoolean()); } @@ -717,7 +717,7 @@ public class KeyguardUpdateMonitorTest extends SysuiTestCase { when(mStrongAuthTracker.getStrongAuthForUser(anyInt())).thenReturn( KeyguardUpdateMonitor.StrongAuthTracker.STRONG_AUTH_REQUIRED_AFTER_LOCKOUT); - mKeyguardUpdateMonitor.onKeyguardVisibilityChanged(true); + keyguardIsVisible(); verify(mFaceManager).authenticate(any(), any(), any(), any(), anyInt(), anyBoolean()); } @@ -738,7 +738,7 @@ public class KeyguardUpdateMonitorTest extends SysuiTestCase { public void testFaceAndFingerprintLockout_onlyFace() { mKeyguardUpdateMonitor.dispatchStartedWakingUp(); mTestableLooper.processAllMessages(); - mKeyguardUpdateMonitor.onKeyguardVisibilityChanged(true); + keyguardIsVisible(); faceAuthLockedOut(); @@ -749,7 +749,7 @@ public class KeyguardUpdateMonitorTest extends SysuiTestCase { public void testFaceAndFingerprintLockout_onlyFingerprint() { mKeyguardUpdateMonitor.dispatchStartedWakingUp(); mTestableLooper.processAllMessages(); - mKeyguardUpdateMonitor.onKeyguardVisibilityChanged(true); + keyguardIsVisible(); mKeyguardUpdateMonitor.mFingerprintAuthenticationCallback .onAuthenticationError(FINGERPRINT_ERROR_LOCKOUT_PERMANENT, ""); @@ -761,7 +761,7 @@ public class KeyguardUpdateMonitorTest extends SysuiTestCase { public void testFaceAndFingerprintLockout() { mKeyguardUpdateMonitor.dispatchStartedWakingUp(); mTestableLooper.processAllMessages(); - mKeyguardUpdateMonitor.onKeyguardVisibilityChanged(true); + keyguardIsVisible(); faceAuthLockedOut(); mKeyguardUpdateMonitor.mFingerprintAuthenticationCallback @@ -860,7 +860,7 @@ public class KeyguardUpdateMonitorTest extends SysuiTestCase { mKeyguardUpdateMonitor.dispatchStartedWakingUp(); mTestableLooper.processAllMessages(); - mKeyguardUpdateMonitor.onKeyguardVisibilityChanged(true); + keyguardIsVisible(); verify(mFaceManager).authenticate(any(), any(), any(), any(), anyInt(), anyBoolean()); verify(mFingerprintManager).authenticate(any(), any(), any(), any(), anyInt(), anyInt(), @@ -1033,8 +1033,7 @@ public class KeyguardUpdateMonitorTest extends SysuiTestCase { public void testOccludingAppFingerprintListeningState() { // GIVEN keyguard isn't visible (app occluding) mKeyguardUpdateMonitor.dispatchStartedWakingUp(); - mKeyguardUpdateMonitor.setKeyguardOccluded(true); - mKeyguardUpdateMonitor.onKeyguardVisibilityChanged(false); + mKeyguardUpdateMonitor.setKeyguardShowing(true, true); when(mStrongAuthTracker.hasUserAuthenticatedSinceBoot()).thenReturn(true); // THEN we shouldn't listen for fingerprints @@ -1049,8 +1048,7 @@ public class KeyguardUpdateMonitorTest extends SysuiTestCase { public void testOccludingAppRequestsFingerprint() { // GIVEN keyguard isn't visible (app occluding) mKeyguardUpdateMonitor.dispatchStartedWakingUp(); - mKeyguardUpdateMonitor.setKeyguardOccluded(true); - mKeyguardUpdateMonitor.onKeyguardVisibilityChanged(false); + mKeyguardUpdateMonitor.setKeyguardShowing(true, true); // WHEN an occluding app requests fp mKeyguardUpdateMonitor.requestFingerprintAuthOnOccludingApp(true); @@ -1142,7 +1140,7 @@ public class KeyguardUpdateMonitorTest extends SysuiTestCase { setKeyguardBouncerVisibility(false /* isVisible */); mKeyguardUpdateMonitor.dispatchStartedWakingUp(); when(mKeyguardBypassController.canBypass()).thenReturn(true); - mKeyguardUpdateMonitor.onKeyguardVisibilityChanged(true); + keyguardIsVisible(); // WHEN status bar state reports a change to the keyguard that would normally indicate to // start running face auth @@ -1153,8 +1151,9 @@ public class KeyguardUpdateMonitorTest extends SysuiTestCase { // listening state to update assertThat(mKeyguardUpdateMonitor.isFaceDetectionRunning()).isEqualTo(false); - // WHEN biometric listening state is updated - mKeyguardUpdateMonitor.onKeyguardVisibilityChanged(true); + // WHEN biometric listening state is updated when showing state changes from false => true + mKeyguardUpdateMonitor.setKeyguardShowing(false, false); + mKeyguardUpdateMonitor.setKeyguardShowing(true, false); // THEN face unlock is running assertThat(mKeyguardUpdateMonitor.isFaceDetectionRunning()).isEqualTo(true); @@ -1520,7 +1519,7 @@ public class KeyguardUpdateMonitorTest extends SysuiTestCase { public void testFingerprintCanAuth_whenCancellationNotReceivedAndAuthFailed() { mKeyguardUpdateMonitor.dispatchStartedWakingUp(); mTestableLooper.processAllMessages(); - mKeyguardUpdateMonitor.onKeyguardVisibilityChanged(true); + keyguardIsVisible(); verify(mFaceManager).authenticate(any(), any(), any(), any(), anyInt(), anyBoolean()); verify(mFingerprintManager).authenticate(any(), any(), any(), any(), anyInt(), anyInt(), @@ -1529,7 +1528,7 @@ public class KeyguardUpdateMonitorTest extends SysuiTestCase { mKeyguardUpdateMonitor.onFaceAuthenticated(0, false); // Make sure keyguard is going away after face auth attempt, and that it calls // updateBiometricStateListeningState. - mKeyguardUpdateMonitor.onKeyguardVisibilityChanged(false); + mKeyguardUpdateMonitor.setKeyguardShowing(false, false); mTestableLooper.processAllMessages(); verify(mHandler).postDelayed(mKeyguardUpdateMonitor.mFpCancelNotReceived, @@ -1589,7 +1588,7 @@ public class KeyguardUpdateMonitorTest extends SysuiTestCase { } private void keyguardIsVisible() { - mKeyguardUpdateMonitor.onKeyguardVisibilityChanged(true); + mKeyguardUpdateMonitor.setKeyguardShowing(true, false); } private void triggerAuthInterrupt() { diff --git a/packages/SystemUI/tests/src/com/android/systemui/biometrics/AuthRippleControllerTest.kt b/packages/SystemUI/tests/src/com/android/systemui/biometrics/AuthRippleControllerTest.kt index 37bb0c296735..0b528a5c8d1e 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/biometrics/AuthRippleControllerTest.kt +++ b/packages/SystemUI/tests/src/com/android/systemui/biometrics/AuthRippleControllerTest.kt @@ -117,13 +117,12 @@ class AuthRippleControllerTest : SysuiTestCase() { } @Test - fun testFingerprintTrigger_KeyguardVisible_Ripple() { - // GIVEN fp exists, keyguard is visible, user doesn't need strong auth + fun testFingerprintTrigger_KeyguardShowing_Ripple() { + // GIVEN fp exists, keyguard is showing, user doesn't need strong auth val fpsLocation = Point(5, 5) `when`(authController.fingerprintSensorLocation).thenReturn(fpsLocation) controller.onViewAttached() - `when`(keyguardUpdateMonitor.isKeyguardVisible).thenReturn(true) - `when`(keyguardUpdateMonitor.isDreaming).thenReturn(false) + `when`(keyguardStateController.isShowing).thenReturn(true) `when`(keyguardUpdateMonitor.userNeedsStrongAuth()).thenReturn(false) // WHEN fingerprint authenticated @@ -140,39 +139,15 @@ class AuthRippleControllerTest : SysuiTestCase() { } @Test - fun testFingerprintTrigger_Dreaming_Ripple() { - // GIVEN fp exists, keyguard is visible, user doesn't need strong auth - val fpsLocation = Point(5, 5) - `when`(authController.fingerprintSensorLocation).thenReturn(fpsLocation) - controller.onViewAttached() - `when`(keyguardUpdateMonitor.isKeyguardVisible).thenReturn(false) - `when`(keyguardUpdateMonitor.isDreaming).thenReturn(true) - `when`(keyguardUpdateMonitor.userNeedsStrongAuth()).thenReturn(false) - - // WHEN fingerprint authenticated - val captor = ArgumentCaptor.forClass(KeyguardUpdateMonitorCallback::class.java) - verify(keyguardUpdateMonitor).registerCallback(captor.capture()) - captor.value.onBiometricAuthenticated( - 0 /* userId */, - BiometricSourceType.FINGERPRINT /* type */, - false /* isStrongBiometric */) - - // THEN update sensor location and show ripple - verify(rippleView).setFingerprintSensorLocation(fpsLocation, 0f) - verify(rippleView).startUnlockedRipple(any()) - } - - @Test - fun testFingerprintTrigger_KeyguardNotVisible_NotDreaming_NoRipple() { + fun testFingerprintTrigger_KeyguardNotShowing_NoRipple() { // GIVEN fp exists & user doesn't need strong auth val fpsLocation = Point(5, 5) `when`(authController.udfpsLocation).thenReturn(fpsLocation) controller.onViewAttached() `when`(keyguardUpdateMonitor.userNeedsStrongAuth()).thenReturn(false) - // WHEN keyguard is NOT visible & fingerprint authenticated - `when`(keyguardUpdateMonitor.isKeyguardVisible).thenReturn(false) - `when`(keyguardUpdateMonitor.isDreaming).thenReturn(false) + // WHEN keyguard is NOT showing & fingerprint authenticated + `when`(keyguardStateController.isShowing).thenReturn(false) val captor = ArgumentCaptor.forClass(KeyguardUpdateMonitorCallback::class.java) verify(keyguardUpdateMonitor).registerCallback(captor.capture()) captor.value.onBiometricAuthenticated( @@ -186,11 +161,11 @@ class AuthRippleControllerTest : SysuiTestCase() { @Test fun testFingerprintTrigger_StrongAuthRequired_NoRipple() { - // GIVEN fp exists & keyguard is visible + // GIVEN fp exists & keyguard is showing val fpsLocation = Point(5, 5) `when`(authController.udfpsLocation).thenReturn(fpsLocation) controller.onViewAttached() - `when`(keyguardUpdateMonitor.isKeyguardVisible).thenReturn(true) + `when`(keyguardStateController.isShowing).thenReturn(true) // WHEN user needs strong auth & fingerprint authenticated `when`(keyguardUpdateMonitor.userNeedsStrongAuth()).thenReturn(true) @@ -207,12 +182,12 @@ class AuthRippleControllerTest : SysuiTestCase() { @Test fun testFaceTriggerBypassEnabled_Ripple() { - // GIVEN face auth sensor exists, keyguard is visible & strong auth isn't required + // GIVEN face auth sensor exists, keyguard is showing & strong auth isn't required val faceLocation = Point(5, 5) `when`(authController.faceSensorLocation).thenReturn(faceLocation) controller.onViewAttached() - `when`(keyguardUpdateMonitor.isKeyguardVisible).thenReturn(true) + `when`(keyguardStateController.isShowing).thenReturn(true) `when`(keyguardUpdateMonitor.userNeedsStrongAuth()).thenReturn(false) // WHEN bypass is enabled & face authenticated @@ -299,7 +274,7 @@ class AuthRippleControllerTest : SysuiTestCase() { val fpsLocation = Point(5, 5) `when`(authController.fingerprintSensorLocation).thenReturn(fpsLocation) controller.onViewAttached() - `when`(keyguardUpdateMonitor.isKeyguardVisible).thenReturn(true) + `when`(keyguardStateController.isShowing).thenReturn(true) `when`(biometricUnlockController.isWakeAndUnlock).thenReturn(true) controller.showUnlockRipple(BiometricSourceType.FINGERPRINT) @@ -317,7 +292,7 @@ class AuthRippleControllerTest : SysuiTestCase() { val faceLocation = Point(5, 5) `when`(authController.faceSensorLocation).thenReturn(faceLocation) controller.onViewAttached() - `when`(keyguardUpdateMonitor.isKeyguardVisible).thenReturn(true) + `when`(keyguardStateController.isShowing).thenReturn(true) `when`(biometricUnlockController.isWakeAndUnlock).thenReturn(true) `when`(authController.isUdfpsFingerDown).thenReturn(true) -- cgit v1.2.3-59-g8ed1b