Esempio n. 1
0
 public static void write(String file, String text) {
   RootUtils.mount(true, "/system");
   RootFile f = new RootFile(INITD + "/" + file);
   f.write(text, false);
   RootUtils.chmod(INITD + "/" + file, "755");
   RootUtils.mount(false, "/system");
 }
Esempio n. 2
0
 public static List<String> list() {
   RootFile file = new RootFile(INITD);
   if (!file.exists()) {
     RootUtils.mount(true, "/system");
     file.mkdir();
     RootUtils.mount(false, "/system");
   }
   return file.list();
 }
Esempio n. 3
0
 @Override
 public void onDestroy() {
   super.onDestroy();
   RootUtils.mount(false, "/system");
   if (mLoader != null) {
     mLoader.cancel(true);
     mLoader = null;
   }
   mLoaded = false;
 }
  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();
  }
Esempio n. 5
0
 public static String execute(String file) {
   RootUtils.chmod(INITD + "/" + file, "755");
   return RootUtils.runCommand(INITD + "/" + file);
 }
Esempio n. 6
0
 public static void delete(String file) {
   RootUtils.mount(true, "/system");
   RootFile f = new RootFile(INITD + "/" + file);
   f.delete();
   RootUtils.mount(false, "/system");
 }