diff --git a/res/values/overlay.xml b/res/values/overlay.xml index 0019965a2..1a68d5348 100644 --- a/res/values/overlay.xml +++ b/res/values/overlay.xml @@ -25,8 +25,49 @@ /system - - /system/xbin/su + + + /system/bin/cat, + /system/bin/chmod, + /system/bin/chown, + /system/bin/dd, + /system/bin/df, + /system/bin/gzip, + /system/bin/id, + /system/bin/kill, + /system/bin/ln, + /system/bin/ls, + /system/bin/mkdir, + /system/bin/mount, + /system/bin/mv, + /system/bin/ps, + /system/bin/rm, + /system/bin/sh, + /system/xbin/awk, + /system/xbin/bunzip2, + /system/xbin/bzip2, + /system/xbin/cp, + /system/xbin/cut, + /system/xbin/dirname, + /system/xbin/echo, + /system/xbin/find, + /system/xbin/grep, + /system/xbin/groups, + /system/xbin/gunzip, + /system/xbin/pwd, + /system/xbin/readlink, + /system/xbin/su, + /system/xbin/tar, + /system/xbin/uncompress, + /system/xbin/unlzma, + /system/xbin/unxz, + /system/xbin/unzip, + /system/xbin/xargs + /proc/mounts diff --git a/res/xml/command_list.xml b/res/xml/command_list.xml index c79aee77d..26cd51ebf 100644 --- a/res/xml/command_list.xml +++ b/res/xml/command_list.xml @@ -52,7 +52,7 @@ - + diff --git a/src/com/cyanogenmod/filemanager/FileManagerApplication.java b/src/com/cyanogenmod/filemanager/FileManagerApplication.java index d3ecf9f9e..c765ee351 100644 --- a/src/com/cyanogenmod/filemanager/FileManagerApplication.java +++ b/src/com/cyanogenmod/filemanager/FileManagerApplication.java @@ -203,9 +203,7 @@ private void register() { sIsDebuggable = (0 != (getApplicationInfo().flags &= ApplicationInfo.FLAG_DEBUGGABLE)); // Check if the device is rooted - sIsDeviceRooted = - new File(getString(R.string.su_binary)).exists() && - getSystemProperty("ro.cm.version") != null; //$NON-NLS-1$ + sIsDeviceRooted = areShellCommandsPresent(); // Register the notify broadcast receiver IntentFilter filter = new IntentFilter(); @@ -419,4 +417,41 @@ private static void readSystemProperties() { } } + /** + * Method that check if all shell commands are present in the device + * + * @return boolean Check if the device has all of the shell commands + */ + private boolean areShellCommandsPresent() { + try { + String shellCommands = getString(R.string.shell_required_commands); + String[] commands = shellCommands.split(","); //$NON-NLS-1$ + int cc = commands.length; + if (cc == 0) { + //??? + Log.w(TAG, "No shell commands."); //$NON-NLS-1$ + return false; + } + for (int i = 0; i < cc; i++) { + String c = commands[i].trim(); + if (c.length() == 0) continue; + File cmd = new File(c); + if (!cmd.exists() || !cmd.isFile()) { + Log.w(TAG, + String.format( + "Command %s not found. Exists: %s; IsFile: %s.", //$NON-NLS-1$ + c, + String.valueOf(cmd.exists()), + String.valueOf(cmd.isFile()))); + return false; + } + } + // All commands are present + return true; + } catch (Exception e) { + Log.e(TAG, + "Failed to read shell commands.", e); //$NON-NLS-1$ + } + return false; + } }