Loading core/java/android/hardware/biometrics/BiometricPrompt.java +22 −1 Original line number Diff line number Diff line Loading @@ -472,6 +472,10 @@ public class BiometricPrompt implements BiometricAuthenticator, BiometricConstan @Override public void onCancel() { if (!mIsPromptShowing) { Log.w(TAG, "BP is not showing"); return; } Log.d(TAG, "Cancel BP authentication requested for: " + mAuthRequestId); cancelAuthentication(mAuthRequestId); } Loading @@ -496,6 +500,7 @@ public class BiometricPrompt implements BiometricAuthenticator, BiometricConstan final AuthenticationResult result = new AuthenticationResult(mCryptoObject, authenticationType); mAuthenticationCallback.onAuthenticationSucceeded(result); mIsPromptShowing = false; }); } Loading @@ -503,6 +508,7 @@ public class BiometricPrompt implements BiometricAuthenticator, BiometricConstan public void onAuthenticationFailed() { mExecutor.execute(() -> { mAuthenticationCallback.onAuthenticationFailed(); mIsPromptShowing = false; }); } Loading Loading @@ -550,6 +556,7 @@ public class BiometricPrompt implements BiometricAuthenticator, BiometricConstan final String stringToSend = errorMessage; mExecutor.execute(() -> { mAuthenticationCallback.onAuthenticationError(error, stringToSend); mIsPromptShowing = false; }); } Loading @@ -566,8 +573,10 @@ public class BiometricPrompt implements BiometricAuthenticator, BiometricConstan if (reason == DISMISSED_REASON_NEGATIVE) { mNegativeButtonInfo.executor.execute(() -> { mNegativeButtonInfo.listener.onClick(null, DialogInterface.BUTTON_NEGATIVE); mIsPromptShowing = false; }); } else { mIsPromptShowing = false; Log.e(TAG, "Unknown reason: " + reason); } } Loading @@ -580,12 +589,15 @@ public class BiometricPrompt implements BiometricAuthenticator, BiometricConstan } }; private boolean mIsPromptShowing; private BiometricPrompt(Context context, PromptInfo promptInfo, ButtonInfo negativeButtonInfo) { mContext = context; mPromptInfo = promptInfo; mNegativeButtonInfo = negativeButtonInfo; mService = IAuthService.Stub.asInterface( ServiceManager.getService(Context.AUTH_SERVICE)); mIsPromptShowing = false; } /** Loading Loading @@ -1095,7 +1107,6 @@ public class BiometricPrompt implements BiometricAuthenticator, BiometricConstan @NonNull @CallbackExecutor Executor executor, @NonNull AuthenticationCallback callback, int userId) { // Ensure we don't return the wrong crypto object as an auth result. if (mCryptoObject != null && mCryptoObject.getOpId() != operationId) { Log.w(TAG, "CryptoObject operation ID does not match argument; setting field to null"); Loading @@ -1110,6 +1121,14 @@ public class BiometricPrompt implements BiometricAuthenticator, BiometricConstan mExecutor = executor; mAuthenticationCallback = callback; if (mIsPromptShowing) { final String stringToSend = mContext.getString(R.string.biometric_error_canceled); mExecutor.execute(() -> { mAuthenticationCallback.onAuthenticationError(BIOMETRIC_ERROR_CANCELED, stringToSend); }); return -1; } final PromptInfo promptInfo; if (operationId != 0L) { Loading @@ -1131,6 +1150,8 @@ public class BiometricPrompt implements BiometricAuthenticator, BiometricConstan final long authId = mService.authenticate(mToken, operationId, userId, mBiometricServiceReceiver, mContext.getPackageName(), promptInfo); cancel.setOnCancelListener(new OnAuthenticationCancelListener(authId)); mIsPromptShowing = true; return authId; } catch (RemoteException e) { Log.e(TAG, "Remote exception while authenticating", e); Loading Loading
core/java/android/hardware/biometrics/BiometricPrompt.java +22 −1 Original line number Diff line number Diff line Loading @@ -472,6 +472,10 @@ public class BiometricPrompt implements BiometricAuthenticator, BiometricConstan @Override public void onCancel() { if (!mIsPromptShowing) { Log.w(TAG, "BP is not showing"); return; } Log.d(TAG, "Cancel BP authentication requested for: " + mAuthRequestId); cancelAuthentication(mAuthRequestId); } Loading @@ -496,6 +500,7 @@ public class BiometricPrompt implements BiometricAuthenticator, BiometricConstan final AuthenticationResult result = new AuthenticationResult(mCryptoObject, authenticationType); mAuthenticationCallback.onAuthenticationSucceeded(result); mIsPromptShowing = false; }); } Loading @@ -503,6 +508,7 @@ public class BiometricPrompt implements BiometricAuthenticator, BiometricConstan public void onAuthenticationFailed() { mExecutor.execute(() -> { mAuthenticationCallback.onAuthenticationFailed(); mIsPromptShowing = false; }); } Loading Loading @@ -550,6 +556,7 @@ public class BiometricPrompt implements BiometricAuthenticator, BiometricConstan final String stringToSend = errorMessage; mExecutor.execute(() -> { mAuthenticationCallback.onAuthenticationError(error, stringToSend); mIsPromptShowing = false; }); } Loading @@ -566,8 +573,10 @@ public class BiometricPrompt implements BiometricAuthenticator, BiometricConstan if (reason == DISMISSED_REASON_NEGATIVE) { mNegativeButtonInfo.executor.execute(() -> { mNegativeButtonInfo.listener.onClick(null, DialogInterface.BUTTON_NEGATIVE); mIsPromptShowing = false; }); } else { mIsPromptShowing = false; Log.e(TAG, "Unknown reason: " + reason); } } Loading @@ -580,12 +589,15 @@ public class BiometricPrompt implements BiometricAuthenticator, BiometricConstan } }; private boolean mIsPromptShowing; private BiometricPrompt(Context context, PromptInfo promptInfo, ButtonInfo negativeButtonInfo) { mContext = context; mPromptInfo = promptInfo; mNegativeButtonInfo = negativeButtonInfo; mService = IAuthService.Stub.asInterface( ServiceManager.getService(Context.AUTH_SERVICE)); mIsPromptShowing = false; } /** Loading Loading @@ -1095,7 +1107,6 @@ public class BiometricPrompt implements BiometricAuthenticator, BiometricConstan @NonNull @CallbackExecutor Executor executor, @NonNull AuthenticationCallback callback, int userId) { // Ensure we don't return the wrong crypto object as an auth result. if (mCryptoObject != null && mCryptoObject.getOpId() != operationId) { Log.w(TAG, "CryptoObject operation ID does not match argument; setting field to null"); Loading @@ -1110,6 +1121,14 @@ public class BiometricPrompt implements BiometricAuthenticator, BiometricConstan mExecutor = executor; mAuthenticationCallback = callback; if (mIsPromptShowing) { final String stringToSend = mContext.getString(R.string.biometric_error_canceled); mExecutor.execute(() -> { mAuthenticationCallback.onAuthenticationError(BIOMETRIC_ERROR_CANCELED, stringToSend); }); return -1; } final PromptInfo promptInfo; if (operationId != 0L) { Loading @@ -1131,6 +1150,8 @@ public class BiometricPrompt implements BiometricAuthenticator, BiometricConstan final long authId = mService.authenticate(mToken, operationId, userId, mBiometricServiceReceiver, mContext.getPackageName(), promptInfo); cancel.setOnCancelListener(new OnAuthenticationCancelListener(authId)); mIsPromptShowing = true; return authId; } catch (RemoteException e) { Log.e(TAG, "Remote exception while authenticating", e); Loading