获取root 权限
2011-11-04 18:37
267 查看
public static boolean runRootCommand(String command) {
Process process = null;
DataOutputStream os = null;
try {
process = Runtime.getRuntime().exec("su");
os = new DataOutputStream(process.getOutputStream());
os.writeBytes(command+"\n");
os.writeBytes("exit\n");
os.flush();
process.waitFor();
} catch (Exception e) {
Log.d("*** DEBUG ***", "Unexpected error - Here is what I know: "+e.getMessage());
return false;
}
finally {
try {
if (os != null) {
os.close();
}
process.destroy();
} catch (Exception e) {
// nothing
}
}
return true;
}
}
Process process = null;
DataOutputStream os = null;
try {
process = Runtime.getRuntime().exec("su");
os = new DataOutputStream(process.getOutputStream());
os.writeBytes(command+"\n");
os.writeBytes("exit\n");
os.flush();
process.waitFor();
} catch (Exception e) {
Log.d("*** DEBUG ***", "Unexpected error - Here is what I know: "+e.getMessage());
return false;
}
finally {
try {
if (os != null) {
os.close();
}
process.destroy();
} catch (Exception e) {
// nothing
}
}
return true;
}
}
相关文章推荐
- 默认 redis 安装存在漏洞, 可以直接 获取 root 权限
- 获取 Android 4.2 的 ROOT 权限(越狱)
- 获取手机权限,如果已经root了
- ubuntu 终端下获取root。。。权限问题与配置JDK
- 获取 Android 模拟器root 权限(解决data权限问题)
- linux2.6内核本地提权,低权限获取root
- 小米手机通过安卓开发包来获取ROOT 权限教程
- Android手机root权限的判断与获取
- 手机root教程,获取手机root权限,roo卸载,适用于各安卓机型
- ubantu系统获取root 权限 且 修改文件内容的方法
- android app 获取root 权限
- Ubuntu 16.04 获取 root 用户权限并以 root权限登录
- 获取MAC系统root权限
- 获取 Android 4.2 的 ROOT 权限
- Android编程获取手机root权限
- ubuntu下如何打开root文件夹,如何用root权限管理员权限打开文件夹,以及如何获取root权限
- 如何获取android root 启动权限
- 一个获取Android手机root权限的程序
- Ubuntu 获取 root 权限 (临时&永久)
- Linux下用户获取root权限执行程序