diff options
| author | Danny Baumann <dannybaumann@web.de> | 2013-10-07 12:26:24 +0200 |
|---|---|---|
| committer | Danny Baumann <dannybaumann@web.de> | 2013-10-08 08:50:54 +0200 |
| commit | b34d8ace66d96f918ba3f35f850a5e1bd262ee1f (patch) | |
| tree | 4f4d0eb747089e9ad46867c6b213f6a3a9d7eca5 | |
| parent | e1ca27306fadf4093d0e7b2b6db767472156696e (diff) | |
| download | android_packages_apps_CMFileManager-b34d8ace66d96f918ba3f35f850a5e1bd262ee1f.tar.gz android_packages_apps_CMFileManager-b34d8ace66d96f918ba3f35f850a5e1bd262ee1f.tar.bz2 android_packages_apps_CMFileManager-b34d8ace66d96f918ba3f35f850a5e1bd262ee1f.zip | |
Mount emulated storage in root mode.
Make sure to tell su to mount the emulated storage. As this means that
the su shell lives in its own mount namespace, perform remount
operations on both the foreground and the background console.
Change-Id: I9372eefa1df91d1ecd3c89a25a391b977d77da45
6 files changed, 85 insertions, 53 deletions
diff --git a/src/com/cyanogenmod/filemanager/adapters/FileSystemObjectAdapter.java b/src/com/cyanogenmod/filemanager/adapters/FileSystemObjectAdapter.java index c83da5df..1f64e2a5 100644 --- a/src/com/cyanogenmod/filemanager/adapters/FileSystemObjectAdapter.java +++ b/src/com/cyanogenmod/filemanager/adapters/FileSystemObjectAdapter.java @@ -98,8 +98,6 @@ public class FileSystemObjectAdapter String mSize; } - private static final int MESSAGE_REDRAW = 1; - private DataHolder[] mData; private IconHolder mIconHolder; private final int mItemViewResourceId; diff --git a/src/com/cyanogenmod/filemanager/commands/shell/Shell.java b/src/com/cyanogenmod/filemanager/commands/shell/Shell.java index 36b89fdd..43e43368 100644 --- a/src/com/cyanogenmod/filemanager/commands/shell/Shell.java +++ b/src/com/cyanogenmod/filemanager/commands/shell/Shell.java @@ -68,6 +68,15 @@ public abstract class Shell extends Command { } /** + * Method that returns the desired runtime environment of the console + * + * @return The environment + */ + public String[] getEnvironment() { + return null; + } + + /** * {@inheritDoc} */ @Override diff --git a/src/com/cyanogenmod/filemanager/commands/shell/SuperuserShell.java b/src/com/cyanogenmod/filemanager/commands/shell/SuperuserShell.java index d693137d..5eb57bf9 100644 --- a/src/com/cyanogenmod/filemanager/commands/shell/SuperuserShell.java +++ b/src/com/cyanogenmod/filemanager/commands/shell/SuperuserShell.java @@ -35,6 +35,10 @@ public class SuperuserShell extends Shell { private static final String ID = "su"; //$NON-NLS-1$ + private static final String[] MOUNT_STORAGE_ENV = new String[] { + "MOUNT_EMULATED_STORAGE=1" + }; + /** * Constructor of <code>SuperuserShell</code>. * @@ -47,6 +51,13 @@ public class SuperuserShell extends Shell { /** * {@inheritDoc} */ + public String[] getEnvironment() { + return MOUNT_STORAGE_ENV; + } + + /** + * {@inheritDoc} + */ @Override public void checkExitCode(int exitCode) throws InsufficientPermissionsException, CommandNotFoundException, ExecutionException { diff --git a/src/com/cyanogenmod/filemanager/console/shell/ShellConsole.java b/src/com/cyanogenmod/filemanager/console/shell/ShellConsole.java index 5cdc583a..bc97b25a 100644 --- a/src/com/cyanogenmod/filemanager/console/shell/ShellConsole.java +++ b/src/com/cyanogenmod/filemanager/console/shell/ShellConsole.java @@ -53,6 +53,7 @@ import java.io.OutputStream; import java.security.SecureRandom; import java.text.ParseException; import java.util.ArrayList; +import java.util.Arrays; import java.util.List; import java.util.regex.Matcher; import java.util.regex.Pattern; @@ -220,17 +221,18 @@ public abstract class ShellConsole extends Console implements Program.ProgramLis this.mProc = rt.exec( cmd.toArray(new String[cmd.size()]), - null, + this.mShell.getEnvironment(), new File(FileHelper.ROOT_DIRECTORY).getCanonicalFile()); synchronized (this.mSync) { this.mActive = true; } if (isTrace()) { Log.v(TAG, - String.format("Create console %s, command: %s, args: %s", //$NON-NLS-1$ + String.format("Create console %s, command: %s, args: %s, env: %s", //$NON-NLS-1$ this.mShell.getId(), this.mShell.getCommand(), - this.mShell.getArguments())); + this.mShell.getArguments(), + Arrays.toString(this.mShell.getEnvironment()))); } //Allocate buffers diff --git a/src/com/cyanogenmod/filemanager/ui/dialogs/FilesystemInfoDialog.java b/src/com/cyanogenmod/filemanager/ui/dialogs/FilesystemInfoDialog.java index d0786d10..7c63d0a0 100644 --- a/src/com/cyanogenmod/filemanager/ui/dialogs/FilesystemInfoDialog.java +++ b/src/com/cyanogenmod/filemanager/ui/dialogs/FilesystemInfoDialog.java @@ -30,6 +30,7 @@ import android.widget.TextView; import com.cyanogenmod.filemanager.FileManagerApplication; import com.cyanogenmod.filemanager.R; +import com.cyanogenmod.filemanager.console.Console; import com.cyanogenmod.filemanager.console.ConsoleBuilder; import com.cyanogenmod.filemanager.model.DiskUsage; import com.cyanogenmod.filemanager.model.MountPoint; @@ -338,6 +339,16 @@ public class FilesystemInfoDialog implements OnClickListener, OnCheckedChangeLis ret = CommandHelper.remount( this.mContext, this.mMountPoint, isChecked, null); + + if (ret) { + Console bgConsole = FileManagerApplication.getBackgroundConsole(); + if (bgConsole != null) { + ret = CommandHelper.remount( + this.mContext, + this.mMountPoint, isChecked, bgConsole); + } + } + //Hide warning message this.mInfoMsgView.setVisibility(View.GONE); //Communicate the mount change diff --git a/src/com/cyanogenmod/filemanager/util/ExceptionUtil.java b/src/com/cyanogenmod/filemanager/util/ExceptionUtil.java index 12a33e92..26f084f2 100644 --- a/src/com/cyanogenmod/filemanager/util/ExceptionUtil.java +++ b/src/com/cyanogenmod/filemanager/util/ExceptionUtil.java @@ -271,59 +271,60 @@ public final class ExceptionUtil { } //Create a yes/no dialog and ask the user - AlertDialog alert = DialogHelper.createYesNoDialog( - context, - R.string.confirm_operation, - relaunchable.getQuestionResourceId(), - new DialogInterface.OnClickListener() { - @Override - public void onClick(DialogInterface dialog, int which) { - if (which == DialogInterface.BUTTON_POSITIVE) { - //Run the executable again - try { - //Prepare the system before re-launch the command - prepare(context, relaunchable); + final DialogInterface.OnClickListener clickListener = + new DialogInterface.OnClickListener() { + @Override + public void onClick(DialogInterface dialog, int which) { + if (which == DialogInterface.BUTTON_POSITIVE) { + //Run the executable again + try { + //Prepare the system before re-launch the command + prepare(context, relaunchable); - //Re-execute the command - List<SyncResultExecutable> executables = - relaunchable.getExecutables(); - int cc = executables.size(); - for (int i = 0; i < cc; i++) { - SyncResultExecutable executable = executables.get(i); - Object result = CommandHelper.reexecute( - context, executable, null); - if (relaunchable.getTask() != null) { - relaunchable.getTask().execute(result); - } - } + //Re-execute the command + List<SyncResultExecutable> executables = relaunchable.getExecutables(); + int cc = executables.size(); + for (int i = 0; i < cc; i++) { + SyncResultExecutable executable = executables.get(i); + Object result = CommandHelper.reexecute(context, executable, null); + AsyncTask<Object, Integer, Boolean> task = relaunchable.getTask(); + if (task != null && task.getStatus() != AsyncTask.Status.RUNNING) { + task.execute(result); + } + } - // Operation complete - if (listener != null) { - listener.onSuccess(); - } + // Operation complete + if (listener != null) { + listener.onSuccess(); + } - } catch (Throwable ex) { - //Capture the exception, this time in quiet mode, if the - //exception is the same - boolean ask = - ex.getClass().getName().compareTo( - relaunchable.getClass().getName()) == 0; - translateException( - context, ex, quiet, !ask, listener); + } catch (Throwable ex) { + //Capture the exception, this time in quiet mode, if the + //exception is the same + boolean ask = ex.getClass().getName().compareTo( + relaunchable.getClass().getName()) == 0; + translateException(context, ex, quiet, !ask, listener); - // Operation failed - if (listener != null) { - listener.onFailed(ex); - } - } - } else { - // Operation cancelled - if (listener != null) { - listener.onCancelled(); - } - } + // Operation failed + if (listener != null) { + listener.onFailed(ex); } - }); + } + } else { + // Operation cancelled + if (listener != null) { + listener.onCancelled(); + } + } + } + }; + + AlertDialog alert = DialogHelper.createYesNoDialog( + context, + R.string.confirm_operation, + relaunchable.getQuestionResourceId(), + clickListener); + alert.setOnDismissListener(new DialogInterface.OnDismissListener() { @Override public void onDismiss(DialogInterface dialog) { |
