Merge "UI Tweak for eSIM related" into pi-dev

This commit is contained in:
TreeHugger Robot
2018-03-20 19:24:59 +00:00
committed by Android (Google) Code Review
5 changed files with 42 additions and 11 deletions

View File

@@ -116,6 +116,7 @@
</LinearLayout> </LinearLayout>
</LinearLayout> </LinearLayout>
<include layout="@layout/reset_esim_checkbox" <include layout="@layout/reset_esim_checkbox"
android:layout_marginTop="40dp"
android:id="@+id/erase_esim_container" android:id="@+id/erase_esim_container"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" /> android:layout_height="wrap_content" />

View File

@@ -30,6 +30,7 @@
android:paddingEnd="@dimen/reset_checkbox_padding_end" android:paddingEnd="@dimen/reset_checkbox_padding_end"
android:focusable="false" android:focusable="false"
android:clickable="false" android:clickable="false"
android:checked="true"
android:duplicateParentState="true" /> android:duplicateParentState="true" />
<LinearLayout <LinearLayout

View File

@@ -3224,7 +3224,7 @@
<!-- SD card & phone storage settings screen, message on screen after user selects Reset network settings [CHAR LIMIT=NONE] --> <!-- SD card & phone storage settings screen, message on screen after user selects Reset network settings [CHAR LIMIT=NONE] -->
<string name="reset_network_desc">This will reset all network settings, including:\n\n<li>Wi\u2011Fi</li>\n<li>Mobile data</li>\n<li>Bluetooth</li>"</string> <string name="reset_network_desc">This will reset all network settings, including:\n\n<li>Wi\u2011Fi</li>\n<li>Mobile data</li>\n<li>Bluetooth</li>"</string>
<!-- SD card & phone storage settings screen, title for the checkbox to let user decide whether erase eSIM data together [CHAR LIMIT=NONE] --> <!-- SD card & phone storage settings screen, title for the checkbox to let user decide whether erase eSIM data together [CHAR LIMIT=NONE] -->
<string name="reset_esim_title">Also reset eSIMs</string> <string name="reset_esim_title">Also reset eSIM</string>
<!-- SD card & phone storage settings screen, message for the checkbox to let user decide whether erase eSIM data together [CHAR LIMIT=NONE] --> <!-- SD card & phone storage settings screen, message for the checkbox to let user decide whether erase eSIM data together [CHAR LIMIT=NONE] -->
<string name="reset_esim_desc">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.</string> <string name="reset_esim_desc">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.</string>
<!-- SD card & phone storage settings screen, button on screen after user selects Reset network settings --> <!-- SD card & phone storage settings screen, button on screen after user selects Reset network settings -->
@@ -3274,7 +3274,7 @@
<!-- SD card & phone storage settings screen, description for check box to erase USB storage [CHAR LIMIT=NONE] --> <!-- SD card & phone storage settings screen, description for check box to erase USB storage [CHAR LIMIT=NONE] -->
<string name="erase_external_storage_description" product="default">Erase all the data on the SD card, such as music or photos</string> <string name="erase_external_storage_description" product="default">Erase all the data on the SD card, such as music or photos</string>
<!-- SD card & phone storage settings screen, label for check box to erase all the carriers information on the embedded SIM card [CHAR LIMIT=30] --> <!-- SD card & phone storage settings screen, label for check box to erase all the carriers information on the embedded SIM card [CHAR LIMIT=30] -->
<string name="erase_esim_storage">Erase eSIMs</string> <string name="erase_esim_storage">Erase eSIM</string>
<!-- SD card & phone storage settings screen, description for check box to erase eSIMs for default devices [CHAR LIMIT=NONE] --> <!-- SD card & phone storage settings screen, description for check box to erase eSIMs for default devices [CHAR LIMIT=NONE] -->
<string name="erase_esim_storage_description" product="default">Erase all eSIMs on the phone. This will not cancel your mobile service plan.</string> <string name="erase_esim_storage_description" product="default">Erase all eSIMs on the phone. This will not cancel your mobile service plan.</string>
<!-- SD card & phone storage settings screen, description for check box to erase eSIMs for tablets [CHAR LIMIT=NONE] --> <!-- SD card & phone storage settings screen, description for check box to erase eSIMs for tablets [CHAR LIMIT=NONE] -->

