Last active
March 4, 2018 08:39
-
-
Save rajsuvariya/881c6aff0f9502f2a662d2ae97aae1c0 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private static boolean checkRootMethod1() { | |
String buildTags = android.os.Build.TAGS; | |
return buildTags != null && buildTags.contains("test-keys"); | |
} | |
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", "/su/bin/su"}; | |
for (String path : paths) { | |
if (new File(path).exists()) return true; | |
} | |
return false; | |
} | |
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(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment