Reputation: 151
I would like to know if there is any way to block the installation of an android app, at installation time. I know there are ways to obstruct the execution like the methods listed below, but I would like to know if it is possible to apply some control in the installation phase of the app.
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 = new ProcessBuilder("/system/xbin/which", "su").start();
BufferedReader in = new BufferedReader(new
InputStreamReader(process.getInputStream()));
return in.readLine() != null; }
catch (Throwable t) { return false; }
finally { if (process != null) process.destroy(); } }
Upvotes: 0
Views: 333
Reputation: 8851
Execute this method and check the status code
Runtime.getRuntime().exec("su");
If it returns a process object , then you will know the device is rooted and if it does not , you can let the user use the app.
Upvotes: 1