OSDN Git Service

Fix transparent inverted color
authorjruesga <jorge@ruesga.com>
Sat, 20 Oct 2012 15:35:25 +0000 (17:35 +0200)
committerjruesga <jorge@ruesga.com>
Sat, 20 Oct 2012 15:35:25 +0000 (17:35 +0200)
35 files changed:
res/drawable-hdpi/btn_holo_light_check_on_normal_inverted.png
res/drawable-mdpi/btn_holo_light_check_on_normal_inverted.png
res/drawable-xhdpi/btn_holo_light_check_on_normal_inverted.png
res/values/strings.xml
res/xml/preferences_general.xml
src/com/cyanogenmod/explorer/ExplorerApplication.java
src/com/cyanogenmod/explorer/activities/BookmarksActivity.java
src/com/cyanogenmod/explorer/activities/NavigationActivity.java
src/com/cyanogenmod/explorer/activities/SearchActivity.java
src/com/cyanogenmod/explorer/activities/preferences/SettingsPreferences.java
src/com/cyanogenmod/explorer/commands/ExecutableCreator.java
src/com/cyanogenmod/explorer/commands/shell/IdentityCommand.java
src/com/cyanogenmod/explorer/commands/shell/ListCommand.java
src/com/cyanogenmod/explorer/console/Console.java
src/com/cyanogenmod/explorer/console/ConsoleBuilder.java
src/com/cyanogenmod/explorer/console/shell/ShellConsole.java
src/com/cyanogenmod/explorer/model/Permissions.java
src/com/cyanogenmod/explorer/parcelables/NavigationViewInfoParcelable.java
src/com/cyanogenmod/explorer/preferences/ExplorerSettings.java
src/com/cyanogenmod/explorer/tasks/SearchResultDrawingAsyncTask.java
src/com/cyanogenmod/explorer/ui/dialogs/ActionsDialog.java
src/com/cyanogenmod/explorer/ui/dialogs/ChooseConsoleDialog.java
src/com/cyanogenmod/explorer/ui/policy/CopyMoveActionPolicy.java
src/com/cyanogenmod/explorer/ui/policy/DeleteActionPolicy.java
src/com/cyanogenmod/explorer/ui/widgets/Breadcrumb.java
src/com/cyanogenmod/explorer/ui/widgets/BreadcrumbView.java
src/com/cyanogenmod/explorer/ui/widgets/NavigationView.java
src/com/cyanogenmod/explorer/ui/widgets/NonFocusableButtonItem.java
src/com/cyanogenmod/explorer/ui/widgets/TransparentNonFocusableButtonItem.java
src/com/cyanogenmod/explorer/util/CommandHelper.java
src/com/cyanogenmod/explorer/util/FileHelper.java
src/com/cyanogenmod/explorer/util/ParseHelper.java
src/com/cyanogenmod/explorer/util/StorageHelper.java
tests/src/com/cyanogenmod/explorer/commands/shell/ProcessIdCommandTest.java
tests/src/com/cyanogenmod/explorer/commands/shell/SendSignalCommandTest.java

index 6d86f49..0704de4 100644 (file)
Binary files a/res/drawable-hdpi/btn_holo_light_check_on_normal_inverted.png and b/res/drawable-hdpi/btn_holo_light_check_on_normal_inverted.png differ
index d558871..c8e2778 100644 (file)
Binary files a/res/drawable-mdpi/btn_holo_light_check_on_normal_inverted.png and b/res/drawable-mdpi/btn_holo_light_check_on_normal_inverted.png differ
index 7a8352c..32b6364 100644 (file)
Binary files a/res/drawable-xhdpi/btn_holo_light_check_on_normal_inverted.png and b/res/drawable-xhdpi/btn_holo_light_check_on_normal_inverted.png differ
index 8493c87..a86e2b5 100644 (file)
   <string name="msgs_operation_failure">The operation failed.</string>
   <!-- A console couldn\'t be allocated -->
   <string name="msgs_console_alloc_failure">A console couldn\'t be allocated.</string>
-  <!-- An operation can't be cancelled -->
+  <!-- An operation cann't be cancelled -->
   <string name="msgs_operation_can_not_be_cancelled">The operation can\'t be cancelled.</string>
   <!-- The operation requieres mount the filesystem prior to execute the command -->
   <string name="msgs_read_only_filesystem">The filesystem is read-only. Try to mount the
     properties dialog.</string>
     <!-- Preferences * General * Advanced settings category -->
   <string name="pref_general_advanced_settings_category">Advanced settings</string>
-  <!-- Preferences * General * Allow console selection title -->
-  <string name="pref_allow_console_selection">Allow console selection</string>
-  <!-- Preferences * General * Allow console selection summary on -->
-  <string name="pref_allow_console_selection_on">Allow select the type of console to
-    use on the app when navigate. This enable the \'Select console\' menu and adds some advices
-    when the app need to use a privileged action.</string>
-  <!-- Preferences * General * Allow console selection summary off -->
-  <string name="pref_allow_console_selection_off">Use only a privileged console. This requires
-    that the app have \'su\' privilege to run.</string>
+  <!-- Preferences * General * Advanced mode -->
+  <string name="pref_advanced_mode">Advanced mode</string>
+  <!-- Preferences * General * Advanced mode summary on -->
+  <string name="pref_advanced_mode_on">Advanced mode is enabled. You are running in a privileged
+    environment. You are under your own risk.</string>
+  <!-- Preferences * General * Advanced mode summary off -->
+  <string name="pref_advanced_mode_off">Advanced mode is disabled. You are running in a
+    secure environment.</string>
   <!-- Preferences * Search * Results category -->
   <string name="pref_search_results_category">Results</string>
   <!-- Preferences * Search * Show relevance widget -->
index 84477fc..aafa253 100644 (file)
       android:key="general_advanced_settings"
       android:title="@string/pref_general_advanced_settings_category">
 
-      <!-- Allow console selection -->
+      <!-- Advanced mode -->
       <CheckBoxPreference
-        android:key="cm_explorer_allow_console_selection"
-        android:title="@string/pref_allow_console_selection"
-        android:summaryOn="@string/pref_allow_console_selection_on"
-        android:summaryOff="@string/pref_allow_console_selection_off"
+        android:key="cm_explorer_advanced_mode"
+        android:title="@string/pref_advanced_mode"
+        android:summaryOn="@string/pref_advanced_mode_on"
+        android:summaryOff="@string/pref_advanced_mode_off"
         android:persistent="true"
-        android:defaultValue="true" />
+        android:defaultValue="false" />
 
     </PreferenceCategory>
 </PreferenceScreen>
\ No newline at end of file
index 63916fc..be3cdf8 100644 (file)
@@ -83,21 +83,31 @@ public final class ExplorerApplication extends Application {
                         }
                     } catch (Throwable _throw) {/**NON BLOCK**/}
                 } else if (key != null && key.compareTo(
-                        ExplorerSettings.SETTINGS_ALLOW_CONSOLE_SELECTION.getId()) == 0) {
+                        ExplorerSettings.SETTINGS_ADVANCE_MODE.getId()) == 0) {
                     // Force to change to a privileged console.
-                    boolean allowConsoleSelection = Preferences.getSharedPreferences().getBoolean(
-                            ExplorerSettings.SETTINGS_ALLOW_CONSOLE_SELECTION.getId(),
-                            ((Boolean)ExplorerSettings.
-                                    SETTINGS_ALLOW_CONSOLE_SELECTION.
-                                        getDefaultValue()).booleanValue());
-                    if (!allowConsoleSelection) {
-                        ConsoleBuilder.changeToPrivilegedConsole(context);
-                        try {
-                            Preferences.savePreference(
-                                    ExplorerSettings.SETTINGS_SUPERUSER_MODE, Boolean.TRUE, true);
-                        } catch (Throwable ex) {
-                            Log.w(TAG, "Can't save console preference", ex); //$NON-NLS-1$
+                    boolean advancedMode = isAdvancedMode();
+                    if (!advancedMode) {
+                        // First change to non-privileged console
+                        if (!ConsoleBuilder.changeToNonPrivilegedConsole(context)) {
+                            // Try with a privileged console
+                            ConsoleBuilder.changeToPrivilegedConsole(context);
+                            try {
+                                Preferences.savePreference(
+                                        ExplorerSettings.SETTINGS_SUPERUSER_MODE,
+                                        Boolean.TRUE, true);
+                            } catch (Throwable ex) {
+                                Log.w(TAG, "cann't save console preference", ex); //$NON-NLS-1$
+                            }
+                        } else {
+                            try {
+                                Preferences.savePreference(
+                                        ExplorerSettings.SETTINGS_SUPERUSER_MODE,
+                                        Boolean.FALSE, true);
+                            } catch (Throwable ex) {
+                                Log.w(TAG, "cann't save console preference", ex); //$NON-NLS-1$
+                            }
                         }
+                        
                     }
                 }
             }
@@ -218,7 +228,7 @@ public final class ExplorerApplication extends Application {
     /**
      * Method that changes the background console to a privileged console
      *
-     * @throws ConsoleAllocException If the console can't be allocated
+     * @throws ConsoleAllocException If the console cann't be allocated
      */
     public static void changeBackgroundConsoleToPriviligedConsole()
             throws ConsoleAllocException {
@@ -273,4 +283,32 @@ public final class ExplorerApplication extends Application {
         return false;
     }
 
+    /**
+     * Method that returns if the application is running in superuser mode
+     * 
+     * @return boolean If the application is running in superuser mode
+     */
+    public static boolean isSuperuserMode() {
+        boolean defaultValue =
+                ((Boolean)ExplorerSettings.
+                        SETTINGS_SUPERUSER_MODE.
+                            getDefaultValue()).booleanValue();
+       String id = ExplorerSettings.SETTINGS_SUPERUSER_MODE.getId();
+       return Preferences.getSharedPreferences().getBoolean(id, defaultValue);
+    }
+
+    /**
+     * Method that returns if the application is running in advanced mode
+     * 
+     * @return boolean If the application is running in advanced mode
+     */
+    public static boolean isAdvancedMode() {
+        boolean defaultValue =
+                ((Boolean)ExplorerSettings.
+                        SETTINGS_ADVANCE_MODE.
+                            getDefaultValue()).booleanValue();
+        String id = ExplorerSettings.SETTINGS_ADVANCE_MODE.getId();
+       return Preferences.getSharedPreferences().getBoolean(id, defaultValue);
+    }
+
 }
index 29855e1..556199b 100644 (file)
@@ -36,6 +36,7 @@ import android.widget.TextView;
 import android.widget.Toast;
 
 import com.android.internal.util.XmlUtils;
+import com.cyanogenmod.explorer.ExplorerApplication;
 import com.cyanogenmod.explorer.R;
 import com.cyanogenmod.explorer.adapters.BookmarksAdapter;
 import com.cyanogenmod.explorer.console.NoSuchFileOrDirectory;
@@ -70,6 +71,8 @@ public class BookmarksActivity extends Activity implements OnItemClickListener,
 
     private ListView mBookmarksListView;
 
+    private boolean mJailRoom;
+
     /**
      * {@inheritDoc}
      */
@@ -79,6 +82,9 @@ public class BookmarksActivity extends Activity implements OnItemClickListener,
             Log.d(TAG, "NavigationActivity.onCreate"); //$NON-NLS-1$
         }
 
+        // Is in jail room?
+        this.mJailRoom = !ExplorerApplication.isAdvancedMode();
+
         //Request features
         setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
         //Set in transition
@@ -267,10 +273,13 @@ public class BookmarksActivity extends Activity implements OnItemClickListener,
      * @return List<Bookmark>
      */
     private List<Bookmark> loadBookmarks() {
-        //Bookmarks = HOME + FILESYSTEM + SD STORAGES + USER DEFINED
+        // Bookmarks = HOME + FILESYSTEM + SD STORAGES + USER DEFINED
+        // In jail room mode = SD STORAGES + USER DEFINED (from SD STORAGES)
         List<Bookmark> bookmarks = new ArrayList<Bookmark>();
-        bookmarks.add(loadHomeBookmarks());
-        bookmarks.addAll(loadFilesystemBookmarks());
+        if (!this.mJailRoom) {
+            bookmarks.add(loadHomeBookmarks());
+            bookmarks.addAll(loadFilesystemBookmarks());
+        }
         bookmarks.addAll(loadSdStorageBookmarks());
         bookmarks.addAll(loadUserBookmarks());
         return bookmarks;
@@ -405,7 +414,11 @@ public class BookmarksActivity extends Activity implements OnItemClickListener,
         Cursor cursor = Bookmarks.getAllBookmarks(this.getContentResolver());
         if (cursor != null && cursor.moveToFirst()) {
             do {
-                bookmarks.add(new Bookmark(cursor));
+                Bookmark bm = new Bookmark(cursor);
+                if (this.mJailRoom && StorageHelper.isPathInStorageVolume(bm.mPath)) {
+                    continue;
+                }
+                bookmarks.add(bm);
             } while (cursor.moveToNext());
             cursor.close();
         }
index 2b1e4f3..f57ea4e 100644 (file)
@@ -29,6 +29,7 @@ import android.content.pm.ActivityInfo;
 import android.os.Bundle;
 import android.os.Handler;
 import android.os.Parcelable;
+import android.os.storage.StorageVolume;
 import android.util.Log;
 import android.view.KeyEvent;
 import android.view.Menu;
@@ -41,6 +42,7 @@ import android.widget.ListPopupWindow;
 import android.widget.PopupWindow;
 import android.widget.Toast;
 
+import com.cyanogenmod.explorer.ExplorerApplication;
 import com.cyanogenmod.explorer.R;
 import com.cyanogenmod.explorer.activities.preferences.SettingsPreferences;
 import com.cyanogenmod.explorer.adapters.HighlightedSimpleMenuListAdapter;
@@ -79,6 +81,7 @@ import com.cyanogenmod.explorer.util.CommandHelper;
 import com.cyanogenmod.explorer.util.DialogHelper;
 import com.cyanogenmod.explorer.util.ExceptionUtil;
 import com.cyanogenmod.explorer.util.FileHelper;
+import com.cyanogenmod.explorer.util.StorageHelper;
 
 import java.io.FileNotFoundException;
 import java.io.Serializable;
@@ -200,6 +203,20 @@ public class NavigationActivity extends Activity
                         getCurrentNavigationView().refresh();
                         return;
                     }
+
+                    // Advanced mode
+                    if (key.compareTo(ExplorerSettings.
+                            SETTINGS_ADVANCE_MODE.getId()) == 0) {
+                        // Is it necessary to create or exit of the jail room?
+                        boolean jailRoom = !ExplorerApplication.isAdvancedMode();
+                        if (jailRoom != NavigationActivity.this.mJailRoom) {  
+                            if (jailRoom) {
+                                createJailRoom();
+                            } else {
+                                exitJailRoom();
+                            }
+                        }
+                    }
                 }
             }
         }
