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

Commit 541185d3 authored by Diya Bera's avatar Diya Bera
Browse files

Fixes loop in Fingerprint Enrollment

Remove "Try again" in error dialog, since credential has timed out and
user needs to use pin/password/pattern before being able to enroll
fingerprint

Bug: 258307019
Test: Try to enroll fingerprint after 10 minutes of entering credential,
timeout dialog is shown with only one button to avoid looping

Change-Id: Ibb9a9e2095a1277fa01adc8eb5ce04af1b9ce495
parent 2552ae08
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -415,7 +415,7 @@ public class FingerprintEnrollEnrolling extends BiometricsEnrollEnrolling {
        // showErrorDialog() will cause onWindowFocusChanged(false), set mIsCanceled to false
        // before showErrorDialog() to prevent that another error dialog is triggered again.
        mIsCanceled = true;
        FingerprintErrorDialog.showErrorDialog(this, errorMsgId);
        FingerprintErrorDialog.showErrorDialog(this, errorMsgId, mCanAssumeUdfps);
        mIsOrientationChanged = false;
        cancelEnrollment();
        stopIconAnimation();
+1 −1
Original line number Diff line number Diff line
@@ -279,7 +279,7 @@ public class FingerprintEnrollFindSensor extends BiometricEnrollBase implements
        if (mNextClicked && errMsgId == FingerprintManager.FINGERPRINT_ERROR_CANCELED) {
            proceedToEnrolling(false /* cancelEnrollment */);
        } else {
            FingerprintErrorDialog.showErrorDialog(this, errMsgId);
            FingerprintErrorDialog.showErrorDialog(this, errMsgId, mCanAssumeUdfps);
        }
    }

+8 −5
Original line number Diff line number Diff line
@@ -169,12 +169,12 @@ public class FingerprintEnrollFinish extends BiometricEnrollBase {
    @Override
    protected void onNextButtonClick(View view) {
        updateFingerprintSuggestionEnableState();
        finishAndToNext();
        finishAndToNext(RESULT_FINISHED);
    }

    private void finishAndToNext() {
    private void finishAndToNext(int resultCode) {
        mIsAddAnotherOrFinish = true;
        setResult(RESULT_FINISHED);
        setResult(resultCode);
        if (WizardManagerHelper.isAnySetupWizard(getIntent())) {
            postEnroll();
        }
@@ -221,9 +221,12 @@ public class FingerprintEnrollFinish extends BiometricEnrollBase {
    @Override
    protected void onActivityResult(int requestCode, int resultCode, Intent data) {
        updateFingerprintSuggestionEnableState();
        if (requestCode == BiometricUtils.REQUEST_ADD_ANOTHER && resultCode != RESULT_CANCELED) {
        if (requestCode == BiometricUtils.REQUEST_ADD_ANOTHER && resultCode == RESULT_TIMEOUT) {
            finishAndToNext(resultCode);
        } else if (requestCode == BiometricUtils.REQUEST_ADD_ANOTHER
                && resultCode != RESULT_CANCELED) {
            // If user cancel during "Add another", just use similar flow on "Next" button
            finishAndToNext();
            finishAndToNext(RESULT_FINISHED);
        } else {
            super.onActivityResult(requestCode, resultCode, data);
        }
+19 −8
Original line number Diff line number Diff line
@@ -41,12 +41,14 @@ public class FingerprintErrorDialog extends InstrumentedDialogFragment {

    public static final String KEY_ERROR_MSG = "error_msg";
    public static final String KEY_ERROR_ID = "error_id";
    public static final String KEY_UDFPS = "is_udfps";

    @Override
    public Dialog onCreateDialog(Bundle savedInstanceState) {
        AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
        CharSequence errorString = getArguments().getCharSequence(KEY_ERROR_MSG);
        final int errMsgId = getArguments().getInt(KEY_ERROR_ID);
        final boolean canAssumeUdfps = getArguments().getBoolean(KEY_UDFPS, false);
        boolean wasTimeout = errMsgId == BiometricConstants.BIOMETRIC_ERROR_TIMEOUT;

        builder.setTitle(R.string.security_settings_fingerprint_enroll_error_dialog_title)
@@ -59,11 +61,15 @@ public class FingerprintErrorDialog extends InstrumentedDialogFragment {
                            public void onClick(DialogInterface dialog, int which) {
                                dialog.dismiss();
                                Activity activity = getActivity();
                                if (wasTimeout && !canAssumeUdfps) {
                                    activity.setResult(RESULT_TIMEOUT);
                                } else {
                                    activity.setResult(RESULT_FINISHED);
                                }
                                activity.finish();
                            }
                        });
        if (wasTimeout) {
        if (wasTimeout && canAssumeUdfps) {
            builder.setPositiveButton(
                            R.string.security_settings_fingerprint_enroll_dialog_try_again,
                            new DialogInterface.OnClickListener() {
@@ -95,18 +101,21 @@ public class FingerprintErrorDialog extends InstrumentedDialogFragment {
        return dialog;
    }

    public static void showErrorDialog(BiometricEnrollBase host, int errMsgId) {
    public static void showErrorDialog(BiometricEnrollBase host, int errMsgId,
            boolean canAssumeUdfps) {
        if (host.isFinishing()) {
            return;
        }

        final FragmentManager fragmentManager = host.getSupportFragmentManager();
        if (fragmentManager.isDestroyed() || fragmentManager.isStateSaved()) {
            return;
        }

        final CharSequence errMsg = host.getText(getErrorMessage(errMsgId));
        final FingerprintErrorDialog dialog = newInstance(errMsg, errMsgId);
        CharSequence errMsg = host.getText(getErrorMessage(errMsgId));
        if (!canAssumeUdfps
                && errMsgId == BiometricConstants.BIOMETRIC_ERROR_TIMEOUT) {
            errMsg = host.getText(getErrorMessage(BiometricConstants.BIOMETRIC_ERROR_CANCELED));
        }
        final FingerprintErrorDialog dialog = newInstance(errMsg, errMsgId, canAssumeUdfps);
        dialog.show(fragmentManager, FingerprintErrorDialog.class.getName());
    }

@@ -124,11 +133,13 @@ public class FingerprintErrorDialog extends InstrumentedDialogFragment {
        }
    }

    private static FingerprintErrorDialog newInstance(CharSequence msg, int msgId) {
    private static FingerprintErrorDialog newInstance(CharSequence msg, int msgId,
            boolean canAssumeUdfps) {
        FingerprintErrorDialog dialog = new FingerprintErrorDialog();
        Bundle args = new Bundle();
        args.putCharSequence(KEY_ERROR_MSG, msg);
        args.putInt(KEY_ERROR_ID, msgId);
        args.putBoolean(KEY_UDFPS, canAssumeUdfps);
        dialog.setArguments(args);
        return dialog;
    }