Android 判断手机是否root
2017-11-15 12:08
288 查看
//判断手机是否root
public static boolean isRoot() {
String binPath = "/system/bin/su";
String xBinPath = "/system/xbin/su";
if (new File(binPath).exists() && isCanExecute(binPath)) {
return true;
}
if (new File(xBinPath).exists() && isCanExecute(xBinPath)) {
return true;
}
return false;
}
private static boolean isCanExecute(String filePath) {
java.lang.Process process = null;
try {
process = Runtime.getRuntime().exec("ls -l " + filePath);
BufferedReader in = new BufferedReader(new InputStreamReader(process.getInputStream()));
String str = in.readLine();
if (str != null && str.length() >= 4) {
char flag = str.charAt(3);
if (flag == 's' || flag == 'x')
return true;
}
} catch (IOException e) {
e.printStackTrace();
} finally {
if (process != null) {
process.destroy();
}
}
return false;
}
public static boolean isRoot() {
String binPath = "/system/bin/su";
String xBinPath = "/system/xbin/su";
if (new File(binPath).exists() && isCanExecute(binPath)) {
return true;
}
if (new File(xBinPath).exists() && isCanExecute(xBinPath)) {
return true;
}
return false;
}
private static boolean isCanExecute(String filePath) {
java.lang.Process process = null;
try {
process = Runtime.getRuntime().exec("ls -l " + filePath);
BufferedReader in = new BufferedReader(new InputStreamReader(process.getInputStream()));
String str = in.readLine();
if (str != null && str.length() >= 4) {
char flag = str.charAt(3);
if (flag == 's' || flag == 'x')
return true;
}
} catch (IOException e) {
e.printStackTrace();
} finally {
if (process != null) {
process.destroy();
}
}
return false;
}
相关文章推荐
- android判断手机是否root
- Android中判断手机是否已经Root
- 判断android手机是否root过。
- Android 判断手机是否root
- android判断手机是否root
- 判断手机是否ROOT 代码实现+ Android 操作系统 获取Root权限 原理解析
- android 判断手机是否Root
- Android中判断手机是否已经Root
- Android 判断手机是否已经ROOT
- android通过代码判断手机是否root
- Android 一:通过adb命令判断手机是否被root过
- Android代码判断手机是否已root
- 判断android设备(如手机)是否已经ROOT的方法
- android端判断手机是否有网,并且无网时跳转到设置界面
- android 判断 手机号码、邮编、Email邮箱、是否正确
- Android 判断是否为手机号码的方法
- android-判断手机是否支持相机,有几个摄像头?
- JS判断客户端是否是iOS或者Android手机移动端
- Android(判断wifi是否开启,手机屏幕状态,sdcard是否被拔出,设置全屏)
- Android检查手机是否被root