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

Commit 62190bda authored by Kevin Chyn's avatar Kevin Chyn
Browse files

Allow BIOMETRIC_CONVENIENCE to register with BiometricService

BiometricService should be able to handle things other than the public
android.hardware.biometrics APIs - use this class as the source of truth
for all biometric sensors, configurations etc. On the same note, just
because a sensor is registered here does not mean it will participate in
the android.hardware.biometrics APIs.

This default implementation allows device with BIOMETRIC_CONVENIENCE to
successfully boot and pass the CTS tests.

Bug: 150014844

Test: Manually configure a device to be BIOMETRIC_CONVENIENCE only,
      then run the CTS tests
Test: atest com.android.server.biometrics

Change-Id: I704914b2529e17582ef9b87498e2d57184c560fc
parent 7e141fb6
Loading
Loading
Loading
Loading
+9 −2
Original line number Diff line number Diff line
@@ -764,8 +764,13 @@ public class BiometricService extends SystemService {
                        + " config_biometric_sensors?");
            }

            // Note that we allow BIOMETRIC_CONVENIENCE to register because BiometricService
            // also does / will do other things such as keep track of lock screen timeout, etc.
            // Just because a biometric is registered does not mean it can participate in
            // the android.hardware.biometrics APIs.
            if (strength != Authenticators.BIOMETRIC_STRONG
                    && strength != Authenticators.BIOMETRIC_WEAK) {
                    && strength != Authenticators.BIOMETRIC_WEAK
                    && strength != Authenticators.BIOMETRIC_CONVENIENCE) {
                throw new IllegalStateException("Unsupported strength");
            }

@@ -1192,8 +1197,10 @@ public class BiometricService extends SystemService {
                        BiometricConstants.BIOMETRIC_ERROR_NO_DEVICE_CREDENTIAL);
            }
        } else {
            // This should not be possible via the public API surface and is here mainly for
            // "correctness". An exception should have been thrown before getting here.
            Slog.e(TAG, "No authenticators requested");
            return new Pair<>(TYPE_NONE, BiometricConstants.BIOMETRIC_ERROR_HW_UNAVAILABLE);
            return new Pair<>(TYPE_NONE, BiometricConstants.BIOMETRIC_ERROR_HW_NOT_PRESENT);
        }
    }

+0 −14
Original line number Diff line number Diff line
@@ -1276,20 +1276,6 @@ public class BiometricServiceTest {
                mFingerprintAuthenticator);
    }

    @Test(expected = IllegalStateException.class)
    public void testRegistrationWithUnsupportedStrength_throwsIllegalStateException()
            throws Exception {
        mBiometricService = new BiometricService(mContext, mInjector);
        mBiometricService.onStart();

        // Only STRONG and WEAK are supported. Let's enforce that CONVENIENCE cannot be
        // registered. If there is a compelling reason, we can remove this constraint.
        mBiometricService.mImpl.registerAuthenticator(
                0 /* id */, 2 /* modality */,
                Authenticators.BIOMETRIC_CONVENIENCE /* strength */,
                mFingerprintAuthenticator);
    }

    @Test(expected = IllegalArgumentException.class)
    public void testRegistrationWithNullAuthenticator_throwsIllegalArgumentException()
            throws Exception {