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

Commit 328be58b authored by Milton Wu's avatar Milton Wu
Browse files

Do not show 2nd FingerprintErrorDialog

When fingerprint enrollment is stopped because of credential timeout, it
pops a FingerprintErrorDialog, and this error dialog triggers
onWindowFocusChanged(), and the 2nd FingerprintErrorDialog is shown. To
fix this case, checking mIsCanceled flag do nothing  in
onWindowFocusChanged() method.

On the first dialog, the 'Try again' button relaunch activity with new
Intent, and it causes that activity result fails to pass back to caller.
To fix this bug, add FLAG_ACTIVITY_FORWARD_RESULT on new Intent to pass
result back.

Bug: 248165760
Test: Manually test credential timeout behavior and dialog buttons
Test: Manually test enrollment process has been cancelled for scenarios,
      like "Swipe down Notification Shade" and "Recents"
Test: robo test for FingerprintEnrollEnrollingTest
Change-Id: I4441ba026db9b594f1d6184280668a374126a2fb
parent a94259a7
Loading
Loading
Loading
Loading
+6 −3
Original line number Diff line number Diff line
@@ -168,7 +168,8 @@ public class FingerprintEnrollEnrolling extends BiometricsEnrollEnrolling {
    private Vibrator mVibrator;
    private boolean mIsSetupWizard;
    private boolean mIsOrientationChanged;
    private boolean mIsCanceled;
    @VisibleForTesting
    boolean mIsCanceled;
    private AccessibilityManager mAccessibilityManager;
    private boolean mIsAccessibilityEnabled;
    private LottieAnimationView mIllustrationLottie;
@@ -196,7 +197,7 @@ public class FingerprintEnrollEnrolling extends BiometricsEnrollEnrolling {

    @Override
    public void onWindowFocusChanged(boolean hasFocus) {
        if (hasFocus) {
        if (hasFocus || mIsCanceled) {
            return;
        }

@@ -411,8 +412,10 @@ public class FingerprintEnrollEnrolling extends BiometricsEnrollEnrolling {

    @VisibleForTesting
    void onCancelEnrollment(@IdRes int errorMsgId) {
        FingerprintErrorDialog.showErrorDialog(this, errorMsgId);
        // 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);
        mIsOrientationChanged = false;
        cancelEnrollment();
        stopIconAnimation();
+1 −0
Original line number Diff line number Diff line
@@ -72,6 +72,7 @@ public class FingerprintErrorDialog extends InstrumentedDialogFragment {
                                    dialog.dismiss();
                                    Activity activity = getActivity();
                                    Intent intent = activity.getIntent();
                                    intent.addFlags(Intent.FLAG_ACTIVITY_FORWARD_RESULT);
                                    intent.putExtra(KEY_STATE_CANCELED, false);
                                    activity.startActivity(intent);
                                    activity.finish();
+10 −0
Original line number Diff line number Diff line
@@ -150,6 +150,16 @@ public class FingerprintEnrollEnrollingTest {
        verify(mActivity, never()).onCancelEnrollment(anyInt());
    }

    @Test
    public void fingerprintUdfpsOverlayEnrollment_loseFocusWithCancelFlag_shouldNotCancelAgain() {
        initializeActivityFor(TYPE_UDFPS_OPTICAL);

        mActivity.mIsCanceled = true;
        mActivity.onWindowFocusChanged(true);

        verify(mActivity, never()).onCancelEnrollment(anyInt());
    }

    @Test
    public void fingerprintSfpsEnroll_PlaysAllAnimationsAssetsCorrectly() {
        initializeActivityFor(TYPE_POWER_BUTTON);