OSDN Git Service

Skip option missing on pattern lock screen
authorAjay Nadathur <ajayns@google.com>
Thu, 11 Jan 2018 21:25:26 +0000 (13:25 -0800)
committerAjay Nadathur <ajayns@google.com>
Thu, 11 Jan 2018 22:30:12 +0000 (14:30 -0800)
- 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

src/com/android/settings/password/ChooseLockPattern.java
src/com/android/settings/password/SetupChooseLockPattern.java
tests/robotests/src/com/android/settings/SetupChooseLockPatternTest.java

index 746a977..972fac8 100644 (file)
@@ -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() {
index b1c9fac..4ae5839 100644 (file)
@@ -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;
@@ -72,6 +73,24 @@ public class SetupChooseLockPattern extends ChooseLockPattern {
         }
 
         @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
             // optional step if the lock screen was set up.
index 1f701c2..81a6bb3 100644 (file)
@@ -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);