当用户添加新指纹或删除任何现有指纹然后尝试启动应用程序时,它会抛出KeyPermanentlyInvalidatedException
这是我的指纹代码:
public Boolean auth(FingerprintManager.AuthenticationCallback callback) {
try {
KeyStore store = accessKeyStore(DEFAULT_KEYSTORE);
if (store == null) {
return null;
}
Cipher cipher = accessCipher();
if (cipher == null) {
return null;
}
store.load(null);
SecretKey key = (SecretKey) store.getKey(DEFAULT_KEY_NAME, DEFAULT_STORE_PASS.toCharArray());
cipher.init(Cipher.ENCRYPT_MODE, key);
FingerprintManager manager = initManager();
if (manager == null) {
return null;
}
manager.authenticate(
generateCryptoObject(cipher),
generateCancellationSignal(),
0,
callback,
null
);
return true;
} catch (Throwable exc) {
Logger.error(TAG, exc.getLocalizedMessage(), exc);
return null;
}
}
private Cipher accessCipher() { …Run Code Online (Sandbox Code Playgroud)