@@ -222,6 +239,11 @@ public class NavigationActivity extends Activity
     /**
      * @hide
      */
+    boolean mJailRoom;
+
+    /**
+     * @hide
+     */
     Handler mHandler;
 
     /**
@@ -333,6 +355,7 @@ public class NavigationActivity extends Activity
      */
     private void init() {
         this.mHistory = new ArrayList<History>();
+        this.mJailRoom = !ExplorerApplication.isAdvancedMode();
     }
 
     /**
@@ -461,12 +484,7 @@ public class NavigationActivity extends Activity
                         throw new ConsoleAllocException("console == null"); //$NON-NLS-1$
                     }
                 } catch (Throwable ex) {
-                    boolean allowConsoleSelection = Preferences.getSharedPreferences().getBoolean(
-                            ExplorerSettings.SETTINGS_ALLOW_CONSOLE_SELECTION.getId(),
-                            ((Boolean)ExplorerSettings.
-                                    SETTINGS_ALLOW_CONSOLE_SELECTION.
-                                        getDefaultValue()).booleanValue());
-                    if (allowConsoleSelection) {
+                    if (!NavigationActivity.this.mJailRoom) {
                         //Show exception and exists
                         Log.e(TAG, getString(R.string.msgs_cant_create_console), ex);
                         // We don't have any console
@@ -492,6 +510,14 @@ public class NavigationActivity extends Activity
                             Preferences.getSharedPreferences().getString(
                                 ExplorerSettings.SETTINGS_INITIAL_DIR.getId(),
                                 (String)ExplorerSettings.SETTINGS_INITIAL_DIR.getDefaultValue());
+                    if (NavigationActivity.this.mJailRoom) {
+                        // Initial directory is the first external sdcard (sdcard, emmc, usb, ...)
+                        StorageVolume[] volumes =
+                                StorageHelper.getStorageVolumes(NavigationActivity.this);
+                        if (volumes != null && volumes.length > 0) {
+                            initialDir = volumes[0].getPath();
+                        }
+                    }
 
                     //Ensure initial is an absolute directory
                     try {
@@ -632,12 +658,20 @@ public class NavigationActivity extends Activity
                                 new ExplorerSettings[]{ExplorerSettings.SETTINGS_LAYOUT_MODE}));
                 break;
             case R.id.ab_view_options:
-                showSettingsPopUp(view,
-                        Arrays.asList(new ExplorerSettings[]{
-                                ExplorerSettings.SETTINGS_SHOW_DIRS_FIRST,
-                                ExplorerSettings.SETTINGS_SHOW_HIDDEN,
-                                ExplorerSettings.SETTINGS_SHOW_SYSTEM,
-                                ExplorerSettings.SETTINGS_SHOW_SYMLINKS}));
+                // If we are in jail room, then don't show non-secure items
+                if (this.mJailRoom) {
+                    showSettingsPopUp(view,
+                            Arrays.asList(new ExplorerSettings[]{
+                                    ExplorerSettings.SETTINGS_SHOW_DIRS_FIRST}));
+                } else {
+                    showSettingsPopUp(view,
+                            Arrays.asList(new ExplorerSettings[]{
+                                    ExplorerSettings.SETTINGS_SHOW_DIRS_FIRST,
+                                    ExplorerSettings.SETTINGS_SHOW_HIDDEN,
+                                    ExplorerSettings.SETTINGS_SHOW_SYSTEM,
+                                    ExplorerSettings.SETTINGS_SHOW_SYMLINKS}));
+                }
+                
                 break;
 
             //######################
@@ -914,11 +948,7 @@ public class NavigationActivity extends Activity
         }
 
         // Check if console selection is allowed
-        boolean allowConsoleSelection = Preferences.getSharedPreferences().getBoolean(
-                ExplorerSettings.SETTINGS_ALLOW_CONSOLE_SELECTION.getId(),
-                ((Boolean)ExplorerSettings.
-                        SETTINGS_ALLOW_CONSOLE_SELECTION.getDefaultValue()).booleanValue());
-        if (!allowConsoleSelection) {
+        if (this.mJailRoom) {
             menu.removeItem(R.id.mnu_console);
         }
 
@@ -1294,14 +1324,14 @@ public class NavigationActivity extends Activity
                         }
 
                         // Ok. Now try to change to advanced selection console. Any crash
-                        // here is a fatal error. We don't have any console
+                        // here is a fatal error. We won't have any console to operate.
                         try {
                             // Change console
                             ConsoleBuilder.changeToNonPrivilegedConsole(NavigationActivity.this);
 
                             // Save preferences
                             Preferences.savePreference(
-                                    ExplorerSettings.SETTINGS_ALLOW_CONSOLE_SELECTION,
+                                    ExplorerSettings.SETTINGS_ADVANCE_MODE,
                                     Boolean.TRUE, true);
                             Preferences.savePreference(
                                     ExplorerSettings.SETTINGS_SUPERUSER_MODE,
@@ -1320,4 +1350,43 @@ public class NavigationActivity extends Activity
         dialog.show();
     }
 
+    /**
+     * Method that creates a jail room, protecting the user to break anything in the device
+     * @hide
+     */
+    void createJailRoom() {
+        // If we are in a jail room, then do nothing
+        if (this.mJailRoom) return;
+        this.mJailRoom = true;
+
+        int cc = this.mNavigationViews.length;
+        for (int i = 0; i < cc; i++) {
+            this.mNavigationViews[i].createJailRoom();
+        }
+
+        // Remove the selection
+        cc = this.mNavigationViews.length;
+        for (int i = 0; i < cc; i++) {
+            getCurrentNavigationView().onDeselectAll();
+        }
+
+        // Remove the history (don't allow to access to previous data)
+        clearHistory();
+    }
+
+    /**
+     * Method that exits from a jail room
+     * @hide
+     */
+    void exitJailRoom() {
+        // If we aren't in a jail room, then do nothing
+        if (!this.mJailRoom) return;
+        this.mJailRoom = false;
+
+        int cc = this.mNavigationViews.length;
+        for (int i = 0; i < cc; i++) {
+            this.mNavigationViews[i].exitJailRoom();
+        }
+    }
+
 }
index ad7f4f0..fe897f0 100644 (file)
@@ -321,7 +321,7 @@ public class SearchActivity extends Activity
                 state.putParcelable(EXTRA_SEARCH_RESTORE, createSearchInfo());
             }
         } catch (Throwable ex) {
-            Log.w(TAG, "The state can't be saved", ex); //$NON-NLS-1$
+            Log.w(TAG, "The state cann't be saved", ex); //$NON-NLS-1$
         }
     }
 
@@ -336,7 +336,7 @@ public class SearchActivity extends Activity
                 this.mRestoreState = state.getParcelable(EXTRA_SEARCH_RESTORE);
             }
         } catch (Throwable ex) {
-            Log.w(TAG, "The state can't be restored", ex); //$NON-NLS-1$
+            Log.w(TAG, "The state cann't be restored", ex); //$NON-NLS-1$
         }
     }
 
index cdc60f2..21f1640 100644 (file)
@@ -221,7 +221,7 @@ public class SettingsPreferences extends PreferenceActivity {
             // Allow console selection
             this.mAllowConsoleSelection =
                     (CheckBoxPreference)findPreference(
-                            ExplorerSettings.SETTINGS_ALLOW_CONSOLE_SELECTION.getId());
+                            ExplorerSettings.SETTINGS_ADVANCE_MODE.getId());
             this.mAllowConsoleSelection.setOnPreferenceChangeListener(this.mOnChangeListener);
 
             // Loaded
