Merge "When there is a convenience strength sensor, BiometricPrompt.BIOMETRIC_ERROR_HW_NOT_PRESENT(12) error should be returned for testWhenCredentialNotEnrolled.because convenience authenticator status is BIOMETRIC_INSUFFICIENT_STRENGTH" into android12L-tests-dev
diff --git a/tests/framework/base/biometrics/src/android/server/biometrics/BiometricSimpleTests.java b/tests/framework/base/biometrics/src/android/server/biometrics/BiometricSimpleTests.java
index 716db8d..d07c3ce 100644
--- a/tests/framework/base/biometrics/src/android/server/biometrics/BiometricSimpleTests.java
+++ b/tests/framework/base/biometrics/src/android/server/biometrics/BiometricSimpleTests.java
@@ -174,15 +174,31 @@
// Third case above. Since the deprecated API is intended to allow credential in addition
// to biometrics, we should be receiving BIOMETRIC_ERROR_NO_BIOMETRICS.
final boolean noSensors = mSensorProperties.isEmpty();
+ int expectedError;
+ if (noSensors) {
+ expectedError = BiometricPrompt.BIOMETRIC_ERROR_NO_DEVICE_CREDENTIAL;
+ } else if (hasOnlyConvenienceSensors()) {
+ expectedError = BiometricPrompt.BIOMETRIC_ERROR_HW_NOT_PRESENT;
+ } else {
+ expectedError = BiometricPrompt.BIOMETRIC_ERROR_NO_BIOMETRICS;
+ }
callback = mock(BiometricPrompt.AuthenticationCallback.class);
showDeviceCredentialAllowedBiometricPrompt(callback, new CancellationSignal(),
false /* shouldShow */);
verify(callback).onAuthenticationError(
- eq(noSensors ? BiometricPrompt.BIOMETRIC_ERROR_NO_DEVICE_CREDENTIAL
- : BiometricPrompt.BIOMETRIC_ERROR_NO_BIOMETRICS),
+ eq(expectedError),
any());
}
+ private boolean hasOnlyConvenienceSensors() {
+ for (SensorProperties sensor : mSensorProperties) {
+ if (sensor.getSensorStrength() != SensorProperties.STRENGTH_CONVENIENCE) {
+ return false;
+ }
+ }
+ return true;
+ }
+
/**
* When device credential is enrolled, check the behavior for
* 1) BiometricManager#canAuthenticate(DEVICE_CREDENTIAL)