Android指纹没有超时
我正在我的应用程序中实现android原生指纹API。 根据文档,FINGERPRINT_ERROR_TIMEOUT(3)是超时情况下应接收的错误代码。还提到:Android指纹没有超时,android,android-fingerprint-api,Android,Android Fingerprint Api,我正在我的应用程序中实现android原生指纹API。 根据文档,FINGERPRINT_ERROR_TIMEOUT(3)是超时情况下应接收的错误代码。还提到: int FINGERPRINT_ERROR_TIMEOUT Error state returned when the current request has been running too long. This is intended to prevent programs from waiting for the fingerpr
int FINGERPRINT_ERROR_TIMEOUT
Error state returned when the current request has been running too long.
This is intended to prevent programs from waiting for the fingerprint sensor indefinitely.
The timeout is platform and sensor-specific, but is generally on the order of 30 seconds.
在我的例子中,这个超时回调没有发生。我目前正在使用三星S7进行测试。有人能帮助我们如何配置这个值,以及确定为什么默认情况下没有超时吗
编辑1:
添加指纹处理程序的代码:
@RequiresApi(api = Build.VERSION_CODES.M)
public class FingerprintHandler extends
FingerprintManager.AuthenticationCallback {
private CancellationSignal cancellationSignal;
private Context appContext;
private boolean sendCancellation=false;
public FingerprintHandler(Context context) {
appContext = context;
}
public void startAuth(FingerprintManager manager,
FingerprintManager.CryptoObject cryptoObject) {
cancellationSignal = new CancellationSignal();
if (ActivityCompat.checkSelfPermission(appContext,
Manifest.permission.USE_FINGERPRINT) !=
PackageManager.PERMISSION_GRANTED) {
return;
}
manager.authenticate(cryptoObject, cancellationSignal, 0, this, null);
}
@Override
public void onAuthenticationError(int errMsgId,
CharSequence errString) {
Log.d(TAG,"Authentication error callback");
Log.d(TAG,"Error Value: "+errMsgId);
switch(errMsgId){
case FINGERPRINT_ERROR_LOCKOUT:
Log.d(TAG,"Fingerprint error lockout");
nativeLocked = true;
mPreferences.edit().putLong(LAST_FAILURE, System.currentTimeMillis()).apply();
mPreferences.edit().putBoolean("nativeLocked", true).apply();
showError(getString(R.string.test_bio_fingerprint_fingerprint_authentication_failed));
mCancelButton.setEnabled(true);
dialogHandler.postDelayed(new Runnable() {
@Override
public void run() {
mCancelButton.setEnabled(true);
dismissDialog();
sendFailure();
}
}, SUCCESS_OR_FAIL_DELAY_MILLIS);
break;
case FINGERPRINT_ERROR_CANCELED:
Log.d(TAG,"Fingerprint has been cancelled");
if(sendCancellation) {
dismissDialog();
if (useEye)
sendCancelForEye();
else
sendCancel();
}
break;
}
}
@Override
public void onAuthenticationHelp(int helpMsgId,
CharSequence helpString) {
Log.d(TAG,"Authentication helper callback");
retryWithError(R.string.test_bio_fingerprint_fingerprint_too_fast);
}
@Override
public void onAuthenticationFailed() {
Log.d(TAG,"Authentication failed callback");
retryWithError(R.string.test_bio_fingerprint_fingerprint_not_recognized);
}
@Override
public void onAuthenticationSucceeded(
FingerprintManager.AuthenticationResult result) {
Log.d(TAG,"Authentication successfull callback");
onAuthenticationSuccess();
}
public void stopListening(boolean sendCancellation) {
this.sendCancellation=sendCancellation;
Log.d(TAG,"stopListening called");
if (cancellationSignal != null) {
cancellationSignal.cancel();
cancellationSignal = null;
}
}
}
这个处理程序被放在一个FingerprintDialog类中,该类扩展了DialogFragment类
下面的代码是初始化处理程序和启动身份验证的代码:
helper = new FingerprintHandler(getContext());
fingerprintManager =(FingerprintManager) getContext().getSystemService(FINGERPRINT_SERVICE);
helper.startAuth(fingerprintManager, null);
编辑2:
如果有人能给我指出一个源代码,这个实现可以正常工作,超时值已经配置好了,那就太好了。
然后,我可以将我的实现与正在工作的实现进行比较,以确定我的实现中是否存在任何问题。
我在android开发者网站或stackoverflow上找不到任何有用的东西。
我也向谷歌提出了一个问题:你能包括你正在运行的代码吗?@ralphie9224:添加了与指纹部分相关的代码。嗨@Sid,我也遇到了类似的问题。你能找到解决办法吗?如果是这样,我可能会从中受益it@user1527152:我无法找到解决方案,据我记忆所及,我在应用程序中添加了处理超时的代码。