Throw up ProgressDialog when erasing PST partition
This needs to be done here, but we should let the user know we're doing work. Bug: 17185720 Change-Id: I0d71ae38145e0649a430a8231b7e3f250c003ee8
This commit is contained in:
@@ -2493,6 +2493,10 @@
|
||||
<string name="master_clear_confirm_title">Reset?</string>
|
||||
<!-- Error message for users that aren't allowed to factory reset [CHAR LIMIT=none] -->
|
||||
<string name="master_clear_not_available">Factory reset is not available for this user</string>
|
||||
<!-- Master clear progress screen title [CHAR LIMIT=30] -->
|
||||
<string name="master_clear_progress_title" >Erasing</string>
|
||||
<!-- Master clear progress screen text [CHAR LIMIT=75] -->
|
||||
<string name="master_clear_progress_text">Please wait...</string>
|
||||
|
||||
<!-- Media Format -->
|
||||
<!-- SD card & phone storage settings screen, setting option name under Internal phone storage heading [CHAR LIMIT=25] -->
|
||||
|
@@ -16,22 +16,21 @@
|
||||
|
||||
package com.android.settings;
|
||||
|
||||
import android.app.ProgressDialog;
|
||||
import android.content.Context;
|
||||
import android.content.pm.ActivityInfo;
|
||||
import android.os.AsyncTask;
|
||||
import android.service.persistentdata.PersistentDataBlockManager;
|
||||
import com.android.internal.os.storage.ExternalStorageFormatter;
|
||||
import com.android.internal.widget.LockPatternUtils;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.app.Fragment;
|
||||
import android.content.Intent;
|
||||
import android.content.res.Resources;
|
||||
import android.os.Bundle;
|
||||
import android.os.UserManager;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.Button;
|
||||
import android.widget.CheckBox;
|
||||
|
||||
/**
|
||||
* Confirm and execute a reset of the device to a clean "just out of the box"
|
||||
@@ -47,7 +46,6 @@ public class MasterClearConfirm extends Fragment {
|
||||
|
||||
private View mContentView;
|
||||
private boolean mEraseSdCard;
|
||||
private Button mFinalButton;
|
||||
|
||||
/**
|
||||
* The user has gone through the multiple confirmation, so now we go ahead
|
||||
@@ -61,16 +59,52 @@ public class MasterClearConfirm extends Fragment {
|
||||
return;
|
||||
}
|
||||
|
||||
PersistentDataBlockManager pdbManager = (PersistentDataBlockManager)
|
||||
final PersistentDataBlockManager pdbManager = (PersistentDataBlockManager)
|
||||
getActivity().getSystemService(Context.PERSISTENT_DATA_BLOCK_SERVICE);
|
||||
|
||||
if (pdbManager != null) {
|
||||
// if OEM unlock is enabled, this will be wiped during FR process.
|
||||
if (!pdbManager.getOemUnlockEnabled()) {
|
||||
final ProgressDialog progressDialog = getProgressDialog();
|
||||
progressDialog.show();
|
||||
|
||||
// need to prevent orientation changes as we're about to go into
|
||||
// a long IO request, so we won't be able to access inflate resources on flash
|
||||
final int oldOrientation = getActivity().getRequestedOrientation();
|
||||
getActivity().setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LOCKED);
|
||||
new AsyncTask<Void, Void, Void>() {
|
||||
@Override
|
||||
protected Void doInBackground(Void... params) {
|
||||
pdbManager.wipe();
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onPostExecute(Void aVoid) {
|
||||
progressDialog.hide();
|
||||
getActivity().setRequestedOrientation(oldOrientation);
|
||||
doMasterClear();
|
||||
}
|
||||
}.execute();
|
||||
}
|
||||
} else {
|
||||
doMasterClear();
|
||||
}
|
||||
}
|
||||
|
||||
private ProgressDialog getProgressDialog() {
|
||||
final ProgressDialog progressDialog = new ProgressDialog(getActivity());
|
||||
progressDialog.setIndeterminate(true);
|
||||
progressDialog.setCancelable(false);
|
||||
progressDialog.setTitle(
|
||||
getActivity().getString(R.string.master_clear_progress_title));
|
||||
progressDialog.setMessage(
|
||||
getActivity().getString(R.string.master_clear_progress_text));
|
||||
return progressDialog;
|
||||
}
|
||||
};
|
||||
|
||||
private void doMasterClear() {
|
||||
if (mEraseSdCard) {
|
||||
Intent intent = new Intent(ExternalStorageFormatter.FORMAT_AND_FACTORY_RESET);
|
||||
intent.setComponent(ExternalStorageFormatter.COMPONENT_NAME);
|
||||
@@ -80,14 +114,13 @@ public class MasterClearConfirm extends Fragment {
|
||||
// Intent handling is asynchronous -- assume it will happen soon.
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Configure the UI for the final confirmation interaction
|
||||
*/
|
||||
private void establishFinalConfirmationState() {
|
||||
mFinalButton = (Button) mContentView.findViewById(R.id.execute_master_clear);
|
||||
mFinalButton.setOnClickListener(mFinalClickListener);
|
||||
mContentView.findViewById(R.id.execute_master_clear)
|
||||
.setOnClickListener(mFinalClickListener);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -107,6 +140,6 @@ public class MasterClearConfirm extends Fragment {
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
Bundle args = getArguments();
|
||||
mEraseSdCard = args != null ? args.getBoolean(MasterClear.ERASE_EXTERNAL_EXTRA) : false;
|
||||
mEraseSdCard = args != null && args.getBoolean(MasterClear.ERASE_EXTERNAL_EXTRA);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user