diff options
| author | Kevin Chyn <kchyn@google.com> | 2019-10-05 02:37:26 +0000 |
|---|---|---|
| committer | Android (Google) Code Review <android-gerrit@google.com> | 2019-10-05 02:37:26 +0000 |
| commit | f8ff281ae0246cf0aadcbd3c3d7dd8445d6f8edc (patch) | |
| tree | 77c6d9756af0e006cfff4548874838ed983805ab /core/java | |
| parent | e10e901b7fae3400a7c594fd069947398ddbde5a (diff) | |
| parent | 484466e2b858ac8c263c88b19f549162028d1347 (diff) | |
Merge changes from topic "biometric-ui-credentials"
* changes:
Animate panel to transparent if profile is managed
17/n: Show credential UI if setDeviceCredentialAllowed(true) and no biometrics
16/n: Add PIN/Password
15/n: Allow Auth UI to start in credential UI
14/n: Animate to device credential UI when lockout occurs
13/n: persist device credential across configuration changes
12/n: Add LockPatternView for setDeviceCredentialAllowed(true)
11/n: Animate panel to full-screen when "Use Password" is pressed
Removing old confirm device credential logic
Diffstat (limited to 'core/java')
| -rw-r--r-- | core/java/android/app/KeyguardManager.java | 6 | ||||
| -rw-r--r-- | core/java/android/hardware/biometrics/Authenticator.java (renamed from core/java/android/hardware/biometrics/IBiometricConfirmDeviceCredentialCallback.aidl) | 19 | ||||
| -rw-r--r-- | core/java/android/hardware/biometrics/BiometricManager.java | 50 | ||||
| -rw-r--r-- | core/java/android/hardware/biometrics/BiometricPrompt.java | 82 | ||||
| -rw-r--r-- | core/java/android/hardware/biometrics/IBiometricService.aidl | 17 | ||||
| -rw-r--r-- | core/java/android/hardware/biometrics/IBiometricServiceReceiverInternal.aidl | 2 | ||||
| -rw-r--r-- | core/java/com/android/internal/statusbar/IStatusBar.aidl | 14 | ||||
| -rw-r--r-- | core/java/com/android/internal/statusbar/IStatusBarService.aidl | 14 |
8 files changed, 55 insertions, 149 deletions
diff --git a/core/java/android/app/KeyguardManager.java b/core/java/android/app/KeyguardManager.java index 9b667a118ebc..b1565ab8a501 100644 --- a/core/java/android/app/KeyguardManager.java +++ b/core/java/android/app/KeyguardManager.java @@ -87,12 +87,6 @@ public class KeyguardManager { "android.app.action.CONFIRM_FRP_CREDENTIAL"; /** - * @hide - */ - public static final String EXTRA_BIOMETRIC_PROMPT_BUNDLE = - "android.app.extra.BIOMETRIC_PROMPT_BUNDLE"; - - /** * A CharSequence dialog title to show to the user when used with a * {@link #ACTION_CONFIRM_DEVICE_CREDENTIAL}. * @hide diff --git a/core/java/android/hardware/biometrics/IBiometricConfirmDeviceCredentialCallback.aidl b/core/java/android/hardware/biometrics/Authenticator.java index 8b35852efd31..6d7e7488f2d0 100644 --- a/core/java/android/hardware/biometrics/IBiometricConfirmDeviceCredentialCallback.aidl +++ b/core/java/android/hardware/biometrics/Authenticator.java @@ -17,10 +17,19 @@ package android.hardware.biometrics; /** - * Communication channel between ConfirmDeviceCredential / ConfirmLock* and BiometricService. + * Type of authenticators defined on a granularity that the BiometricManager / BiometricPrompt + * supports. * @hide */ -interface IBiometricConfirmDeviceCredentialCallback { - // Invoked when authentication should be canceled. - oneway void cancel(); -}
\ No newline at end of file +public class Authenticator { + + /** + * Device credential, e.g. Pin/Pattern/Password. + */ + public static final int TYPE_CREDENTIAL = 1 << 0; + /** + * Encompasses all biometrics on the device, e.g. Fingerprint/Iris/Face. + */ + public static final int TYPE_BIOMETRIC = 1 << 1; + +} diff --git a/core/java/android/hardware/biometrics/BiometricManager.java b/core/java/android/hardware/biometrics/BiometricManager.java index d8110f33d723..cbe8a052db2f 100644 --- a/core/java/android/hardware/biometrics/BiometricManager.java +++ b/core/java/android/hardware/biometrics/BiometricManager.java @@ -201,55 +201,5 @@ public class BiometricManager { } } - /** - * TODO(b/123378871): Remove when moved. - * @hide - */ - @RequiresPermission(USE_BIOMETRIC_INTERNAL) - public void onConfirmDeviceCredentialSuccess() { - if (mService != null) { - try { - mService.onConfirmDeviceCredentialSuccess(); - } catch (RemoteException e) { - throw e.rethrowFromSystemServer(); - } - } else { - Slog.w(TAG, "onConfirmDeviceCredentialSuccess(): Service not connected"); - } - } - - /** - * TODO(b/123378871): Remove when moved. - * @hide - */ - @RequiresPermission(USE_BIOMETRIC_INTERNAL) - public void onConfirmDeviceCredentialError(int error, String message) { - if (mService != null) { - try { - mService.onConfirmDeviceCredentialError(error, message); - } catch (RemoteException e) { - throw e.rethrowFromSystemServer(); - } - } else { - Slog.w(TAG, "onConfirmDeviceCredentialError(): Service not connected"); - } - } - - /** - * TODO(b/123378871): Remove when moved. - * @hide - */ - @RequiresPermission(USE_BIOMETRIC_INTERNAL) - public void registerCancellationCallback(IBiometricConfirmDeviceCredentialCallback callback) { - if (mService != null) { - try { - mService.registerCancellationCallback(callback); - } catch (RemoteException e) { - throw e.rethrowFromSystemServer(); - } - } else { - Slog.w(TAG, "registerCancellationCallback(): Service not connected"); - } - } } diff --git a/core/java/android/hardware/biometrics/BiometricPrompt.java b/core/java/android/hardware/biometrics/BiometricPrompt.java index fb6b231632f1..cf86e25112d2 100644 --- a/core/java/android/hardware/biometrics/BiometricPrompt.java +++ b/core/java/android/hardware/biometrics/BiometricPrompt.java @@ -69,24 +69,21 @@ public class BiometricPrompt implements BiometricAuthenticator, BiometricConstan /** * @hide */ - public static final String KEY_POSITIVE_TEXT = "positive_text"; - /** - * @hide - */ public static final String KEY_NEGATIVE_TEXT = "negative_text"; /** * @hide */ public static final String KEY_REQUIRE_CONFIRMATION = "require_confirmation"; /** + * This is deprecated. Internally we should use {@link #KEY_AUTHENTICATORS_ALLOWED} * @hide */ public static final String KEY_ALLOW_DEVICE_CREDENTIAL = "allow_device_credential"; /** + * If this key is set, we will ignore {@link #KEY_ALLOW_DEVICE_CREDENTIAL} * @hide */ - public static final String KEY_FROM_CONFIRM_DEVICE_CREDENTIAL - = "from_confirm_device_credential"; + public static final String KEY_AUTHENTICATORS_ALLOWED = "authenticators_allowed"; /** * Error/help message will show for this amount of time. @@ -100,7 +97,7 @@ public class BiometricPrompt implements BiometricAuthenticator, BiometricConstan /** * @hide */ - public static final int DISMISSED_REASON_CONFIRMED = 1; + public static final int DISMISSED_REASON_BIOMETRIC_CONFIRMED = 1; /** * Dialog is done animating away after user clicked on the button set via @@ -119,7 +116,7 @@ public class BiometricPrompt implements BiometricAuthenticator, BiometricConstan * Authenticated, confirmation not required. Dialog animated away. * @hide */ - public static final int DISMISSED_REASON_CONFIRM_NOT_REQUIRED = 4; + public static final int DISMISSED_REASON_BIOMETRIC_CONFIRM_NOT_REQUIRED = 4; /** * Error message shown on SystemUI. When BiometricService receives this, the UI is already @@ -134,6 +131,11 @@ public class BiometricPrompt implements BiometricAuthenticator, BiometricConstan */ public static final int DISMISSED_REASON_SERVER_REQUESTED = 6; + /** + * @hide + */ + public static final int DISMISSED_REASON_CREDENTIAL_CONFIRMED = 7; + private static class ButtonInfo { Executor executor; DialogInterface.OnClickListener listener; @@ -203,30 +205,6 @@ public class BiometricPrompt implements BiometricAuthenticator, BiometricConstan } /** - * Optional: Set the text for the positive button. If not set, the positive button - * will not show. - * @param text - * @return - * @hide - */ - @NonNull public Builder setPositiveButton(@NonNull CharSequence text, - @NonNull @CallbackExecutor Executor executor, - @NonNull DialogInterface.OnClickListener listener) { - if (TextUtils.isEmpty(text)) { - throw new IllegalArgumentException("Text must be set and non-empty"); - } - if (executor == null) { - throw new IllegalArgumentException("Executor must not be null"); - } - if (listener == null) { - throw new IllegalArgumentException("Listener must not be null"); - } - mBundle.putCharSequence(KEY_POSITIVE_TEXT, text); - mPositiveButtonInfo = new ButtonInfo(executor, listener); - return this; - } - - /** * Required: Set the text for the negative button. This would typically be used as a * "Cancel" button, but may be also used to show an alternative method for authentication, * such as screen that asks for a backup password. @@ -298,17 +276,6 @@ public class BiometricPrompt implements BiometricAuthenticator, BiometricConstan } /** - * TODO(123378871): Remove when moved. - * @return - * @hide - */ - @RequiresPermission(USE_BIOMETRIC_INTERNAL) - @NonNull public Builder setFromConfirmDeviceCredential() { - mBundle.putBoolean(KEY_FROM_CONFIRM_DEVICE_CREDENTIAL, true); - return this; - } - - /** * Creates a {@link BiometricPrompt}. * @return a {@link BiometricPrompt} * @throws IllegalArgumentException if any of the required fields are not set. @@ -317,15 +284,19 @@ public class BiometricPrompt implements BiometricAuthenticator, BiometricConstan final CharSequence title = mBundle.getCharSequence(KEY_TITLE); final CharSequence negative = mBundle.getCharSequence(KEY_NEGATIVE_TEXT); final boolean useDefaultTitle = mBundle.getBoolean(KEY_USE_DEFAULT_TITLE); - final boolean enableFallback = mBundle.getBoolean(KEY_ALLOW_DEVICE_CREDENTIAL); + final boolean allowCredential = mBundle.getBoolean(KEY_ALLOW_DEVICE_CREDENTIAL); + final Object authenticatorsAllowed = mBundle.get(KEY_AUTHENTICATORS_ALLOWED); if (TextUtils.isEmpty(title) && !useDefaultTitle) { throw new IllegalArgumentException("Title must be set and non-empty"); - } else if (TextUtils.isEmpty(negative) && !enableFallback) { + } else if (TextUtils.isEmpty(negative) && !allowCredential) { throw new IllegalArgumentException("Negative text must be set and non-empty"); - } else if (!TextUtils.isEmpty(negative) && enableFallback) { + } else if (!TextUtils.isEmpty(negative) && allowCredential) { throw new IllegalArgumentException("Can't have both negative button behavior" + " and device credential enabled"); + } else if (authenticatorsAllowed != null && allowCredential) { + throw new IllegalArgumentException("setAuthenticatorsAllowed and" + + " setDeviceCredentialAllowed should not be used simultaneously"); } return new BiometricPrompt(mContext, mBundle, mPositiveButtonInfo, mNegativeButtonInfo); } @@ -384,7 +355,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_CONFIRMED) { + if (reason == DISMISSED_REASON_BIOMETRIC_CONFIRMED) { mPositiveButtonInfo.executor.execute(() -> { mPositiveButtonInfo.listener.onClick(null, DialogInterface.BUTTON_POSITIVE); }); @@ -532,8 +503,7 @@ public class BiometricPrompt implements BiometricAuthenticator, BiometricConstan public void authenticateUser(@NonNull CancellationSignal cancel, @NonNull @CallbackExecutor Executor executor, @NonNull AuthenticationCallback callback, - int userId, - IBiometricConfirmDeviceCredentialCallback confirmDeviceCredentialCallback) { + int userId) { if (cancel == null) { throw new IllegalArgumentException("Must supply a cancellation signal"); } @@ -543,8 +513,7 @@ public class BiometricPrompt implements BiometricAuthenticator, BiometricConstan if (callback == null) { throw new IllegalArgumentException("Must supply a callback"); } - authenticateInternal(null /* crypto */, cancel, executor, callback, userId, - confirmDeviceCredentialCallback); + authenticateInternal(null /* crypto */, cancel, executor, callback, userId); } /** @@ -595,8 +564,7 @@ public class BiometricPrompt implements BiometricAuthenticator, BiometricConstan if (mBundle.getBoolean(KEY_ALLOW_DEVICE_CREDENTIAL)) { throw new IllegalArgumentException("Device credential not supported with crypto"); } - authenticateInternal(crypto, cancel, executor, callback, mContext.getUserId(), - null /* confirmDeviceCredentialCallback */); + authenticateInternal(crypto, cancel, executor, callback, mContext.getUserId()); } /** @@ -638,8 +606,7 @@ public class BiometricPrompt implements BiometricAuthenticator, BiometricConstan if (callback == null) { throw new IllegalArgumentException("Must supply a callback"); } - authenticateInternal(null /* crypto */, cancel, executor, callback, mContext.getUserId(), - null /* confirmDeviceCredentialCallback */); + authenticateInternal(null /* crypto */, cancel, executor, callback, mContext.getUserId()); } private void cancelAuthentication() { @@ -656,8 +623,7 @@ public class BiometricPrompt implements BiometricAuthenticator, BiometricConstan @NonNull CancellationSignal cancel, @NonNull @CallbackExecutor Executor executor, @NonNull AuthenticationCallback callback, - int userId, - IBiometricConfirmDeviceCredentialCallback confirmDeviceCredentialCallback) { + int userId) { try { if (cancel.isCanceled()) { Log.w(TAG, "Authentication already canceled"); @@ -672,7 +638,7 @@ public class BiometricPrompt implements BiometricAuthenticator, BiometricConstan final long sessionId = crypto != null ? crypto.getOpId() : 0; if (BiometricManager.hasBiometrics(mContext)) { mService.authenticate(mToken, sessionId, userId, mBiometricServiceReceiver, - mContext.getOpPackageName(), mBundle, confirmDeviceCredentialCallback); + mContext.getOpPackageName(), mBundle); } else { mExecutor.execute(() -> { callback.onAuthenticationError(BiometricPrompt.BIOMETRIC_ERROR_HW_NOT_PRESENT, diff --git a/core/java/android/hardware/biometrics/IBiometricService.aidl b/core/java/android/hardware/biometrics/IBiometricService.aidl index f0a0b2f0235f..6a3bf38a97e1 100644 --- a/core/java/android/hardware/biometrics/IBiometricService.aidl +++ b/core/java/android/hardware/biometrics/IBiometricService.aidl @@ -17,7 +17,6 @@ package android.hardware.biometrics; import android.os.Bundle; -import android.hardware.biometrics.IBiometricConfirmDeviceCredentialCallback; import android.hardware.biometrics.IBiometricEnabledOnKeyguardCallback; import android.hardware.biometrics.IBiometricServiceReceiver; @@ -31,10 +30,8 @@ import android.hardware.biometrics.IBiometricServiceReceiver; interface IBiometricService { // Requests authentication. The service choose the appropriate biometric to use, and show // the corresponding BiometricDialog. - // TODO(b/123378871): Remove callback when moved. void authenticate(IBinder token, long sessionId, int userId, - IBiometricServiceReceiver receiver, String opPackageName, in Bundle bundle, - IBiometricConfirmDeviceCredentialCallback callback); + IBiometricServiceReceiver receiver, String opPackageName, in Bundle bundle); // Cancel authentication for the given sessionId void cancelAuthentication(IBinder token, String opPackageName); @@ -57,16 +54,4 @@ interface IBiometricService { // Reset the lockout when user authenticates with strong auth (e.g. PIN, pattern or password) void resetLockout(in byte [] token); - - // TODO(b/123378871): Remove when moved. - // CDCA needs to send results to BiometricService if it was invoked using BiometricPrompt's - // setAllowDeviceCredential method, since there's no way for us to intercept onActivityResult. - // CDCA is launched from BiometricService (startActivityAsUser) instead of *ForResult. - void onConfirmDeviceCredentialSuccess(); - // TODO(b/123378871): Remove when moved. - void onConfirmDeviceCredentialError(int error, String message); - // TODO(b/123378871): Remove when moved. - // When ConfirmLock* is invoked from BiometricPrompt, it needs to register a callback so that - // it can receive the cancellation signal. - void registerCancellationCallback(IBiometricConfirmDeviceCredentialCallback callback); } diff --git a/core/java/android/hardware/biometrics/IBiometricServiceReceiverInternal.aidl b/core/java/android/hardware/biometrics/IBiometricServiceReceiverInternal.aidl index ca6114e4d842..66b6e896fc13 100644 --- a/core/java/android/hardware/biometrics/IBiometricServiceReceiverInternal.aidl +++ b/core/java/android/hardware/biometrics/IBiometricServiceReceiverInternal.aidl @@ -38,4 +38,6 @@ oneway interface IBiometricServiceReceiverInternal { void onDialogDismissed(int reason); // Notifies that the user has pressed the "try again" button on SystemUI void onTryAgainPressed(); + // Notifies that the user has pressed the "use password" button on SystemUI + void onDeviceCredentialPressed(); } diff --git a/core/java/com/android/internal/statusbar/IStatusBar.aidl b/core/java/com/android/internal/statusbar/IStatusBar.aidl index 9441825a1ed6..c8ba52a63151 100644 --- a/core/java/com/android/internal/statusbar/IStatusBar.aidl +++ b/core/java/com/android/internal/statusbar/IStatusBar.aidl @@ -151,17 +151,17 @@ oneway interface IStatusBar void showShutdownUi(boolean isReboot, String reason); - // Used to show the dialog when BiometricService starts authentication - void showBiometricDialog(in Bundle bundle, IBiometricServiceReceiverInternal receiver, int type, - boolean requireConfirmation, int userId, String opPackageName); - // Used to hide the dialog when a biometric is authenticated + // Used to show the authentication dialog (Biometrics, Device Credential) + void showAuthenticationDialog(in Bundle bundle, IBiometricServiceReceiverInternal receiver, + int biometricModality, boolean requireConfirmation, int userId, String opPackageName); + // Used to notify the authentication dialog that a biometric has been authenticated or rejected void onBiometricAuthenticated(boolean authenticated, String failureReason); // Used to set a temporary message, e.g. fingerprint not recognized, finger moved too fast, etc void onBiometricHelp(String message); // Used to set a message - the dialog will dismiss after a certain amount of time - void onBiometricError(String error); - // Used to hide the biometric dialog when the AuthenticationClient is stopped - void hideBiometricDialog(); + void onBiometricError(int errorCode, String error); + // Used to hide the authentication dialog, e.g. when the application cancels authentication + void hideAuthenticationDialog(); /** * Notifies System UI that the display is ready to show system decorations. diff --git a/core/java/com/android/internal/statusbar/IStatusBarService.aidl b/core/java/com/android/internal/statusbar/IStatusBarService.aidl index 4c3a177a013b..a845b587c49f 100644 --- a/core/java/com/android/internal/statusbar/IStatusBarService.aidl +++ b/core/java/com/android/internal/statusbar/IStatusBarService.aidl @@ -99,15 +99,15 @@ interface IStatusBarService void showPinningEnterExitToast(boolean entering); void showPinningEscapeToast(); - // Used to show the dialog when BiometricService starts authentication - void showBiometricDialog(in Bundle bundle, IBiometricServiceReceiverInternal receiver, int type, - boolean requireConfirmation, int userId, String opPackageName); - // Used to hide the dialog when a biometric is authenticated + // Used to show the authentication dialog (Biometrics, Device Credential) + void showAuthenticationDialog(in Bundle bundle, IBiometricServiceReceiverInternal receiver, + int biometricModality, boolean requireConfirmation, int userId, String opPackageName); + // Used to notify the authentication dialog that a biometric has been authenticated or rejected void onBiometricAuthenticated(boolean authenticated, String failureReason); // Used to set a temporary message, e.g. fingerprint not recognized, finger moved too fast, etc void onBiometricHelp(String message); // Used to set a message - the dialog will dismiss after a certain amount of time - void onBiometricError(String error); - // Used to hide the biometric dialog when the AuthenticationClient is stopped - void hideBiometricDialog(); + void onBiometricError(int errorCode, String error); + // Used to hide the authentication dialog, e.g. when the application cancels authentication + void hideAuthenticationDialog(); } |
