代码无弹窗判断设备是否root
2016-09-26 17:51
246 查看
public class RootUtil { private final static String TAG = "RootUtil"; /** 判断手机是否root,不弹出root请求框<br/> */ public static boolean isRoot() { String binPath = "/system/bin/su"; String xBinPath = "/system/xbin/su"; if (new File(binPath).exists() && isExecutable(binPath)) return true; if (new File(xBinPath).exists() && isExecutable(xBinPath)) return true; return false; } private static boolean isExecutable(String filePath) { Process p = null; try { p = Runtime.getRuntime().exec("ls -l " + filePath); // 获取返回内容 BufferedReader in = new BufferedReader(new InputStreamReader( p.getInputStream())); String str = in.readLine(); Log.i(TAG, str); 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(p!=null){ p.destroy(); } } return false; } }
相关文章推荐
- iOS设备是否越狱的判断代码
- Android 判断设备是否Root
- 判断手机是否ROOT 代码实现+ Android 操作系统 获取Root权限 原理解析
- JS判断来路是否是百度等搜索索引进行弹窗或自动跳转的实现代码
- 【Android】Android 代码判断当前设备是否为模拟器
- JS判断设备是否是移动端自动跳转到对应页面的简单代码
- 判断android设备是否root
- iOS 设备是否越狱的判断代码
- 判断设备是否越狱代码
- iOS设备是否越狱的判断代码
- iOS设备是否越狱的判断代码
- iOS设备是否越狱的判断代码
- 判断用户设备是否是 iPhone 4 Retina 屏的代码
- iOS设备是否越狱的判断代码
- 判断用户设备是否是 iPhone 4 Retina 屏的代码
- 判断android设备(如手机)是否已经ROOT的方法
- Android代码判断当前设备是否为模拟器
- android判断设备是否有相机的实例代码
- js判断设备是否是移动端代码
- 判断是否移动端设备的JS代码