@Override public void onAuthenticationFailed() { mCallback.onAuthFailed(AuthErrorCodes.CANNOT_RECOGNIZE_ERROR, null); }
/** * Check if the finger print hardware is available. * * @param context instance of the caller. * @return true if finger print authentication is supported. */ private boolean checkFingerPrintAvailability(@NonNull Context context) { // Check if we're running on Android 6.0 (M) or higher if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { //Fingerprint API only available on from Android 6.0 (M) FingerprintManagerCompat fingerprintManager = FingerprintManagerCompat.from(context); if (!fingerprintManager.isHardwareDetected()) { // Device doesn't support fingerprint authentication mCallback.onNoFingerPrintHardwareFound(); return false; } else if (!fingerprintManager.hasEnrolledFingerprints()) { // User hasn't enrolled any fingerprints to authenticate with mCallback.onNoFingerPrintRegistered(); return false; } return true; } else { mCallback.onBelowMarshmallow(); return false; } }
@Override public void onAuthenticationSucceeded(FingerprintManager.AuthenticationResult result) { mCallback.onAuthSuccess(result.getCryptoObject()); } }, null);
@Override public void onAuthenticationHelp(int helpMsgId, CharSequence helpString) { mCallback.onAuthFailed(AuthErrorCodes.RECOVERABLE_ERROR, helpString.toString()); }
@Override public void onAuthenticationError(int errMsgId, CharSequence errString) { mCallback.onAuthFailed(AuthErrorCodes.NON_RECOVERABLE_ERROR, errString.toString()); }
mCallback.onAuthFailed(AuthErrorCodes.NON_RECOVERABLE_ERROR, ERROR_FAILED_TO_GENERATE_KEY); return false; } catch (NoSuchAlgorithmException | NoSuchPaddingException e) { mCallback.onAuthFailed(AuthErrorCodes.NON_RECOVERABLE_ERROR, ERROR_FAILED_TO_GENERATE_KEY); return false; return true; } catch (KeyPermanentlyInvalidatedException e) { mCallback.onAuthFailed(AuthErrorCodes.NON_RECOVERABLE_ERROR, ERROR_FAILED_TO_INIT_CHIPPER); return false; } catch (KeyStoreException | CertificateException | UnrecoverableKeyException | IOException | NoSuchAlgorithmException | InvalidKeyException e) { mCallback.onAuthFailed(AuthErrorCodes.NON_RECOVERABLE_ERROR, ERROR_FAILED_TO_INIT_CHIPPER); return false;
mCallback.onAuthFailed(AuthErrorCodes.NON_RECOVERABLE_ERROR, ERROR_FAILED_TO_INIT_CHIPPER); } else { mCancellationSignal = new CancellationSignal();