From e0681db9210bdb32d3405c2da730ba32492ae504 Mon Sep 17 00:00:00 2001 From: Qingxi Li Date: Wed, 14 Mar 2018 16:00:47 -0700 Subject: [PATCH] UI Tweak for eSIM related This CL update following UI of eSIM: 1. update title of eSIM reset checkbox under network reset and FDR screens. 2. update eSIM reset checkbox to default is checked. 3. Show eSIM reset checkbox in FDR when user is under developer mode. Bug: 74083169 Bug: 74085673 Bug: 74771900 Bug: 74122440 Test: E2E & make RunSettingsRoboTests Change-Id: Ia49fdae98d6ef541398b1dfb36c54beea1f2ba39 --- res/layout/master_clear.xml | 1 + res/layout/reset_esim_checkbox.xml | 1 + res/values/strings.xml | 4 +- src/com/android/settings/MasterClear.java | 4 +- .../com/android/settings/MasterClearTest.java | 43 +++++++++++++++---- 5 files changed, 42 insertions(+), 11 deletions(-) diff --git a/res/layout/master_clear.xml b/res/layout/master_clear.xml index d328478761a..c1e224f4210 100644 --- a/res/layout/master_clear.xml +++ b/res/layout/master_clear.xml @@ -116,6 +116,7 @@ diff --git a/res/layout/reset_esim_checkbox.xml b/res/layout/reset_esim_checkbox.xml index d830bf479fb..fb15fe66766 100644 --- a/res/layout/reset_esim_checkbox.xml +++ b/res/layout/reset_esim_checkbox.xml @@ -30,6 +30,7 @@ android:paddingEnd="@dimen/reset_checkbox_padding_end" android:focusable="false" android:clickable="false" + android:checked="true" android:duplicateParentState="true" /> This will reset all network settings, including:\n\n
  • Wi\u2011Fi
  • \n
  • Mobile data
  • \n
  • Bluetooth
  • "
    - Also reset eSIMs + Also reset eSIM Erase all eSIMs on the phone. You\u2019ll have to contact your carrier to redownload your eSIMs. This will not cancel your mobile service plan. @@ -3267,7 +3267,7 @@ Erase all the data on the SD card, such as music or photos - Erase eSIMs + Erase eSIM Erase all eSIMs on the phone. This will not cancel your mobile service plan. diff --git a/src/com/android/settings/MasterClear.java b/src/com/android/settings/MasterClear.java index 46e0d41cfac..766c6ae7f1d 100644 --- a/src/com/android/settings/MasterClear.java +++ b/src/com/android/settings/MasterClear.java @@ -357,7 +357,9 @@ public class MasterClear extends InstrumentedFragment implements OnGlobalLayoutL return false; } ContentResolver cr = context.getContentResolver(); - return Settings.Global.getInt(cr, Settings.Global.EUICC_PROVISIONED, 0) != 0; + return Settings.Global.getInt(cr, Settings.Global.EUICC_PROVISIONED, 0) != 0 + || Settings.Global.getInt( + cr, Settings.Global.DEVELOPMENT_SETTINGS_ENABLED, 0) != 0; } @VisibleForTesting diff --git a/tests/robotests/src/com/android/settings/MasterClearTest.java b/tests/robotests/src/com/android/settings/MasterClearTest.java index dc956aa5c13..64dab16118c 100644 --- a/tests/robotests/src/com/android/settings/MasterClearTest.java +++ b/tests/robotests/src/com/android/settings/MasterClearTest.java @@ -45,6 +45,7 @@ import android.view.LayoutInflater; import android.view.View; import android.view.ViewTreeObserver; import android.widget.Button; +import android.widget.CheckBox; import android.widget.LinearLayout; import android.widget.ScrollView; @@ -142,27 +143,43 @@ public class MasterClearTest { @Test public void testShowWipeEuicc_euiccDisabled() { - prepareEuiccState(false /* isEuiccEnabled */, true /* isEuiccProvisioned */); + prepareEuiccState( + false /* isEuiccEnabled */, + true /* isEuiccProvisioned */, + false /* isDeveloper */); assertThat(mMasterClear.showWipeEuicc()).isFalse(); } @Test public void testShowWipeEuicc_euiccEnabled_unprovisioned() { - prepareEuiccState(true /* isEuiccEnabled */, false /* isEuiccProvisioned */); + prepareEuiccState( + true /* isEuiccEnabled */, + false /* isEuiccProvisioned */, + false /* isDeveloper */); assertThat(mMasterClear.showWipeEuicc()).isFalse(); } @Test public void testShowWipeEuicc_euiccEnabled_provisioned() { - prepareEuiccState(true /* isEuiccEnabled */, true /* isEuiccProvisioned */); + prepareEuiccState( + true /* isEuiccEnabled */, + true /* isEuiccProvisioned */, + false /* isDeveloper */); assertThat(mMasterClear.showWipeEuicc()).isTrue(); } - private void prepareEuiccState(boolean isEuiccEnabled, boolean isEuiccProvisioned) { - doReturn(mActivity).when(mMasterClear).getContext(); - doReturn(isEuiccEnabled).when(mMasterClear).isEuiccEnabled(any()); - ContentResolver cr = mActivity.getContentResolver(); - Settings.Global.putInt(cr, Settings.Global.EUICC_PROVISIONED, isEuiccProvisioned ? 1 : 0); + @Test + public void testShowWipeEuicc_developerMode_unprovisioned() { + prepareEuiccState( + true /* isEuiccEnabled */, + false /* isEuiccProvisioned */, + true /* isDeveloper */); + assertThat(mMasterClear.showWipeEuicc()).isTrue(); + } + + @Test + public void testEsimRecheckBoxDefaultChecked() { + assertThat(((CheckBox) mContentView.findViewById(R.id.erase_esim)).isChecked()).isTrue(); } @Test @@ -373,6 +390,16 @@ public class MasterClearTest { verify(viewTreeObserver, never()).removeOnGlobalLayoutListener(mMasterClear); } + private void prepareEuiccState( + boolean isEuiccEnabled, boolean isEuiccProvisioned, boolean isDeveloper) { + doReturn(mActivity).when(mMasterClear).getContext(); + doReturn(isEuiccEnabled).when(mMasterClear).isEuiccEnabled(any()); + ContentResolver cr = mActivity.getContentResolver(); + Settings.Global.putInt(cr, Settings.Global.EUICC_PROVISIONED, isEuiccProvisioned ? 1 : 0); + Settings.Global.putInt( + cr, Settings.Global.DEVELOPMENT_SETTINGS_ENABLED, isDeveloper ? 1 : 0); + } + private void initScrollView(int height, int scrollY, int childBottom) { when(mScrollView.getHeight()).thenReturn(height); when(mScrollView.getScrollY()).thenReturn(scrollY);