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

Commit 7880a86f authored by Joe Bolinger's avatar Joe Bolinger
Browse files

Prevent multiple calls to handleOnDialogAnimatedIn.

This also adds the request id to the methods that hide the prompt to prevent stale requests from being handled. I wasn't able to reproduce the bug locally but it appears to be caused by these stale events.

Fix: 225275518
Bug: 213899762
Test: atest BiometricServiceTest AuthContainerViewTest
Change-Id: Iac414763dd0012e51b331abe649a50e353df5e1c
parent 6c319e05
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -169,7 +169,7 @@ oneway interface IStatusBar
    /**
    * Used to hide the authentication dialog, e.g. when the application cancels authentication.
    */
    void hideAuthenticationDialog();
    void hideAuthenticationDialog(long requestId);
    /* Used to notify the biometric service of events that occur outside of an operation. */
    void setBiometicContextListener(in IBiometricContextListener listener);

+1 −1
Original line number Diff line number Diff line
@@ -131,7 +131,7 @@ interface IStatusBarService
    // Used to show an error - the dialog will dismiss after a certain amount of time
    void onBiometricError(int modality, int error, int vendorCode);
    // Used to hide the authentication dialog, e.g. when the application cancels authentication
    void hideAuthenticationDialog();
    void hideAuthenticationDialog(long requestId);
    // Used to notify the biometric service of events that occur outside of an operation.
    void setBiometicContextListener(in IBiometricContextListener listener);

+14 −2
Original line number Diff line number Diff line
@@ -126,7 +126,7 @@ public class AuthContainerView extends LinearLayout
        int[] mSensorIds;
        boolean mSkipIntro;
        long mOperationId;
        long mRequestId;
        long mRequestId = -1;
        boolean mSkipAnimation = false;
        @BiometricMultiSensorMode int mMultiSensorConfig = BIOMETRIC_MULTI_SENSOR_DEFAULT;
    }
@@ -598,6 +598,11 @@ public class AuthContainerView extends LinearLayout
        return mConfig.mOpPackageName;
    }

    @Override
    public long getRequestId() {
        return mConfig.mRequestId;
    }

    @Override
    public void animateToCredentialUI() {
        mBiometricView.startTransitionToCredentialUI();
@@ -678,8 +683,10 @@ public class AuthContainerView extends LinearLayout
            return;
        }
        mContainerState = STATE_GONE;
        if (isAttachedToWindow()) {
            mWindowManager.removeView(this);
        }
    }

    private void onDialogAnimatedIn() {
        if (mContainerState == STATE_PENDING_DISMISS) {
@@ -687,6 +694,11 @@ public class AuthContainerView extends LinearLayout
            animateAway(AuthDialogCallback.DISMISSED_USER_CANCELED);
            return;
        }
        if (mContainerState == STATE_ANIMATING_OUT || mContainerState == STATE_GONE) {
            Log.d(TAG, "onDialogAnimatedIn(): ignore, already animating out or gone - state: "
                    + mContainerState);
            return;
        }
        mContainerState = STATE_SHOWING;
        if (mBiometricView != null) {
            mConfig.mCallback.onDialogAnimatedIn();
+6 −1
Original line number Diff line number Diff line
@@ -768,7 +768,7 @@ public class AuthController extends CoreStartable implements CommandQueue.Callba
    }

    @Override
    public void hideAuthenticationDialog() {
    public void hideAuthenticationDialog(long requestId) {
        if (DEBUG) Log.d(TAG, "hideAuthenticationDialog: " + mCurrentDialog);

        if (mCurrentDialog == null) {
@@ -777,6 +777,11 @@ public class AuthController extends CoreStartable implements CommandQueue.Callba
            if (DEBUG) Log.d(TAG, "dialog already gone");
            return;
        }
        if (requestId != mCurrentDialog.getRequestId()) {
            Log.w(TAG, "ignore - ids do not match: " + requestId + " current: "
                    + mCurrentDialog.getRequestId());
            return;
        }

        mCurrentDialog.dismissFromSystemServer();

+3 −0
Original line number Diff line number Diff line
@@ -150,6 +150,9 @@ public interface AuthDialog {
     */
    String getOpPackageName();

    /** The requestId of the underlying operation within the framework. */
    long getRequestId();

    /**
     * Animate to credential UI. Typically called after biometric is locked out.
     */
Loading