Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- * this method run any terminal command
- * @param command
- * @return
- */
- public static String runProcessCommand(String command) {
- try {
- Timber.tag(TAG_APK_UTILS).i("runProcessCommand [command: %s]", "su -c " + command);
- String commands[] = { "su", "-c", command};
- // Process process1 = Runtime.getRuntime().exec(commands);
- Process process = Runtime.getRuntime().exec("su");
- DataOutputStream os = new DataOutputStream(process.getOutputStream());
- os.writeBytes(command);
- os.flush();
- os.writeBytes("exit\n");
- os.flush();
- process.waitFor();
- return getResultFromProcess(process);
- } catch (IOException e) {
- Timber.tag(TAG_APK_UTILS).e(e,"runProcessCommand >> IOException");
- e.printStackTrace();
- } catch (InterruptedException e) {
- Timber.tag(TAG_APK_UTILS).e(e,"runProcessCommand >> InterruptedException");
- e.printStackTrace();
- }
- //Some problem happened to execute update apk
- return null;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement