Merge "Update error prioritization in PreAutInfo" into sc-dev
This commit is contained in:
@@ -259,6 +259,21 @@ class PreAuthInfo {
|
|||||||
this.confirmationRequested = confirmationRequested;
|
this.confirmationRequested = confirmationRequested;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private Pair<BiometricSensor, Integer> calculateErrorByPriority() {
|
||||||
|
// If the caller requested STRONG, and the device contains both STRONG and non-STRONG
|
||||||
|
// sensors, prioritize BIOMETRIC_NOT_ENROLLED over the weak sensor's
|
||||||
|
// BIOMETRIC_INSUFFICIENT_STRENGTH error. Pretty sure we can always prioritize
|
||||||
|
// BIOMETRIC_NOT_ENROLLED over any other error (unless of course its calculation is
|
||||||
|
// wrong, in which case we should fix that instead).
|
||||||
|
for (Pair<BiometricSensor, Integer> pair : ineligibleSensors) {
|
||||||
|
if (pair.second == BIOMETRIC_NOT_ENROLLED) {
|
||||||
|
return pair;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return ineligibleSensors.get(0);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* With {@link PreAuthInfo} generated with the requested authenticators from the public API
|
* With {@link PreAuthInfo} generated with the requested authenticators from the public API
|
||||||
* surface, combined with the actual sensor/credential and user/system settings, calculate the
|
* surface, combined with the actual sensor/credential and user/system settings, calculate the
|
||||||
@@ -281,8 +296,9 @@ class PreAuthInfo {
|
|||||||
} else {
|
} else {
|
||||||
// Pick the first sensor error if it exists
|
// Pick the first sensor error if it exists
|
||||||
if (!ineligibleSensors.isEmpty()) {
|
if (!ineligibleSensors.isEmpty()) {
|
||||||
modality |= ineligibleSensors.get(0).first.modality;
|
final Pair<BiometricSensor, Integer> pair = calculateErrorByPriority();
|
||||||
status = ineligibleSensors.get(0).second;
|
modality |= pair.first.modality;
|
||||||
|
status = pair.second;
|
||||||
} else {
|
} else {
|
||||||
modality |= TYPE_CREDENTIAL;
|
modality |= TYPE_CREDENTIAL;
|
||||||
status = CREDENTIAL_NOT_ENROLLED;
|
status = CREDENTIAL_NOT_ENROLLED;
|
||||||
@@ -297,8 +313,9 @@ class PreAuthInfo {
|
|||||||
} else {
|
} else {
|
||||||
// Pick the first sensor error if it exists
|
// Pick the first sensor error if it exists
|
||||||
if (!ineligibleSensors.isEmpty()) {
|
if (!ineligibleSensors.isEmpty()) {
|
||||||
modality |= ineligibleSensors.get(0).first.modality;
|
final Pair<BiometricSensor, Integer> pair = calculateErrorByPriority();
|
||||||
status = ineligibleSensors.get(0).second;
|
modality |= pair.first.modality;
|
||||||
|
status = pair.second;
|
||||||
} else {
|
} else {
|
||||||
modality |= TYPE_NONE;
|
modality |= TYPE_NONE;
|
||||||
status = BIOMETRIC_NO_HARDWARE;
|
status = BIOMETRIC_NO_HARDWARE;
|
||||||
|
|||||||
Reference in New Issue
Block a user