List of utility methods to do Shell Run
int | runSuCommand(Context context, String command) run Su Command return runSuCommandAsync(context, command).waitFor();
|
Process | runSuCommandAsync(Context context, String command) run Su Command Async DataOutputStream fout = new DataOutputStream( context.openFileOutput(SCRIPT_NAME, 0)); fout.writeBytes(command); fout.close(); String[] args = new String[] { "su", "-c", ". " + context.getFilesDir().getAbsolutePath() + "/" ... |
int | runSuCommandNoScriptWrapper(Context context, String command) run Su Command No Script Wrapper String[] args = new String[] { "su", "-c", command }; Process proc = Runtime.getRuntime().exec(args); return proc.waitFor(); |
String | getRoot(String loc) get Root if (loc.startsWith("/mnt/sdcard")) { return "/mnt/sdcard"; } else if (loc.startsWith("/mnt/innerDisk")) { return "/mnt/innerDisk"; } else { return "/mnt/usbDisk1"; |
boolean | requestRootPermission(String path) request Root Permission Process process = null; DataOutputStream dos = null; try { process = Runtime.getRuntime().exec("su"); if (process == null) { return false; OutputStream os = process.getOutputStream(); ... |
void | KillProcess() Kill Process android.os.Process.killProcess(android.os.Process.myPid()); |