Update eSIM deletion strings.
Adds some conditional behavior for the confirmation screens.
When the erase eSIM option is visible and checked, shows alternate string.
Fixes: 126262481
Fixes: 118751918
Test: visual inspection & make -j RunSettingsRoboTests
Change-Id: I40f983b03ad470d785bf104e645dbc92e7897d2d
diff --git a/res/layout/reset_network_confirm.xml b/res/layout/reset_network_confirm.xml
index ffaafb3..0e5327f 100644
--- a/res/layout/reset_network_confirm.xml
+++ b/res/layout/reset_network_confirm.xml
@@ -19,6 +19,7 @@
android:orientation="vertical">
<TextView
+ android:id="@+id/reset_network_confirm"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="12dp"
diff --git a/res/values/strings.xml b/res/values/strings.xml
index 2593bd0..2c97471 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -3592,14 +3592,18 @@
<string name="reset_network_title">Reset Wi-Fi, mobile & Bluetooth</string>
<!-- 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>
+
<!-- SD card & phone storage settings screen, title for the checkbox to let user decide whether erase eSIM data together [CHAR LIMIT=30] -->
- <string name="reset_esim_title">Erase eSIMs</string>
+ <string name="reset_esim_title">Erase downloaded SIMs</string>
<!-- 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">You\u2019ll have to contact your carrier to download replacement eSIMs. This won\u2019t cancel any mobile service plans.</string>
+ <string name="reset_esim_desc">To download replacement SIMs, contact your carrier. This won\u2019t cancel any mobile service plans.</string>
+
<!-- SD card & phone storage settings screen, button on screen after user selects Reset network settings -->
<string name="reset_network_button_text">Reset settings</string>
<!-- SD card & phone storage settings screen, message on screen after user selects Reset settings button -->
- <string name="reset_network_final_desc">Reset all network settings? You can\u2019t undo this action!</string>
+ <string name="reset_network_final_desc">Reset all network settings? You can\u2019t undo this action.</string>
+ <!-- SD card & phone storage settings screen, message on screen after user selects Reset settings button [CHAR LIMIT=NONE] -->
+ <string name="reset_network_final_desc_esim">Reset all network settings and erase downloaded SIMs? You can\u2019t undo this action.</string>
<!-- SD card & phone storage settings screen, button on screen after user selects Reset settings button -->
<string name="reset_network_final_button_text">Reset settings</string>
<!-- Reset settings confirmation screen title [CHAR LIMIT=30] -->
@@ -3609,9 +3613,9 @@
<!-- Reset settings complete toast text [CHAR LIMIT=75] -->
<string name="reset_network_complete_toast">Network settings have been reset</string>
<!-- Title of the error message shown when error happens during erase eSIM data [CHAR LIMIT=NONE] -->
- <string name="reset_esim_error_title">Cant\u2019t reset eSIMs</string>
+ <string name="reset_esim_error_title">Can\u2019t erase SIMs</string>
<!-- Message of the error message shown when error happens during erase eSIM data [CHAR LIMIT=NONE] -->
- <string name="reset_esim_error_msg">The eSIMs can\u2019tt be reset due to an error.</string>
+ <string name="reset_esim_error_msg">Downloaded SIMs can\u2019t be erased due to an error.\n\nRestart your device and try again.</string>
<!-- Master Clear -->
<!-- Button title to factory data reset the entire device -->
@@ -3649,7 +3653,9 @@
<!-- SD card & phone storage settings screen, button on screen after user selects Factory data reset -->
<string name="master_clear_button_text" product="default">Erase all data</string>
<!-- SD card & phone storage settings screen, message on screen after user selects Reset phone button -->
- <string name="master_clear_final_desc">All of your personal information and downloaded apps will be deleted. You can\u2019t undo this action!</string>
+ <string name="master_clear_final_desc">All of your personal information and downloaded apps will be deleted. You can\u2019t undo this action.</string>
+ <!-- SD card & phone storage settings screen, message on screen after user selects Reset phone button [CHAR LIMIT=NONE] -->
+ <string name="master_clear_final_desc_esim">All of your personal information, including downloaded apps & SIMs, will be deleted. You can\u2019t undo this action.</string>
<!-- SD card & phone storage settings screen, button on screen after user selects Reset phone button -->
<string name="master_clear_final_button_text">Erase everything</string>
<!-- Master clear failed message -->
diff --git a/src/com/android/settings/MasterClear.java b/src/com/android/settings/MasterClear.java
index c78115d..14a6aed 100644
--- a/src/com/android/settings/MasterClear.java
+++ b/src/com/android/settings/MasterClear.java
@@ -102,7 +102,8 @@
private View mExternalStorageContainer;
@VisibleForTesting
CheckBox mExternalStorage;
- private View mEsimStorageContainer;
+ @VisibleForTesting
+ View mEsimStorageContainer;
@VisibleForTesting
CheckBox mEsimStorage;
@VisibleForTesting
@@ -181,7 +182,8 @@
void showFinalConfirmation() {
final Bundle args = new Bundle();
args.putBoolean(ERASE_EXTERNAL_EXTRA, mExternalStorage.isChecked());
- args.putBoolean(ERASE_ESIMS_EXTRA, mEsimStorage.isChecked());
+ args.putBoolean(ERASE_ESIMS_EXTRA,
+ mEsimStorageContainer.getVisibility() == View.VISIBLE && mEsimStorage.isChecked());
new SubSettingLauncher(getContext())
.setDestination(MasterClearConfirm.class.getName())
.setArguments(args)
diff --git a/src/com/android/settings/MasterClearConfirm.java b/src/com/android/settings/MasterClearConfirm.java
index 618dd2c..ac97c11 100644
--- a/src/com/android/settings/MasterClearConfirm.java
+++ b/src/com/android/settings/MasterClearConfirm.java
@@ -40,6 +40,8 @@
import android.widget.Button;
import android.widget.TextView;
+import androidx.annotation.VisibleForTesting;
+
import com.android.settings.core.InstrumentedFragment;
import com.android.settings.enterprise.ActionDisabledByAdminDialogHelper;
import com.android.settingslib.RestrictedLockUtilsInternal;
@@ -62,9 +64,9 @@
public class MasterClearConfirm extends InstrumentedFragment {
private final static String TAG = "MasterClearConfirm";
- private View mContentView;
+ @VisibleForTesting View mContentView;
private boolean mEraseSdCard;
- private boolean mEraseEsims;
+ @VisibleForTesting boolean mEraseEsims;
/**
* The user has gone through the multiple confirmation, so now we go ahead
@@ -199,6 +201,7 @@
setUpActionBarAndTitle();
establishFinalConfirmationState();
setAccessibilityTitle();
+ setSubtitle();
return mContentView;
}
@@ -212,6 +215,14 @@
}
}
+ @VisibleForTesting
+ void setSubtitle() {
+ if (mEraseEsims) {
+ ((TextView) mContentView.findViewById(R.id.master_clear_confirm))
+ .setText(R.string.master_clear_final_desc_esim);
+ }
+ }
+
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
diff --git a/src/com/android/settings/ResetNetwork.java b/src/com/android/settings/ResetNetwork.java
index 5d7dd99..424d976 100644
--- a/src/com/android/settings/ResetNetwork.java
+++ b/src/com/android/settings/ResetNetwork.java
@@ -42,6 +42,8 @@
import android.widget.Spinner;
import android.widget.TextView;
+import androidx.annotation.VisibleForTesting;
+
import com.android.internal.telephony.PhoneConstants;
import com.android.settings.core.InstrumentedFragment;
import com.android.settings.core.SubSettingLauncher;
@@ -74,8 +76,8 @@
private View mContentView;
private Spinner mSubscriptionSpinner;
private Button mInitiateButton;
- private View mEsimContainer;
- private CheckBox mEsimCheckbox;
+ @VisibleForTesting View mEsimContainer;
+ @VisibleForTesting CheckBox mEsimCheckbox;
@Override
public void onCreate(@Nullable Bundle savedInstanceState) {
@@ -112,14 +114,16 @@
}
}
- private void showFinalConfirmation() {
+ @VisibleForTesting
+ void showFinalConfirmation() {
Bundle args = new Bundle();
if (mSubscriptions != null && mSubscriptions.size() > 0) {
int selectedIndex = mSubscriptionSpinner.getSelectedItemPosition();
SubscriptionInfo subscription = mSubscriptions.get(selectedIndex);
args.putInt(PhoneConstants.SUBSCRIPTION_KEY, subscription.getSubscriptionId());
}
- args.putBoolean(MasterClear.ERASE_ESIMS_EXTRA, mEsimCheckbox.isChecked());
+ args.putBoolean(MasterClear.ERASE_ESIMS_EXTRA,
+ mEsimContainer.getVisibility() == View.VISIBLE && mEsimCheckbox.isChecked());
new SubSettingLauncher(getContext())
.setDestination(ResetNetworkConfirm.class.getName())
.setArguments(args)
diff --git a/src/com/android/settings/ResetNetworkConfirm.java b/src/com/android/settings/ResetNetworkConfirm.java
index 72e1919..376b726 100644
--- a/src/com/android/settings/ResetNetworkConfirm.java
+++ b/src/com/android/settings/ResetNetworkConfirm.java
@@ -40,6 +40,7 @@
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
+import android.widget.TextView;
import android.widget.Toast;
import androidx.annotation.VisibleForTesting;
@@ -64,7 +65,7 @@
*/
public class ResetNetworkConfirm extends InstrumentedFragment {
- private View mContentView;
+ @VisibleForTesting View mContentView;
private int mSubId = SubscriptionManager.INVALID_SUBSCRIPTION_ID;
@VisibleForTesting boolean mEraseEsim;
@VisibleForTesting EraseEsimAsyncTask mEraseEsimTask;
@@ -207,6 +208,14 @@
.setOnClickListener(mFinalClickListener);
}
+ @VisibleForTesting
+ void setSubtitle() {
+ if (mEraseEsim) {
+ ((TextView) mContentView.findViewById(R.id.reset_network_confirm))
+ .setText(R.string.reset_network_final_desc_esim);
+ }
+ }
+
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
@@ -224,6 +233,7 @@
}
mContentView = inflater.inflate(R.layout.reset_network_confirm, null);
establishFinalConfirmationState();
+ setSubtitle();
return mContentView;
}
diff --git a/tests/robotests/src/com/android/settings/MasterClearConfirmTest.java b/tests/robotests/src/com/android/settings/MasterClearConfirmTest.java
new file mode 100644
index 0000000..0c6903a
--- /dev/null
+++ b/tests/robotests/src/com/android/settings/MasterClearConfirmTest.java
@@ -0,0 +1,67 @@
+/*
+ * Copyright (C) 2019 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.settings;
+
+import static com.google.common.truth.Truth.assertThat;
+
+import android.app.Activity;
+import android.view.LayoutInflater;
+import android.widget.TextView;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.robolectric.Robolectric;
+import org.robolectric.RobolectricTestRunner;
+
+@RunWith(RobolectricTestRunner.class)
+public class MasterClearConfirmTest {
+ private Activity mActivity;
+
+ @Before
+ public void setUp() {
+ mActivity = Robolectric.setupActivity(Activity.class);
+ }
+
+ @Test
+ public void setSubtitle_eraseEsim() {
+ MasterClearConfirm masterClearConfirm = new MasterClearConfirm();
+ masterClearConfirm.mEraseEsims = true;
+ masterClearConfirm.mContentView =
+ LayoutInflater.from(mActivity).inflate(R.layout.master_clear_confirm, null);
+
+ masterClearConfirm.setSubtitle();
+
+ assertThat(((TextView) masterClearConfirm.mContentView
+ .findViewById(R.id.master_clear_confirm)).getText())
+ .isEqualTo(mActivity.getString(R.string.master_clear_final_desc_esim));
+ }
+
+ @Test
+ public void setSubtitle_notEraseEsim() {
+ MasterClearConfirm masterClearConfirm = new MasterClearConfirm();
+ masterClearConfirm.mEraseEsims = false;
+ masterClearConfirm.mContentView =
+ LayoutInflater.from(mActivity).inflate(R.layout.master_clear_confirm, null);
+
+ masterClearConfirm.setSubtitle();
+
+ assertThat(((TextView) masterClearConfirm.mContentView
+ .findViewById(R.id.master_clear_confirm)).getText())
+ .isEqualTo(mActivity.getString(R.string.master_clear_final_desc));
+ }
+}
diff --git a/tests/robotests/src/com/android/settings/MasterClearTest.java b/tests/robotests/src/com/android/settings/MasterClearTest.java
index 749373b..813e4aa 100644
--- a/tests/robotests/src/com/android/settings/MasterClearTest.java
+++ b/tests/robotests/src/com/android/settings/MasterClearTest.java
@@ -108,12 +108,14 @@
}
@Test
- public void testShowFinalConfirmation_eraseEsimChecked() {
+ public void testShowFinalConfirmation_eraseEsimVisible_eraseEsimChecked() {
final Context context = mock(Context.class);
when(mMasterClear.getContext()).thenReturn(context);
mMasterClear.mEsimStorage = mContentView.findViewById(R.id.erase_esim);
mMasterClear.mExternalStorage = mContentView.findViewById(R.id.erase_external);
+ mMasterClear.mEsimStorageContainer = mContentView.findViewById(R.id.erase_esim_container);
+ mMasterClear.mEsimStorageContainer.setVisibility(View.VISIBLE);
mMasterClear.mEsimStorage.setChecked(true);
mMasterClear.showFinalConfirmation();
@@ -126,12 +128,14 @@
}
@Test
- public void testShowFinalConfirmation_eraseEsimUnchecked() {
+ public void testShowFinalConfirmation_eraseEsimVisible_eraseEsimUnchecked() {
final Context context = mock(Context.class);
when(mMasterClear.getContext()).thenReturn(context);
mMasterClear.mEsimStorage = mContentView.findViewById(R.id.erase_esim);
mMasterClear.mExternalStorage = mContentView.findViewById(R.id.erase_external);
+ mMasterClear.mEsimStorageContainer = mContentView.findViewById(R.id.erase_esim_container);
+ mMasterClear.mEsimStorageContainer.setVisibility(View.VISIBLE);
mMasterClear.mEsimStorage.setChecked(false);
mMasterClear.showFinalConfirmation();
final ArgumentCaptor<Intent> intent = ArgumentCaptor.forClass(Intent.class);
@@ -143,6 +147,45 @@
}
@Test
+ public void testShowFinalConfirmation_eraseEsimGone_eraseEsimChecked() {
+ final Context context = mock(Context.class);
+ when(mMasterClear.getContext()).thenReturn(context);
+
+ mMasterClear.mEsimStorage = mContentView.findViewById(R.id.erase_esim);
+ mMasterClear.mExternalStorage = mContentView.findViewById(R.id.erase_external);
+ mMasterClear.mEsimStorageContainer = mContentView.findViewById(R.id.erase_esim_container);
+ mMasterClear.mEsimStorageContainer.setVisibility(View.GONE);
+ mMasterClear.mEsimStorage.setChecked(true);
+ mMasterClear.showFinalConfirmation();
+
+ final ArgumentCaptor<Intent> intent = ArgumentCaptor.forClass(Intent.class);
+
+ verify(context).startActivity(intent.capture());
+ assertThat(intent.getValue().getBundleExtra(SettingsActivity.EXTRA_SHOW_FRAGMENT_ARGUMENTS)
+ .getBoolean(MasterClear.ERASE_ESIMS_EXTRA, false))
+ .isFalse();
+ }
+
+ @Test
+ public void testShowFinalConfirmation_eraseEsimGone_eraseEsimUnchecked() {
+ final Context context = mock(Context.class);
+ when(mMasterClear.getContext()).thenReturn(context);
+
+ mMasterClear.mEsimStorage = mContentView.findViewById(R.id.erase_esim);
+ mMasterClear.mExternalStorage = mContentView.findViewById(R.id.erase_external);
+ mMasterClear.mEsimStorageContainer = mContentView.findViewById(R.id.erase_esim_container);
+ mMasterClear.mEsimStorageContainer.setVisibility(View.GONE);
+ mMasterClear.mEsimStorage.setChecked(false);
+ mMasterClear.showFinalConfirmation();
+ final ArgumentCaptor<Intent> intent = ArgumentCaptor.forClass(Intent.class);
+
+ verify(context).startActivity(intent.capture());
+ assertThat(intent.getValue().getBundleExtra(SettingsActivity.EXTRA_SHOW_FRAGMENT_ARGUMENTS)
+ .getBoolean(MasterClear.ERASE_ESIMS_EXTRA, false))
+ .isFalse();
+ }
+
+ @Test
public void testShowWipeEuicc_euiccDisabled() {
prepareEuiccState(
false /* isEuiccEnabled */,
diff --git a/tests/robotests/src/com/android/settings/ResetNetworkConfirmTest.java b/tests/robotests/src/com/android/settings/ResetNetworkConfirmTest.java
index 0e4592d..1e960bf 100644
--- a/tests/robotests/src/com/android/settings/ResetNetworkConfirmTest.java
+++ b/tests/robotests/src/com/android/settings/ResetNetworkConfirmTest.java
@@ -21,6 +21,8 @@
import static org.mockito.Mockito.spy;
import android.app.Activity;
+import android.view.LayoutInflater;
+import android.widget.TextView;
import com.android.settings.testutils.shadow.ShadowRecoverySystem;
import com.android.settings.testutils.shadow.ShadowWifiP2pManager;
@@ -86,4 +88,30 @@
assertThat(ShadowWifiP2pManager.getFactoryResetCount()).isEqualTo(1);
}
+
+ @Test
+ public void setSubtitle_eraseEsim() {
+ mResetNetworkConfirm.mEraseEsim = true;
+ mResetNetworkConfirm.mContentView =
+ LayoutInflater.from(mActivity).inflate(R.layout.reset_network_confirm, null);
+
+ mResetNetworkConfirm.setSubtitle();
+
+ assertThat(((TextView) mResetNetworkConfirm.mContentView
+ .findViewById(R.id.reset_network_confirm)).getText())
+ .isEqualTo(mActivity.getString(R.string.reset_network_final_desc_esim));
+ }
+
+ @Test
+ public void setSubtitle_notEraseEsim() {
+ mResetNetworkConfirm.mEraseEsim = false;
+ mResetNetworkConfirm.mContentView =
+ LayoutInflater.from(mActivity).inflate(R.layout.reset_network_confirm, null);
+
+ mResetNetworkConfirm.setSubtitle();
+
+ assertThat(((TextView) mResetNetworkConfirm.mContentView
+ .findViewById(R.id.reset_network_confirm)).getText())
+ .isEqualTo(mActivity.getString(R.string.reset_network_final_desc));
+ }
}
diff --git a/tests/robotests/src/com/android/settings/ResetNetworkTest.java b/tests/robotests/src/com/android/settings/ResetNetworkTest.java
new file mode 100644
index 0000000..3b1d73b
--- /dev/null
+++ b/tests/robotests/src/com/android/settings/ResetNetworkTest.java
@@ -0,0 +1,98 @@
+/*
+ * Copyright (C) 2019 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.settings;
+
+import static com.google.common.truth.Truth.assertThat;
+
+import static org.robolectric.Shadows.shadowOf;
+
+import static org.mockito.Mockito.spy;
+import static org.mockito.Mockito.when;
+
+import android.app.Activity;
+import android.content.Intent;
+import android.view.View;
+import android.widget.CheckBox;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.robolectric.Robolectric;
+import org.robolectric.RobolectricTestRunner;
+
+@RunWith(RobolectricTestRunner.class)
+public class ResetNetworkTest {
+ private Activity mActivity;
+ private ResetNetwork mResetNetwork;
+
+ @Before
+ public void setUp() {
+ mActivity = Robolectric.setupActivity(Activity.class);
+ mResetNetwork = spy(new ResetNetwork());
+ when(mResetNetwork.getContext()).thenReturn(mActivity);
+ mResetNetwork.mEsimContainer = new View(mActivity);
+ mResetNetwork.mEsimCheckbox = new CheckBox(mActivity);
+ }
+
+ @Test
+ public void showFinalConfirmation_checkboxVisible_eraseEsimChecked() {
+ mResetNetwork.mEsimContainer.setVisibility(View.VISIBLE);
+ mResetNetwork.mEsimCheckbox.setChecked(true);
+
+ mResetNetwork.showFinalConfirmation();
+
+ Intent intent = shadowOf(mActivity).getNextStartedActivity();
+ assertThat(intent.getBundleExtra(SettingsActivity.EXTRA_SHOW_FRAGMENT_ARGUMENTS)
+ .getBoolean(MasterClear.ERASE_ESIMS_EXTRA, false)).isTrue();
+ }
+
+ @Test
+ public void showFinalConfirmation_checkboxVisible_eraseEsimUnchecked() {
+ mResetNetwork.mEsimContainer.setVisibility(View.VISIBLE);
+ mResetNetwork.mEsimCheckbox.setChecked(false);
+
+ mResetNetwork.showFinalConfirmation();
+
+ Intent intent = shadowOf(mActivity).getNextStartedActivity();
+ assertThat(intent.getBundleExtra(SettingsActivity.EXTRA_SHOW_FRAGMENT_ARGUMENTS)
+ .getBoolean(MasterClear.ERASE_ESIMS_EXTRA, false)).isFalse();
+ }
+
+ @Test
+ public void showFinalConfirmation_checkboxGone_eraseEsimChecked() {
+ mResetNetwork.mEsimContainer.setVisibility(View.GONE);
+ mResetNetwork.mEsimCheckbox.setChecked(true);
+
+ mResetNetwork.showFinalConfirmation();
+
+ Intent intent = shadowOf(mActivity).getNextStartedActivity();
+ assertThat(intent.getBundleExtra(SettingsActivity.EXTRA_SHOW_FRAGMENT_ARGUMENTS)
+ .getBoolean(MasterClear.ERASE_ESIMS_EXTRA, false)).isFalse();
+ }
+
+ @Test
+ public void showFinalConfirmation_checkboxGone_eraseEsimUnchecked() {
+ mResetNetwork.mEsimContainer.setVisibility(View.GONE);
+ mResetNetwork.mEsimCheckbox.setChecked(false);
+
+ mResetNetwork.showFinalConfirmation();
+
+ Intent intent = shadowOf(mActivity).getNextStartedActivity();
+ assertThat(intent.getBundleExtra(SettingsActivity.EXTRA_SHOW_FRAGMENT_ARGUMENTS)
+ .getBoolean(MasterClear.ERASE_ESIMS_EXTRA, false)).isFalse();
+ }
+}