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

Commit 078dcf1c authored by Kevin Chyn's avatar Kevin Chyn
Browse files

BiometricPrompt negative button should show "cancel" after onAuthenticated

When the biometric is authenticated, the negative button should show
"cancel" instead. It should also invoke onUserCanceled instead of
onNegativePressed.

Fixes: 131274300
Test: manual

Change-Id: I104857e5e448bcd11c59311776c28e280566c2e0
parent 8d39b4ec
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -249,7 +249,7 @@ public class BiometricDialogImpl extends SystemUI implements CommandQueue.Callba
                    mContext.getResources()
                            .getText(mCurrentDialog.getAuthenticatedAccessibilityResourceId()));
            if (mCurrentDialog.requiresConfirmation()) {
                mCurrentDialog.onReadyForConfirmation();
                mCurrentDialog.updateState(BiometricDialogView.STATE_PENDING_CONFIRMATION);
            } else {
                mCurrentDialog.updateState(BiometricDialogView.STATE_AUTHENTICATED);
                mHandler.postDelayed(() -> {
+16 −12
Original line number Diff line number Diff line
@@ -95,7 +95,7 @@ public abstract class BiometricDialogView extends LinearLayout {

    private Bundle mBundle;

    private int mLastState;
    private int mState;
    private boolean mAnimatingAway;
    private boolean mWasForceRemoved;
    private boolean mSkipIntro;
@@ -209,7 +209,11 @@ public abstract class BiometricDialogView extends LinearLayout {
        setDismissesDialog(rightSpace);

        mNegativeButton.setOnClickListener((View v) -> {
            if (mState == STATE_PENDING_CONFIRMATION || mState == STATE_AUTHENTICATED) {
                mCallback.onUserCanceled();
            } else {
                mCallback.onNegativePressed();
            }
        });

        mPositiveButton.setOnClickListener((View v) -> {
@@ -260,7 +264,7 @@ public abstract class BiometricDialogView extends LinearLayout {
            mDialog.getLayoutParams().width = (int) mDialogWidth;
        }

        mLastState = STATE_IDLE;
        mState = STATE_IDLE;
        updateState(STATE_AUTHENTICATING);

        CharSequence titleText = mBundle.getCharSequence(BiometricPrompt.KEY_TITLE);
@@ -332,7 +336,7 @@ public abstract class BiometricDialogView extends LinearLayout {
    private void setDismissesDialog(View v) {
        v.setClickable(true);
        v.setOnTouchListener((View view, MotionEvent event) -> {
            if (mLastState != STATE_AUTHENTICATED && shouldGrayAreaDismissDialog()) {
            if (mState != STATE_AUTHENTICATED && shouldGrayAreaDismissDialog()) {
                mCallback.onUserCanceled();
            }
            return true;
@@ -411,12 +415,6 @@ public abstract class BiometricDialogView extends LinearLayout {
        return mRequireConfirmation;
    }

    public void onReadyForConfirmation() {
        mHandler.removeMessages(MSG_CLEAR_MESSAGE);
        updateState(STATE_PENDING_CONFIRMATION);
        mPositiveButton.setEnabled(true);
    }

    public void setUserId(int userId) {
        mUserId = userId;
    }
@@ -453,15 +451,21 @@ public abstract class BiometricDialogView extends LinearLayout {

    public void updateState(int newState) {
        if (newState == STATE_PENDING_CONFIRMATION) {
            mHandler.removeMessages(MSG_CLEAR_MESSAGE);
            mErrorText.setVisibility(View.INVISIBLE);
            mPositiveButton.setEnabled(true);
        } else if (newState == STATE_AUTHENTICATED) {
            mPositiveButton.setVisibility(View.GONE);
            mNegativeButton.setVisibility(View.GONE);
            mErrorText.setVisibility(View.INVISIBLE);
        }

        updateIcon(mLastState, newState);
        mLastState = newState;
        if (newState == STATE_PENDING_CONFIRMATION || newState == STATE_AUTHENTICATED) {
            mNegativeButton.setText(R.string.cancel);
        }

        updateIcon(mState, newState);
        mState = newState;
    }

    public void showTryAgainButton(boolean show) {