<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 -->
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
}
} 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$
+ }
}
+
}
}
}
/**
* 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 {
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);
+ }
+
}
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;
private ListView mBookmarksListView;
+ private boolean mJailRoom;
+
/**
* {@inheritDoc}
*/
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
* @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;
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();
}
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;
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;
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;
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();
+ }
+ }
+ }
}
}
}
/**
* @hide
*/
+ boolean mJailRoom;
+
+ /**
+ * @hide
+ */
Handler mHandler;
/**
*/
private void init() {
this.mHistory = new ArrayList<History>();
+ this.mJailRoom = !ExplorerApplication.isAdvancedMode();
}
/**
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
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 {
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;
//######################
}
// 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);
}
}
// 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,
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();
+ }
+ }
+
}
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$
}
}
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$
}
}
// Allow console selection
this.mAllowConsoleSelection =
(CheckBoxPreference)findPreference(
- ExplorerSettings.SETTINGS_ALLOW_CONSOLE_SELECTION.getId());
+ ExplorerSettings.SETTINGS_ADVANCE_MODE.getId());
this.mAllowConsoleSelection.setOnPreferenceChangeListener(this.mOnChangeListener);
// Loaded
* @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;
* @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;
* @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;
* @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;
* @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;
* @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;
*
* @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;
* @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;
* @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;
*
* @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;
* @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;
*
* @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;
* @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;
* @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)
* @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)
* 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;
* 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;
* @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;
*
* @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)
* @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)
* @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;
*
* @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;
* @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;
* @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;
*
* @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;
* @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;
* @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;
* @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)
* @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;
* @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;
* @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;
* @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)
* @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,
* @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)
* 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)
* @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
* @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
* @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
}
} 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;
/**
* 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;
* 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;
package com.cyanogenmod.explorer.console;
import android.content.Context;
-import android.content.SharedPreferences.Editor;
import android.util.Log;
import android.widget.Toast;
* @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)
* @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)
* @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
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;
//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();
}
* @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)
* @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
*/
* @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
*/
* @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
*/
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$
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());
* 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 {
*/
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;
}
*/
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;
}
*
* @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 {
*
* @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();
private int mId;
private String mCurrentDir;
+ private boolean mJailRoom;
private List<FileSystemObject> mFiles;
private List<FileSystemObject> mSelectedFiles;
}
/**
+ * 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
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);
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>();
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
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;
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>() {
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;
final Context mContext;
private final boolean mGlobal;
private final boolean mSearch;
+ private final boolean mJailRoom;
/**
* @hide
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);
* @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) {
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
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);
}
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);
+ }
}
/**
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$
}
}
}
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 =
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 =
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 =
* 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.
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;
* {@inheritDoc}
*/
@Override
- public void changeBreadcrumbPath(final String newPath) {
+ public void changeBreadcrumbPath(final String newPath, final boolean jailRoom) {
//Sets the current path
this.mCurrentPath = newPath;
//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
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;
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;
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;
private OnNavigationSelectionChangedListener mOnNavigationSelectionChangedListener;
private OnNavigationRequestMenuListener mOnNavigationRequestMenuListener;
+ private boolean mJailRoom;
+
/**
* @hide
*/
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;
//Restore the data
this.mId = info.getId();
this.mCurrentDir = info.getCurrentDir();
+ this.mJailRoom = info.getJailRoom();
this.mFiles = info.getFiles();
this.mAdapter.setSelectedItems(info.getSelectedFiles());
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.
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
//(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) {
onPostExecuteTask(
files, addToHistory,
isNewHistory, hasChanged,
- searchInfo, newDir, scrollTo);
+ searchInfo, fNewDir, scrollTo);
}
});
return Boolean.TRUE;
protected void onPostExecute(List<FileSystemObject> files) {
onPostExecuteTask(
files, addToHistory, isNewHistory,
- hasChanged, searchInfo, newDir, scrollTo);
+ hasChanged, searchInfo, fNewDir, scrollTo);
}
};
- task.execute(newDir);
+ task.execute(fNewDir);
}
}
//Apply user preferences
List<FileSystemObject> sortedFiles =
- FileHelper.applyUserPreferences(files);
+ FileHelper.applyUserPreferences(files, this.mJailRoom);
//Load the data
loadData(sortedFiles);
//Change the breadcrumb
if (NavigationView.this.mBreadcrumb != null) {
- NavigationView.this.mBreadcrumb.changeBreadcrumbPath(newDir);
+ NavigationView.this.mBreadcrumb.changeBreadcrumbPath(newDir, this.mJailRoom);
}
//Scroll to object?
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;
+ }
+
}
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 {
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 {
* @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
* @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
* @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
* @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
* @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
* @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
* @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
* @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
* @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
* @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
* @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
* @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
* @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
* @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
* @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
* @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
* @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
* @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
* @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
* @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
* @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
* @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
* @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
* @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
* @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
* @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
* @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
* @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
* @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
* @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
* @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
* @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
* @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
* @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
* @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
* @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
* 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
* @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
* @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
//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
}
* @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
* (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);
}
/**
*
* @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;
//Hidden files
if (!prefs.getBoolean(
showHiddenPref.getId(),
- ((Boolean)showHiddenPref.getDefaultValue()).booleanValue())) {
+ ((Boolean)showHiddenPref.getDefaultValue()).booleanValue()) || jailRoom) {
if (file.isHidden()) {
files.remove(i);
continue;
//System files
if (!prefs.getBoolean(
showSystemPref.getId(),
- ((Boolean)showSystemPref.getDefaultValue()).booleanValue())) {
+ ((Boolean)showSystemPref.getDefaultValue()).booleanValue()) || jailRoom) {
if (file instanceof SystemFile) {
files.remove(i);
continue;
//Symlinks files
if (!prefs.getBoolean(
showSymlinksPref.getId(),
- ((Boolean)showSymlinksPref.getDefaultValue()).booleanValue())) {
+ ((Boolean)showSymlinksPref.getDefaultValue()).booleanValue()) || jailRoom) {
if (file instanceof Symlink) {
files.remove(i);
continue;
* @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(
* @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>
*
* @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 {
*
* @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
*
* @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
* 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
* @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;
}
/**
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.
}
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.
}