private static final String[] rootRelatedDirs = new String[]{
"/su", "/su/bin/su", "/sbin/su",
"/data/local/xbin/su", "/data/local/bin/su", "/data/local/su",
"/system/xbin/su",
"/system/bin/su", "/system/sd/xbin/su", "/system/bin/failsafe/su",
"/system/bin/cufsdosck", "/system/xbin/cufsdosck", "/system/bin/cufsmgr",
"/system/xbin/cufsmgr", "/system/bin/cufaevdd", "/system/xbin/cufaevdd",
"/system/bin/conbb", "/system/xbin/conbb"};
public static boolean hasRootPrivilege() {
boolean hasRootDir = false;
String[] rootDirs;
int dirCount = (rootDirs = rootRelatedDirs).length;
for (int i = 0; i < dirCount; ++i) {
String dir = rootDirs[i];
if ((new File(dir)).exists()) {
hasRootDir = true;
break;
}
}
return Build.TAGS != null && Build.TAGS.contains("test-keys") || hasRootDir;
}
网友评论