Android-Collection icon indicating copy to clipboard operation
Android-Collection copied to clipboard

判断手机是否 root

Open jp1017 opened this issue 9 years ago • 0 comments

    /**
     * 判断设备是否 root
     * @return the boolean
     */
    public boolean isDeviceRooted() {
         String su = "su";
         String[] locations = {"/sbin/", "/system/bin/", "/system/xbin/", "/system/sd/xbin/", "/system/bin/failsafe/",
                         "/data/local/xbin/", "/data/local/bin/", "/data/local/"};
         for (String location: locations) {
               if (new File(location + su).exists()) {
                     return true;
               }
         }

         return false;
    }

来源:

https://github.com/nisrulz/easydeviceinfo/pull/2/commits/be804f0da6893e0cdbcfe21299c2a52b3028b5df

jp1017 avatar May 13 '16 02:05 jp1017