Loading packages/SystemUI/src/com/android/keyguard/KeyguardUpdateMonitor.java +19 −35 Original line number Diff line number Diff line Loading @@ -396,7 +396,6 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener, Dumpab private int mFaceRunningState = BIOMETRIC_STATE_STOPPED; private boolean mIsDreaming; private boolean mLogoutEnabled; private boolean mIsFaceEnrolled; private int mActiveMobileDataSubscription = SubscriptionManager.INVALID_SUBSCRIPTION_ID; private int mPostureState = DEVICE_POSTURE_UNKNOWN; private FingerprintInteractiveToAuthProvider mFingerprintInteractiveToAuthProvider; Loading Loading @@ -2573,16 +2572,6 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener, Dumpab } } private void updateFaceEnrolled(int userId) { final Boolean isFaceEnrolled = isFaceSupported() && mBiometricEnabledForUser.get(userId) && mAuthController.isFaceAuthEnrolled(userId); if (mIsFaceEnrolled != isFaceEnrolled) { mLogger.logFaceEnrolledUpdated(mIsFaceEnrolled, isFaceEnrolled); } mIsFaceEnrolled = isFaceEnrolled; } private boolean isFaceSupported() { return mFaceManager != null && !mFaceSensorProperties.isEmpty(); } Loading Loading @@ -2622,10 +2611,17 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener, Dumpab } /** * @return true if there's at least one face enrolled * @return true if there's at least one face enrolled for the given user */ private boolean isFaceEnrolled(int userId) { return mAuthController.isFaceAuthEnrolled(userId); } /** * @return true if there's at least one face enrolled for the current user */ public boolean isFaceEnrolled() { return mIsFaceEnrolled; return isFaceEnrolled(getCurrentUser()); } private final UserTracker.Callback mUserChangedCallback = new UserTracker.Callback() { Loading Loading @@ -3284,14 +3280,13 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener, Dumpab @SuppressLint("MissingPermission") @VisibleForTesting boolean isUnlockWithFingerprintPossible(int userId) { // TODO (b/242022358), make this rely on onEnrollmentChanged event and update it only once. boolean newFpEnrolled = isFingerprintSupported() && !isFingerprintDisabled(userId) && mFpm.hasEnrolledTemplates(userId); Boolean oldFpEnrolled = mIsUnlockWithFingerprintPossible.getOrDefault(userId, false); if (oldFpEnrolled != newFpEnrolled) { mLogger.logFpEnrolledUpdated(userId, oldFpEnrolled, newFpEnrolled); } mIsUnlockWithFingerprintPossible.put(userId, newFpEnrolled); boolean newFpPossible = isFingerprintSupported() && !isFingerprintDisabled(userId) && mAuthController.isFingerprintEnrolled(userId); Boolean oldFpPossible = mIsUnlockWithFingerprintPossible.getOrDefault(userId, false); if (oldFpPossible != newFpPossible) { mLogger.logFpPossibleUpdated(userId, oldFpPossible, newFpPossible); } mIsUnlockWithFingerprintPossible.put(userId, newFpPossible); return mIsUnlockWithFingerprintPossible.get(userId); } Loading @@ -3306,24 +3301,13 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener, Dumpab /** * @deprecated This is being migrated to use modern architecture. */ @VisibleForTesting @Deprecated private boolean isUnlockWithFacePossible(int userId) { public boolean isUnlockWithFacePossible(int userId) { if (isFaceAuthInteractorEnabled()) { return getFaceAuthInteractor().canFaceAuthRun(); } return isFaceAuthEnabledForUser(userId) && !isFaceDisabled(userId); } /** * If face hardware is available, user has enrolled and enabled auth via setting. * * @deprecated This is being migrated to use modern architecture. */ @Deprecated public boolean isFaceAuthEnabledForUser(int userId) { // TODO (b/242022358), make this rely on onEnrollmentChanged event and update it only once. updateFaceEnrolled(userId); return mIsFaceEnrolled; return isFaceSupported() && isFaceEnrolled(userId) && !isFaceDisabled(userId); } private void stopListeningForFingerprint() { Loading packages/SystemUI/src/com/android/keyguard/logging/KeyguardUpdateMonitorLogger.kt +2 −2 Original line number Diff line number Diff line Loading @@ -630,7 +630,7 @@ constructor(@KeyguardUpdateMonitorLog private val logBuffer: LogBuffer) { ) } fun logFpEnrolledUpdated(userId: Int, oldValue: Boolean, newValue: Boolean) { fun logFpPossibleUpdated(userId: Int, oldValue: Boolean, newValue: Boolean) { logBuffer.log( TAG, DEBUG, Loading @@ -639,7 +639,7 @@ constructor(@KeyguardUpdateMonitorLog private val logBuffer: LogBuffer) { bool1 = oldValue bool2 = newValue }, { "Fp enrolled state changed for userId: $int1 old: $bool1, new: $bool2" } { "Fp possible state changed for userId: $int1 old: $bool1, new: $bool2" } ) } Loading packages/SystemUI/src/com/android/systemui/statusbar/phone/KeyguardLiftController.kt +1 −3 Original line number Diff line number Diff line Loading @@ -115,9 +115,7 @@ class KeyguardLiftController @Inject constructor( val onKeyguard = keyguardUpdateMonitor.isKeyguardVisible && !statusBarStateController.isDozing val userId = KeyguardUpdateMonitor.getCurrentUser() val isFaceEnabled = keyguardUpdateMonitor.isFaceAuthEnabledForUser(userId) val shouldListen = (onKeyguard || bouncerVisible) && isFaceEnabled val shouldListen = (onKeyguard || bouncerVisible) && keyguardUpdateMonitor.isFaceEnrolled if (shouldListen != isListening) { isListening = shouldListen Loading packages/SystemUI/src/com/android/systemui/statusbar/policy/KeyguardStateControllerImpl.java +1 −1 Original line number Diff line number Diff line Loading @@ -240,7 +240,7 @@ public class KeyguardStateControllerImpl implements KeyguardStateController, Dum || (Build.IS_DEBUGGABLE && DEBUG_AUTH_WITH_ADB && mDebugUnlocked); boolean trustManaged = mKeyguardUpdateMonitor.getUserTrustIsManaged(user); boolean trusted = mKeyguardUpdateMonitor.getUserHasTrust(user); boolean faceAuthEnabled = mKeyguardUpdateMonitor.isFaceAuthEnabledForUser(user); boolean faceAuthEnabled = mKeyguardUpdateMonitor.isFaceEnrolled(); boolean changed = secure != mSecure || canDismissLockScreen != mCanDismissLockScreen || trustManaged != mTrustManaged || mTrusted != trusted || mFaceAuthEnabled != faceAuthEnabled; Loading packages/SystemUI/tests/src/com/android/keyguard/KeyguardUpdateMonitorTest.java +15 −8 Original line number Diff line number Diff line Loading @@ -383,6 +383,7 @@ public class KeyguardUpdateMonitorTest extends SysuiTestCase { } private void setupFingerprintAuth(boolean isClass3) throws RemoteException { when(mAuthController.isFingerprintEnrolled(anyInt())).thenReturn(true); when(mFingerprintManager.isHardwareDetected()).thenReturn(true); when(mFingerprintManager.hasEnrolledTemplates(anyInt())).thenReturn(true); mFingerprintSensorProperties = List.of( Loading Loading @@ -2692,33 +2693,42 @@ public class KeyguardUpdateMonitorTest extends SysuiTestCase { } @Test public void testFingerprintSensorProperties() throws RemoteException { // GIVEN no fingerprint sensor properties when(mAuthController.isFingerprintEnrolled(anyInt())).thenReturn(true); mFingerprintAuthenticatorsRegisteredCallback.onAllAuthenticatorsRegistered( new ArrayList<>()); // THEN fingerprint is not possible assertThat(mKeyguardUpdateMonitor.isUnlockWithFingerprintPossible( KeyguardUpdateMonitor.getCurrentUser())).isFalse(); // WHEN there are fingerprint sensor properties mFingerprintAuthenticatorsRegisteredCallback .onAllAuthenticatorsRegistered(mFingerprintSensorProperties); verifyFingerprintAuthenticateCall(); // THEN unlock with fp is possible & fingerprint starts listening assertThat(mKeyguardUpdateMonitor.isUnlockWithFingerprintPossible( KeyguardUpdateMonitor.getCurrentUser())).isTrue(); verifyFingerprintAuthenticateCall(); } @Test public void testFaceSensorProperties() throws RemoteException { // GIVEN no face sensor properties when(mAuthController.isFaceAuthEnrolled(anyInt())).thenReturn(true); mFaceAuthenticatorsRegisteredCallback.onAllAuthenticatorsRegistered(new ArrayList<>()); assertThat(mKeyguardUpdateMonitor.isFaceAuthEnabledForUser( // THEN face is not possible assertThat(mKeyguardUpdateMonitor.isUnlockWithFacePossible( KeyguardUpdateMonitor.getCurrentUser())).isFalse(); // WHEN there are face sensor properties mFaceAuthenticatorsRegisteredCallback.onAllAuthenticatorsRegistered(mFaceSensorProperties); biometricsEnabledForCurrentUser(); // THEN face is possible but face does NOT start listening immediately assertThat(mKeyguardUpdateMonitor.isUnlockWithFacePossible( KeyguardUpdateMonitor.getCurrentUser())).isTrue(); verifyFaceAuthenticateNeverCalled(); verifyFaceDetectNeverCalled(); assertThat(mKeyguardUpdateMonitor.isFaceAuthEnabledForUser( KeyguardUpdateMonitor.getCurrentUser())).isTrue(); } @Test Loading Loading @@ -2791,9 +2801,6 @@ public class KeyguardUpdateMonitorTest extends SysuiTestCase { } private void mockCanBypassLockscreen(boolean canBypass) { // force update the isFaceEnrolled cache: mKeyguardUpdateMonitor.isFaceAuthEnabledForUser(getCurrentUser()); mKeyguardUpdateMonitor.setKeyguardBypassController(mKeyguardBypassController); when(mKeyguardBypassController.canBypass()).thenReturn(canBypass); } Loading Loading
packages/SystemUI/src/com/android/keyguard/KeyguardUpdateMonitor.java +19 −35 Original line number Diff line number Diff line Loading @@ -396,7 +396,6 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener, Dumpab private int mFaceRunningState = BIOMETRIC_STATE_STOPPED; private boolean mIsDreaming; private boolean mLogoutEnabled; private boolean mIsFaceEnrolled; private int mActiveMobileDataSubscription = SubscriptionManager.INVALID_SUBSCRIPTION_ID; private int mPostureState = DEVICE_POSTURE_UNKNOWN; private FingerprintInteractiveToAuthProvider mFingerprintInteractiveToAuthProvider; Loading Loading @@ -2573,16 +2572,6 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener, Dumpab } } private void updateFaceEnrolled(int userId) { final Boolean isFaceEnrolled = isFaceSupported() && mBiometricEnabledForUser.get(userId) && mAuthController.isFaceAuthEnrolled(userId); if (mIsFaceEnrolled != isFaceEnrolled) { mLogger.logFaceEnrolledUpdated(mIsFaceEnrolled, isFaceEnrolled); } mIsFaceEnrolled = isFaceEnrolled; } private boolean isFaceSupported() { return mFaceManager != null && !mFaceSensorProperties.isEmpty(); } Loading Loading @@ -2622,10 +2611,17 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener, Dumpab } /** * @return true if there's at least one face enrolled * @return true if there's at least one face enrolled for the given user */ private boolean isFaceEnrolled(int userId) { return mAuthController.isFaceAuthEnrolled(userId); } /** * @return true if there's at least one face enrolled for the current user */ public boolean isFaceEnrolled() { return mIsFaceEnrolled; return isFaceEnrolled(getCurrentUser()); } private final UserTracker.Callback mUserChangedCallback = new UserTracker.Callback() { Loading Loading @@ -3284,14 +3280,13 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener, Dumpab @SuppressLint("MissingPermission") @VisibleForTesting boolean isUnlockWithFingerprintPossible(int userId) { // TODO (b/242022358), make this rely on onEnrollmentChanged event and update it only once. boolean newFpEnrolled = isFingerprintSupported() && !isFingerprintDisabled(userId) && mFpm.hasEnrolledTemplates(userId); Boolean oldFpEnrolled = mIsUnlockWithFingerprintPossible.getOrDefault(userId, false); if (oldFpEnrolled != newFpEnrolled) { mLogger.logFpEnrolledUpdated(userId, oldFpEnrolled, newFpEnrolled); } mIsUnlockWithFingerprintPossible.put(userId, newFpEnrolled); boolean newFpPossible = isFingerprintSupported() && !isFingerprintDisabled(userId) && mAuthController.isFingerprintEnrolled(userId); Boolean oldFpPossible = mIsUnlockWithFingerprintPossible.getOrDefault(userId, false); if (oldFpPossible != newFpPossible) { mLogger.logFpPossibleUpdated(userId, oldFpPossible, newFpPossible); } mIsUnlockWithFingerprintPossible.put(userId, newFpPossible); return mIsUnlockWithFingerprintPossible.get(userId); } Loading @@ -3306,24 +3301,13 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener, Dumpab /** * @deprecated This is being migrated to use modern architecture. */ @VisibleForTesting @Deprecated private boolean isUnlockWithFacePossible(int userId) { public boolean isUnlockWithFacePossible(int userId) { if (isFaceAuthInteractorEnabled()) { return getFaceAuthInteractor().canFaceAuthRun(); } return isFaceAuthEnabledForUser(userId) && !isFaceDisabled(userId); } /** * If face hardware is available, user has enrolled and enabled auth via setting. * * @deprecated This is being migrated to use modern architecture. */ @Deprecated public boolean isFaceAuthEnabledForUser(int userId) { // TODO (b/242022358), make this rely on onEnrollmentChanged event and update it only once. updateFaceEnrolled(userId); return mIsFaceEnrolled; return isFaceSupported() && isFaceEnrolled(userId) && !isFaceDisabled(userId); } private void stopListeningForFingerprint() { Loading
packages/SystemUI/src/com/android/keyguard/logging/KeyguardUpdateMonitorLogger.kt +2 −2 Original line number Diff line number Diff line Loading @@ -630,7 +630,7 @@ constructor(@KeyguardUpdateMonitorLog private val logBuffer: LogBuffer) { ) } fun logFpEnrolledUpdated(userId: Int, oldValue: Boolean, newValue: Boolean) { fun logFpPossibleUpdated(userId: Int, oldValue: Boolean, newValue: Boolean) { logBuffer.log( TAG, DEBUG, Loading @@ -639,7 +639,7 @@ constructor(@KeyguardUpdateMonitorLog private val logBuffer: LogBuffer) { bool1 = oldValue bool2 = newValue }, { "Fp enrolled state changed for userId: $int1 old: $bool1, new: $bool2" } { "Fp possible state changed for userId: $int1 old: $bool1, new: $bool2" } ) } Loading
packages/SystemUI/src/com/android/systemui/statusbar/phone/KeyguardLiftController.kt +1 −3 Original line number Diff line number Diff line Loading @@ -115,9 +115,7 @@ class KeyguardLiftController @Inject constructor( val onKeyguard = keyguardUpdateMonitor.isKeyguardVisible && !statusBarStateController.isDozing val userId = KeyguardUpdateMonitor.getCurrentUser() val isFaceEnabled = keyguardUpdateMonitor.isFaceAuthEnabledForUser(userId) val shouldListen = (onKeyguard || bouncerVisible) && isFaceEnabled val shouldListen = (onKeyguard || bouncerVisible) && keyguardUpdateMonitor.isFaceEnrolled if (shouldListen != isListening) { isListening = shouldListen Loading
packages/SystemUI/src/com/android/systemui/statusbar/policy/KeyguardStateControllerImpl.java +1 −1 Original line number Diff line number Diff line Loading @@ -240,7 +240,7 @@ public class KeyguardStateControllerImpl implements KeyguardStateController, Dum || (Build.IS_DEBUGGABLE && DEBUG_AUTH_WITH_ADB && mDebugUnlocked); boolean trustManaged = mKeyguardUpdateMonitor.getUserTrustIsManaged(user); boolean trusted = mKeyguardUpdateMonitor.getUserHasTrust(user); boolean faceAuthEnabled = mKeyguardUpdateMonitor.isFaceAuthEnabledForUser(user); boolean faceAuthEnabled = mKeyguardUpdateMonitor.isFaceEnrolled(); boolean changed = secure != mSecure || canDismissLockScreen != mCanDismissLockScreen || trustManaged != mTrustManaged || mTrusted != trusted || mFaceAuthEnabled != faceAuthEnabled; Loading
packages/SystemUI/tests/src/com/android/keyguard/KeyguardUpdateMonitorTest.java +15 −8 Original line number Diff line number Diff line Loading @@ -383,6 +383,7 @@ public class KeyguardUpdateMonitorTest extends SysuiTestCase { } private void setupFingerprintAuth(boolean isClass3) throws RemoteException { when(mAuthController.isFingerprintEnrolled(anyInt())).thenReturn(true); when(mFingerprintManager.isHardwareDetected()).thenReturn(true); when(mFingerprintManager.hasEnrolledTemplates(anyInt())).thenReturn(true); mFingerprintSensorProperties = List.of( Loading Loading @@ -2692,33 +2693,42 @@ public class KeyguardUpdateMonitorTest extends SysuiTestCase { } @Test public void testFingerprintSensorProperties() throws RemoteException { // GIVEN no fingerprint sensor properties when(mAuthController.isFingerprintEnrolled(anyInt())).thenReturn(true); mFingerprintAuthenticatorsRegisteredCallback.onAllAuthenticatorsRegistered( new ArrayList<>()); // THEN fingerprint is not possible assertThat(mKeyguardUpdateMonitor.isUnlockWithFingerprintPossible( KeyguardUpdateMonitor.getCurrentUser())).isFalse(); // WHEN there are fingerprint sensor properties mFingerprintAuthenticatorsRegisteredCallback .onAllAuthenticatorsRegistered(mFingerprintSensorProperties); verifyFingerprintAuthenticateCall(); // THEN unlock with fp is possible & fingerprint starts listening assertThat(mKeyguardUpdateMonitor.isUnlockWithFingerprintPossible( KeyguardUpdateMonitor.getCurrentUser())).isTrue(); verifyFingerprintAuthenticateCall(); } @Test public void testFaceSensorProperties() throws RemoteException { // GIVEN no face sensor properties when(mAuthController.isFaceAuthEnrolled(anyInt())).thenReturn(true); mFaceAuthenticatorsRegisteredCallback.onAllAuthenticatorsRegistered(new ArrayList<>()); assertThat(mKeyguardUpdateMonitor.isFaceAuthEnabledForUser( // THEN face is not possible assertThat(mKeyguardUpdateMonitor.isUnlockWithFacePossible( KeyguardUpdateMonitor.getCurrentUser())).isFalse(); // WHEN there are face sensor properties mFaceAuthenticatorsRegisteredCallback.onAllAuthenticatorsRegistered(mFaceSensorProperties); biometricsEnabledForCurrentUser(); // THEN face is possible but face does NOT start listening immediately assertThat(mKeyguardUpdateMonitor.isUnlockWithFacePossible( KeyguardUpdateMonitor.getCurrentUser())).isTrue(); verifyFaceAuthenticateNeverCalled(); verifyFaceDetectNeverCalled(); assertThat(mKeyguardUpdateMonitor.isFaceAuthEnabledForUser( KeyguardUpdateMonitor.getCurrentUser())).isTrue(); } @Test Loading Loading @@ -2791,9 +2801,6 @@ public class KeyguardUpdateMonitorTest extends SysuiTestCase { } private void mockCanBypassLockscreen(boolean canBypass) { // force update the isFaceEnrolled cache: mKeyguardUpdateMonitor.isFaceAuthEnabledForUser(getCurrentUser()); mKeyguardUpdateMonitor.setKeyguardBypassController(mKeyguardBypassController); when(mKeyguardBypassController.canBypass()).thenReturn(canBypass); } Loading