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

Commit 7b1d96a3 authored by Ajay Nadathur's avatar Ajay Nadathur
Browse files

Skip option missing on pattern lock screen

- Skip present during suw/deferred + non-fingerprint flow
- Skip hidden when opened from settings
- Skip hidden during suw/deferred when trying to setup up fingerprint

Test: Manually verified, robolectric tests updated
bug: 71763670
Change-Id: Ie3aac68a6d04c7727320af83532640580248bd47
parent d99a8ef4
Loading
Loading
Loading
Loading
+12 −8
Original line number Diff line number Diff line
@@ -412,7 +412,7 @@ public class ChooseLockPattern extends SettingsActivity {
        private ChooseLockSettingsHelper mChooseLockSettingsHelper;
        private SaveAndFinishWorker mSaveAndFinishWorker;
        protected int mUserId;
        private boolean mForFingerprint;
        protected boolean mForFingerprint;

        private static final String KEY_UI_STAGE = "uiStage";
        private static final String KEY_PATTERN_CHOICE = "chosenPattern";
@@ -657,13 +657,7 @@ public class ChooseLockPattern extends SettingsActivity {
                mFooterText.setText(stage.footerMessage);
            }

            if (stage.leftMode == LeftButtonMode.Gone) {
                mFooterLeftButton.setVisibility(View.GONE);
            } else {
                mFooterLeftButton.setVisibility(View.VISIBLE);
                mFooterLeftButton.setText(stage.leftMode.text);
                mFooterLeftButton.setEnabled(stage.leftMode.enabled);
            }
            updateFooterLeftButton(stage, mFooterLeftButton);

            setRightButtonText(stage.rightMode.text);
            setRightButtonEnabled(stage.rightMode.enabled);
@@ -713,6 +707,16 @@ public class ChooseLockPattern extends SettingsActivity {
            }
        }

        protected void updateFooterLeftButton(Stage stage, TextView footerLeftButton) {
            if (stage.leftMode == LeftButtonMode.Gone) {
                footerLeftButton.setVisibility(View.GONE);
            } else {
                footerLeftButton.setVisibility(View.VISIBLE);
                footerLeftButton.setText(stage.leftMode.text);
                footerLeftButton.setEnabled(stage.leftMode.enabled);
            }
        }

        // clear the wrong pattern unless they have started a new one
        // already
        private void postClearPatternRunnable() {
+19 −0
Original line number Diff line number Diff line
@@ -22,6 +22,7 @@ import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;

import com.android.settings.R;
import com.android.settings.SetupRedactionInterstitial;
@@ -71,6 +72,24 @@ public class SetupChooseLockPattern extends ChooseLockPattern {
            startChooseLockActivity(lock, getActivity());
        }

        @Override
        protected void updateFooterLeftButton(Stage stage, TextView footerLeftButton) {
            super.updateFooterLeftButton(stage, footerLeftButton);
            // enable skip button only during setupwizard and not with fingerprint flow.
            if (!mForFingerprint) {
                footerLeftButton.setVisibility(View.VISIBLE);
                footerLeftButton.setText(R.string.skip_label);
            }
        }

        @Override
        public void handleLeftButton() {
            SetupSkipDialog dialog = SetupSkipDialog.newInstance(
                    getActivity().getIntent()
                            .getBooleanExtra(SetupSkipDialog.EXTRA_FRP_SUPPORTED, false));
            dialog.show(getFragmentManager());
        }

        @Override
        protected Intent getRedactionInterstitialIntent(Context context) {
            // Setup wizard's redaction interstitial is deferred to optional step. Enable that
+27 −0
Original line number Diff line number Diff line
@@ -102,6 +102,33 @@ public class SetupChooseLockPatternTest {
        assertThat(count).named("List items shown").isEqualTo(3);
    }

    @Test
    public void skipButton_shouldBeVisible_duringNonFingerprintFlow() {
        Button button = mActivity.findViewById(R.id.footerLeftButton);
        assertThat(button).isNotNull();
        assertThat(button.getVisibility()).isEqualTo(View.VISIBLE);

        button.performClick();
        AlertDialog chooserDialog = ShadowAlertDialog.getLatestAlertDialog();
        assertThat(chooserDialog).isNotNull();
    }

    @Test
    public void skipButton_shouldNotBeVisible_duringFingerprintFlow() {
        mActivity = Robolectric.buildActivity(
                SetupChooseLockPattern.class,
                SetupChooseLockPattern.modifyIntentForSetup(
                        application,
                        new IntentBuilder(application)
                                .setUserId(UserHandle.myUserId())
                                .setForFingerprint(true)
                                .build()))
                .setup().get();
        Button button = mActivity.findViewById(R.id.footerLeftButton);
        assertThat(button).isNotNull();
        assertThat(button.getVisibility()).isEqualTo(View.GONE);
    }

    private ChooseLockPatternFragment findFragment(Activity activity) {
        return (ChooseLockPatternFragment)
                activity.getFragmentManager().findFragmentById(R.id.main_content);