index ce377ee..2ed3674 100644 (file)
@@ -36,7 +36,7 @@ public interface ExecutableCreator {
      * @param dir The absolute path of the new directory to establish as current directory
      * @return ChangeCurrentDirExecutable A {@link ChangeCurrentDirExecutable} executable
      * implementation reference
-     * @throws CommandNotFoundException If the executable can't be created
+     * @throws CommandNotFoundException If the executable cann't be created
      */
     ChangeCurrentDirExecutable createChangeCurrentDirExecutable(
             String dir) throws CommandNotFoundException;
@@ -49,7 +49,7 @@ public interface ExecutableCreator {
      * @param newGroup The new group of the file system object
      * @return ChangeOwnerExecutable A {@link ChangeOwnerExecutable} executable
      * implementation reference
-     * @throws CommandNotFoundException If the executable can't be created
+     * @throws CommandNotFoundException If the executable cann't be created
      */
     ChangeOwnerExecutable createChangeOwnerExecutable(
             String fso, User newUser, Group newGroup) throws CommandNotFoundException;
@@ -61,7 +61,7 @@ public interface ExecutableCreator {
      * @param newPermissions The new permissions of the file system object
      * @return ChangePermissionsExecutable A {@link ChangePermissionsExecutable} executable
      * implementation reference
-     * @throws CommandNotFoundException If the executable can't be created
+     * @throws CommandNotFoundException If the executable cann't be created
      */
     ChangePermissionsExecutable createChangePermissionsExecutable(
             String fso, Permissions newPermissions) throws CommandNotFoundException;
@@ -73,7 +73,7 @@ public interface ExecutableCreator {
      * @param src The absolute path to the source file system object
      * @param dst The absolute path to the destination file system object
      * @return CopyExecutable A {@link CopyExecutable} executable implementation reference
-     * @throws CommandNotFoundException If the executable can't be created
+     * @throws CommandNotFoundException If the executable cann't be created
      */
     CopyExecutable createCopyExecutable(String src, String dst) throws CommandNotFoundException;
 
@@ -83,7 +83,7 @@ public interface ExecutableCreator {
      * @param dir The absolute path of the new directory
      * @return CreateDirExecutable A {@link CreateDirExecutable} executable implementation
      * reference
-     * @throws CommandNotFoundException If the executable can't be created
+     * @throws CommandNotFoundException If the executable cann't be created
      */
     CreateDirExecutable createCreateDirectoryExecutable(String dir)
             throws CommandNotFoundException;
@@ -94,7 +94,7 @@ public interface ExecutableCreator {
      * @param file The absolute path of the new file
      * @return CreateFileExecutable A {@link CreateFileExecutable} executable
      * implementation reference
-     * @throws CommandNotFoundException If the executable can't be created
+     * @throws CommandNotFoundException If the executable cann't be created
      */
     CreateFileExecutable createCreateFileExecutable(String file) throws CommandNotFoundException;
 
@@ -103,7 +103,7 @@ public interface ExecutableCreator {
      *
      * @return CurrentDirExecutable A {@link CurrentDirExecutable} executable
      * implementation reference
-     * @throws CommandNotFoundException If the executable can't be created
+     * @throws CommandNotFoundException If the executable cann't be created
      */
     CurrentDirExecutable createCurrentDirExecutable() throws CommandNotFoundException;
 
@@ -113,7 +113,7 @@ public interface ExecutableCreator {
      * @param dir The absolute path to the directory to be deleted
      * @return DeleteDirExecutable A {@link DeleteDirExecutable} executable implementation
      * reference
-     * @throws CommandNotFoundException If the executable can't be created
+     * @throws CommandNotFoundException If the executable cann't be created
      */
     DeleteDirExecutable createDeleteDirExecutable(String dir) throws CommandNotFoundException;
 
@@ -123,7 +123,7 @@ public interface ExecutableCreator {
      * @param file The absolute path to the file to be deleted
      * @return DeleteFileExecutable A {@link DeleteFileExecutable} executable
      * implementation reference
-     * @throws CommandNotFoundException If the executable can't be created
+     * @throws CommandNotFoundException If the executable cann't be created
      */
     DeleteFileExecutable createDeleteFileExecutable(String file) throws CommandNotFoundException;
 
@@ -133,7 +133,7 @@ public interface ExecutableCreator {
      *
      * @return DiskUsageExecutable A {@link DiskUsageExecutable} executable implementation
      * reference
-     * @throws CommandNotFoundException If the executable can't be created
+     * @throws CommandNotFoundException If the executable cann't be created
      */
     DiskUsageExecutable createDiskUsageExecutable() throws CommandNotFoundException;
 
@@ -144,7 +144,7 @@ public interface ExecutableCreator {
      * @param dir The absolute path to the directory
      * @return DiskUsageExecutable A {@link DiskUsageExecutable} executable implementation
      * reference
-     * @throws CommandNotFoundException If the executable can't be created
+     * @throws CommandNotFoundException If the executable cann't be created
      */
     DiskUsageExecutable createDiskUsageExecutable(String dir) throws CommandNotFoundException;
 
@@ -154,7 +154,7 @@ public interface ExecutableCreator {
      *
      * @param msg The message to expand
      * @return EchoExecutable A {@link EchoExecutable} executable implementation reference
-     * @throws CommandNotFoundException If the executable can't be created
+     * @throws CommandNotFoundException If the executable cann't be created
      */
     EchoExecutable createEchoExecutable(String msg) throws CommandNotFoundException;
 
@@ -164,7 +164,7 @@ public interface ExecutableCreator {
      * @param cmd The command to execute
      * @param asyncResultListener The listener where to return partial results
      * @return ExecExecutable A {@link ExecExecutable} executable implementation reference
-     * @throws CommandNotFoundException If the executable can't be created
+     * @throws CommandNotFoundException If the executable cann't be created
      */
     ExecExecutable createExecExecutable(
             String cmd, AsyncResultListener asyncResultListener) throws CommandNotFoundException;
@@ -176,7 +176,7 @@ public interface ExecutableCreator {
      * @param query The term of the query
      * @param asyncResultListener The listener where to return partial results
      * @return FindExecutable A {@link FindExecutable} executable implementation reference
-     * @throws CommandNotFoundException If the executable can't be created
+     * @throws CommandNotFoundException If the executable cann't be created
      */
     FindExecutable createFindExecutable(
             String directory, Query query, AsyncResultListener asyncResultListener)
@@ -189,7 +189,7 @@ public interface ExecutableCreator {
      * @param asyncResultListener The listener where to return partial results
      * @return FolderUsageExecutable A {@link FolderUsageExecutable} executable
      * implementation reference
-     * @throws CommandNotFoundException If the executable can't be created
+     * @throws CommandNotFoundException If the executable cann't be created
      */
     FolderUsageExecutable createFolderUsageExecutable(
             String directory, AsyncResultListener asyncResultListener)
@@ -199,7 +199,7 @@ public interface ExecutableCreator {
      * Method that creates an executable for retrieve the groups of the current user.
      *
      * @return GroupsExecutable A {@link GroupsExecutable} executable implementation reference
-     * @throws CommandNotFoundException If the executable can't be created
+     * @throws CommandNotFoundException If the executable cann't be created
      */
     GroupsExecutable createGroupsExecutable()
             throws com.cyanogenmod.explorer.console.CommandNotFoundException;
@@ -208,7 +208,7 @@ public interface ExecutableCreator {
      * Method that creates an executable for retrieve identity information of the current user.
      *
      * @return IdentityExecutable A {@link IdentityExecutable} executable implementation reference
-     * @throws CommandNotFoundException If the executable can't be created
+     * @throws CommandNotFoundException If the executable cann't be created
      */
     IdentityExecutable createIdentityExecutable() throws CommandNotFoundException;
 
@@ -218,7 +218,7 @@ public interface ExecutableCreator {
      * @param src The absolute path to the source fso
      * @param link The absolute path to the link fso
      * @return LinkExecutable A {@link LinkExecutable} executable implementation reference
-     * @throws CommandNotFoundException If the executable can't be created
+     * @throws CommandNotFoundException If the executable cann't be created
      */
     LinkExecutable createLinkExecutable(
             String src, String link) throws CommandNotFoundException;
@@ -228,7 +228,7 @@ public interface ExecutableCreator {
      *
      * @param src The directory where to do the listing
      * @return ListExecutable A {@link ListExecutable} executable implementation reference
-     * @throws CommandNotFoundException If the executable can't be created
+     * @throws CommandNotFoundException If the executable cann't be created
      * @see LIST_MODE
      */
     ListExecutable createListExecutable(String src)
@@ -240,7 +240,7 @@ public interface ExecutableCreator {
      * @param src The directory where to do the listing
      * @param followSymlinks If follow the symlink
      * @return ListExecutable A {@link ListExecutable} executable implementation reference
-     * @throws CommandNotFoundException If the executable can't be created
+     * @throws CommandNotFoundException If the executable cann't be created
      * @see LIST_MODE
      */
     ListExecutable createFileInfoExecutable(String src, boolean followSymlinks)
@@ -252,7 +252,7 @@ public interface ExecutableCreator {
      * @param mp The mount point to mount
      * @param rw Indicates if the operation mount the device as read-write
      * @return MountExecutable A {@link MountExecutable} executable implementation reference
-     * @throws CommandNotFoundException If the executable can't be created
+     * @throws CommandNotFoundException If the executable cann't be created
      */
     MountExecutable createMountExecutable(
             MountPoint mp, boolean rw) throws CommandNotFoundException;
@@ -262,7 +262,7 @@ public interface ExecutableCreator {
      *
      * @return MountPointInfoExecutable A {@link MountPointInfoExecutable} executable
      * implementation reference
-     * @throws CommandNotFoundException If the executable can't be created
+     * @throws CommandNotFoundException If the executable cann't be created
      */
     MountPointInfoExecutable createMountPointInfoExecutable() throws CommandNotFoundException;
 
@@ -273,7 +273,7 @@ public interface ExecutableCreator {
      * @param src The absolute path to the source file system object
      * @param dst The absolute path to the destination file system object
      * @return MoveExecutable A {@link MoveExecutable} executable implementation reference
-     * @throws CommandNotFoundException If the executable can't be created
+     * @throws CommandNotFoundException If the executable cann't be created
      */
     MoveExecutable createMoveExecutable(String src, String dst) throws CommandNotFoundException;
 
@@ -284,7 +284,7 @@ public interface ExecutableCreator {
      * @param fso The absolute path to the file system object
      * @return ParentDirExecutable A {@link ParentDirExecutable} executable implementation
      * reference
-     * @throws CommandNotFoundException If the executable can't be created
+     * @throws CommandNotFoundException If the executable cann't be created
      */
     ParentDirExecutable createParentDirExecutable(String fso) throws CommandNotFoundException;
 
@@ -294,7 +294,7 @@ public interface ExecutableCreator {
      *
      * @return ProcessIdExecutable A {@link ProcessIdExecutable} executable implementation
      * reference
-     * @throws CommandNotFoundException If the executable can't be created
+     * @throws CommandNotFoundException If the executable cann't be created
      */
     ProcessIdExecutable createShellProcessIdExecutable() throws CommandNotFoundException;
 
@@ -306,7 +306,7 @@ public interface ExecutableCreator {
      * @param processName The process name
      * @return ProcessIdExecutable A {@link ProcessIdExecutable} executable implementation
      * reference
-     * @throws CommandNotFoundException If the executable can't be created
+     * @throws CommandNotFoundException If the executable cann't be created
      */
     ProcessIdExecutable createProcessIdExecutable(
             int pid, String processName) throws CommandNotFoundException;
@@ -318,7 +318,7 @@ public interface ExecutableCreator {
      * @param regexp The regular expression
      * @return ProcessIdExecutable A {@link ProcessIdExecutable} executable implementation
      * reference
-     * @throws CommandNotFoundException If the executable can't be created
+     * @throws CommandNotFoundException If the executable cann't be created
      */
     QuickFolderSearchExecutable createQuickFolderSearchExecutable(
             String regexp) throws CommandNotFoundException;
@@ -329,7 +329,7 @@ public interface ExecutableCreator {
      * @param file The file where to read the data
      * @param asyncResultListener The listener where to return partial results
      * @return ReadExecutable A {@link ReadExecutable} executable implementation reference
-     * @throws CommandNotFoundException If the executable can't be created
+     * @throws CommandNotFoundException If the executable cann't be created
      */
     ReadExecutable createReadExecutable(
             String file, AsyncResultListener asyncResultListener)
@@ -342,7 +342,7 @@ public interface ExecutableCreator {
      * @param fso The absolute path to the file system object
      * @return ResolveLinkExecutable A {@link ResolveLinkExecutable} executable
      * implementation reference
-     * @throws CommandNotFoundException If the executable can't be created
+     * @throws CommandNotFoundException If the executable cann't be created
      */
     ResolveLinkExecutable createResolveLinkExecutable(String fso) throws CommandNotFoundException;
 
@@ -352,7 +352,7 @@ public interface ExecutableCreator {
      * @param process The process which to send the signal
      * @param signal The signal to send
      * @return SendSignalExecutable A {@link SendSignalExecutable} executable implementation reference
-     * @throws CommandNotFoundException If the executable can't be created
+     * @throws CommandNotFoundException If the executable cann't be created
      */
     SendSignalExecutable createSendSignalExecutable(
             int process, SIGNAL signal) throws CommandNotFoundException;
@@ -363,7 +363,7 @@ public interface ExecutableCreator {
      * @param process The process which to send the signal
      * @param signal The signal to send
      * @return SendSignalExecutable A {@link SendSignalExecutable} executable implementation reference
-     * @throws CommandNotFoundException If the executable can't be created
+     * @throws CommandNotFoundException If the executable cann't be created
      */
     SendSignalExecutable createKillExecutable(
             int process) throws CommandNotFoundException;
@@ -374,7 +374,7 @@ public interface ExecutableCreator {
      * @param file The file where to write the data
      * @param asyncResultListener The listener where to return partial results
      * @return WriteExecutable A {@link WriteExecutable} executable implementation reference
-     * @throws CommandNotFoundException If the executable can't be created
+     * @throws CommandNotFoundException If the executable cann't be created
      */
     WriteExecutable createWriteExecutable(
             String file, AsyncResultListener asyncResultListener)
@@ -388,7 +388,7 @@ public interface ExecutableCreator {
      * @param src The array of source files to compress
      * @param asyncResultListener The listener where to return partial results
      * @return CompressExecutable A {@link CompressExecutable} executable implementation reference
-     * @throws CommandNotFoundException If the executable can't be created
+     * @throws CommandNotFoundException If the executable cann't be created
      */
     CompressExecutable createCompressExecutable(
             CompressionMode mode, String dst, String[] src,
@@ -402,7 +402,7 @@ public interface ExecutableCreator {
      * @param src The file to compress
      * @param asyncResultListener The listener where to return partial results
      * @return CompressExecutable A {@link CompressExecutable} executable implementation reference
-     * @throws CommandNotFoundException If the executable can't be created
+     * @throws CommandNotFoundException If the executable cann't be created
      */
     CompressExecutable createCompressExecutable(
             CompressionMode mode, String src, AsyncResultListener asyncResultListener)
@@ -416,7 +416,7 @@ public interface ExecutableCreator {
      * fit based on the src)
      * @param asyncResultListener The listener where to return partial results
      * @return UncompressExecutable A {@link UncompressExecutable} executable implementation reference
-     * @throws CommandNotFoundException If the executable can't be created
+     * @throws CommandNotFoundException If the executable cann't be created
      */
     UncompressExecutable createUncompressExecutable(
             String src, String dst, AsyncResultListener asyncResultListener)
index 0d741f4..7c53ffe 100644 (file)
@@ -157,7 +157,7 @@ public class IdentityCommand extends SyncResultProgram implements IdentityExecut
      * @param src The string to parsed into a {@link AID}
      * @param clazz The {@link User} or {@link Group} class from which create the AID object
      * @return AID The identity reference
-     * @throws ParseException If can't create the {@link AID} reference from the string
+     * @throws ParseException If cann't create the {@link AID} reference from the string
      * @throws NoSuchMethodException If the constructor can not be found.
      * @exception InstantiationException If the class cannot be instantiated
      * @exception IllegalAccessException If this constructor is not accessible
index 0250ac6..fdb0cbe 100644 (file)
@@ -70,7 +70,7 @@ public class ListCommand extends SyncResultProgram implements ListExecutable {
      * @throws FileNotFoundException If the initial directory not exists
      * @throws NoSuchFileOrDirectory If the file or directory was not found
      * @throws IOException If initial directory couldn't be checked
-     * @throws ConsoleAllocException If the console can't be allocated
+     * @throws ConsoleAllocException If the console cann't be allocated
      * @throws InsufficientPermissionsException If an operation requires elevated permissions
      * @throws CommandNotFoundException If the command was not found
      * @throws OperationTimeoutException If the operation exceeded the maximum time of wait
@@ -112,7 +112,7 @@ public class ListCommand extends SyncResultProgram implements ListExecutable {
      * @throws FileNotFoundException If the initial directory not exists
      * @throws NoSuchFileOrDirectory If the file or directory was not found
      * @throws IOException If initial directory couldn't be checked
-     * @throws ConsoleAllocException If the console can't be allocated
+     * @throws ConsoleAllocException If the console cann't be allocated
      * @throws InsufficientPermissionsException If an operation requires elevated permissions
      * @throws CommandNotFoundException If the command was not found
      * @throws OperationTimeoutException If the operation exceeded the maximum time of wait
@@ -299,7 +299,7 @@ public class ListCommand extends SyncResultProgram implements ListExecutable {
                                 }
                             } catch (Throwable ex) {
                                 //If parsing the file failed, ignore it and threat as a regular
-                                //file (the destination file not exists or can't be resolved)
+                                //file (the destination file not exists or cann't be resolved)
                             }
                         }
                         break;
index 3ffcecd..25629ee 100644 (file)
@@ -69,7 +69,7 @@ public abstract class Console
     /**
      * Method that allocates the console.
      *
-     * @throws ConsoleAllocException If the console can't be allocated
+     * @throws ConsoleAllocException If the console cann't be allocated
      */
     public abstract void alloc() throws ConsoleAllocException;
 
@@ -82,7 +82,7 @@ public abstract class Console
     * Method that reallocates the console. This method drops the actual console
     * and create a new one exactly as the current.
     *
-    * @throws ConsoleAllocException If the console can't be reallocated
+    * @throws ConsoleAllocException If the console cann't be reallocated
     */
    public abstract void realloc() throws ConsoleAllocException;
 
index 9bad04f..63ee7e7 100644 (file)
@@ -17,7 +17,6 @@
 package com.cyanogenmod.explorer.console;
 
 import android.content.Context;
-import android.content.SharedPreferences.Editor;
 import android.util.Log;
 import android.widget.Toast;
 
@@ -62,7 +61,7 @@ public final class ConsoleBuilder {
      * @throws FileNotFoundException If the initial directory not exists
      * @throws IOException If initial directory couldn't be checked
      * @throws InvalidCommandDefinitionException If the command has an invalid definition
-     * @throws ConsoleAllocException If the console can't be allocated
+     * @throws ConsoleAllocException If the console cann't be allocated
      * @throws InsufficientPermissionsException If the console created is not a privileged console
      */
     public static Console getConsole(Context context)
@@ -81,7 +80,7 @@ public final class ConsoleBuilder {
      * @throws FileNotFoundException If the initial directory not exists
      * @throws IOException If initial directory couldn't be checked
      * @throws InvalidCommandDefinitionException If the command has an invalid definition
-     * @throws ConsoleAllocException If the console can't be allocated
+     * @throws ConsoleAllocException If the console cann't be allocated
      * @throws InsufficientPermissionsException If the console created is not a privileged console
      */
     public static Console getConsole(Context context, boolean createIfNotExists)
@@ -176,7 +175,7 @@ public final class ConsoleBuilder {
      * @throws FileNotFoundException If the initial directory not exists
      * @throws IOException If initial directory couldn't be checked
      * @throws InvalidCommandDefinitionException If the command has an invalid definition
-     * @throws ConsoleAllocException If the console can't be allocated
+     * @throws ConsoleAllocException If the console cann't be allocated
      * @throws InsufficientPermissionsException If the console created is not a privileged console
      */
     //IMP! This must be invoked from the main activity creation
@@ -186,32 +185,23 @@ public final class ConsoleBuilder {
 
         synchronized (ConsoleBuilder.SYNC) {
             //Gets superuser mode settings
-            boolean requiredSuConsole =
-                    Preferences.getSharedPreferences().getBoolean(
-                            ExplorerSettings.SETTINGS_SUPERUSER_MODE.getId(),
-                            ((Boolean)ExplorerSettings.SETTINGS_SUPERUSER_MODE.
-                                    getDefaultValue()).booleanValue());
-            boolean allowConsoleSelection = Preferences.getSharedPreferences().getBoolean(
-                    ExplorerSettings.SETTINGS_ALLOW_CONSOLE_SELECTION.getId(),
-                    ((Boolean)ExplorerSettings.
-                            SETTINGS_ALLOW_CONSOLE_SELECTION.
-                                getDefaultValue()).booleanValue());
-            if (!requiredSuConsole && !allowConsoleSelection) {
-                // allowConsoleSelection forces the su console
+            boolean superuserMode = ExplorerApplication.isSuperuserMode();
+            boolean advancedMode = ExplorerApplication.isAdvancedMode();
+            if (superuserMode && !advancedMode) {
                 try {
                     Preferences.savePreference(
-                            ExplorerSettings.SETTINGS_SUPERUSER_MODE, Boolean.TRUE, true);
+                            ExplorerSettings.SETTINGS_SUPERUSER_MODE, Boolean.FALSE, true);
                 } catch (Throwable ex) {
-                    Log.w(TAG, "Can't save console preference", ex); //$NON-NLS-1$
+                    Log.w(TAG, "cann't save console preference", ex); //$NON-NLS-1$
                 }
-                requiredSuConsole = true;
+                superuserMode = false;
             }
 
             //Check if console settings has changed
             if (sHolder != null) {
                 if (
-                    (sHolder.getConsole() instanceof NonPriviledgeConsole && requiredSuConsole)
-                    || (sHolder.getConsole() instanceof PrivilegedConsole && !requiredSuConsole)) {
+                    (sHolder.getConsole() instanceof NonPriviledgeConsole && superuserMode)
+                    || (sHolder.getConsole() instanceof PrivilegedConsole && !superuserMode)) {
                     //Deallocate actual console
                     sHolder.dispose();
                     sHolder = null;
@@ -220,13 +210,13 @@ public final class ConsoleBuilder {
 
             //Is there a console allocated
             if (sHolder == null) {
-                sHolder = (requiredSuConsole)
+                sHolder = (superuserMode)
                         ? new ConsoleHolder(
                                 createAndCheckPrivilegedConsole(
                                         context, FileHelper.ROOT_DIRECTORY))
                         : new ConsoleHolder(
                                 createNonPrivilegedConsole(context, FileHelper.ROOT_DIRECTORY));
-                if (requiredSuConsole) {
+                if (superuserMode) {
                     // Change also the background console to privileged
                     ExplorerApplication.changeBackgroundConsoleToPriviligedConsole();
                 }
@@ -258,7 +248,7 @@ public final class ConsoleBuilder {
      * @throws FileNotFoundException If the initial directory not exists
      * @throws IOException If initial directory couldn't be checked
      * @throws InvalidCommandDefinitionException If the command has an invalid definition
-     * @throws ConsoleAllocException If the console can't be allocated
+     * @throws ConsoleAllocException If the console cann't be allocated
      * @see NonPriviledgeConsole
      */
     public static Console createNonPrivilegedConsole(Context context, String initialDirectory)
@@ -280,7 +270,7 @@ public final class ConsoleBuilder {
      * @throws FileNotFoundException If the initial directory not exists
      * @throws IOException If initial directory couldn't be checked
      * @throws InvalidCommandDefinitionException If the command has an invalid definition
-     * @throws ConsoleAllocException If the console can't be allocated
+     * @throws ConsoleAllocException If the console cann't be allocated
      * @throws InsufficientPermissionsException If the console created is not a privileged console
      * @see PrivilegedConsole
      */
@@ -312,7 +302,7 @@ public final class ConsoleBuilder {
      * @throws FileNotFoundException If the initial directory not exists
      * @throws IOException If initial directory couldn't be checked
      * @throws InvalidCommandDefinitionException If the command has an invalid definition
-     * @throws ConsoleAllocException If the console can't be allocated
+     * @throws ConsoleAllocException If the console cann't be allocated
      * @throws InsufficientPermissionsException If the console created is not a privileged console
      * @see PrivilegedConsole
      */
@@ -333,7 +323,7 @@ public final class ConsoleBuilder {
      * @throws FileNotFoundException If the initial directory not exists
      * @throws IOException If initial directory couldn't be checked
      * @throws InvalidCommandDefinitionException If the command has an invalid definition
-     * @throws ConsoleAllocException If the console can't be allocated
+     * @throws ConsoleAllocException If the console cann't be allocated
      * @throws InsufficientPermissionsException If the console created is not a privileged console
      * @see PrivilegedConsole
      */
@@ -363,21 +353,16 @@ public final class ConsoleBuilder {
                     DialogHelper.showToast(context,
                             R.string.msgs_privileged_console_alloc_failed, Toast.LENGTH_LONG);
                 } catch (Exception ex) {
-                    Log.e(TAG, "Can't show toast", ex);  //$NON-NLS-1$
+                    Log.e(TAG, "cann't show toast", ex);  //$NON-NLS-1$
                 }
             }
 
-            boolean allowConsoleSelection = Preferences.getSharedPreferences().getBoolean(
-                    ExplorerSettings.SETTINGS_ALLOW_CONSOLE_SELECTION.getId(),
-                    ((Boolean)ExplorerSettings.
-                            SETTINGS_ALLOW_CONSOLE_SELECTION.
-                                getDefaultValue()).booleanValue());
-            if (allowConsoleSelection) {
+            boolean advancedMode = ExplorerApplication.isAdvancedMode();
+            if (advancedMode) {
                 //Save settings
                 try {
-                    Editor editor = Preferences.getSharedPreferences().edit();
-                    editor.putBoolean(ExplorerSettings.SETTINGS_SUPERUSER_MODE.getId(), false);
-                    editor.commit();
+                    Preferences.savePreference(
+                            ExplorerSettings.SETTINGS_SUPERUSER_MODE, Boolean.FALSE, true);
                 } catch (Exception ex) {
                     Log.e(TAG,
                             String.format("Failed to save %s property",  //$NON-NLS-1$
index 20ca93e..4ba3e00 100644 (file)
@@ -282,7 +282,7 @@ public abstract class ShellConsole extends Console implements Program.ProgramLis
             Integer pid = processIdCmd.getResult();
             if (pid == null) {
                 throw new ConsoleAllocException(
-                        "Can't retrieve the PID of the shell."); //$NON-NLS-1$
+                        "cann't retrieve the PID of the shell."); //$NON-NLS-1$
             }
             this.mShell.setPid(pid.intValue());
 
@@ -834,7 +834,7 @@ public abstract class ShellConsole extends Console implements Program.ProgramLis
      * Method that checks the console status and restart the console
      * if this is unusable.
      *
-     * @throws ConsoleAllocException If the console can't be reallocated
+     * @throws ConsoleAllocException If the console cann't be reallocated
      */
     private void checkConsole() throws ConsoleAllocException {
         try {
@@ -995,7 +995,7 @@ public abstract class ShellConsole extends Console implements Program.ProgramLis
      */
     private boolean killCurrentCommand() {
         synchronized (this.mSync) {
-            //Is synchronous program? Otherwise it can't be cancelled
+            //Is synchronous program? Otherwise it cann't be cancelled
             if (!(this.mActiveCommand instanceof AsyncResultProgram)) {
                 return false;
             }
@@ -1054,7 +1054,7 @@ public abstract class ShellConsole extends Console implements Program.ProgramLis
      */
     private boolean sendSignalToCurrentCommand(SIGNAL signal) {
         synchronized (this.mSync) {
-            //Is synchronous program? Otherwise it can't be cancelled
+            //Is synchronous program? Otherwise it cann't be cancelled
             if (!(this.mActiveCommand instanceof AsyncResultProgram)) {
                 return false;
             }
index 3d28539..ffa0ab4 100644 (file)
@@ -250,7 +250,7 @@ public class Permissions implements Serializable, Comparable<Permissions> {
      *
      * @param rawPermissions The raw permissions
      * @return Permissions An object with all the permissions
-     * @throws ParseException If the permissions can't be parsed
+     * @throws ParseException If the permissions cann't be parsed
      * @see ParseHelper#parsePermission(String)
      */
     public static Permissions fromRawString(String rawPermissions) throws ParseException {
@@ -262,7 +262,7 @@ public class Permissions implements Serializable, Comparable<Permissions> {
      *
      * @param octalPermissions The octal permissions
      * @return Permissions An object with all the permissions
-     * @throws ParseException If the permissions can't be parsed
+     * @throws ParseException If the permissions cann't be parsed
      */
     public static Permissions fromOctalString(String octalPermissions) throws ParseException {
         int size = octalPermissions.length();
index 9fcd8f6..9fd8f62 100644 (file)
@@ -37,6 +37,7 @@ public class NavigationViewInfoParcelable extends HistoryNavigable {
 
     private int mId;
     private String mCurrentDir;
+    private boolean mJailRoom;
     private List<FileSystemObject> mFiles;
     private List<FileSystemObject> mSelectedFiles;
 
@@ -113,6 +114,24 @@ public class NavigationViewInfoParcelable extends HistoryNavigable {
     }
 
     /**
+     * Method that returns if the view is in a jail room.
+     *
+     * @return boolean If the view is in a jail room
+     */
+    public boolean getJailRoom() {
+        return this.mJailRoom;
+    }
+
+    /**
+     * Method that sets if the view is in a jail room.
+     *
+     * @param jailRoom If the view is in a jail room
+     */
+    public void setJailRoom(boolean jailRoom) {
+        this.mJailRoom = jailRoom;
+    }
+
+    /**
      * Method that returns the current file list.
      *
      * @return List<FileSystemObject> The current file list
@@ -169,11 +188,13 @@ public class NavigationViewInfoParcelable extends HistoryNavigable {
             dest.writeString(this.mCurrentDir);
         }
         //- 2
+        dest.writeInt(this.mJailRoom ? 1 : 0);
+        //- 3
         dest.writeInt(this.mSelectedFiles == null ? 0 : 1);
         if (this.mSelectedFiles != null) {
             dest.writeList(this.mSelectedFiles);
         }
-        //- 3
+        //- 4
         dest.writeInt(this.mFiles == null ? 0 : 1);
         if (this.mFiles != null) {
             dest.writeList(this.mFiles);
@@ -194,13 +215,15 @@ public class NavigationViewInfoParcelable extends HistoryNavigable {
             this.mCurrentDir = in.readString();
         }
         //- 2
+        this.mJailRoom = (in.readInt() == 1);
+        //- 3
         int hasSelectedFiles = in.readInt();
         if (hasSelectedFiles == 1) {
             List<FileSystemObject> selectedFiles = new ArrayList<FileSystemObject>();
             in.readList(selectedFiles, NavigationViewInfoParcelable.class.getClassLoader());
             this.mSelectedFiles = new ArrayList<FileSystemObject>(selectedFiles);
         }
-        //- 3
+        //- 4
         int hasFiles = in.readInt();
         if (hasFiles == 1) {
             List<FileSystemObject> files = new ArrayList<FileSystemObject>();
index a40e309..7c82361 100644 (file)
@@ -98,11 +98,11 @@ public enum ExplorerSettings {
     SETTINGS_COMPUTE_FOLDER_STATISTICS(
             "cm_explorer_compute_folder_statistics", Boolean.FALSE), //$NON-NLS-1$
     /**
-     * When to use case sensitive comparison in sorting of files
+     * When to run in advanced mode
      * @hide
      */
-    SETTINGS_ALLOW_CONSOLE_SELECTION(
-            "cm_explorer_allow_console_selection", Boolean.TRUE), //$NON-NLS-1$
+    SETTINGS_ADVANCE_MODE(
+            "cm_explorer_advanced_mode", Boolean.FALSE), //$NON-NLS-1$
 
     /**
      * When to highlight the terms of the search in the search results
index 2215ba8..a4a02ee 100644 (file)
@@ -21,6 +21,7 @@ import android.view.View;
 import android.widget.ListView;
 import android.widget.ProgressBar;
 
+import com.cyanogenmod.explorer.ExplorerApplication;
 import com.cyanogenmod.explorer.R;
 import com.cyanogenmod.explorer.adapters.SearchResultAdapter;
 import com.cyanogenmod.explorer.adapters.SearchResultAdapter.OnRequestMenuListener;
@@ -113,10 +114,13 @@ public class SearchResultDrawingAsyncTask extends AsyncTask<Object, Integer, Boo
                                 defaultValue);
             SearchSortResultMode mode = SearchSortResultMode.fromId(value);
 
+            // Is in jail room?
+            boolean jailRoom = !ExplorerApplication.isAdvancedMode();
+
             //Process all the data
             final List<SearchResult> result =
                     SearchHelper.convertToResults(
-                            FileHelper.applyUserPreferences(this.mFiles, true),
+                            FileHelper.applyUserPreferences(this.mFiles, true, jailRoom),
                             this.mQueries);
             if (mode.compareTo(SearchSortResultMode.NAME) == 0) {
                 Collections.sort(result, new Comparator<SearchResult>() {
index 2da394b..23541bf 100644 (file)
@@ -32,6 +32,7 @@ import android.widget.ListView;
 import android.widget.TextView;
 import android.widget.Toast;
 
+import com.cyanogenmod.explorer.ExplorerApplication;
 import com.cyanogenmod.explorer.R;
 import com.cyanogenmod.explorer.adapters.TwoColumnsMenuListAdapter;
 import com.cyanogenmod.explorer.listeners.OnRequestRefreshListener;
@@ -71,6 +72,7 @@ public class ActionsDialog implements OnItemClickListener, OnItemLongClickListen
     final Context mContext;
     private final boolean mGlobal;
     private final boolean mSearch;
+    private final boolean mJailRoom;
 
     /**
      * @hide
@@ -107,6 +109,7 @@ public class ActionsDialog implements OnItemClickListener, OnItemLongClickListen
         this.mContext = context;
         this.mGlobal = global;
         this.mSearch = search;
+        this.mJailRoom = !ExplorerApplication.isAdvancedMode();
 
         //Initialize dialog
         init(context, global ? R.id.mnu_actions_global : R.id.mnu_actions_fso);
@@ -529,7 +532,13 @@ public class ActionsDialog implements OnItemClickListener, OnItemLongClickListen
      * @param menu The menu to configure
      */
     private void configureMenu(Menu menu) {
-        // Check actions that needs a valid reference
+        // Selection
+        List<FileSystemObject> selection = null;
+        if (this.mOnSelectionListener != null) {
+            selection = this.mOnSelectionListener.onRequestSelectedFiles();
+        }
+
+        //- Check actions that needs a valid reference
         if (!this.mGlobal && this.mFso != null) {
             //- Select/Deselect -> Only one of them
             if (this.mOnSelectionListener != null) {
@@ -569,13 +578,8 @@ public class ActionsDialog implements OnItemClickListener, OnItemLongClickListen
             menu.removeItem(R.id.mnu_actions_add_to_bookmarks_current_folder);
         }
 
-        // Paste/Move only when have a selection
-        // Create link
+        //- Paste/Move only when have a selection
         if (this.mGlobal) {
-            List<FileSystemObject> selection = null;
-            if (this.mOnSelectionListener != null) {
-                selection = this.mOnSelectionListener.onRequestSelectedFiles();
-            }
             if (selection == null || selection.size() == 0 ||
                     (this.mFso != null && !FileHelper.isDirectory(this.mFso))) {
                 // Remove paste/move actions
@@ -583,26 +587,28 @@ public class ActionsDialog implements OnItemClickListener, OnItemLongClickListen
                 menu.removeItem(R.id.mnu_actions_move_selection);
                 menu.removeItem(R.id.mnu_actions_delete_selection);
             }
-            if (selection == null || selection.size() == 0 || selection.size() > 1) {
-                // Only when one item is selected
-                menu.removeItem(R.id.mnu_actions_create_link_global);
-            } else {
-                // Create link (not allow in storage volume)
-                FileSystemObject fso = selection.get(0);
-                if (StorageHelper.isPathInStorageVolume(fso.getFullPath())) {
-                    menu.removeItem(R.id.mnu_actions_create_link);
-                }
+        }
+        //- Create link
+        if (this.mGlobal && (selection == null || selection.size() == 0 || selection.size() > 1)) {
+            // Only when one item is selected
+            menu.removeItem(R.id.mnu_actions_create_link_global);
+        } else if (this.mGlobal  && selection != null) {
+            // Create link (not allow in storage volume)
+            FileSystemObject fso = selection.get(0);
+            if (StorageHelper.isPathInStorageVolume(fso.getFullPath())) {
+                menu.removeItem(R.id.mnu_actions_create_link);
+            }
+        } else if (!this.mGlobal) {
+            // Create link (not allow in storage volume)
+            if (StorageHelper.isPathInStorageVolume(this.mFso.getFullPath())) {
+                menu.removeItem(R.id.mnu_actions_create_link);
             }
         }
 
-        // Compress/Uncompress (only when selection is available)
+        //- Compress/Uncompress (only when selection is available)
         if (this.mOnSelectionListener != null) {
             //Compress
             if (this.mGlobal) {
-                List<FileSystemObject> selection = null;
-                if (this.mOnSelectionListener != null) {
-                    selection = this.mOnSelectionListener.onRequestSelectedFiles();
-                }
                 if (selection == null || selection.size() == 0) {
                     menu.removeItem(R.id.mnu_actions_compress_selection);
                 }
@@ -629,6 +635,15 @@ public class ActionsDialog implements OnItemClickListener, OnItemLongClickListen
         if (!this.mSearch) {
             menu.removeItem(R.id.mnu_actions_open_parent_folder);
         }
+
+        // Remove jail room actions (actions that cann't be present when running in
+        // unprivileged mode)
+        if (this.mJailRoom) {
+            menu.removeItem(R.id.mnu_actions_create_link);
+            menu.removeItem(R.id.mnu_actions_create_link_global);
+            menu.removeItem(R.id.mnu_actions_execute);
+            menu.removeItem(R.id.mnu_actions_execute);
+        }
     }
 
     /**
index 952f334..4e42020 100644 (file)
@@ -148,7 +148,7 @@ public class ChooseConsoleDialog implements OnItemClickListener {
                 Preferences.savePreference(
                         ExplorerSettings.SETTINGS_SUPERUSER_MODE, superuser, true);
             } catch (Throwable ex) {
-                Log.w(TAG, "Can't save console preference", ex); //$NON-NLS-1$
+                Log.w(TAG, "cann't save console preference", ex); //$NON-NLS-1$
             }
         }
     }
index b8de116..29f3044 100644 (file)
@@ -495,7 +495,7 @@ public final class CopyMoveActionPolicy extends ActionsPolicy {
             String src = linkRes.mSrc.getAbsolutePath();
             String dst = linkRes.mDst.getAbsolutePath();
 
-            // 1.- Current directory can't be moved
+            // 1.- Current directory cann't be moved
             if (currentDirectory != null && currentDirectory.startsWith(src)) {
                 // Operation not allowed
                 AlertDialog dialog =
@@ -505,7 +505,7 @@ public final class CopyMoveActionPolicy extends ActionsPolicy {
                 return false;
             }
 
-            // 2.- Destination can't be a child of source
+            // 2.- Destination cann't be a child of source
             if (dst.startsWith(src)) {
                 // Operation not allowed
                 AlertDialog dialog =
index 8e0aa36..470ae2d 100644 (file)
@@ -302,7 +302,7 @@ public final class DeleteActionPolicy extends ActionsPolicy {
         for (int i = 0; i < cc; i++) {
             FileSystemObject fso = files.get(i);
 
-            // 1.- Current directory can't be deleted
+            // 1.- Current directory cann't be deleted
             if (currentDirectory.startsWith(fso.getFullPath())) {
                 // Operation not allowed
                 AlertDialog dialog =
index 0f45a42..02854bd 100644 (file)
@@ -38,8 +38,9 @@ public interface Breadcrumb {
      * Method that changes the path of the breadcrumb.
      *
      * @param newPath The new path
+     * @param jailRoom If the breadcrumb should be in a jail room
      */
-    void changeBreadcrumbPath(final String newPath);
+    void changeBreadcrumbPath(final String newPath, boolean jailRoom);
 
     /**
      * Method that adds a new breadcrumb listener.
index cc421db..6de8b2c 100644 (file)
@@ -32,6 +32,7 @@ import com.cyanogenmod.explorer.model.DiskUsage;
 import com.cyanogenmod.explorer.model.MountPoint;
 import com.cyanogenmod.explorer.tasks.FilesystemAsyncTask;
 import com.cyanogenmod.explorer.util.FileHelper;
+import com.cyanogenmod.explorer.util.StorageHelper;
 
 import java.io.File;
 import java.util.ArrayList;
@@ -184,7 +185,7 @@ public class BreadcrumbView extends RelativeLayout implements Breadcrumb, OnClic
      * {@inheritDoc}
      */
     @Override
-    public void changeBreadcrumbPath(final String newPath) {
+    public void changeBreadcrumbPath(final String newPath, final boolean jailRoom) {
         //Sets the current path
         this.mCurrentPath = newPath;
 
@@ -194,15 +195,31 @@ public class BreadcrumbView extends RelativeLayout implements Breadcrumb, OnClic
         //Remove all views
         this.mBreadcrumbBar.removeAllViews();
 
-        //The first is always the root
-        this.mBreadcrumbBar.addView(createBreadcrumbItem(new File(FileHelper.ROOT_DIRECTORY)));
+        //The first is always the root (if not in a jail room)
+        if (!jailRoom) {
+            this.mBreadcrumbBar.addView(createBreadcrumbItem(new File(FileHelper.ROOT_DIRECTORY)));
+        }
 
         //Add the rest of the path
         String[] dirs = newPath.split(File.separator);
         int cc = dirs.length;
-        for (int i = 1; i < cc; i++) {
-            this.mBreadcrumbBar.addView(createItemDivider());
-            this.mBreadcrumbBar.addView(createBreadcrumbItem(createFile(dirs, i)));
+        if (jailRoom) {
+            boolean first = true;
+            for (int i = 1; i < cc; i++) {
+                File f = createFile(dirs, i);
+                if (StorageHelper.isPathInStorageVolume(f.getAbsolutePath())) {
+                    if (!first) {
+                        this.mBreadcrumbBar.addView(createItemDivider());
+                    }
+                    first = false;
+                    this.mBreadcrumbBar.addView(createBreadcrumbItem(f));
+                } 
+            }
+        } else {
+            for (int i = 1; i < cc; i++) {
+                this.mBreadcrumbBar.addView(createItemDivider());
+                this.mBreadcrumbBar.addView(createBreadcrumbItem(createFile(dirs, i)));
+            }
         }
 
         //Set scrollbar at the end
index 2f2a0e2..2e86aa7 100644 (file)
@@ -20,6 +20,7 @@ import android.app.Activity;
 import android.content.Context;
 import android.content.SharedPreferences;
 import android.os.AsyncTask;
+import android.os.storage.StorageVolume;
 import android.util.AttributeSet;
 import android.util.Log;
 import android.view.View;
@@ -28,6 +29,7 @@ import android.widget.ListAdapter;
 import android.widget.RelativeLayout;
 import android.widget.Toast;
 
+import com.cyanogenmod.explorer.ExplorerApplication;
 import com.cyanogenmod.explorer.R;
 import com.cyanogenmod.explorer.adapters.FileSystemObjectAdapter;
 import com.cyanogenmod.explorer.adapters.FileSystemObjectAdapter.OnRequestMenuListener;
@@ -54,6 +56,7 @@ import com.cyanogenmod.explorer.util.CommandHelper;
 import com.cyanogenmod.explorer.util.DialogHelper;
 import com.cyanogenmod.explorer.util.ExceptionUtil;
 import com.cyanogenmod.explorer.util.FileHelper;
+import com.cyanogenmod.explorer.util.StorageHelper;
 
 import java.util.ArrayList;
 import java.util.List;
@@ -115,6 +118,8 @@ public class NavigationView extends RelativeLayout implements
     private OnNavigationSelectionChangedListener mOnNavigationSelectionChangedListener;
     private OnNavigationRequestMenuListener mOnNavigationRequestMenuListener;
 
+    private boolean mJailRoom;
+
     /**
      * @hide
      */
@@ -187,6 +192,7 @@ public class NavigationView extends RelativeLayout implements
         NavigationViewInfoParcelable parcel = new NavigationViewInfoParcelable();
         parcel.setId(this.mId);
         parcel.setCurrentDir(this.mCurrentDir);
+        parcel.setJailRoom(this.mJailRoom);
         parcel.setSelectedFiles(this.mAdapter.getSelectedItems());
         parcel.setFiles(this.mFiles);
         return parcel;
@@ -201,6 +207,7 @@ public class NavigationView extends RelativeLayout implements
         //Restore the data
         this.mId = info.getId();
         this.mCurrentDir = info.getCurrentDir();
+        this.mJailRoom = info.getJailRoom();
         this.mFiles = info.getFiles();
         this.mAdapter.setSelectedItems(info.getSelectedFiles());
 
@@ -215,6 +222,9 @@ public class NavigationView extends RelativeLayout implements
     private void init() {
         //Initialize variables
         this.mFiles = new ArrayList<FileSystemObject>();
+        
+        // Is in jail room?
+        this.mJailRoom = !ExplorerApplication.isAdvancedMode();
 
         // Default long-click action
         String defaultValue = ((ObjectStringIdentifier)ExplorerSettings.
@@ -532,14 +542,19 @@ public class NavigationView extends RelativeLayout implements
             final String newDir, final boolean addToHistory,
             final boolean reload, final boolean useCurrent,
             final SearchInfoParcelable searchInfo, final FileSystemObject scrollTo) {
+
+        // Check navigation security (don't allow to go outside the jail room if one
+        // is created)
+        final String fNewDir = checkJailRoomNavigation(newDir);
+        
         synchronized (this.mSync) {
             //Check that it is really necessary change the directory
-            if (!reload && this.mCurrentDir != null && this.mCurrentDir.compareTo(newDir) == 0) {
+            if (!reload && this.mCurrentDir != null && this.mCurrentDir.compareTo(fNewDir) == 0) {
                 return;
             }
 
             final boolean hasChanged =
-                    !(this.mCurrentDir != null && this.mCurrentDir.compareTo(newDir) == 0);
+                    !(this.mCurrentDir != null && this.mCurrentDir.compareTo(fNewDir) == 0);
             final boolean isNewHistory = (this.mCurrentDir != null);
 
             //Execute the listing in a background process
@@ -575,7 +590,7 @@ public class NavigationView extends RelativeLayout implements
                                 //(sort, hidden, ...)
                                 List<FileSystemObject> files = NavigationView.this.mFiles;
                                 if (!useCurrent) {
-                                    files = CommandHelper.listFiles(getContext(), newDir, null);
+                                    files = CommandHelper.listFiles(getContext(), fNewDir, null);
                                 }
                                 return files;
                             } catch (final ConsoleAllocException e) {
@@ -618,7 +633,7 @@ public class NavigationView extends RelativeLayout implements
                                                             onPostExecuteTask(
                                                                     files, addToHistory,
                                                                     isNewHistory, hasChanged,
-                                                                    searchInfo, newDir, scrollTo);
+                                                                    searchInfo, fNewDir, scrollTo);
                                                         }
                                                     });
                                             return Boolean.TRUE;
@@ -637,10 +652,10 @@ public class NavigationView extends RelativeLayout implements
                         protected void onPostExecute(List<FileSystemObject> files) {
                             onPostExecuteTask(
                                     files, addToHistory, isNewHistory,
-                                    hasChanged, searchInfo, newDir, scrollTo);
+                                    hasChanged, searchInfo, fNewDir, scrollTo);
                         }
                    };
-            task.execute(newDir);
+            task.execute(fNewDir);
         }
     }
 
@@ -669,7 +684,7 @@ public class NavigationView extends RelativeLayout implements
 
             //Apply user preferences
             List<FileSystemObject> sortedFiles =
-                    FileHelper.applyUserPreferences(files);
+                    FileHelper.applyUserPreferences(files, this.mJailRoom);
 
             //Load the data
             loadData(sortedFiles);
@@ -688,7 +703,7 @@ public class NavigationView extends RelativeLayout implements
 
             //Change the breadcrumb
             if (NavigationView.this.mBreadcrumb != null) {
-                NavigationView.this.mBreadcrumb.changeBreadcrumbPath(newDir);
+                NavigationView.this.mBreadcrumb.changeBreadcrumbPath(newDir, this.mJailRoom);
             }
 
             //Scroll to object?
@@ -951,4 +966,54 @@ public class NavigationView extends RelativeLayout implements
         return this.mCurrentDir;
     }
 
+    /**
+     * Method that creates a jail room, protecting the user to break anything in the device
+     * @hide
+     */
+    public void createJailRoom() {
+        // If we are in a jail room, then do nothing
+        if (this.mJailRoom) return;
+        this.mJailRoom = true;
+
+        //Change to first storage volume
+        StorageVolume[] volumes =
+                StorageHelper.getStorageVolumes(getContext());
+        if (volumes != null && volumes.length > 0) {
+            changeCurrentDir(volumes[0].getPath(), false, true, false, null, null);
+        }
+    }
+
+    /**
+     * Method that exits from a jail room
+     * @hide
+     */
+    public void exitJailRoom() {
+        // If we aren't in a jail room, then do nothing
+        if (!this.mJailRoom) return;
+        this.mJailRoom = false;
+
+        // Refresh
+        refresh();
+    }
+
+    /**
+     * Method that ensures that the user don't go outside the jail room
+     * 
+     * @param newDir The new directory to navigate to
+     * @return String
+     */
+    private String checkJailRoomNavigation(String newDir) {
+        // If we aren't in jail room, then there is nothing to check
+        if (!this.mJailRoom) return newDir;
+
+        // Check if the path is owned by one of the storage volumes
+        if (!StorageHelper.isPathInStorageVolume(newDir)) {
+            StorageVolume[] volumes = StorageHelper.getStorageVolumes(getContext());
+            if (volumes != null && volumes.length > 0) {
+                return volumes[0].getPath();
+            }
+        }
+        return newDir;
+    }
+
 }
index ab91677..75a433b 100644 (file)
@@ -22,7 +22,7 @@ import android.util.AttributeSet;
 import com.cyanogenmod.explorer.R;
 
 /**
- * A class that represents a button from an action bar that can't gain focus.
+ * A class that represents a button from an action bar that cann't gain focus.
  */
 public class NonFocusableButtonItem extends ButtonItem {
 
index bb099d7..119e7d0 100644 (file)
@@ -20,7 +20,7 @@ import android.content.Context;
 import android.util.AttributeSet;
 
 /**
- * A class that represents a button from an action bar that can't gain focus
+ * A class that represents a button from an action bar that cann't gain focus
  * without background.
  */
 public class TransparentNonFocusableButtonItem extends NonFocusableButtonItem {
index 433a03d..d1473d3 100644 (file)
@@ -104,7 +104,7 @@ public final class CommandHelper {
      * @throws IOException If initial directory couldn't be checked
      * @throws InvalidCommandDefinitionException If the command has an invalid definition
      * @throws NoSuchFileOrDirectory If the file or directory was not found
-     * @throws ConsoleAllocException If the console can't be allocated
+     * @throws ConsoleAllocException If the console cann't be allocated
      * @throws InsufficientPermissionsException If an operation requires elevated permissions
      * @throws CommandNotFoundException If the command was not found
      * @throws OperationTimeoutException If the operation exceeded the maximum time of wait
@@ -137,7 +137,7 @@ public final class CommandHelper {
      * @throws IOException If initial directory couldn't be checked
      * @throws InvalidCommandDefinitionException If the command has an invalid definition
      * @throws NoSuchFileOrDirectory If the file or directory was not found
-     * @throws ConsoleAllocException If the console can't be allocated
+     * @throws ConsoleAllocException If the console cann't be allocated
      * @throws InsufficientPermissionsException If an operation requires elevated permissions
      * @throws CommandNotFoundException If the command was not found
      * @throws OperationTimeoutException If the operation exceeded the maximum time of wait
@@ -172,7 +172,7 @@ public final class CommandHelper {
      * @throws IOException If initial directory couldn't be checked
      * @throws InvalidCommandDefinitionException If the command has an invalid definition
      * @throws NoSuchFileOrDirectory If the file or directory was not found
-     * @throws ConsoleAllocException If the console can't be allocated
+     * @throws ConsoleAllocException If the console cann't be allocated
      * @throws InsufficientPermissionsException If an operation requires elevated permissions
      * @throws CommandNotFoundException If the command was not found
      * @throws OperationTimeoutException If the operation exceeded the maximum time of wait
@@ -206,7 +206,7 @@ public final class CommandHelper {
      * @throws IOException If initial directory couldn't be checked
      * @throws InvalidCommandDefinitionException If the command has an invalid definition
      * @throws NoSuchFileOrDirectory If the file or directory was not found
-     * @throws ConsoleAllocException If the console can't be allocated
+     * @throws ConsoleAllocException If the console cann't be allocated
      * @throws InsufficientPermissionsException If an operation requires elevated permissions
      * @throws CommandNotFoundException If the command was not found
      * @throws OperationTimeoutException If the operation exceeded the maximum time of wait
@@ -238,7 +238,7 @@ public final class CommandHelper {
      * @throws IOException If initial directory couldn't be checked
      * @throws InvalidCommandDefinitionException If the command has an invalid definition
      * @throws NoSuchFileOrDirectory If the file or directory was not found
-     * @throws ConsoleAllocException If the console can't be allocated
+     * @throws ConsoleAllocException If the console cann't be allocated
      * @throws InsufficientPermissionsException If an operation requires elevated permissions
      * @throws CommandNotFoundException If the command was not found
      * @throws OperationTimeoutException If the operation exceeded the maximum time of wait
@@ -270,7 +270,7 @@ public final class CommandHelper {
      * @throws IOException If initial directory couldn't be checked
      * @throws InvalidCommandDefinitionException If the command has an invalid definition
      * @throws NoSuchFileOrDirectory If the file or directory was not found
-     * @throws ConsoleAllocException If the console can't be allocated
+     * @throws ConsoleAllocException If the console cann't be allocated
      * @throws InsufficientPermissionsException If an operation requires elevated permissions
      * @throws CommandNotFoundException If the command was not found
      * @throws OperationTimeoutException If the operation exceeded the maximum time of wait
@@ -302,7 +302,7 @@ public final class CommandHelper {
      * @throws IOException If initial directory couldn't be checked
      * @throws InvalidCommandDefinitionException If the command has an invalid definition
      * @throws NoSuchFileOrDirectory If the file or directory was not found
-     * @throws ConsoleAllocException If the console can't be allocated
+     * @throws ConsoleAllocException If the console cann't be allocated
      * @throws InsufficientPermissionsException If an operation requires elevated permissions
      * @throws CommandNotFoundException If the command was not found
      * @throws OperationTimeoutException If the operation exceeded the maximum time of wait
@@ -334,7 +334,7 @@ public final class CommandHelper {
      * @throws IOException If initial directory couldn't be checked
      * @throws InvalidCommandDefinitionException If the command has an invalid definition
      * @throws NoSuchFileOrDirectory If the file or directory was not found
-     * @throws ConsoleAllocException If the console can't be allocated
+     * @throws ConsoleAllocException If the console cann't be allocated
      * @throws InsufficientPermissionsException If an operation requires elevated permissions
      * @throws CommandNotFoundException If the command was not found
      * @throws OperationTimeoutException If the operation exceeded the maximum time of wait
@@ -369,7 +369,7 @@ public final class CommandHelper {
      * @throws IOException If initial directory couldn't be checked
      * @throws InvalidCommandDefinitionException If the command has an invalid definition
      * @throws NoSuchFileOrDirectory If the file or directory was not found
-     * @throws ConsoleAllocException If the console can't be allocated
+     * @throws ConsoleAllocException If the console cann't be allocated
      * @throws InsufficientPermissionsException If an operation requires elevated permissions
      * @throws CommandNotFoundException If the command was not found
      * @throws OperationTimeoutException If the operation exceeded the maximum time of wait
@@ -399,7 +399,7 @@ public final class CommandHelper {
      * @throws IOException If initial directory couldn't be checked
      * @throws InvalidCommandDefinitionException If the command has an invalid definition
      * @throws NoSuchFileOrDirectory If the file or directory was not found
-     * @throws ConsoleAllocException If the console can't be allocated
+     * @throws ConsoleAllocException If the console cann't be allocated
      * @throws InsufficientPermissionsException If an operation requires elevated permissions
      * @throws CommandNotFoundException If the command was not found
      * @throws OperationTimeoutException If the operation exceeded the maximum time of wait
@@ -430,7 +430,7 @@ public final class CommandHelper {
      * @throws IOException If initial directory couldn't be checked
      * @throws InvalidCommandDefinitionException If the command has an invalid definition
      * @throws NoSuchFileOrDirectory If the file or directory was not found
-     * @throws ConsoleAllocException If the console can't be allocated
+     * @throws ConsoleAllocException If the console cann't be allocated
      * @throws InsufficientPermissionsException If an operation requires elevated permissions
      * @throws CommandNotFoundException If the command was not found
      * @throws OperationTimeoutException If the operation exceeded the maximum time of wait
@@ -458,7 +458,7 @@ public final class CommandHelper {
      * @throws IOException If initial directory couldn't be checked
      * @throws InvalidCommandDefinitionException If the command has an invalid definition
      * @throws NoSuchFileOrDirectory If the file or directory was not found
-     * @throws ConsoleAllocException If the console can't be allocated
+     * @throws ConsoleAllocException If the console cann't be allocated
      * @throws InsufficientPermissionsException If an operation requires elevated permissions
      * @throws CommandNotFoundException If the command was not found
      * @throws OperationTimeoutException If the operation exceeded the maximum time of wait
@@ -496,7 +496,7 @@ public final class CommandHelper {
      * @throws IOException If initial directory couldn't be checked
      * @throws InvalidCommandDefinitionException If the command has an invalid definition
      * @throws NoSuchFileOrDirectory If the file or directory was not found
-     * @throws ConsoleAllocException If the console can't be allocated
+     * @throws ConsoleAllocException If the console cann't be allocated
      * @throws InsufficientPermissionsException If an operation requires elevated permissions
      * @throws CommandNotFoundException If the command was not found
      * @throws OperationTimeoutException If the operation exceeded the maximum time of wait
@@ -526,7 +526,7 @@ public final class CommandHelper {
     * @throws IOException If initial directory couldn't be checked
     * @throws InvalidCommandDefinitionException If the command has an invalid definition
     * @throws NoSuchFileOrDirectory If the file or directory was not found
-    * @throws ConsoleAllocException If the console can't be allocated
+    * @throws ConsoleAllocException If the console cann't be allocated
     * @throws InsufficientPermissionsException If an operation requires elevated permissions
     * @throws CommandNotFoundException If the command was not found
     * @throws OperationTimeoutException If the operation exceeded the maximum time of wait
@@ -558,7 +558,7 @@ public final class CommandHelper {
     * @throws IOException If initial directory couldn't be checked
     * @throws InvalidCommandDefinitionException If the command has an invalid definition
     * @throws NoSuchFileOrDirectory If the file or directory was not found
-    * @throws ConsoleAllocException If the console can't be allocated
+    * @throws ConsoleAllocException If the console cann't be allocated
     * @throws InsufficientPermissionsException If an operation requires elevated permissions
     * @throws CommandNotFoundException If the command was not found
     * @throws OperationTimeoutException If the operation exceeded the maximum time of wait
@@ -590,7 +590,7 @@ public final class CommandHelper {
      * @throws IOException If initial directory couldn't be checked
      * @throws InvalidCommandDefinitionException If the command has an invalid definition
      * @throws NoSuchFileOrDirectory If the file or directory was not found
-     * @throws ConsoleAllocException If the console can't be allocated
+     * @throws ConsoleAllocException If the console cann't be allocated
      * @throws InsufficientPermissionsException If an operation requires elevated permissions
      * @throws CommandNotFoundException If the command was not found
      * @throws OperationTimeoutException If the operation exceeded the maximum time of wait
@@ -622,7 +622,7 @@ public final class CommandHelper {
      * @throws IOException If initial directory couldn't be checked
      * @throws InvalidCommandDefinitionException If the command has an invalid definition
      * @throws NoSuchFileOrDirectory If the file or directory was not found
-     * @throws ConsoleAllocException If the console can't be allocated
+     * @throws ConsoleAllocException If the console cann't be allocated
      * @throws InsufficientPermissionsException If an operation requires elevated permissions
      * @throws CommandNotFoundException If the command was not found
      * @throws OperationTimeoutException If the operation exceeded the maximum time of wait
@@ -653,7 +653,7 @@ public final class CommandHelper {
      * @throws IOException If initial directory couldn't be checked
      * @throws InvalidCommandDefinitionException If the command has an invalid definition
      * @throws NoSuchFileOrDirectory If the file or directory was not found
-     * @throws ConsoleAllocException If the console can't be allocated
+     * @throws ConsoleAllocException If the console cann't be allocated
      * @throws InsufficientPermissionsException If an operation requires elevated permissions
      * @throws CommandNotFoundException If the command was not found
      * @throws OperationTimeoutException If the operation exceeded the maximum time of wait
@@ -689,7 +689,7 @@ public final class CommandHelper {
      * @throws IOException If initial directory couldn't be checked
      * @throws InvalidCommandDefinitionException If the command has an invalid definition
      * @throws NoSuchFileOrDirectory If the file or directory was not found
-     * @throws ConsoleAllocException If the console can't be allocated
+     * @throws ConsoleAllocException If the console cann't be allocated
      * @throws InsufficientPermissionsException If an operation requires elevated permissions
      * @throws CommandNotFoundException If the command was not found
      * @throws OperationTimeoutException If the operation exceeded the maximum time of wait
@@ -722,7 +722,7 @@ public final class CommandHelper {
      * @throws IOException If initial directory couldn't be checked
      * @throws InvalidCommandDefinitionException If the command has an invalid definition
      * @throws NoSuchFileOrDirectory If the file or directory was not found
-     * @throws ConsoleAllocException If the console can't be allocated
+     * @throws ConsoleAllocException If the console cann't be allocated
      * @throws InsufficientPermissionsException If an operation requires elevated permissions
      * @throws CommandNotFoundException If the command was not found
      * @throws OperationTimeoutException If the operation exceeded the maximum time of wait
@@ -755,7 +755,7 @@ public final class CommandHelper {
      * @throws IOException If initial directory couldn't be checked
      * @throws InvalidCommandDefinitionException If the command has an invalid definition
      * @throws NoSuchFileOrDirectory If the file or directory was not found
-     * @throws ConsoleAllocException If the console can't be allocated
+     * @throws ConsoleAllocException If the console cann't be allocated
      * @throws InsufficientPermissionsException If an operation requires elevated permissions
      * @throws CommandNotFoundException If the command was not found
      * @throws OperationTimeoutException If the operation exceeded the maximum time of wait
@@ -790,7 +790,7 @@ public final class CommandHelper {
      * @throws IOException If initial directory couldn't be checked
      * @throws InvalidCommandDefinitionException If the command has an invalid definition
      * @throws NoSuchFileOrDirectory If the file or directory was not found
-     * @throws ConsoleAllocException If the console can't be allocated
+     * @throws ConsoleAllocException If the console cann't be allocated
      * @throws InsufficientPermissionsException If an operation requires elevated permissions
      * @throws CommandNotFoundException If the command was not found
      * @throws OperationTimeoutException If the operation exceeded the maximum time of wait
@@ -826,7 +826,7 @@ public final class CommandHelper {
      * @throws IOException If initial directory couldn't be checked
      * @throws InvalidCommandDefinitionException If the command has an invalid definition
      * @throws NoSuchFileOrDirectory If the file or directory was not found
-     * @throws ConsoleAllocException If the console can't be allocated
+     * @throws ConsoleAllocException If the console cann't be allocated
      * @throws InsufficientPermissionsException If an operation requires elevated permissions
      * @throws CommandNotFoundException If the command was not found
      * @throws OperationTimeoutException If the operation exceeded the maximum time of wait
@@ -860,7 +860,7 @@ public final class CommandHelper {
      * @throws IOException If initial directory couldn't be checked
      * @throws InvalidCommandDefinitionException If the command has an invalid definition
      * @throws NoSuchFileOrDirectory If the file or directory was not found
-     * @throws ConsoleAllocException If the console can't be allocated
+     * @throws ConsoleAllocException If the console cann't be allocated
      * @throws InsufficientPermissionsException If an operation requires elevated permissions
      * @throws CommandNotFoundException If the command was not found
      * @throws OperationTimeoutException If the operation exceeded the maximum time of wait
@@ -891,7 +891,7 @@ public final class CommandHelper {
      * @throws IOException If initial directory couldn't be checked
      * @throws InvalidCommandDefinitionException If the command has an invalid definition
      * @throws NoSuchFileOrDirectory If the file or directory was not found
-     * @throws ConsoleAllocException If the console can't be allocated
+     * @throws ConsoleAllocException If the console cann't be allocated
      * @throws InsufficientPermissionsException If an operation requires elevated permissions
      * @throws CommandNotFoundException If the command was not found
      * @throws OperationTimeoutException If the operation exceeded the maximum time of wait
@@ -925,7 +925,7 @@ public final class CommandHelper {
      * @throws IOException If initial directory couldn't be checked
      * @throws InvalidCommandDefinitionException If the command has an invalid definition
      * @throws NoSuchFileOrDirectory If the file or directory was not found
-     * @throws ConsoleAllocException If the console can't be allocated
+     * @throws ConsoleAllocException If the console cann't be allocated
      * @throws InsufficientPermissionsException If an operation requires elevated permissions
      * @throws CommandNotFoundException If the command was not found
      * @throws OperationTimeoutException If the operation exceeded the maximum time of wait
@@ -957,7 +957,7 @@ public final class CommandHelper {
      * @throws IOException If initial directory couldn't be checked
      * @throws InvalidCommandDefinitionException If the command has an invalid definition
      * @throws NoSuchFileOrDirectory If the file or directory was not found
-     * @throws ConsoleAllocException If the console can't be allocated
+     * @throws ConsoleAllocException If the console cann't be allocated
      * @throws InsufficientPermissionsException If an operation requires elevated permissions
      * @throws CommandNotFoundException If the command was not found
      * @throws OperationTimeoutException If the operation exceeded the maximum time of wait
@@ -988,7 +988,7 @@ public final class CommandHelper {
      * @throws IOException If initial directory couldn't be checked
      * @throws InvalidCommandDefinitionException If the command has an invalid definition
      * @throws NoSuchFileOrDirectory If the file or directory was not found
-     * @throws ConsoleAllocException If the console can't be allocated
+     * @throws ConsoleAllocException If the console cann't be allocated
      * @throws InsufficientPermissionsException If an operation requires elevated permissions
      * @throws CommandNotFoundException If the command was not found
      * @throws OperationTimeoutException If the operation exceeded the maximum time of wait
@@ -1021,7 +1021,7 @@ public final class CommandHelper {
      * @throws IOException If initial directory couldn't be checked
      * @throws InvalidCommandDefinitionException If the command has an invalid definition
      * @throws NoSuchFileOrDirectory If the file or directory was not found
-     * @throws ConsoleAllocException If the console can't be allocated
+     * @throws ConsoleAllocException If the console cann't be allocated
      * @throws InsufficientPermissionsException If an operation requires elevated permissions
      * @throws CommandNotFoundException If the command was not found
      * @throws OperationTimeoutException If the operation exceeded the maximum time of wait
@@ -1053,7 +1053,7 @@ public final class CommandHelper {
      * @throws IOException If initial directory couldn't be checked
      * @throws InvalidCommandDefinitionException If the command has an invalid definition
      * @throws NoSuchFileOrDirectory If the file or directory was not found
-     * @throws ConsoleAllocException If the console can't be allocated
+     * @throws ConsoleAllocException If the console cann't be allocated
      * @throws InsufficientPermissionsException If an operation requires elevated permissions
      * @throws CommandNotFoundException If the command was not found
      * @throws OperationTimeoutException If the operation exceeded the maximum time of wait
@@ -1083,7 +1083,7 @@ public final class CommandHelper {
      * @throws IOException If initial directory couldn't be checked
      * @throws InvalidCommandDefinitionException If the command has an invalid definition
      * @throws NoSuchFileOrDirectory If the file or directory was not found
-     * @throws ConsoleAllocException If the console can't be allocated
+     * @throws ConsoleAllocException If the console cann't be allocated
      * @throws InsufficientPermissionsException If an operation requires elevated permissions
      * @throws CommandNotFoundException If the command was not found
      * @throws OperationTimeoutException If the operation exceeded the maximum time of wait
@@ -1115,7 +1115,7 @@ public final class CommandHelper {
      * @throws IOException If initial directory couldn't be checked
      * @throws InvalidCommandDefinitionException If the command has an invalid definition
      * @throws NoSuchFileOrDirectory If the file or directory was not found
-     * @throws ConsoleAllocException If the console can't be allocated
+     * @throws ConsoleAllocException If the console cann't be allocated
      * @throws InsufficientPermissionsException If an operation requires elevated permissions
      * @throws CommandNotFoundException If the command was not found
      * @throws OperationTimeoutException If the operation exceeded the maximum time of wait
@@ -1151,7 +1151,7 @@ public final class CommandHelper {
      * @throws IOException If initial directory couldn't be checked
      * @throws InvalidCommandDefinitionException If the command has an invalid definition
      * @throws NoSuchFileOrDirectory If the file or directory was not found
-     * @throws ConsoleAllocException If the console can't be allocated
+     * @throws ConsoleAllocException If the console cann't be allocated
      * @throws InsufficientPermissionsException If an operation requires elevated permissions
      * @throws CommandNotFoundException If the command was not found
      * @throws OperationTimeoutException If the operation exceeded the maximum time of wait
@@ -1199,7 +1199,7 @@ public final class CommandHelper {
      * @throws IOException If initial directory couldn't be checked
      * @throws InvalidCommandDefinitionException If the command has an invalid definition
      * @throws NoSuchFileOrDirectory If the file or directory was not found
-     * @throws ConsoleAllocException If the console can't be allocated
+     * @throws ConsoleAllocException If the console cann't be allocated
      * @throws InsufficientPermissionsException If an operation requires elevated permissions
      * @throws CommandNotFoundException If the command was not found
      * @throws OperationTimeoutException If the operation exceeded the maximum time of wait
@@ -1252,7 +1252,7 @@ public final class CommandHelper {
      * @throws IOException If initial directory couldn't be checked
      * @throws InvalidCommandDefinitionException If the command has an invalid definition
      * @throws NoSuchFileOrDirectory If the file or directory was not found
-     * @throws ConsoleAllocException If the console can't be allocated
+     * @throws ConsoleAllocException If the console cann't be allocated
      * @throws InsufficientPermissionsException If an operation requires elevated permissions
      * @throws CommandNotFoundException If the command was not found
      * @throws OperationTimeoutException If the operation exceeded the maximum time of wait
@@ -1306,7 +1306,7 @@ public final class CommandHelper {
      * @throws IOException If initial directory couldn't be checked
      * @throws InvalidCommandDefinitionException If the command has an invalid definition
      * @throws NoSuchFileOrDirectory If the file or directory was not found
-     * @throws ConsoleAllocException If the console can't be allocated
+     * @throws ConsoleAllocException If the console cann't be allocated
      * @throws InsufficientPermissionsException If an operation requires elevated permissions
      * @throws CommandNotFoundException If the command was not found
      * @throws OperationTimeoutException If the operation exceeded the maximum time of wait
@@ -1364,7 +1364,7 @@ public final class CommandHelper {
      * to attach to the default console
      * @return Object The result of the re-execution
      * @throws NoSuchFileOrDirectory If the file or directory was not found
-     * @throws ConsoleAllocException If the console can't be allocated
+     * @throws ConsoleAllocException If the console cann't be allocated
      * @throws InsufficientPermissionsException If an operation requires elevated permissions
      * @throws CommandNotFoundException If the command was not found
      * @throws OperationTimeoutException If the operation exceeded the maximum time of wait
@@ -1394,7 +1394,7 @@ public final class CommandHelper {
      * @param console The console in which execute the program. <code>null</code> to attach
      * to the default console
      * @throws NoSuchFileOrDirectory If the file or directory was not found
-     * @throws ConsoleAllocException If the console can't be allocated
+     * @throws ConsoleAllocException If the console cann't be allocated
      * @throws InsufficientPermissionsException If an operation requires elevated permissions
      * @throws CommandNotFoundException If the command was not found
      * @throws OperationTimeoutException If the operation exceeded the maximum time of wait
@@ -1422,7 +1422,7 @@ public final class CommandHelper {
      * @param console The console in which execute the program. <code>null</code> to attach
      * to the default console
      * @throws NoSuchFileOrDirectory If the file or directory was not found
-     * @throws ConsoleAllocException If the console can't be allocated
+     * @throws ConsoleAllocException If the console cann't be allocated
      * @throws InsufficientPermissionsException If an operation requires elevated permissions
      * @throws CommandNotFoundException If the command was not found
      * @throws OperationTimeoutException If the operation exceeded the maximum time of wait
@@ -1446,7 +1446,7 @@ public final class CommandHelper {
                     //Mount point is already read-write
                 }
             } else {
-                //For security or physical reasons the mount point can't be
+                //For security or physical reasons the mount point cann't be
                 //mounted as read-write. Execute the command
                 //and notify to the user
             }
@@ -1515,7 +1515,7 @@ public final class CommandHelper {
      * @param console The console passed
      * @return Console The console passed if not is null. Otherwise, the default console
      * @throws InsufficientPermissionsException If an operation requires elevated permissions
-     * @throws ConsoleAllocException If the console can't be allocated
+     * @throws ConsoleAllocException If the console cann't be allocated
      * @throws InvalidCommandDefinitionException If the command has an invalid definition
      * @throws IOException If initial directory couldn't be checked
      * @throws FileNotFoundException If the initial directory not exists
index 6039608..ff2fb25 100644 (file)
@@ -444,10 +444,12 @@ public final class FileHelper {
      * (sort mode, hidden files, ...).
      *
      * @param files The listed files
+     * @param jailRoom If app run with no privileges
      * @return List<FileSystemObject> The applied mode listed files
      */
-    public static List<FileSystemObject> applyUserPreferences(List<FileSystemObject> files) {
-        return applyUserPreferences(files, false);
+    public static List<FileSystemObject> applyUserPreferences(
+                    List<FileSystemObject> files, boolean jailRoom) {
+        return applyUserPreferences(files, false, jailRoom);
     }
 
     /**
@@ -456,10 +458,11 @@ public final class FileHelper {
      *
      * @param files The listed files
      * @param noSort If sort must be applied
+     * @param jailRoom If app run with no privileges
      * @return List<FileSystemObject> The applied mode listed files
      */
     public static List<FileSystemObject> applyUserPreferences(
-            List<FileSystemObject> files, boolean noSort) {
+            List<FileSystemObject> files, boolean noSort, boolean jailRoom) {
         //Retrieve user preferences
         SharedPreferences prefs = Preferences.getSharedPreferences();
         ExplorerSettings sortModePref = ExplorerSettings.SETTINGS_SORT_MODE;
@@ -476,7 +479,7 @@ public final class FileHelper {
             //Hidden files
             if (!prefs.getBoolean(
                     showHiddenPref.getId(),
-                    ((Boolean)showHiddenPref.getDefaultValue()).booleanValue())) {
+                    ((Boolean)showHiddenPref.getDefaultValue()).booleanValue()) || jailRoom) {
                 if (file.isHidden()) {
                     files.remove(i);
                     continue;
@@ -486,7 +489,7 @@ public final class FileHelper {
             //System files
             if (!prefs.getBoolean(
                     showSystemPref.getId(),
-                    ((Boolean)showSystemPref.getDefaultValue()).booleanValue())) {
+                    ((Boolean)showSystemPref.getDefaultValue()).booleanValue()) || jailRoom) {
                 if (file instanceof SystemFile) {
                     files.remove(i);
                     continue;
@@ -496,7 +499,7 @@ public final class FileHelper {
             //Symlinks files
             if (!prefs.getBoolean(
                     showSymlinksPref.getId(),
-                    ((Boolean)showSymlinksPref.getDefaultValue()).booleanValue())) {
+                    ((Boolean)showSymlinksPref.getDefaultValue()).booleanValue()) || jailRoom) {
                 if (file instanceof Symlink) {
                     files.remove(i);
                     continue;
index f05ebba..b455dd5 100644 (file)
@@ -66,7 +66,7 @@ public final class ParseHelper {
      * @param parent The parent of the object
      * @param src The unix string style line
      * @return FileSystemObject The file system object reference
-     * @throws ParseException If the line can't be parsed
+     * @throws ParseException If the line cann't be parsed
      * @see #toFileSystemObject(String, String, boolean)
      */
     public static FileSystemObject toFileSystemObject(
@@ -82,7 +82,7 @@ public final class ParseHelper {
      * @param src The unix string style line
      * @param quick Do not resolve data (User and Group doesn't have a valid reference)
      * @return FileSystemObject The file system object reference
-     * @throws ParseException If the line can't be parsed
+     * @throws ParseException If the line cann't be parsed
      */
     //
     //<permission> <user> <group> <size> <last modified>  <name>
@@ -226,7 +226,7 @@ public final class ParseHelper {
      *
      * @param permissions The raw permissions
      * @return Permissions An object with all the permissions
-     * @throws ParseException If the permissions can't be parsed
+     * @throws ParseException If the permissions cann't be parsed
      * @{link "http://en.wikipedia.org/wiki/File_system_permissions"}
      */
     public static Permissions parsePermission(String permissions) throws ParseException {
@@ -308,7 +308,7 @@ public final class ParseHelper {
      *
      * @param src The disk usage line
      * @return DiskUsage The disk usage information
-     * @throws ParseException If the line can't be parsed
+     * @throws ParseException If the line cann't be parsed
      */
     // Filesystem             Size   Used   Free   Blksize
     // /dev                   414M    48K   414M   4096
@@ -348,7 +348,7 @@ public final class ParseHelper {
      *
      * @param src The mount point line
      * @return MountPoint The mount point information
-     * @throws ParseException If the line can't be parsed
+     * @throws ParseException If the line cann't be parsed
      */
     // rootfs / rootfs ro,relatime 0 0
     // tmpfs /dev tmpfs rw,nosuid,relatime,mode=755 0 0
index 99afcde..0cb8672 100644 (file)
@@ -31,6 +31,8 @@ import java.lang.reflect.Method;
  * A helper class with useful methods for deal with storages.
  */
 public final class StorageHelper {
+    
+    private static StorageVolume[] sStorageVolumes;
 
     /**
      * Method that returns the storage volumes defined in the system.  This method uses
@@ -40,32 +42,38 @@ public final class StorageHelper {
      * @param ctx The current context
      * @return StorageVolume[] The storage volumes defined in the system
      */
-    public static StorageVolume[] getStorageVolumes(Context ctx) {
-        //IMP!! Android SDK doesn't have a "getVolumeList" but is supported by CM10.
-        //Use reflect to get this value (if possible)
-        try {
-            StorageManager sm = (StorageManager) ctx.getSystemService(Context.STORAGE_SERVICE);
-            Method method = sm.getClass().getMethod("getVolumeList"); //$NON-NLS-1$
-            return (StorageVolume[])method.invoke(sm);
-        } catch (Exception ex) {
-            //Ignore. Android SDK StorageManager class doesn't have this method
-            //Use default android information from environment
+    public static synchronized StorageVolume[] getStorageVolumes(Context ctx) {
+        if (sStorageVolumes == null) {
+            //IMP!! Android SDK doesn't have a "getVolumeList" but is supported by CM10.
+            //Use reflect to get this value (if possible)
             try {
-                File externalStorage = Environment.getExternalStorageDirectory();
-                String path = externalStorage.getCanonicalPath();
-                String description = null;
-                if (path.toLowerCase().indexOf("usb") != -1) { //$NON-NLS-1$
-                    description = ctx.getString(R.string.usb_storage);
-                } else {
-                    description = ctx.getString(R.string.external_storage);
+                StorageManager sm = (StorageManager) ctx.getSystemService(Context.STORAGE_SERVICE);
+                Method method = sm.getClass().getMethod("getVolumeList"); //$NON-NLS-1$
+                sStorageVolumes = (StorageVolume[])method.invoke(sm);
+                
+            } catch (Exception ex) {
+                //Ignore. Android SDK StorageManager class doesn't have this method
+                //Use default android information from environment
+                try {
+                    File externalStorage = Environment.getExternalStorageDirectory();
+                    String path = externalStorage.getCanonicalPath();
+                    String description = null;
+                    if (path.toLowerCase().indexOf("usb") != -1) { //$NON-NLS-1$
+                        description = ctx.getString(R.string.usb_storage);
+                    } else {
+                        description = ctx.getString(R.string.external_storage);
+                    }
+                    StorageVolume sv = new StorageVolume(path, description, false, false, 0, false, 0);
+                    sStorageVolumes = new StorageVolume[]{sv};
+                } catch (Exception ex2) {
+                    /**NON BLOCK**/
                 }
-                StorageVolume sv = new StorageVolume(path, description, false, false, 0, false, 0);
-                return new StorageVolume[]{sv};
-            } catch (Exception ex2) {
-                /**NON BLOCK**/
+            }
+            if (sStorageVolumes == null) {
+                sStorageVolumes = new StorageVolume[]{};
             }
         }
-        return new StorageVolume[]{};
+        return sStorageVolumes;
     }
 
     /**
index 0e4818b..6a45fe6 100644 (file)
@@ -30,6 +30,6 @@ public class ProcessIdCommandTest extends AbstractConsoleTest {
         return false;
     }
 
-    // Can't perform any test, because a running program in a shell is needed, and the PID of
+    // cann't perform any test, because a running program in a shell is needed, and the PID of
     // the shell is not available for external use outside the console.
 }
index 83a8ccf..232bf37 100644 (file)
@@ -30,5 +30,5 @@ public class SendSignalCommandTest extends AbstractConsoleTest {
         return false;
     }
 
-    // Can't perform any test, because a running program in a shell is needed.
+    // cann't perform any test, because a running program in a shell is needed.
 }