Gan*_*nga 8 android biometrics samsung-mobile samsung-galaxy
我们实现了新的android.hardware.biometrics.BiometricPrompt,取代了现有的android.hardware.fingerprint。在我们将“首选生物特征”称为“指纹”之前,新的生物特征API会按预期工作。
当我们将“首选生物特征识别”设置为“面部识别”并尝试使用面部识别作为应用程序的身份验证机制时,我们在onAuthenticationSucceeded中收到“ java.security.SignatureException:android.security.KeyStoreException:密钥用户未通过身份验证” (BiometricPrompt.AuthenticationResult结果)。
在配备Android P的三星设备中似乎可以重现此问题。在配备Android P的Pixel设备中,该问题运行良好(我相信当前Pixel设备不支持第三方应用程序的人脸识别功能)。
private BiometricPrompt.AuthenticationCallback getAuthenticationCallback() {
@Override
public void onAuthenticationSucceeded(BiometricPrompt.AuthenticationResult result) {
Log.i(TAG, "onAuthenticationSucceeded");
super.onAuthenticationSucceeded(result);
Signature signature = result.getCryptoObject().getSignature();
try {
//Exception is thrown when we try to update the Signature with our message.
signature.update(mToBeSignedMessage.getBytes());
String signatureString = Base64.encodeToString(signature.sign(), Base64.URL_SAFE);
Log.i(TAG, "Message: " + mToBeSignedMessage);
Log.i(TAG, "Signature (Base64 EncodeD): " + signatureString);
Toast.makeText(getApplicationContext(), mToBeSignedMessage + ":" + signatureString, Toast.LENGTH_SHORT).show();
} catch (SignatureException e) {
Log.d(TAG, e.getLocalizedMessage());
//java.security.SignatureException: android.security.KeyStoreException: Key user not authenticated"
}
}
}
Run Code Online (Sandbox Code Playgroud)
为什么只有在“首选生物特征”为“面部识别”时才尝试更新签名值,而却得到“ KeyStoreException:密钥用户未通过身份验证”。
| 归档时间: |
|
| 查看次数: |
651 次 |
| 最近记录: |