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

Commit d4e0b3b0 authored by Kevin Chyn's avatar Kevin Chyn
Browse files

Don't show hint while authenticating, show hint while pending confirmation

Also, restore "enabled" state of confirm button, otherwise it becomes
available when changing configurations.

Also, "confirm" button should become visible+disabled when tapping try again

Fixes: 135618797

Test: E2E fingerprint and face, with various tests such as rotation during
      various states

Change-Id: I1073a4479077355f1c275faed933ac8510927251
parent ad1aefd3
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -303,6 +303,8 @@
    <string name="biometric_dialog_face_icon_description_authenticated">Face authenticated</string>
    <!-- Content description for the face icon when the user has been authenticated and the confirm button has been pressed [CHAR LIMIT=NONE] -->
    <string name="biometric_dialog_face_icon_description_confirmed">Confirmed</string>
    <!-- Message shown when a biometric is authenticated, waiting for the user to confirm authentication [CHAR LIMIT=40]-->
    <string name="biometric_dialog_tap_confirm">Tap Confirm to complete</string>

    <!-- Message shown when the system-provided fingerprint dialog is shown, asking for authentication -->
    <string name="fingerprint_dialog_touch_sensor">Touch the fingerprint sensor</string>
+21 −4
Original line number Diff line number Diff line
@@ -59,6 +59,7 @@ public abstract class BiometricDialogView extends LinearLayout {

    private static final String KEY_TRY_AGAIN_VISIBILITY = "key_try_again_visibility";
    private static final String KEY_CONFIRM_VISIBILITY = "key_confirm_visibility";
    private static final String KEY_CONFIRM_ENABLED = "key_confirm_enabled";
    private static final String KEY_STATE = "key_state";
    private static final String KEY_ERROR_TEXT_VISIBILITY = "key_error_text_visibility";
    private static final String KEY_ERROR_TEXT_STRING = "key_error_text_string";
@@ -232,6 +233,10 @@ public abstract class BiometricDialogView extends LinearLayout {
            handleResetMessage();
            updateState(STATE_AUTHENTICATING);
            showTryAgainButton(false /* show */);

            mPositiveButton.setVisibility(View.VISIBLE);
            mPositiveButton.setEnabled(false);

            mCallback.onTryAgainPressed();
        });

@@ -243,6 +248,7 @@ public abstract class BiometricDialogView extends LinearLayout {
    public void onSaveState(Bundle bundle) {
        bundle.putInt(KEY_TRY_AGAIN_VISIBILITY, mTryAgainButton.getVisibility());
        bundle.putInt(KEY_CONFIRM_VISIBILITY, mPositiveButton.getVisibility());
        bundle.putBoolean(KEY_CONFIRM_ENABLED, mPositiveButton.isEnabled());
        bundle.putInt(KEY_STATE, mState);
        bundle.putInt(KEY_ERROR_TEXT_VISIBILITY, mErrorText.getVisibility());
        bundle.putCharSequence(KEY_ERROR_TEXT_STRING, mErrorText.getText());
@@ -275,9 +281,15 @@ public abstract class BiometricDialogView extends LinearLayout {

        if (mRestoredState == null) {
            updateState(STATE_AUTHENTICATING);
            mErrorText.setText(getHintStringResourceId());
            mErrorText.setContentDescription(mContext.getString(getHintStringResourceId()));
            final int hint = getHintStringResourceId();
            if (hint != 0) {
                mErrorText.setText(hint);
                mErrorText.setContentDescription(mContext.getString(hint));
                mErrorText.setVisibility(View.VISIBLE);
            } else {
                mErrorText.setVisibility(View.INVISIBLE);
            }
            announceAccessibilityEvent();
        } else {
            updateState(mState);
        }
@@ -425,6 +437,7 @@ public abstract class BiometricDialogView extends LinearLayout {
        mErrorText.setText(message);
        mErrorText.setTextColor(mErrorColor);
        mErrorText.setContentDescription(message);
        mErrorText.setVisibility(View.VISIBLE);
        mHandler.sendMessageDelayed(mHandler.obtainMessage(MSG_RESET_MESSAGE),
                BiometricPrompt.HIDE_DIALOG_DELAY);
    }
@@ -458,7 +471,9 @@ public abstract class BiometricDialogView extends LinearLayout {
    public void updateState(int newState) {
        if (newState == STATE_PENDING_CONFIRMATION) {
            mHandler.removeMessages(MSG_RESET_MESSAGE);
            mErrorText.setVisibility(View.INVISIBLE);
            mErrorText.setTextColor(mTextColor);
            mErrorText.setText(R.string.biometric_dialog_tap_confirm);
            mErrorText.setVisibility(View.VISIBLE);
            announceAccessibilityEvent();
            mPositiveButton.setVisibility(View.VISIBLE);
            mPositiveButton.setEnabled(true);
@@ -489,6 +504,8 @@ public abstract class BiometricDialogView extends LinearLayout {
        mTryAgainButton.setVisibility(tryAgainVisibility);
        final int confirmVisibility = bundle.getInt(KEY_CONFIRM_VISIBILITY);
        mPositiveButton.setVisibility(confirmVisibility);
        final boolean confirmEnabled = bundle.getBoolean(KEY_CONFIRM_ENABLED);
        mPositiveButton.setEnabled(confirmEnabled);
        mState = bundle.getInt(KEY_STATE);
        mErrorText.setText(bundle.getCharSequence(KEY_ERROR_TEXT_STRING));
        mErrorText.setContentDescription(bundle.getCharSequence(KEY_ERROR_TEXT_STRING));
+3 −10
Original line number Diff line number Diff line
@@ -289,16 +289,10 @@ public class FaceDialogView extends BiometricDialogView {

    @Override
    protected void handleResetMessage() {
        mErrorText.setText(getHintStringResourceId());
        mErrorText.setContentDescription(mContext.getString(getHintStringResourceId()));
        mErrorText.setTextColor(mTextColor);
        if (getState() == STATE_AUTHENTICATING) {
            mErrorText.setVisibility(View.VISIBLE);
        } else {
        mErrorText.setVisibility(View.INVISIBLE);
        announceAccessibilityEvent();
    }
    }

    @Override
    public void restoreState(Bundle bundle) {
@@ -383,7 +377,7 @@ public class FaceDialogView extends BiometricDialogView {

    @Override
    protected int getHintStringResourceId() {
        return R.string.face_dialog_looking_for_face;
        return 0;
    }

    @Override
@@ -408,7 +402,6 @@ public class FaceDialogView extends BiometricDialogView {
            mHandler.removeCallbacks(mErrorToIdleAnimationRunnable);
            if (mDialogAnimatedIn) {
                mIconController.startPulsing();
                mErrorText.setVisibility(View.VISIBLE);
            } else {
                mIconController.showIcon(R.drawable.face_dialog_pulse_dark_to_light);
            }