这个问题可能是重复的,但我已经完成了所有的答案,并注意到他们不再工作了。
private static boolean checkRootMethod1() {
String buildTags = android.os.Build.TAGS;
return buildTags != null && buildTags.contains("test-keys");
}
方法1失败
private static boolean checkRootMethod2() {
String[] paths = { "/system/app/Superuser.apk", "/sbin/su", "/system/bin/su", "/system/xbin/su", "/data/local/xbin/su", "/data/local/bin/su", "/system/sd/xbin/su",
"/system/bin/failsafe/su", "/data/local/su" };
for (String path : paths) {
if (new File(path).exists()) return true;
}
return false;
}
方法2也失败了因为" SuperSu"它不再是系统应用程序,它可以卸载,su文件现在出现在单独的文件夹SU / bin / su
上private static boolean checkRootMethod3() {
Process process = null;
try {
process = Runtime.getRuntime().exec(new String[] { "/system/xbin/which", "su" });
BufferedReader in = new BufferedReader(new InputStreamReader(process.getInputStream()));
if (in.readLine() != null) return true;
return false;
} catch (Throwable t) {
return false;
} finally {
if (process != null) process.destroy();
}
}
方法3也失败了,因为没有"哪个"现在在Android设备上的文件
RootTools.isavailable();
也失败了
我的问题是我可以通过检查su文件是否在Su / bin / su文件夹中来检测设备吗?这是检测root设备的正确方法吗?
答案 0 :(得分:1)