diff options
| author | Kevin Chyn <kchyn@google.com> | 2020-03-27 10:15:50 -0700 |
|---|---|---|
| committer | Kevin Chyn <kchyn@google.com> | 2020-03-27 14:44:08 -0700 |
| commit | 0a45b662b035661dce8e5e267bbb705326cd14c8 (patch) | |
| tree | 83d1febb2eb943955263f1040f6a6234ab4ecd13 /core/java/android | |
| parent | 4f9ab82c08ccafa758057843677cb7638e3eae38 (diff) | |
Send "early canceled" to privileged clients
The navigation bar dismissal animation caused by "activity finish"
should be invoked in some cases immediately when the user
cancels authentication. Add a "early user cancel" message
for ConfirmDeviceCredentialActivity to subscribe to. This
message is sent immediately when the user invokes a back gesture or
cancels authentication.
Bug: 148273355
Test: Set up work profile with separate password and biometric
Unlock work profile
Lock screen
Open work profile app
Cancel authentication at various states in various ways
Notice no navigation bar jank
Test: atest com.android.systemui.biometrics
Change-Id: I89c5b5e2782339cae15f936268e6e7b8ad4e5359
Diffstat (limited to 'core/java/android')
4 files changed, 55 insertions, 0 deletions
diff --git a/core/java/android/hardware/biometrics/BiometricConstants.java b/core/java/android/hardware/biometrics/BiometricConstants.java index add67aa436c6..8e3f809e4f88 100644 --- a/core/java/android/hardware/biometrics/BiometricConstants.java +++ b/core/java/android/hardware/biometrics/BiometricConstants.java @@ -204,4 +204,18 @@ public interface BiometricConstants { * @hide */ int BIOMETRIC_ACQUIRED_VENDOR_BASE = 1000; + + // + // Internal messages. + // + + /** + * See {@link BiometricPrompt.Builder#setReceiveSystemEvents(boolean)}. This message is sent + * immediately when the user cancels authentication for example by tapping the back button or + * tapping the scrim. This is before {@link #BIOMETRIC_ERROR_USER_CANCELED}, which is sent when + * dismissal animation completes. + * @hide + */ + int BIOMETRIC_SYSTEM_EVENT_EARLY_USER_CANCEL = 1; + } diff --git a/core/java/android/hardware/biometrics/BiometricPrompt.java b/core/java/android/hardware/biometrics/BiometricPrompt.java index a3aa258fec35..5af7cef3e2b4 100644 --- a/core/java/android/hardware/biometrics/BiometricPrompt.java +++ b/core/java/android/hardware/biometrics/BiometricPrompt.java @@ -63,6 +63,7 @@ public class BiometricPrompt implements BiometricAuthenticator, BiometricConstan /** * @hide */ + @RequiresPermission(USE_BIOMETRIC_INTERNAL) public static final String KEY_USE_DEFAULT_TITLE = "use_default_title"; /** * @hide @@ -75,14 +76,17 @@ public class BiometricPrompt implements BiometricAuthenticator, BiometricConstan /** * @hide */ + @RequiresPermission(USE_BIOMETRIC_INTERNAL) public static final String KEY_DEVICE_CREDENTIAL_TITLE = "device_credential_title"; /** * @hide */ + @RequiresPermission(USE_BIOMETRIC_INTERNAL) public static final String KEY_DEVICE_CREDENTIAL_SUBTITLE = "device_credential_subtitle"; /** * @hide */ + @RequiresPermission(USE_BIOMETRIC_INTERNAL) public static final String KEY_DEVICE_CREDENTIAL_DESCRIPTION = "device_credential_description"; /** * @hide @@ -106,7 +110,15 @@ public class BiometricPrompt implements BiometricAuthenticator, BiometricConstan * If this is set, check the Device Policy Manager for allowed biometrics. * @hide */ + @RequiresPermission(USE_BIOMETRIC_INTERNAL) public static final String EXTRA_DISALLOW_BIOMETRICS_IF_POLICY_EXISTS = "check_dpm"; + /** + * Request to receive system events, such as back gesture/button. See + * {@link AuthenticationCallback#onSystemEvent(int)} + * @hide + */ + @RequiresPermission(USE_BIOMETRIC_INTERNAL) + public static final String KEY_RECEIVE_SYSTEM_EVENTS = "receive_system_events"; /** * Error/help message will show for this amount of time. @@ -384,6 +396,18 @@ public class BiometricPrompt implements BiometricAuthenticator, BiometricConstan } /** + * If set, receive internal events via {@link AuthenticationCallback#onSystemEvent(int)} + * @param set + * @return This builder. + * @hide + */ + @NonNull + public Builder setReceiveSystemEvents(boolean set) { + mBundle.putBoolean(KEY_RECEIVE_SYSTEM_EVENTS, set); + return this; + } + + /** * Creates a {@link BiometricPrompt}. * * @return An instance of {@link BiometricPrompt}. @@ -493,6 +517,13 @@ public class BiometricPrompt implements BiometricAuthenticator, BiometricConstan }); } } + + @Override + public void onSystemEvent(int event) throws RemoteException { + mExecutor.execute(() -> { + mAuthenticationCallback.onSystemEvent(event); + }); + } }; private BiometricPrompt(Context context, Bundle bundle, @@ -732,6 +763,12 @@ public class BiometricPrompt implements BiometricAuthenticator, BiometricConstan */ @Override public void onAuthenticationAcquired(int acquireInfo) {} + + /** + * Receiver for internal system events. See {@link Builder#setReceiveSystemEvents(boolean)} + * @hide + */ + public void onSystemEvent(int event) {} } /** diff --git a/core/java/android/hardware/biometrics/IBiometricServiceReceiver.aidl b/core/java/android/hardware/biometrics/IBiometricServiceReceiver.aidl index 1d43aa640b40..b0cddfd3b47f 100644 --- a/core/java/android/hardware/biometrics/IBiometricServiceReceiver.aidl +++ b/core/java/android/hardware/biometrics/IBiometricServiceReceiver.aidl @@ -30,4 +30,6 @@ oneway interface IBiometricServiceReceiver { void onAcquired(int acquiredInfo, String message); // Notifies that the SystemUI dialog has been dismissed. void onDialogDismissed(int reason); + // Notifies the client that an internal event, e.g. back button has occurred. + void onSystemEvent(int event); } diff --git a/core/java/android/hardware/biometrics/IBiometricServiceReceiverInternal.aidl b/core/java/android/hardware/biometrics/IBiometricServiceReceiverInternal.aidl index e7219caf6cd8..e57abd548057 100644 --- a/core/java/android/hardware/biometrics/IBiometricServiceReceiverInternal.aidl +++ b/core/java/android/hardware/biometrics/IBiometricServiceReceiverInternal.aidl @@ -42,4 +42,6 @@ oneway interface IBiometricServiceReceiverInternal { void onTryAgainPressed(); // Notifies that the user has pressed the "use password" button on SystemUI void onDeviceCredentialPressed(); + // Notifies the client that an internal event, e.g. back button has occurred. + void onSystemEvent(int event); } |
