OSDN Git Service

AF/FR Fix onActivityResult condition.
authorCarlos Valdivia <carlosvaldivia@google.com>
Tue, 23 Jan 2018 17:12:59 +0000 (09:12 -0800)
committerandroid-build-team Robot <android-build-team-robot@google.com>
Wed, 24 Jan 2018 02:55:02 +0000 (02:55 +0000)
Chase list bug. Accidentally bailed on true effectively.

Manual tested by going to Settings > System > Erase All Data
And then hitting then successfully wiping and reseting.

Test: make RunSettingsRoboTests -j40
Bug: 72324059
Change-Id: Ib2a155820811f0ec62a45c1312475c24646ede76
(cherry picked from commit 5dd6ed470eb8b3c59c88f605e96789da2f147cc4)

src/com/android/settings/MasterClear.java
tests/robotests/src/com/android/settings/MasterClearTest.java

index 0e337f6..b7fb694 100644 (file)
@@ -75,7 +75,7 @@ import java.util.List;
 public class MasterClear extends InstrumentedPreferenceFragment {
     private static final String TAG = "MasterClear";
 
-    private static final int KEYGUARD_REQUEST = 55;
+    @VisibleForTesting static final int KEYGUARD_REQUEST = 55;
     @VisibleForTesting static final int CREDENTIAL_CONFIRM_REQUEST = 56;
 
     private static final String KEY_SHOW_ESIM_RESET_CHECKBOX
@@ -118,11 +118,16 @@ public class MasterClear extends InstrumentedPreferenceFragment {
                 request, res.getText(R.string.master_clear_title));
     }
 
+    @VisibleForTesting
+    boolean isValidRequestCode(int requestCode) {
+        return !((requestCode != KEYGUARD_REQUEST) && (requestCode != CREDENTIAL_CONFIRM_REQUEST));
+    }
+
     @Override
     public void onActivityResult(int requestCode, int resultCode, Intent data) {
         super.onActivityResult(requestCode, resultCode, data);
 
-        if (requestCode != KEYGUARD_REQUEST || requestCode != CREDENTIAL_CONFIRM_REQUEST) {
+        if (!isValidRequestCode(requestCode)) {
             return;
         }
 
index ac753c1..9bf3310 100644 (file)
@@ -270,6 +270,13 @@ public class MasterClearTest {
         assertThat(mMasterClear.tryShowAccountConfirmation()).isTrue();
     }
 
+    @Test
+    public void testIsValidRequestCode() {
+        assertThat(mMasterClear.isValidRequestCode(MasterClear.KEYGUARD_REQUEST)).isTrue();
+        assertThat(mMasterClear.isValidRequestCode(MasterClear.CREDENTIAL_CONFIRM_REQUEST)).isTrue();
+        assertThat(mMasterClear.isValidRequestCode(0)).isFalse();
+    }
+
     private void initScrollView(int height, int scrollY, int childBottom) {
         when(mScrollView.getHeight()).thenReturn(height);
         when(mScrollView.getScrollY()).thenReturn(scrollY);