/**
* 判断手机是否ROOT
*/
public static boolean isRoot() {
boolean root = false;
try {
if ((!new File("/system/bin/su").exists()) && (!new File("/system/xbin/su").exists())) {
root = false;
} else {
root = true;
}
} catch (Exception e) {
}
return root;
}
/**
* 应用程序运行命令获取 Root权限,设备必须已破解(获得ROOT权限)
* @param command 命令: String apkRoot="chmod 777 "+getPackageCodePath();
* RootCommand(apkRoot);
* @return 应用程序是/否获取Root权限
*/
public static boolean RootCommand(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 ***", "ROOT REE" + e.getMessage());
return false;
} finally {
try {
if (os != null) {
os.close();
}
process.destroy();
} catch (Exception e) {
}
}
return true;
}
手机root权限
最新推荐文章于 2024-04-13 09:24:34 发布