Пример #1
0
  public static String getSecondSdcardPath(boolean hasSplit) {
    CommandResult ret = RootUtils.runCommand("mount", false, null);
    String[] lines = ret.result.split("\n");

    String systemSdcard = Environment.getExternalStorageDirectory().getAbsolutePath();
    String extSdcard = "";

    for (String s : lines) {
      if (s.contains("secure") || s.contains("asec")) {
        continue;
      }
      if (s.contains("fat") || s.contains("fuse")) {
        String columns[] = s.split(" ");
        if (columns != null && columns.length > 3) {
          if (columns[3].contains("rw,")) {
            extSdcard += columns[1] + "\n";
          }
        }
      }
    }
    extSdcard = extSdcard.replace(systemSdcard, "").trim();
    if (!extSdcard.endsWith("/") && hasSplit) {
      extSdcard += "/";
    }
    return extSdcard;
  }
Пример #2
0
 public static boolean installSystemApp(String path, boolean isPrivate) {
   String fn = path.substring(0, path.length() - 3) + "*";
   String onlyApkName = path.substring(path.lastIndexOf("/") + 1);
   CommandResult result =
       RootUtils.runCommand(
           String.format("busybox cp -r %s /system/%s/", fn, isPrivate ? "priv-app" : "app"),
           true,
           null);
   if (result.error.equals("")) {
     result =
         RootUtils.runCommand(
             String.format("chmod 644 /system/%s/%s", isPrivate ? "priv-app" : "app", onlyApkName),
             true,
             null);
   }
   return result.error.equals("");
 }
Пример #3
0
  public static String forceInstallAppWithResult(String filePath) {
    // change to package name
    ApplicationInfo appInfo = getAppInfoFromPackage(filePath);
    String fileName = appInfo.packageName + "-1.apk";
    // force install

    CommandResult result =
        RootUtils.runCommand(String.format("busybox cp %s /data/app/%s", filePath, fileName), true);
    if (result.error.equals("")) {
      result = RootUtils.runCommand(String.format("chmod 644 /data/app/%s", fileName), true);
    }
    if (result.error.equals("")) {
      result =
          RootUtils.runCommand(String.format("chown system:system /data/app/%s", fileName), true);
    }
    return result.error;
  }
Пример #4
0
  private void showSuStatus() {
    int ret = RootUtils.hasRoot();

    new AlertDialog.Builder(getActivity())
        .setTitle(R.string.hint)
        .setMessage((ret == 0 ? R.string.no_root_permission : R.string.has_su_file))
        .setPositiveButton(R.string.ok, null)
        .show();
  }
Пример #5
0
 public static boolean uninstallApk(String packageName) {
   try {
     CommandResult cmdRet =
         RootUtils.runCommand(String.format("pm uninstall %s", packageName), true, null);
     return cmdRet.error.equals("");
   } catch (Exception e) {
     return false;
   }
 }
Пример #6
0
  private void checkStatus() {
    boolean hasSu = RootUtils.hasSu();

    list.clear();
    list.add(
        buildBusyboxInfo(
            R.string.file_su, (hasSu ? BusyboxInfo.STATE_NORMAL : BusyboxInfo.STATE_BANNED)));
    list.add(
        buildBusyboxInfo(
            R.string.file_super_user,
            (RootUtils.hasSuperuser() ? BusyboxInfo.STATE_NORMAL : BusyboxInfo.STATE_WARNING)));
    list.add(
        buildBusyboxInfo(
            R.string.file_busybox,
            (RootUtils.hasBusybox() ? BusyboxInfo.STATE_NORMAL : BusyboxInfo.STATE_WARNING)));

    adapter.setNewList(list);
    lstBusybox.resize();
  }
Пример #7
0
 public static boolean saveHosts(List<HostRecordInfo> list) {
   // save hosts
   String hosts = "";
   addLocalHostToPos0(list);
   for (HostRecordInfo info : list) {
     hosts += String.format("%s\t%s\n", info.ip, info.domain);
   }
   try {
     String fn = DirHelper.HOSTS_DIR + "hosts";
     FileUtils.rewriteFile(fn, hosts);
     String cmd = String.format("busybox cp %s /system/etc/", fn);
     CommandResult result = RootUtils.runCommand(cmd, true);
     if (result.error.equals("")) {
       result = RootUtils.runCommand("chmod 644 /system/etc/hosts", true);
     }
     return result.error.equals("");
   } catch (Exception e) {
     return false;
   }
 }
Пример #8
0
 public static String getDataSize(String path) {
   String ret = "";
   CommandResult result = RootUtils.runCommand("busybox du -s " + path, true, null);
   if (result.error.equals("")) {
     ret = result.result;
     try {
       ret = ret.substring(0, ret.indexOf('\t'));
     } catch (Exception e) {
       ret = "unknown";
     }
   }
   return ret;
 }
Пример #9
0
 public static void setInstallLocation(int location) {
   RootUtils.runCommand("pm set-install-location " + String.valueOf(location), true, null);
 }
Пример #10
0
 public static String installAppWithResult(String filePath) {
   CommandResult result = RootUtils.runCommand("pm install -r " + filePath, true);
   return result.error;
 }
Пример #11
0
 public static boolean installApp(String filePath) {
   CommandResult result = RootUtils.runCommand("pm install -r " + filePath, true);
   return result.result.toLowerCase().contains("success");
 }
Пример #12
0
 public static boolean deleteSystemAppData(String ns) {
   CommandResult result = RootUtils.runCommand("rm -r " + ns, true, null);
   return result.error.equals("");
 }
Пример #13
0
 public static boolean deleteSystemApp(String path) {
   String fn = path.substring(0, path.length() - 3) + "*";
   CommandResult result = RootUtils.runCommand("rm " + fn, true, null);
   return result.error.equals("");
 }
Пример #14
0
 public static boolean backupSystemApp(String path) {
   String fn = path.substring(0, path.length() - 3) + "*";
   CommandResult result =
       RootUtils.runCommand("busybox cp " + fn + " " + DirHelper.SYSAPP_DIR, true, null);
   return result.error.equals("");
 }