Skip to content

Commit 3a21fc3

Browse files
authored
Merge pull request Blankj#64 from jp1017/patch-3
see 10/19 log
2 parents c77303d + 7d604a3 commit 3a21fc3

1 file changed

Lines changed: 18 additions & 1 deletion

File tree

utilcode/src/main/java/com/blankj/utilcode/utils/DeviceUtils.java

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,23 @@ public class DeviceUtils {
2323
private DeviceUtils() {
2424
throw new UnsupportedOperationException("u can't instantiate me...");
2525
}
26+
27+
/**
28+
* 判断设备是否 root
29+
* @return the boolean
30+
*/
31+
public static boolean isDeviceRooted() {
32+
String su = "su";
33+
String[] locations = {"/sbin/", "/system/bin/", "/system/xbin/", "/system/sd/xbin/", "/system/bin/failsafe/",
34+
"/data/local/xbin/", "/data/local/bin/", "/data/local/"};
35+
for (String location: locations) {
36+
if (new File(location + su).exists()) {
37+
return true;
38+
}
39+
}
40+
41+
return false;
42+
}
2643

2744
/**
2845
* 判断设备是否root
@@ -119,4 +136,4 @@ public static String getModel() {
119136
}
120137
return model;
121138
}
122-
}
139+
}

0 commit comments

Comments
 (0)