Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit f5b30ab8 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Don't start running FP until FPS is registered"

parents 32602509 8dc937df
Loading
Loading
Loading
Loading
+7 −0
Original line number Diff line number Diff line
@@ -2027,6 +2027,7 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener, Dumpab
        mAuthController.addCallback(new AuthController.Callback() {
            @Override
            public void onAllAuthenticatorsRegistered() {
                mainExecutor.execute(() -> updateBiometricListeningState(BIOMETRIC_ACTION_UPDATE));
            }

            @Override
@@ -2156,6 +2157,10 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener, Dumpab
            return;
        }

        // don't start running fingerprint until they're registered
        if (!mAuthController.areAllAuthenticatorsRegistered()) {
            return;
        }
        final boolean shouldListenForFingerprint = shouldListenForFingerprint(isUdfpsSupported());
        final boolean runningOrRestarting = mFingerprintRunningState == BIOMETRIC_STATE_RUNNING
                || mFingerprintRunningState == BIOMETRIC_STATE_CANCELLING_RESTARTING;
@@ -3523,6 +3528,8 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener, Dumpab
            final int strongAuthFlags = mStrongAuthTracker.getStrongAuthForUser(userId);
            BiometricAuthenticated fingerprint = mUserFingerprintAuthenticated.get(userId);
            pw.println("  Fingerprint state (user=" + userId + ")");
            pw.println("    areAllAuthenticatorsRegistered="
                    + mAuthController.areAllAuthenticatorsRegistered());
            pw.println("    allowed="
                    + (fingerprint != null
                            && isUnlockingWithBiometricAllowed(fingerprint.mIsStrongBiometric)));
+9 −0
Original line number Diff line number Diff line
@@ -136,6 +136,7 @@ public class AuthController extends CoreStartable implements CommandQueue.Callba
    @NonNull private final SparseBooleanArray mUdfpsEnrolledForUser;
    @NonNull private final SensorPrivacyManager mSensorPrivacyManager;
    private final WakefulnessLifecycle mWakefulnessLifecycle;
    private boolean mAllAuthenticatorsRegistered;

    private class BiometricTaskStackListener extends TaskStackListener {
        @Override
@@ -226,6 +227,13 @@ public class AuthController extends CoreStartable implements CommandQueue.Callba
        }
    }

    /**
     * Whether all authentictors have been registered.
     */
    public boolean areAllAuthenticatorsRegistered() {
        return mAllAuthenticatorsRegistered;
    }

    private void handleAllAuthenticatorsRegistered(
            List<FingerprintSensorPropertiesInternal> sensors) {
        mExecution.assertIsMainThread();
@@ -233,6 +241,7 @@ public class AuthController extends CoreStartable implements CommandQueue.Callba
            Log.d(TAG, "handleAllAuthenticatorsRegistered | sensors: " + Arrays.toString(
                    sensors.toArray()));
        }
        mAllAuthenticatorsRegistered = true;
        mFpProps = sensors;
        List<FingerprintSensorPropertiesInternal> udfpsProps = new ArrayList<>();
        List<FingerprintSensorPropertiesInternal> sidefpsProps = new ArrayList<>();
+15 −0
Original line number Diff line number Diff line
@@ -243,6 +243,9 @@ public class KeyguardUpdateMonitorTest extends SysuiTestCase {
        verify(mStatusBarStateController).addCallback(mStatusBarStateListenerCaptor.capture());
        mStatusBarStateListener = mStatusBarStateListenerCaptor.getValue();
        mKeyguardUpdateMonitor.registerCallback(mTestCallback);

        mTestableLooper.processAllMessages();
        when(mAuthController.areAllAuthenticatorsRegistered()).thenReturn(true);
    }

    @After
@@ -470,6 +473,18 @@ public class KeyguardUpdateMonitorTest extends SysuiTestCase {
        verify(mFingerprintManager, never()).detectFingerprint(any(), any(), anyInt());
    }

    @Test
    public void test_doesNotTryToAuthenticateFingerprint_whenAuthenticatorsNotRegistered() {
        when(mAuthController.areAllAuthenticatorsRegistered()).thenReturn(false);

        mKeyguardUpdateMonitor.dispatchStartedGoingToSleep(0 /* why */);
        mTestableLooper.processAllMessages();

        verify(mFingerprintManager, never()).authenticate(any(), any(), any(), any(), anyInt(),
                anyInt(), anyInt());
        verify(mFingerprintManager, never()).detectFingerprint(any(), any(), anyInt());
    }

    @Test
    public void testFingerprintDoesNotAuth_whenEncrypted() {
        testFingerprintWhenStrongAuth(