public void onUsepwd() {
if (fingerprintCallback != null)
fingerprintCallback.onUsepwd();
}
@Override
public void onCancle() {//取消指纹验证,通知调用者
if (fingerprintCallback != null)
fingerprintCallback.onCancel();
}
@Override
public void onDismiss() {//验证框消失,取消指纹验证
if (cancellationSignal != null && !cancellationSignal.isCanceled())
cancellationSignal.cancel();
}
};
/**
- 指纹验证结果回调
*/
private FingerprintManagerCompat.AuthenticationCallback authenticationCallback = new FingerprintManagerCompat.AuthenticationCallback() {
@Override
public void onAuthenticationError(int errMsgId, CharSequence errString) {
super.onAuthenticationError(errMsgId, errString);
fingerprintDialog.setTip(errString.toString(), R.color.biometricprompt_color_FF5555);
}
@Override
public void onAuthenticationHelp(int helpMsgId, CharSequence helpString) {
super.onAuthenticationHelp(helpMsgId, helpString);
fingerprintDialog.setTip(helpString.toString(), R.color.biometricprompt_color_FF5555);
}
@Override
public void onAuthenticationSucceeded(FingerprintManagerCompat.AuthenticationResult result) {
super.onAuthenticationSucceeded(result);
fingerprintDialog.setTip(context.getString(R.string.biometricprompt_verify_success), R.color.biometricprompt_color_82C785);
fingerprintCallback.onSucceeded();
fingerprintDialog.dismiss();
}
@Override
public void onAuthenticationFailed() {
super.onAuthenticationFailed();
fingerprintDialog.setTip(context.getString(R.string.biometricprompt_verify_failed), R.color.biometricprompt_color_FF5555);
fingerprintCallback.onFailed();
}
};
/*
- 在 Android Q,Google 提供了 Api BiometricManager.canAuthenticate() 用来检测指纹识别硬件是否可用及是否添加指纹
- 不过尚未开放,标记为"Stub"(存根)
- 所以暂时还是需要使用 Andorid 6.0 的 Api 进行判断
- /
private boolean canAuthenticate(Context context, FingerprintCallback fingerprintCallback) {
/ - 硬件是否支持指纹识别
- */
if (!FingerprintManagerCompat.from(context).isHardwareDetected()) {
fingerprintCallback.onError(FingerprintManager.FINGER