diff options
| author | 2019-12-15 18:21:46 -0800 | |
|---|---|---|
| committer | 2019-12-15 18:25:55 -0800 | |
| commit | 9cef3631fb8eaecd4ea4583337f160af24237e12 (patch) | |
| tree | 773ea700f52159233f676f3bfa6879a93bc4d7d5 | |
| parent | 2291072bd037c068884a5addb9209eda21f43525 (diff) | |
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
| -rw-r--r-- | services/core/java/com/android/server/biometrics/BiometricService.java | 6 | ||||
| -rw-r--r-- | services/tests/servicestests/src/com/android/server/biometrics/BiometricServiceTest.java | 12 |
2 files changed, 18 insertions, 0 deletions
diff --git a/services/core/java/com/android/server/biometrics/BiometricService.java b/services/core/java/com/android/server/biometrics/BiometricService.java index 770ea8676ecb..0f51e39d128a 100644 --- a/services/core/java/com/android/server/biometrics/BiometricService.java +++ b/services/core/java/com/android/server/biometrics/BiometricService.java @@ -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"); diff --git a/services/tests/servicestests/src/com/android/server/biometrics/BiometricServiceTest.java b/services/tests/servicestests/src/com/android/server/biometrics/BiometricServiceTest.java index 9a2ccef4f3fb..211fc4db6211 100644 --- a/services/tests/servicestests/src/com/android/server/biometrics/BiometricServiceTest.java +++ b/services/tests/servicestests/src/com/android/server/biometrics/BiometricServiceTest.java @@ -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. |