Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 9f8b2fc7 authored by Kevin Chyn's avatar Kevin Chyn
Browse files

2/n: Update BiometricService with cleaner lifecycle

Hiding of the BiometricDialog is (almost) all handled by SystemUI now.
BiometricService should only send results to the client when it receives
onDialogDismissed() from SystemUI

Bug: 135082347

Test: atest BiometricServiceTest
Change-Id: Ie91fd54680b942e421b7e187f1107ef7323ea719
parent c53d981e
Loading
Loading
Loading
Loading
+6 −0
Original line number Diff line number Diff line
@@ -103,6 +103,9 @@ public class BiometricPrompt implements BiometricAuthenticator, BiometricConstan
    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;
@@ -113,11 +116,14 @@ 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;
+2 −2
Original line number Diff line number Diff line
@@ -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);
+0 −5
Original line number Diff line number Diff line
@@ -73,15 +73,10 @@ public class BiometricDialogImpl extends SystemUI implements CommandQueue.Callba

            case DialogViewCallback.DISMISSED_AUTHENTICATED:
                sendResultAndCleanUp(BiometricPrompt.DISMISSED_REASON_CONFIRM_NOT_REQUIRED);
                // TODO: BiometricService currently sends the result immediately. This should
                // actually happen when the animation is completed.
                break;

            case DialogViewCallback.DISMISSED_ERROR:
                sendResultAndCleanUp(BiometricPrompt.DISMISSED_REASON_ERROR);
                // TODO: Make sure error isn't received until dialog is dismissed
                // TODO: Similarly, BiometricService currently sends the result immediately.
                // This should happen when the animation is completed.
                break;
            default:
                Log.e(TAG, "Unhandled reason: " + reason);
+1 −2
Original line number Diff line number Diff line
@@ -337,6 +337,7 @@ public abstract class BiometricDialogView extends LinearLayout implements Biomet
        }

        mNegativeButton.setVisibility(View.VISIBLE);
        mNegativeButton.setText(mBundle.getCharSequence(BiometricPrompt.KEY_NEGATIVE_TEXT));

        if (RotationUtils.getRotation(mContext) != RotationUtils.ROTATION_NONE) {
            mDialog.getLayoutParams().width = (int) mDialogWidth;
@@ -344,7 +345,6 @@ public abstract class BiometricDialogView extends LinearLayout implements Biomet

        if (mRestoredState == null) {
            updateState(STATE_AUTHENTICATING);
            mNegativeButton.setText(mBundle.getCharSequence(BiometricPrompt.KEY_NEGATIVE_TEXT));
            final int hint = getHintStringResourceId();
            if (hint != 0) {
                mErrorText.setText(hint);
@@ -570,7 +570,6 @@ public abstract class BiometricDialogView extends LinearLayout implements Biomet
        showTemporaryMessage(error);
        showTryAgainButton(false /* show */);

        // TODO: Is this still used to synchronize animation and client onError timing?
        mHandler.postDelayed(() -> {
            animateAway(DialogViewCallback.DISMISSED_ERROR);
        }, BiometricPrompt.HIDE_DIALOG_DELAY);
+1 −2
Original line number Diff line number Diff line
@@ -209,8 +209,7 @@ public abstract class AuthenticationClient extends ClientMonitor {
                    // will show briefly and be replaced by "device locked out" message.
                    if (listener != null) {
                        if (isBiometricPrompt()) {
                            listener.onAuthenticationFailedInternal(getCookie(),
                                    getRequireConfirmation());
                            listener.onAuthenticationFailedInternal();
                        } else {
                            listener.onAuthenticationFailed(getHalDeviceId());
                        }
Loading