/** * 进入linux cmd执行命令 * * @param command * @return */ private boolean runRootCommand(String command) { Process process = null; DataOutputStream os = null; try { // Runtime.getRuntime().exec("su"); process = Runtime.getRuntime().exec("sh"); os = new DataOutputStream(process.getOutputStream()); os.writeBytes(command + "\n"); os.writeBytes("exit\n"); os.flush(); process.waitFor(); // Log.i(TAG, "root ok ..."); } catch (Exception e) { // Log.d(TAG, "su root - the device is not rooted, error message : " + e.getMessage()); return false; } finally { try { if (null != os) { os.close(); } if (null != process) { process.destroy(); } } catch (Exception e) { e.printStackTrace(); } } return true; }