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

Commit 5a867c04 authored by Diya Bera's avatar Diya Bera
Browse files

Add check for mandatory biometric flag

Flags: android.hardware.biometrics.flag.mandatory_biometrics
Fixes: 370757426
Test: atest UtilsTest
Change-Id: I3886e3bf67d3d08d420b945931b6b1f6052c3a57
parent d6050a9e
Loading
Loading
Loading
Loading
+9 −3
Original line number Diff line number Diff line
@@ -253,9 +253,15 @@ public class Utils {

        // Check if any of the non-biometric and non-credential bits are set. If so, this is
        // invalid.
        final int testBits = ~(Authenticators.DEVICE_CREDENTIAL
        final int testBits;
        if (Flags.mandatoryBiometrics()) {
            testBits = ~(Authenticators.DEVICE_CREDENTIAL
                    | Authenticators.BIOMETRIC_MIN_STRENGTH
                    | Authenticators.MANDATORY_BIOMETRICS);
        } else {
            testBits = ~(Authenticators.DEVICE_CREDENTIAL
                    | Authenticators.BIOMETRIC_MIN_STRENGTH);
        }
        if ((authenticators & testBits) != 0) {
            Slog.e(BiometricService.TAG, "Non-biometric, non-credential bits found."
                    + " Authenticators: " + authenticators);
+7 −1
Original line number Diff line number Diff line
@@ -217,7 +217,13 @@ public class UtilsTest {
        doNothing().when(mContext).enforceCallingOrSelfPermission(
                eq(SET_BIOMETRIC_DIALOG_ADVANCED), any());

        assertTrue(Utils.isValidAuthenticatorConfig(mContext, Authenticators.MANDATORY_BIOMETRICS));
        if (Flags.mandatoryBiometrics()) {
            assertTrue(Utils.isValidAuthenticatorConfig(mContext,
                    Authenticators.MANDATORY_BIOMETRICS));
        } else {
            assertFalse(Utils.isValidAuthenticatorConfig(mContext,
                    Authenticators.MANDATORY_BIOMETRICS));
        }

        // The rest of the bits are not allowed to integrate with the public APIs
        for (int i = 8; i < 32; i++) {