diff options
author | Andres Morales <anmorales@google.com> | 2015-06-01 16:23:41 -0700 |
---|---|---|
committer | Andres Morales <anmorales@google.com> | 2015-06-01 16:23:41 -0700 |
commit | c17ec1be19a45dec12d601f1e6a545f558bdf293 (patch) | |
tree | a490036365c501cf74606781d3e120ed2fc343f9 /src/com/android/settings/MasterClearConfirm.java | |
parent | 47ed6ca004dcfe9498269602b109b1e667fae287 (diff) | |
download | packages_apps_Settings-c17ec1be19a45dec12d601f1e6a545f558bdf293.zip packages_apps_Settings-c17ec1be19a45dec12d601f1e6a545f558bdf293.tar.gz packages_apps_Settings-c17ec1be19a45dec12d601f1e6a545f558bdf293.tar.bz2 |
[MasterClear] fix race in showing dialog
Wiping the PDB effectively starves all other threads from
accessing flash, and freezes the UI. We throw up a dialog
but there's a race between drawing the dialog and starting the
wipe.
Show the dialog in onPreExecute to fix this.
Bug: 20854355
Change-Id: I8462f5ed3ff53ed574ebc1be416a821c2086b4f5
Diffstat (limited to 'src/com/android/settings/MasterClearConfirm.java')
-rw-r--r-- | src/com/android/settings/MasterClearConfirm.java | 28 |
1 files changed, 18 insertions, 10 deletions
diff --git a/src/com/android/settings/MasterClearConfirm.java b/src/com/android/settings/MasterClearConfirm.java index bc3656a..31f1bcc 100644 --- a/src/com/android/settings/MasterClearConfirm.java +++ b/src/com/android/settings/MasterClearConfirm.java @@ -65,14 +65,10 @@ public class MasterClearConfirm extends InstrumentedFragment { if (pdbManager != null && !pdbManager.getOemUnlockEnabled()) { // if OEM unlock is enabled, this will be wiped during FR process. - 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>() { + int mOldOrientation; + ProgressDialog mProgressDialog; + @Override protected Void doInBackground(Void... params) { pdbManager.wipe(); @@ -81,10 +77,21 @@ public class MasterClearConfirm extends InstrumentedFragment { @Override protected void onPostExecute(Void aVoid) { - progressDialog.hide(); - getActivity().setRequestedOrientation(oldOrientation); + mProgressDialog.hide(); + getActivity().setRequestedOrientation(mOldOrientation); doMasterClear(); } + + @Override + protected void onPreExecute() { + mProgressDialog = getProgressDialog(); + mProgressDialog.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 + mOldOrientation = getActivity().getRequestedOrientation(); + getActivity().setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LOCKED); + } }.execute(); } else { doMasterClear(); @@ -143,7 +150,8 @@ public class MasterClearConfirm extends InstrumentedFragment { super.onCreate(savedInstanceState); Bundle args = getArguments(); - mEraseSdCard = args != null && args.getBoolean(MasterClear.ERASE_EXTERNAL_EXTRA); + mEraseSdCard = args != null + && args.getBoolean(MasterClear.ERASE_EXTERNAL_EXTRA); } @Override |