Loading core/java/android/hardware/biometrics/BiometricConstants.java +14 −0 Original line number Diff line number Diff line Loading @@ -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; } core/java/android/hardware/biometrics/BiometricPrompt.java +37 −0 Original line number Diff line number Diff line Loading @@ -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 Loading @@ -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 Loading @@ -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. Loading Loading @@ -383,6 +395,18 @@ public class BiometricPrompt implements BiometricAuthenticator, BiometricConstan return this; } /** * 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}. * Loading Loading @@ -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, Loading Loading @@ -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) {} } /** Loading core/java/android/hardware/biometrics/IBiometricServiceReceiver.aidl +2 −0 Original line number Diff line number Diff line Loading @@ -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); } core/java/android/hardware/biometrics/IBiometricServiceReceiverInternal.aidl +2 −0 Original line number Diff line number Diff line Loading @@ -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); } packages/SystemUI/src/com/android/systemui/biometrics/AuthContainerView.java +9 −0 Original line number Diff line number Diff line Loading @@ -22,6 +22,7 @@ import android.annotation.Nullable; import android.content.Context; import android.graphics.PixelFormat; import android.hardware.biometrics.BiometricAuthenticator; import android.hardware.biometrics.BiometricConstants; import android.os.Binder; import android.os.Bundle; import android.os.Handler; Loading Loading @@ -207,6 +208,7 @@ public class AuthContainerView extends LinearLayout animateAway(AuthDialogCallback.DISMISSED_BIOMETRIC_AUTHENTICATED); break; case AuthBiometricView.Callback.ACTION_USER_CANCELED: sendEarlyUserCanceled(); animateAway(AuthDialogCallback.DISMISSED_USER_CANCELED); break; case AuthBiometricView.Callback.ACTION_BUTTON_NEGATIVE: Loading Loading @@ -286,11 +288,13 @@ public class AuthContainerView extends LinearLayout addView(mFrameLayout); // TODO: De-dupe the logic with AuthCredentialPasswordView setOnKeyListener((v, keyCode, event) -> { if (keyCode != KeyEvent.KEYCODE_BACK) { return false; } if (event.getAction() == KeyEvent.ACTION_UP) { sendEarlyUserCanceled(); animateAway(AuthDialogCallback.DISMISSED_USER_CANCELED); } return true; Loading @@ -300,6 +304,11 @@ public class AuthContainerView extends LinearLayout requestFocus(); } void sendEarlyUserCanceled() { mConfig.mCallback.onSystemEvent( BiometricConstants.BIOMETRIC_SYSTEM_EVENT_EARLY_USER_CANCEL); } @Override public boolean isAllowDeviceCredentials() { return Utils.isDeviceCredentialAllowed(mConfig.mBiometricPromptBundle); Loading Loading
core/java/android/hardware/biometrics/BiometricConstants.java +14 −0 Original line number Diff line number Diff line Loading @@ -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; }
core/java/android/hardware/biometrics/BiometricPrompt.java +37 −0 Original line number Diff line number Diff line Loading @@ -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 Loading @@ -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 Loading @@ -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. Loading Loading @@ -383,6 +395,18 @@ public class BiometricPrompt implements BiometricAuthenticator, BiometricConstan return this; } /** * 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}. * Loading Loading @@ -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, Loading Loading @@ -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) {} } /** Loading
core/java/android/hardware/biometrics/IBiometricServiceReceiver.aidl +2 −0 Original line number Diff line number Diff line Loading @@ -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); }
core/java/android/hardware/biometrics/IBiometricServiceReceiverInternal.aidl +2 −0 Original line number Diff line number Diff line Loading @@ -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); }
packages/SystemUI/src/com/android/systemui/biometrics/AuthContainerView.java +9 −0 Original line number Diff line number Diff line Loading @@ -22,6 +22,7 @@ import android.annotation.Nullable; import android.content.Context; import android.graphics.PixelFormat; import android.hardware.biometrics.BiometricAuthenticator; import android.hardware.biometrics.BiometricConstants; import android.os.Binder; import android.os.Bundle; import android.os.Handler; Loading Loading @@ -207,6 +208,7 @@ public class AuthContainerView extends LinearLayout animateAway(AuthDialogCallback.DISMISSED_BIOMETRIC_AUTHENTICATED); break; case AuthBiometricView.Callback.ACTION_USER_CANCELED: sendEarlyUserCanceled(); animateAway(AuthDialogCallback.DISMISSED_USER_CANCELED); break; case AuthBiometricView.Callback.ACTION_BUTTON_NEGATIVE: Loading Loading @@ -286,11 +288,13 @@ public class AuthContainerView extends LinearLayout addView(mFrameLayout); // TODO: De-dupe the logic with AuthCredentialPasswordView setOnKeyListener((v, keyCode, event) -> { if (keyCode != KeyEvent.KEYCODE_BACK) { return false; } if (event.getAction() == KeyEvent.ACTION_UP) { sendEarlyUserCanceled(); animateAway(AuthDialogCallback.DISMISSED_USER_CANCELED); } return true; Loading @@ -300,6 +304,11 @@ public class AuthContainerView extends LinearLayout requestFocus(); } void sendEarlyUserCanceled() { mConfig.mCallback.onSystemEvent( BiometricConstants.BIOMETRIC_SYSTEM_EVENT_EARLY_USER_CANCEL); } @Override public boolean isAllowDeviceCredentials() { return Utils.isDeviceCredentialAllowed(mConfig.mBiometricPromptBundle); Loading