123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566 |
- package de.tudarmstadt.informatik.hostage.system;
- import java.io.IOException;
- import android.util.Log;
- import de.tudarmstadt.informatik.hostage.commons.HelperUtils;
- public class Device {
- private static String porthackFilepath = "/data/local/bind";
- private static boolean initialized = false;
- private static boolean root = false;
- private static boolean pp = false;
- private static void checkPorthack() {
- initialized = false;
- porthackFilepath = HelperUtils.getPorthackFilepath();
- Log.i("FILEPATH", porthackFilepath);
- String portBinder = "[ -e "+porthackFilepath+" ]";
- try {
- Process su = new ProcessBuilder("su", "-c", portBinder).start();
- switch (su.waitFor()) {
- case 0:
- root = true;
- pp = true;
- break;
- case 1:
- root = true;
- pp = false;
- break;
- case 127:
- root = false;
- pp = false;
- break;
- }
- } catch (InterruptedException e) {
- } catch (IOException e) {
- } finally {
- initialized = true;
- Log.d("hostage", "Root: " + Boolean.toString(root));
- Log.d("hostage", "PP: " + Boolean.toString(pp));
- }
- }
- public static boolean isRooted() {
- assert(initialized);
- return root;
- }
- public static boolean isPorthackInstalled() {
- assert(initialized);
- return pp;
- }
- /**
- * Called after auto-loading porthack. To update the local variables.
- */
- public static boolean updatePorthack(){
- checkPorthack();
- return (pp && root);
- }
- }
|