Android判断用户手机是否获取root权限

在市面上的很多APP是不允许用户手机获取root权限后使用的

废话不多说,封装方法如下:
在这里插入图片描述
源码如下

   public static boolean isDeviceRooted() {
        String[] locations = {"/system/bin/", "/system/xbin/", "/sbin/", "/system/sd/xbin/",
                "/system/bin/failsafe/", "/data/local/xbin/", "/data/local/bin/", "/data/local/",
                "/system/sbin/", "/usr/bin/", "/vendor/bin/"};
        for (String location : locations) {
            if (new File(location + "su").exists()) {
                return true;
            }
        }
        return false;
    }
原创文章 83 获赞 434 访问量 29万+

猜你喜欢

转载自blog.csdn.net/qq_42761395/article/details/104503334
今日推荐