Merge "Update factory reset dialog to new UX spec" into main

This commit is contained in:
Chip Fukuhara
2023-07-18 20:25:24 +00:00
committed by Android (Google) Code Review
2 changed files with 26 additions and 7 deletions

View File

@@ -6545,6 +6545,14 @@ public class Intent implements Parcelable, Cloneable {
@SystemApi
public static final String EXTRA_REASON = "android.intent.extra.REASON";
/**
* Intent extra: Whether to show the wipe progress UI or to skip it.
*
* <p>Type: boolean
* @hide
*/
public static final String EXTRA_SHOW_WIPE_PROGRESS = "android.intent.extra.SHOW_WIPE_PROGRESS";
/**
* {@hide}
* This extra will be send together with {@link #ACTION_FACTORY_RESET}

View File

@@ -49,6 +49,7 @@ public class MasterClearReceiver extends BroadcastReceiver {
private static final String TAG = "MasterClear";
private boolean mWipeExternalStorage;
private boolean mWipeEsims;
private boolean mShowWipeProgress = true;
@Override
public void onReceive(final Context context, final Intent intent) {
@@ -77,8 +78,12 @@ public class MasterClearReceiver extends BroadcastReceiver {
return;
}
final boolean shutdown = intent.getBooleanExtra("shutdown", false);
final String reason = intent.getStringExtra(Intent.EXTRA_REASON);
// Factory reset dialog has its own UI for the reset process, so suppress ours if indicated.
mShowWipeProgress = intent.getBooleanExtra(Intent.EXTRA_SHOW_WIPE_PROGRESS, true);
final boolean shutdown = intent.getBooleanExtra("shutdown", false);
mWipeExternalStorage = intent.getBooleanExtra(Intent.EXTRA_WIPE_EXTERNAL_STORAGE, false);
mWipeEsims = intent.getBooleanExtra(Intent.EXTRA_WIPE_ESIMS, false);
final boolean forceWipe = intent.getBooleanExtra(Intent.EXTRA_FORCE_MASTER_CLEAR, false)
@@ -190,15 +195,19 @@ public class MasterClearReceiver extends BroadcastReceiver {
public WipeDataTask(Context context, Thread chainedTask) {
mContext = context;
mChainedTask = chainedTask;
mProgressDialog = new ProgressDialog(context, R.style.Theme_DeviceDefault_System);
mProgressDialog = mShowWipeProgress
? new ProgressDialog(context, R.style.Theme_DeviceDefault_System)
: null;
}
@Override
protected void onPreExecute() {
mProgressDialog.setIndeterminate(true);
mProgressDialog.getWindow().setType(WindowManager.LayoutParams.TYPE_SYSTEM_ALERT);
mProgressDialog.setMessage(mContext.getText(R.string.progress_erasing));
mProgressDialog.show();
if (mProgressDialog != null) {
mProgressDialog.setIndeterminate(true);
mProgressDialog.getWindow().setType(WindowManager.LayoutParams.TYPE_SYSTEM_ALERT);
mProgressDialog.setMessage(mContext.getText(R.string.progress_erasing));
mProgressDialog.show();
}
}
@Override
@@ -214,7 +223,9 @@ public class MasterClearReceiver extends BroadcastReceiver {
@Override
protected void onPostExecute(Void result) {
mProgressDialog.dismiss();
if (mProgressDialog != null && mProgressDialog.isShowing()) {
mProgressDialog.dismiss();
}
mChainedTask.start();
}