summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--services/core/java/com/android/server/biometrics/Utils.java12
-rw-r--r--services/tests/servicestests/src/com/android/server/biometrics/UtilsTest.java8
2 files changed, 16 insertions, 4 deletions
diff --git a/services/core/java/com/android/server/biometrics/Utils.java b/services/core/java/com/android/server/biometrics/Utils.java
index de7bce78587b..87341365355b 100644
--- a/services/core/java/com/android/server/biometrics/Utils.java
+++ b/services/core/java/com/android/server/biometrics/Utils.java
@@ -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
- | Authenticators.BIOMETRIC_MIN_STRENGTH
- | Authenticators.MANDATORY_BIOMETRICS);
+ 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);
diff --git a/services/tests/servicestests/src/com/android/server/biometrics/UtilsTest.java b/services/tests/servicestests/src/com/android/server/biometrics/UtilsTest.java
index efc2d974a7cc..1bea371c5786 100644
--- a/services/tests/servicestests/src/com/android/server/biometrics/UtilsTest.java
+++ b/services/tests/servicestests/src/com/android/server/biometrics/UtilsTest.java
@@ -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++) {