80,362
社区成员
发帖
与我相关
我的任务
分享
// execute cmd
protected static Vector<String> execRootCmd(String paramString)
{
Vector<String> localVector = new Vector<String>();
DataInputStream dis = null;
Runtime r = Runtime.getRuntime();
try
{
r.exec("su"); // get root
StringBuilder sb = new StringBuilder();
Process p = r.exec(paramString);
InputStream input = p.getInputStream();
dis = new DataInputStream(input);
String content = null;
while ((content = dis.readLine()) != null)
{
sb.append(content).append("\n");
}
// r.exec("exit");
Log.i("UERY", "sb = " + sb.toString());
localVector.add(sb.toString());
}
catch (IOException e)
{
e.printStackTrace();
}
finally
{
if (dis != null)
{
try
{
dis.close();
}
catch (IOException e)
{
e.printStackTrace();
}
}
}
return localVector;
}