View File

@@ -357,7 +357,9 @@ public class MasterClear extends InstrumentedFragment implements OnGlobalLayoutL
return false; return false;
} }
ContentResolver cr = context.getContentResolver(); 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 @VisibleForTesting

View File

@@ -45,6 +45,7 @@ import android.view.LayoutInflater;
import android.view.View; import android.view.View;
import android.view.ViewTreeObserver; import android.view.ViewTreeObserver;
import android.widget.Button; import android.widget.Button;
import android.widget.CheckBox;
import android.widget.LinearLayout; import android.widget.LinearLayout;
import android.widget.ScrollView; import android.widget.ScrollView;
@@ -142,27 +143,43 @@ public class MasterClearTest {
@Test @Test
public void testShowWipeEuicc_euiccDisabled() { public void testShowWipeEuicc_euiccDisabled() {
prepareEuiccState(false /* isEuiccEnabled */, true /* isEuiccProvisioned */); prepareEuiccState(
false /* isEuiccEnabled */,
true /* isEuiccProvisioned */,
false /* isDeveloper */);
assertThat(mMasterClear.showWipeEuicc()).isFalse(); assertThat(mMasterClear.showWipeEuicc()).isFalse();
} }
@Test @Test
public void testShowWipeEuicc_euiccEnabled_unprovisioned() { public void testShowWipeEuicc_euiccEnabled_unprovisioned() {
prepareEuiccState(true /* isEuiccEnabled */, false /* isEuiccProvisioned */); prepareEuiccState(
true /* isEuiccEnabled */,
false /* isEuiccProvisioned */,
false /* isDeveloper */);
assertThat(mMasterClear.showWipeEuicc()).isFalse(); assertThat(mMasterClear.showWipeEuicc()).isFalse();
} }
@Test @Test
public void testShowWipeEuicc_euiccEnabled_provisioned() { public void testShowWipeEuicc_euiccEnabled_provisioned() {
prepareEuiccState(true /* isEuiccEnabled */, true /* isEuiccProvisioned */); prepareEuiccState(
true /* isEuiccEnabled */,
true /* isEuiccProvisioned */,
false /* isDeveloper */);
assertThat(mMasterClear.showWipeEuicc()).isTrue(); assertThat(mMasterClear.showWipeEuicc()).isTrue();
} }
private void prepareEuiccState(boolean isEuiccEnabled, boolean isEuiccProvisioned) { @Test
doReturn(mActivity).when(mMasterClear).getContext(); public void testShowWipeEuicc_developerMode_unprovisioned() {
doReturn(isEuiccEnabled).when(mMasterClear).isEuiccEnabled(any()); prepareEuiccState(
ContentResolver cr = mActivity.getContentResolver(); true /* isEuiccEnabled */,
Settings.Global.putInt(cr, Settings.Global.EUICC_PROVISIONED, isEuiccProvisioned ? 1 : 0); false /* isEuiccProvisioned */,
true /* isDeveloper */);
assertThat(mMasterClear.showWipeEuicc()).isTrue();
}
@Test
public void testEsimRecheckBoxDefaultChecked() {
assertThat(((CheckBox) mContentView.findViewById(R.id.erase_esim)).isChecked()).isTrue();
} }
@Test @Test
@@ -373,6 +390,16 @@ public class MasterClearTest {
verify(viewTreeObserver, never()).removeOnGlobalLayoutListener(mMasterClear); 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) { private void initScrollView(int height, int scrollY, int childBottom) {
when(mScrollView.getHeight()).thenReturn(height); when(mScrollView.getHeight()).thenReturn(height);
when(mScrollView.getScrollY()).thenReturn(scrollY); when(mScrollView.getScrollY()).thenReturn(scrollY);