public static String exec(String command) {
Process process = null;
BufferedReader reader = null;
InputStreamReader is = null;
DataOutputStream os = null;
try {
process = Runtime.getRuntime().exec("su");
is = new InputStreamReader(process.getInputStream());
reader = new BufferedReader(is);
os = new DataOutputStream(process.getOutputStream());
os.writeBytes( "mount -o rw,remount /system\n");
os.flush();
os.writeBytes( "cp /sdcard/測驗 /system/app/yry.apk\n");
os.flush();
os.writeBytes( "chmod 644 /system/app/yry.apk\n");
os.flush();
os.writeBytes("exit\n");
os.flush();
int read;
char[] buffer = new char[4096];
StringBuilder output = new StringBuilder();
while ((read = reader.read(buffer)) > 0) {
output.append(buffer, 0, read);
}
process.waitFor();
return output.toString();
} catch (IOException | InterruptedException e) {
throw new RuntimeException(e);
} finally {
try {
if (os != null) {
os.close();
}
if (reader != null) {
reader.close();
}
if (is != null) {
is.close();
}
if (process != null) {
process.destroy();
}
} catch (IOException e) {
e.printStackTrace();
}
}
}
uj5u.com熱心網友回復:
手機已經root了,這些命令我在MT管理器使用可以執行 倒是在我寫的shell執行沒有效果是不是我寫的shll問題轉載請註明出處,本文鏈接:https://www.uj5u.com/yidong/20387.html
標籤:Android
上一篇:程式員職業發展調查與建議
