Merge changes from topic "biometric-tests"

* changes:
  4/n: Make BiometricDialogView testable
  3/n: Move task stack listener to SystemUI
  2/n: Update BiometricService with cleaner lifecycle
  1/n: Update BiometricDialog (SystemUI side) with cleaner lifecycle
This commit is contained in:
Kevin Chyn
2019-08-16 20:28:23 +00:00
committed by Android (Google) Code Review
19 changed files with 2215 additions and 619 deletions

View File

@@ -100,9 +100,12 @@ public class BiometricPrompt implements BiometricAuthenticator, BiometricConstan
/**
* @hide
*/
public static final int DISMISSED_REASON_POSITIVE = 1;
public static final int DISMISSED_REASON_CONFIRMED = 1;
/**
* Dialog is done animating away after user clicked on the button set via
* {@link BiometricPrompt.Builder#setNegativeButton(CharSequence, Executor,
* DialogInterface.OnClickListener)}.
* @hide
*/
public static final int DISMISSED_REASON_NEGATIVE = 2;
@@ -112,6 +115,25 @@ public class BiometricPrompt implements BiometricAuthenticator, BiometricConstan
*/
public static final int DISMISSED_REASON_USER_CANCEL = 3;
/**
* Authenticated, confirmation not required. Dialog animated away.
* @hide
*/
public static final int DISMISSED_REASON_CONFIRM_NOT_REQUIRED = 4;
/**
* Error message shown on SystemUI. When BiometricService receives this, the UI is already
* gone.
* @hide
*/
public static final int DISMISSED_REASON_ERROR = 5;
/**
* Dialog dismissal requested by BiometricService.
* @hide
*/
public static final int DISMISSED_REASON_SERVER_REQUESTED = 6;
private static class ButtonInfo {
Executor executor;
DialogInterface.OnClickListener listener;
@@ -362,7 +384,7 @@ public class BiometricPrompt implements BiometricAuthenticator, BiometricConstan
@Override
public void onDialogDismissed(int reason) throws RemoteException {
// Check the reason and invoke OnClickListener(s) if necessary
if (reason == DISMISSED_REASON_POSITIVE) {
if (reason == DISMISSED_REASON_CONFIRMED) {
mPositiveButtonInfo.executor.execute(() -> {
mPositiveButtonInfo.listener.onClick(null, DialogInterface.BUTTON_POSITIVE);
});

View File

@@ -27,8 +27,8 @@ oneway interface IBiometricServiceReceiverInternal {
// Notify BiometricService that authentication was successful. If user confirmation is required,
// the auth token must be submitted into KeyStore.
void onAuthenticationSucceeded(boolean requireConfirmation, in byte[] token);
// Notify BiometricService that an error has occurred.
void onAuthenticationFailed(int cookie, boolean requireConfirmation);
// Notify BiometricService authentication was rejected.
void onAuthenticationFailed();
// Notify BiometricService than an error has occured. Forward to the correct receiver depending
// on the cookie.
void onError(int cookie, int error, String message);