Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit f9993a7b authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Add EXTRA_WIPE_ESIMS for factory reset of eSIM"

parents c8e59872 240c2bb6
Loading
Loading
Loading
Loading
+12 −1
Original line number Diff line number Diff line
@@ -4761,9 +4761,20 @@ 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.
+19 −9
Original line number Diff line number Diff line
@@ -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");
            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;
        }