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

Commit 9cef3631 authored by Kevin Chyn's avatar Kevin Chyn
Browse files

Enforce that registered authenticators are not null

OEMs should ensure that the config_biometric_sensors
overlay for core/res/res/values.xml is correct. The majority
of devices already have fingerprint sensors, thus to ease
migration, the default configuration is for a "strong
fingerprint sensor on ID0". On devices where this is not true,
the config must be overlaid with whatever sensor the device
actually has.

Bug: 141025588

Test: atest BiometricServiceTest
Change-Id: I61f56d4f11fb7ce3d164a3528a8ecc3522c7e342
parent 2291072b
Loading
Loading
Loading
Loading
+6 −0
Original line number Diff line number Diff line
@@ -764,6 +764,12 @@ public class BiometricService extends SystemService {
                    + " Modality: " + modality
                    + " Strength: " + strength);

            if (authenticator == null) {
                throw new IllegalArgumentException("Authenticator must not be null."
                        + " Did you forget to modify the core/res/res/values/xml overlay for"
                        + " config_biometric_sensors?");
            }

            if (strength != Authenticators.BIOMETRIC_STRONG
                    && strength != Authenticators.BIOMETRIC_WEAK) {
                throw new IllegalStateException("Unsupported strength");
+12 −0
Original line number Diff line number Diff line
@@ -1177,6 +1177,18 @@ public class BiometricServiceTest {
                mFingerprintAuthenticator);
    }

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

        mBiometricService.mImpl.registerAuthenticator(
                0 /* id */, 2 /* modality */,
                Authenticators.BIOMETRIC_STRONG /* strength */,
                null /* authenticator */);
    }

    @Test
    public void testRegistrationHappyPath_isOk() throws Exception {
        // This is being tested in many of the other cases, but here's the base case.