Handle fingerprint hardware errors

pull/194/merge
M66B 4 years ago
parent c6c63b8a7b
commit d63ddec037

@ -2166,11 +2166,18 @@ public class Helper {
@Override @Override
public void onAuthenticationError(final int errorCode, @NonNull final CharSequence errString) { public void onAuthenticationError(final int errorCode, @NonNull final CharSequence errString) {
if (isCancelled(errorCode))
Log.w("Authenticate biometric error " + errorCode + ": " + errString); Log.w("Authenticate biometric error " + errorCode + ": " + errString);
else
Log.e("Authenticate biometric error " + errorCode + ": " + errString);
if (isHardwareFailure(errorCode)) {
prefs.edit().remove("biometrics").apply();
ApplicationEx.getMainHandler().post(authenticated);
return;
}
if (errorCode != BiometricPrompt.ERROR_NEGATIVE_BUTTON && if (!isCancelled(errorCode))
errorCode != BiometricPrompt.ERROR_CANCELED &&
errorCode != BiometricPrompt.ERROR_USER_CANCELED)
ApplicationEx.getMainHandler().post(new Runnable() { ApplicationEx.getMainHandler().post(new Runnable() {
@Override @Override
public void run() { public void run() {
@ -2196,6 +2203,19 @@ public class Helper {
if (++fails >= 3) if (++fails >= 3)
ApplicationEx.getMainHandler().post(cancelled); ApplicationEx.getMainHandler().post(cancelled);
} }
private boolean isCancelled(int errorCode) {
return (errorCode == BiometricPrompt.ERROR_NEGATIVE_BUTTON ||
errorCode == BiometricPrompt.ERROR_CANCELED ||
errorCode == BiometricPrompt.ERROR_USER_CANCELED);
}
private boolean isHardwareFailure(int errorCode) {
return (errorCode == BiometricPrompt.ERROR_HW_UNAVAILABLE ||
errorCode == BiometricPrompt.ERROR_NO_BIOMETRICS ||
errorCode == BiometricPrompt.ERROR_HW_NOT_PRESENT ||
errorCode == BiometricPrompt.ERROR_NO_DEVICE_CREDENTIAL);
}
}); });
prompt.authenticate(info.build()); prompt.authenticate(info.build());

Loading…
Cancel
Save