public class RootUtil {
public static boolean isDeviceRooted() {
return checkRootMethod1() || checkRootMethod2() || checkRootMethod3() || checkRootMethod4();
}


private static boolean checkRootMethod1() {
String buildTags = android.os.Build.TAGS;
return buildTags != null && buildTags.contains("test-keys");
}


private static boolean checkRootMethod2() {
return new File("/system/app/Superuser.apk").exists();
}


private static boolean checkRootMethod3() {
String[] paths = { "/sbin/su", "/system/bin/su", "/system/xbin/su", "/data/local/xbin/su", "/data/local/bin/su", "/system/sd/xbin/su",
"/system/bin/failsafe/su", "/data/local/su" };
for (String path : paths) {
if (new File(path).exists()) return true;
}
return false;
}


private static boolean checkRootMethod4() {
Process process = null;
try {
process = Runtime.getRuntime().exec(new String[] { "/system/xbin/which", "su" });
BufferedReader in = new BufferedReader(new InputStreamReader(process.getInputStream()));
if (in.readLine() != null) return true;
return false;
} catch (Throwable t) {
return false;
} finally {
if (process != null) process.destroy();
}
}
}

更多相关文章

  1. 代码中设置drawableleft
  2. android 3.0 隐藏 系统标题栏
  3. Android开发中activity切换动画的实现
  4. Android(安卓)学习 笔记_05. 文件下载
  5. Android中直播视频技术探究之—摄像头Camera视频源数据采集解析
  6. 技术博客汇总
  7. android 2.3 wifi (一)
  8. AndRoid Notification的清空和修改
  9. Android中的Chronometer

随机推荐

  1. Android:Picker(DatePicker、TimerPicker、
  2. Android异步处理四:AsyncTask的实现原理
  3. Android(安卓)源码结构
  4. Android可缩放矢量图形(SVG)
  5. Android中的Selector的用法
  6. Android窗口机制(二)Window,PhoneWindow,Deco
  7. Android的IPC机制
  8. [Android]android源码下载&Eclipse关联an
  9. 【android】EditText属性大全
  10. 随笔:Android不爱C++