android FactoryReset
16lz
2021-01-23
阅读更多
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() { 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(); }}
更多相关文章
- Android ListView列表 刷新和加载更多
- Jquery点击加载更多
- 《锋利的jQuery》读书笔记 第5章 jQuery对表单、表格的操作及更
- 关于jQuery Themeroller主题,我在哪里可以找到更多?
- DataTables警告:table id = DataTables_Table_0 - Ajax错误。有
- 总结一些更多的针对webkit的HTML, CSS和Javascript方面的特性.
- Joomla 3.x“错误检出失败,出现以下错误:”没有更多信息
- 如何使用jQuery将输入值插入更多填充的字段?
- 隐藏加载更多记录按钮ASP.net MVC Ajax Javascript