public static void activateCore(int core, boolean active, Context context) { if (context != null) Control.runCommand( active ? "1" : "0", String.format(CPU_CORE_ONLINE, core), Control.CommandType.GENERIC, context); else RootUtils.runCommand( String.format("echo %s > " + String.format(CPU_CORE_ONLINE, core), active ? "1" : "0")); }
private void backupDialog(final Backup.PARTITION partition_type) { LinearLayout layout = new LinearLayout(getActivity()); layout.setPadding(30, 30, 30, 30); final AppCompatEditText editText = new AppCompatEditText(getActivity()); editText.setTextColor( getResources().getColor(Utils.DARKTHEME ? R.color.textcolor_dark : R.color.black)); editText.setLayoutParams( new LinearLayout.LayoutParams( ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT)); if (partition_type == Backup.PARTITION.BOOT) editText.setText(RootUtils.getKernelVersion()); editText.setHint(getString(R.string.name)); layout.addView(editText); new AlertDialog.Builder(getActivity()) .setView(layout) .setNegativeButton( getString(R.string.cancel), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) {} }) .setPositiveButton( getString(R.string.ok), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { final String name = editText.getText().toString().trim(); if (name.isEmpty()) { Utils.toast(getString(R.string.empty_name), getActivity()); return; } File file = null; switch (partition_type) { case BOOT: file = boot; break; case RECOVERY: file = recovery; break; case FOTA: file = fota; break; } if (file != null && new File(file.toString() + "/" + name + ".img").exists()) { Utils.toast(getString(R.string.backup_already_exists), getActivity()); return; } new AsyncTask<Void, Void, Void>() { private ProgressDialog progressDialog; @Override protected void onPreExecute() { super.onPreExecute(); progressDialog = new ProgressDialog(getActivity()); progressDialog.setMessage(getString(R.string.backing_up)); progressDialog.setCancelable(false); progressDialog.show(); } @Override protected Void doInBackground(Void... params) { Backup.backup(name, partition_type); return null; } @Override protected void onPostExecute(Void aVoid) { super.onPostExecute(aVoid); getHandler() .post( new Runnable() { @Override public void run() { create(); progressDialog.dismiss(); } }); } }.execute(); } }) .show(); }