Android判断手机是否Root

2022-04-13  本文已影响0人  小相柳
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;
}
上一篇下一篇

猜你喜欢

热点阅读