我的目标是清除 RAM..为此我的想法是重新启动手机..我得到了这个代码来做到这一点..
public static void rebootSU()
{
Runtime runtime = Runtime.getRuntime();
Process proc = null;
OutputStreamWriter osw = null;
StringBuilder sbstdOut = new StringBuilder();
StringBuilder sbstdErr = new StringBuilder();
String command="/system/bin/reboot";
try {
// Run Script
proc = runtime.exec("su");
osw = new OutputStreamWriter(proc.getOutputStream());
osw.write(command);
osw.flush();
osw.close();
} catch (IOException ex) {
ex.printStackTrace();
} finally {
if (osw != null) {
try {
osw.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
try {
if (proc != null)
proc.waitFor();
} catch (InterruptedException e) {
e.printStackTrace();
}
//sbstdOut.append(ReadBufferedReader(new InputStreamReader(proc.getInputStream())));
//sbstdErr.append(ReadBufferedReader(new InputStreamReader(proc.getErrorStream())));
if (proc.exitValue() != 0)
{
}
}
当我执行此代码时,logcat 中显示以下警告。我也授予了 REBOOT 权限。当我搜索此内容时,他们告诉我们使用某些固件密钥进行签名等。但我根本不知道这一点。 。任何帮助,将不胜感激。
在日志猫中
04-14 10:37:13.526: WARN/PackageManager(58): Not granting permission android.permission.REBOOT to package com.RebootTest (protectionLevel=3 flags=0x8446)
提出并回答了类似的问题here。在获得固件密钥进行签名之前,您无法重新启动未 root 的手机。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)