Update factory reset dialog to new UX spec
This is part of an upstreaming change for ag/18193725, which is being
split out because of its separate logic from the rest of the UX updates.
The commit message of that CL is copied below for reference.
- This change modifies the system progress spinner
(indeterminate/horizontal) for use on w3.
spec: https://docs.google.com/presentation/d/1YqqNzmgW6C6-zZJdhE3zTvxPe24BBn66FLYalpSgww0/edit#slide=id.gdea00a2fd1_0_169
video: https://drive.google.com/file/d/1hZzk-UBx7DOx5W7282_nB-5nDb5ppDxb/view?usp=sharing&resourcekey=0-eD2vvlCeyYhdF5sG2AwSmQ
Note that UI makes use of system color attributes:
- colorControlNormal (spinner)
- colorProgressBackgroundNormal (track)
Bug: 194441833
Bug: 192470870
Bug: 192470222
Test: manual check
- Settings > System > Disconnect & Reset
- Power > Shutdown
- Power > Restart
Change-Id: I489dce4a54505738654610b6c7c1666ecbc415fc
Upstreaming-Bug: b/272532971
Change-Id: Iad1a30e883a01aad381b6825d3450ab5794d5558
diff --git a/core/java/android/content/Intent.java b/core/java/android/content/Intent.java
index c10062c..fe108a5 100644
--- a/core/java/android/content/Intent.java
+++ b/core/java/android/content/Intent.java
@@ -6546,6 +6546,14 @@
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}
*/
diff --git a/services/core/java/com/android/server/MasterClearReceiver.java b/services/core/java/com/android/server/MasterClearReceiver.java
index 7c3a75f..5a15f17 100644
--- a/services/core/java/com/android/server/MasterClearReceiver.java
+++ b/services/core/java/com/android/server/MasterClearReceiver.java
@@ -49,6 +49,7 @@
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 @@
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 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 @@
@Override
protected void onPostExecute(Void result) {
- mProgressDialog.dismiss();
+ if (mProgressDialog != null && mProgressDialog.isShowing()) {
+ mProgressDialog.dismiss();
+ }
mChainedTask.start();
}