diff options
-rw-r--r-- | core/java/android/content/Intent.java | 13 | ||||
-rw-r--r-- | services/core/java/com/android/server/MasterClearReceiver.java | 28 |
2 files changed, 31 insertions, 10 deletions
diff --git a/core/java/android/content/Intent.java b/core/java/android/content/Intent.java index a4b5ffd63ae1..a6e6ceb029fa 100644 --- a/core/java/android/content/Intent.java +++ b/core/java/android/content/Intent.java @@ -4761,10 +4761,21 @@ public class Intent implements Parcelable, Cloneable { /** {@hide} */ public static final String EXTRA_REASON = "android.intent.extra.REASON"; - /** {@hide} */ + /** + * {@hide} + * This extra will be send together with {@link #ACTION_FACTORY_RESET} + */ public static final String EXTRA_WIPE_EXTERNAL_STORAGE = "android.intent.extra.WIPE_EXTERNAL_STORAGE"; /** + * {@hide} + * This extra will be set to true when the user choose to wipe the data on eSIM during factory + * reset for the device with eSIM. This extra will be sent together with + * {@link #ACTION_FACTORY_RESET} + */ + public static final String EXTRA_WIPE_ESIMS = "com.android.internal.intent.extra.WIPE_ESIMS"; + + /** * Optional {@link android.app.PendingIntent} extra used to deliver the result of the SIM * activation request. * TODO: Add information about the structure and response data used with the pending intent. diff --git a/services/core/java/com/android/server/MasterClearReceiver.java b/services/core/java/com/android/server/MasterClearReceiver.java index 26e471e4fc95..7080c41fea26 100644 --- a/services/core/java/com/android/server/MasterClearReceiver.java +++ b/services/core/java/com/android/server/MasterClearReceiver.java @@ -23,6 +23,7 @@ import android.content.Intent; import android.os.AsyncTask; import android.os.RecoverySystem; import android.os.storage.StorageManager; +import android.telephony.euicc.EuiccManager; import android.util.Log; import android.util.Slog; import android.view.WindowManager; @@ -33,6 +34,8 @@ import java.io.IOException; public class MasterClearReceiver extends BroadcastReceiver { private static final String TAG = "MasterClear"; + private boolean mWipeExternalStorage; + private boolean mWipeEims; @Override public void onReceive(final Context context, final Intent intent) { @@ -53,8 +56,8 @@ public class MasterClearReceiver extends BroadcastReceiver { final boolean shutdown = intent.getBooleanExtra("shutdown", false); final String reason = intent.getStringExtra(Intent.EXTRA_REASON); - final boolean wipeExternalStorage = intent.getBooleanExtra( - Intent.EXTRA_WIPE_EXTERNAL_STORAGE, false); + mWipeExternalStorage = intent.getBooleanExtra(Intent.EXTRA_WIPE_EXTERNAL_STORAGE, false); + mWipeEims = intent.getBooleanExtra(Intent.EXTRA_WIPE_ESIMS, false); final boolean forceWipe = intent.getBooleanExtra(Intent.EXTRA_FORCE_MASTER_CLEAR, false) || intent.getBooleanExtra(Intent.EXTRA_FORCE_FACTORY_RESET, false); @@ -74,20 +77,20 @@ public class MasterClearReceiver extends BroadcastReceiver { } }; - if (wipeExternalStorage) { + if (mWipeExternalStorage || mWipeEims) { // thr will be started at the end of this task. - new WipeAdoptableDisksTask(context, thr).execute(); + new WipeDataTask(context, thr).execute(); } else { thr.start(); } } - private class WipeAdoptableDisksTask extends AsyncTask<Void, Void, Void> { + private class WipeDataTask extends AsyncTask<Void, Void, Void> { private final Thread mChainedTask; private final Context mContext; private final ProgressDialog mProgressDialog; - public WipeAdoptableDisksTask(Context context, Thread chainedTask) { + public WipeDataTask(Context context, Thread chainedTask) { mContext = context; mChainedTask = chainedTask; mProgressDialog = new ProgressDialog(context); @@ -104,9 +107,16 @@ public class MasterClearReceiver extends BroadcastReceiver { @Override protected Void doInBackground(Void... params) { Slog.w(TAG, "Wiping adoptable disks"); - StorageManager sm = (StorageManager) mContext.getSystemService( - Context.STORAGE_SERVICE); - sm.wipeAdoptableDisks(); + if (mWipeExternalStorage) { + StorageManager sm = (StorageManager) mContext.getSystemService( + Context.STORAGE_SERVICE); + sm.wipeAdoptableDisks(); + } + if (mWipeEims) { + EuiccManager euiccManager = (EuiccManager) mContext.getSystemService( + Context.EUICC_SERVICE); + // STOPSHIP: add EuiccManager API to factory reset eUICC + } return null; } |