android FactoryReset
private void doMasterClear() { Intent intent = new Intent(Intent.ACTION_FACTORY_RESET); intent.setPackage("android"); intent.addFlags(Intent.FLAG_RECEIVER_FOREGROUND); intent.putExtra(Intent.EXTRA_REASON, "MasterClearConfirm"); intent.putExtra(Intent.EXTRA_WIPE_EXTERNAL_STORAGE, true); intent.putExtra(Intent.EXTRA_WIPE_ESIMS, true); getActivity().sendBroadcast(intent); // Intent handling is asynchronous -- assume it will happen soon. } 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 test(){ if (Utils.isMonkeyRunning()) { return; } final PersistentDataBlockManager pdbManager = (PersistentDataBlockManager) getActivity().getSystemService(Context.PERSISTENT_DATA_BLOCK_SERVICE); final OemLockManager oemLockManager = (OemLockManager) getActivity().getSystemService(Context.OEM_LOCK_SERVICE); if (pdbManager != null && !oemLockManager.isOemUnlockAllowed() && Utils.isDeviceProvisioned(getActivity())) { // if OEM unlock is allowed, the persistent data block will be wiped during FR // process. If disabled, it will be wiped here, unless the device is still being // provisioned, in which case the persistent data block will be preserved. new AsyncTask<Void, Void, Void>() { int mOldOrientation; ProgressDialog mProgressDialog; @Override protected Void doInBackground(Void... params) { pdbManager.wipe(); return null; } @Override protected void onPostExecute(Void aVoid) { mProgressDialog.hide(); if (getActivity() != null) { 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(); } }
相关推荐
huha 2020-10-16
xfcyhades 2020-11-20
sgafdsg 2020-11-04
Michael 2020-11-03
fengyeezju 2020-10-14
ziyexiaoxiao 2020-10-14
业余架构师 2020-10-09
OuNuo0 2020-09-29
moses 2020-09-22
Angelia 2020-09-11
qinxu 2020-09-10
刘炳昭 2020-09-10
Nostalgiachild 2020-09-07
Nostalgiachild 2020-08-17
leavesC 2020-08-14
一青年 2020-08-13
AndroidAiStudy 2020-08-07
ydc0 2020-07-30
绿豆饼 2020-07-28