OSDN Git Service

Expose to the app if the device is rooted
authorjruesga <jorge@ruesga.com>
Sun, 21 Oct 2012 18:52:08 +0000 (20:52 +0200)
committerjruesga <jorge@ruesga.com>
Sun, 21 Oct 2012 18:52:08 +0000 (20:52 +0200)
res/values/overlay.xml
src/com/cyanogenmod/explorer/ExplorerApplication.java

index 8e294d2..1739458 100644 (file)
@@ -28,6 +28,9 @@
   <!-- The system directory -->
   <string name="system_dir">/system</string>
 
+  <!-- The su binary -->
+  <string name="su_binary">/system/xbin/su</string>
+
   <!-- The size of the buffers use by the console (in bytes). Default: 4k -->
   <integer name="buffer_size">4096</integer>
 
index 50601d4..3629b5f 100644 (file)
@@ -37,6 +37,8 @@ import com.cyanogenmod.explorer.util.ExceptionUtil;
 import com.cyanogenmod.explorer.util.FileHelper;
 import com.cyanogenmod.explorer.util.MimeTypeHelper;
 
+import java.io.File;
+
 /**
  * A class that wraps the information of the application (constants,
  * identifiers, statics variables, ...).
@@ -59,6 +61,7 @@ public final class ExplorerApplication extends Application {
     private static ConsoleHolder sBackgroundConsole;
 
     private static boolean sDebuggable = false;
+    private static boolean sRootedDevice = false;
 
     private final BroadcastReceiver mOnSettingChangeReceiver = new BroadcastReceiver() {
         @Override
@@ -177,6 +180,9 @@ public final class ExplorerApplication extends Application {
 
         // Check if the application is debuggable
         sDebuggable = (0 != (getApplicationInfo().flags &= ApplicationInfo.FLAG_DEBUGGABLE));
+        
+        // Check if the device is rooted
+        sRootedDevice = new File(getString(R.string.su_binary)).exists();
 
         // Register the broadcast receiver
         IntentFilter filter = new IntentFilter();
@@ -223,6 +229,15 @@ public final class ExplorerApplication extends Application {
     }
 
     /**
+     * Method that returns if the device is rooted
+     *
+     * @return boolean If the device is rooted
+     */
+    public static boolean isRooted() {
+        return sRootedDevice;
+    }
+
+    /**
      * Method that returns the application background console.
      *
      * @return Console The background console