Merge "Add checkbox to let user wipe eSIM data together with FDR"
This commit is contained in:
committed by
Android (Google) Code Review
commit
01b2d78da1
@@ -115,6 +115,10 @@
|
|||||||
android:text="@string/erase_external_storage_description" />
|
android:text="@string/erase_external_storage_description" />
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
<include layout="@layout/reset_esim_checkbox"
|
||||||
|
android:id="@+id/erase_esim_container"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content" />
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
</ScrollView>
|
</ScrollView>
|
||||||
<Button
|
<Button
|
||||||
|
@@ -13,7 +13,8 @@
|
|||||||
See the License for the specific language governing permissions and
|
See the License for the specific language governing permissions and
|
||||||
limitations under the License.
|
limitations under the License.
|
||||||
-->
|
-->
|
||||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
<LinearLayout
|
||||||
|
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:orientation="horizontal"
|
android:orientation="horizontal"
|
||||||
@@ -21,7 +22,8 @@
|
|||||||
android:clickable="true"
|
android:clickable="true"
|
||||||
android:visibility="gone">
|
android:visibility="gone">
|
||||||
|
|
||||||
<CheckBox android:id="@+id/erase_esim"
|
<CheckBox
|
||||||
|
android:id="@+id/erase_esim"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_gravity="center_vertical"
|
android:layout_gravity="center_vertical"
|
||||||
@@ -30,12 +32,14 @@
|
|||||||
android:clickable="false"
|
android:clickable="false"
|
||||||
android:duplicateParentState="true" />
|
android:duplicateParentState="true" />
|
||||||
|
|
||||||
<LinearLayout android:layout_width="match_parent"
|
<LinearLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_gravity="center_vertical"
|
android:layout_gravity="center_vertical"
|
||||||
android:orientation="vertical">
|
android:orientation="vertical">
|
||||||
|
|
||||||
<TextView android:id="@+id/erase_esim_title"
|
<TextView
|
||||||
|
android:id="@+id/erase_esim_title"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:paddingTop="@dimen/reset_checkbox_title_padding_top"
|
android:paddingTop="@dimen/reset_checkbox_title_padding_top"
|
||||||
|
@@ -3248,7 +3248,7 @@
|
|||||||
<!-- SD card & phone storage settings screen, list of items in user data storage (USB storage or SD card) that will be erased during this operation [CHAR LIMIT=NONE] -->
|
<!-- SD card & phone storage settings screen, list of items in user data storage (USB storage or SD card) that will be erased during this operation [CHAR LIMIT=NONE] -->
|
||||||
<string name="master_clear_desc_also_erases_external">"<li>Music</li>\n<li>Photos</li>\n<li>Other user data</li>"</string>
|
<string name="master_clear_desc_also_erases_external">"<li>Music</li>\n<li>Photos</li>\n<li>Other user data</li>"</string>
|
||||||
<!-- SD card & phone storage settings screen, list of items on an eSIM (embedded SIM) that will be erased during this operation [CHAR LIMIT=NONE] -->
|
<!-- SD card & phone storage settings screen, list of items on an eSIM (embedded SIM) that will be erased during this operation [CHAR LIMIT=NONE] -->
|
||||||
<string name="master_clear_desc_also_erases_esim">"<li>Carriers on eSIM</li>"</string>
|
<string name="master_clear_desc_also_erases_esim">"<li>eSIMs</li>"</string>
|
||||||
<!-- SD card & phone storage settings screen, notification if there are eSIM (embedded SIM) profiles present that the user's mobile service plan will not be canceled [CHAR LIMIT=NONE] -->
|
<!-- SD card & phone storage settings screen, notification if there are eSIM (embedded SIM) profiles present that the user's mobile service plan will not be canceled [CHAR LIMIT=NONE] -->
|
||||||
<string name="master_clear_desc_no_cancel_mobile_plan">"\n\nThis will not cancel your mobile service plan.</string>
|
<string name="master_clear_desc_no_cancel_mobile_plan">"\n\nThis will not cancel your mobile service plan.</string>
|
||||||
<!-- SD card & phone storage settings screen, instructions about whether to also erase the external storage (SD card) when erasing the internal storage [CHAR LIMIT=NONE] -->
|
<!-- SD card & phone storage settings screen, instructions about whether to also erase the external storage (SD card) when erasing the internal storage [CHAR LIMIT=NONE] -->
|
||||||
|
@@ -78,6 +78,9 @@ public class MasterClear extends InstrumentedPreferenceFragment {
|
|||||||
private static final int KEYGUARD_REQUEST = 55;
|
private static final int KEYGUARD_REQUEST = 55;
|
||||||
@VisibleForTesting static final int CREDENTIAL_CONFIRM_REQUEST = 56;
|
@VisibleForTesting static final int CREDENTIAL_CONFIRM_REQUEST = 56;
|
||||||
|
|
||||||
|
private static final String KEY_SHOW_ESIM_RESET_CHECKBOX
|
||||||
|
= "masterclear.allow_retain_esim_profiles_after_fdr";
|
||||||
|
|
||||||
static final String ERASE_EXTERNAL_EXTRA = "erase_sd";
|
static final String ERASE_EXTERNAL_EXTRA = "erase_sd";
|
||||||
static final String ERASE_ESIMS_EXTRA = "erase_esim";
|
static final String ERASE_ESIMS_EXTRA = "erase_esim";
|
||||||
|
|
||||||
@@ -85,6 +88,8 @@ public class MasterClear extends InstrumentedPreferenceFragment {
|
|||||||
private Button mInitiateButton;
|
private Button mInitiateButton;
|
||||||
private View mExternalStorageContainer;
|
private View mExternalStorageContainer;
|
||||||
@VisibleForTesting CheckBox mExternalStorage;
|
@VisibleForTesting CheckBox mExternalStorage;
|
||||||
|
private View mEsimStorageContainer;
|
||||||
|
@VisibleForTesting CheckBox mEsimStorage;
|
||||||
private ScrollView mScrollView;
|
private ScrollView mScrollView;
|
||||||
|
|
||||||
private final OnGlobalLayoutListener mOnGlobalLayoutListener = new OnGlobalLayoutListener() {
|
private final OnGlobalLayoutListener mOnGlobalLayoutListener = new OnGlobalLayoutListener() {
|
||||||
@@ -134,8 +139,7 @@ public class MasterClear extends InstrumentedPreferenceFragment {
|
|||||||
void showFinalConfirmation() {
|
void showFinalConfirmation() {
|
||||||
Bundle args = new Bundle();
|
Bundle args = new Bundle();
|
||||||
args.putBoolean(ERASE_EXTERNAL_EXTRA, mExternalStorage.isChecked());
|
args.putBoolean(ERASE_EXTERNAL_EXTRA, mExternalStorage.isChecked());
|
||||||
// TODO: Offer the user a choice to wipe eSIMs when it is technically feasible to do so.
|
args.putBoolean(ERASE_ESIMS_EXTRA, mEsimStorage.isChecked());
|
||||||
args.putBoolean(ERASE_ESIMS_EXTRA, true);
|
|
||||||
((SettingsActivity) getActivity()).startPreferencePanel(
|
((SettingsActivity) getActivity()).startPreferencePanel(
|
||||||
this, MasterClearConfirm.class.getName(),
|
this, MasterClearConfirm.class.getName(),
|
||||||
args, R.string.master_clear_confirm_title, null, null, 0);
|
args, R.string.master_clear_confirm_title, null, null, 0);
|
||||||
@@ -217,6 +221,8 @@ public class MasterClear extends InstrumentedPreferenceFragment {
|
|||||||
mInitiateButton.setOnClickListener(mInitiateListener);
|
mInitiateButton.setOnClickListener(mInitiateListener);
|
||||||
mExternalStorageContainer = mContentView.findViewById(R.id.erase_external_container);
|
mExternalStorageContainer = mContentView.findViewById(R.id.erase_external_container);
|
||||||
mExternalStorage = (CheckBox) mContentView.findViewById(R.id.erase_external);
|
mExternalStorage = (CheckBox) mContentView.findViewById(R.id.erase_external);
|
||||||
|
mEsimStorageContainer = mContentView.findViewById(R.id.erase_esim_container);
|
||||||
|
mEsimStorage = (CheckBox) mContentView.findViewById(R.id.erase_esim);
|
||||||
mScrollView = (ScrollView) mContentView.findViewById(R.id.master_clear_scrollview);
|
mScrollView = (ScrollView) mContentView.findViewById(R.id.master_clear_scrollview);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -251,11 +257,25 @@ public class MasterClear extends InstrumentedPreferenceFragment {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (showWipeEuicc()) {
|
if (showWipeEuicc()) {
|
||||||
final View esimAlsoErased = mContentView.findViewById(R.id.also_erases_esim);
|
if (showWipeEuiccCheckbox()) {
|
||||||
esimAlsoErased.setVisibility(View.VISIBLE);
|
TextView title = mContentView.findViewById(R.id.erase_esim_title);
|
||||||
|
title.setText(R.string.erase_esim_storage);
|
||||||
|
mEsimStorageContainer.setVisibility(View.VISIBLE);
|
||||||
|
mEsimStorageContainer.setOnClickListener(new View.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(View v) {
|
||||||
|
mEsimStorage.toggle();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
final View esimAlsoErased = mContentView.findViewById(R.id.also_erases_esim);
|
||||||
|
esimAlsoErased.setVisibility(View.VISIBLE);
|
||||||
|
|
||||||
final View noCancelMobilePlan = mContentView.findViewById(R.id.no_cancel_mobile_plan);
|
final View noCancelMobilePlan = mContentView.findViewById(
|
||||||
noCancelMobilePlan.setVisibility(View.VISIBLE);
|
R.id.no_cancel_mobile_plan);
|
||||||
|
noCancelMobilePlan.setVisibility(View.VISIBLE);
|
||||||
|
mEsimStorage.setChecked(true /* checked */);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
final UserManager um = (UserManager) getActivity().getSystemService(Context.USER_SERVICE);
|
final UserManager um = (UserManager) getActivity().getSystemService(Context.USER_SERVICE);
|
||||||
@@ -296,6 +316,12 @@ public class MasterClear extends InstrumentedPreferenceFragment {
|
|||||||
return Settings.Global.getInt(cr, Settings.Global.EUICC_PROVISIONED, 0) != 0;
|
return Settings.Global.getInt(cr, Settings.Global.EUICC_PROVISIONED, 0) != 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@VisibleForTesting
|
||||||
|
boolean showWipeEuiccCheckbox() {
|
||||||
|
return SystemProperties
|
||||||
|
.getBoolean(KEY_SHOW_ESIM_RESET_CHECKBOX, false /* def */);
|
||||||
|
}
|
||||||
|
|
||||||
@VisibleForTesting
|
@VisibleForTesting
|
||||||
protected boolean isEuiccEnabled(Context context) {
|
protected boolean isEuiccEnabled(Context context) {
|
||||||
EuiccManager euiccManager = (EuiccManager) context.getSystemService(Context.EUICC_SERVICE);
|
EuiccManager euiccManager = (EuiccManager) context.getSystemService(Context.EUICC_SERVICE);
|
||||||
|
@@ -81,8 +81,7 @@ public class ResetNetworkConfirm extends InstrumentedPreferenceFragment {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected Boolean doInBackground(Void... params) {
|
protected Boolean doInBackground(Void... params) {
|
||||||
return mRecoverySystem.wipeEuiccData(
|
return mRecoverySystem.wipeEuiccData(mContext, mPackageName);
|
||||||
mContext, true /* isWipeEuicc */, mPackageName);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@@ -29,11 +29,10 @@ public class RecoverySystemWrapper {
|
|||||||
/**
|
/**
|
||||||
* Returns whether wipe Euicc data successfully or not.
|
* Returns whether wipe Euicc data successfully or not.
|
||||||
*
|
*
|
||||||
* @param isWipeEuicc whether we want to wipe Euicc data or not
|
|
||||||
* @param packageName the package name of the caller app.
|
* @param packageName the package name of the caller app.
|
||||||
*/
|
*/
|
||||||
public boolean wipeEuiccData(
|
public boolean wipeEuiccData(
|
||||||
Context context, final boolean isWipeEuicc, final String packageName) {
|
Context context, final String packageName) {
|
||||||
return RecoverySystem.wipeEuiccData(context, isWipeEuicc, packageName);
|
return RecoverySystem.wipeEuiccData(context, packageName);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -41,6 +41,7 @@ import android.os.Bundle;
|
|||||||
import android.provider.Settings;
|
import android.provider.Settings;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
|
import android.widget.CheckBox;
|
||||||
import android.widget.LinearLayout;
|
import android.widget.LinearLayout;
|
||||||
import android.widget.ScrollView;
|
import android.widget.ScrollView;
|
||||||
|
|
||||||
@@ -117,6 +118,32 @@ public class MasterClearTest {
|
|||||||
when(mScrollView.getChildCount()).thenReturn(1);
|
when(mScrollView.getChildCount()).thenReturn(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testShowFinalConfirmation_eraseEsimChecked() {
|
||||||
|
ActivityForTest testActivity = new ActivityForTest();
|
||||||
|
when(mMasterClear.getActivity()).thenReturn(testActivity);
|
||||||
|
|
||||||
|
mMasterClear.mEsimStorage = mContentView.findViewById(R.id.erase_esim);
|
||||||
|
mMasterClear.mExternalStorage = mContentView.findViewById(R.id.erase_external);
|
||||||
|
mMasterClear.mEsimStorage.setChecked(true);
|
||||||
|
mMasterClear.showFinalConfirmation();
|
||||||
|
assertThat(testActivity.getArgs().getBoolean(MasterClear.ERASE_ESIMS_EXTRA, false))
|
||||||
|
.isTrue();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testShowFinalConfirmation_eraseEsimUnchecked() {
|
||||||
|
ActivityForTest testActivity = new ActivityForTest();
|
||||||
|
when(mMasterClear.getActivity()).thenReturn(testActivity);
|
||||||
|
|
||||||
|
mMasterClear.mEsimStorage = mContentView.findViewById(R.id.erase_esim);
|
||||||
|
mMasterClear.mExternalStorage = mContentView.findViewById(R.id.erase_external);
|
||||||
|
mMasterClear.mEsimStorage.setChecked(false);
|
||||||
|
mMasterClear.showFinalConfirmation();
|
||||||
|
assertThat(testActivity.getArgs().getBoolean(MasterClear.ERASE_ESIMS_EXTRA, true))
|
||||||
|
.isFalse();
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testShowWipeEuicc_euiccDisabled() {
|
public void testShowWipeEuicc_euiccDisabled() {
|
||||||
prepareEuiccState(
|
prepareEuiccState(
|
||||||
|
@@ -66,7 +66,7 @@ public class ResetNetworkConfirmTest {
|
|||||||
public void testResetNetworkData_resetEsim() {
|
public void testResetNetworkData_resetEsim() {
|
||||||
mResetNetworkConfirm.mEraseEsim = true;
|
mResetNetworkConfirm.mEraseEsim = true;
|
||||||
doReturn(true)
|
doReturn(true)
|
||||||
.when(mRecoverySystem).wipeEuiccData(any(Context.class), anyBoolean(), anyString());
|
.when(mRecoverySystem).wipeEuiccData(any(Context.class), anyString());
|
||||||
|
|
||||||
mResetNetworkConfirm.esimFactoryReset(mActivity, "" /* packageName */);
|
mResetNetworkConfirm.esimFactoryReset(mActivity, "" /* packageName */);
|
||||||
try {
|
try {
|
||||||
@@ -77,7 +77,7 @@ public class ResetNetworkConfirmTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Assert.assertNotNull(mResetNetworkConfirm.mEraseEsimTask);
|
Assert.assertNotNull(mResetNetworkConfirm.mEraseEsimTask);
|
||||||
verify(mRecoverySystem).wipeEuiccData(any(Context.class), anyBoolean(), anyString());
|
verify(mRecoverySystem).wipeEuiccData(any(Context.class), anyString());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -88,6 +88,6 @@ public class ResetNetworkConfirmTest {
|
|||||||
|
|
||||||
Assert.assertNull(mResetNetworkConfirm.mEraseEsimTask);
|
Assert.assertNull(mResetNetworkConfirm.mEraseEsimTask);
|
||||||
verify(mRecoverySystem, never())
|
verify(mRecoverySystem, never())
|
||||||
.wipeEuiccData(any(Context.class), anyBoolean(), anyString());
|
.wipeEuiccData(any(Context.class), anyString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user