Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit b34d8ace authored by Danny Baumann's avatar Danny Baumann
Browse files

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
parent e1ca2730
Loading
Loading
Loading
Loading
+0 −2
Original line number Diff line number Diff line
@@ -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;
+9 −0
Original line number Diff line number Diff line
@@ -67,6 +67,15 @@ public abstract class Shell extends Command {
        this.mPid = pid;
    }

    /**
     * Method that returns the desired runtime environment of the console
     *
     * @return The environment
     */
    public String[] getEnvironment() {
        return null;
    }

    /**
     * {@inheritDoc}
     */
+11 −0
Original line number Diff line number Diff line
@@ -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>.
     *
@@ -44,6 +48,13 @@ public class SuperuserShell extends Shell {
        super(ID, ShellHelper.getProgramCmdLine(new BashShell()));
    }

    /**
     * {@inheritDoc}
     */
    public String[] getEnvironment() {
        return MOUNT_STORAGE_ENV;
    }

    /**
     * {@inheritDoc}
     */
+5 −3
Original line number Diff line number Diff line
@@ -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
+11 −0
Original line number Diff line number Diff line
@@ -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
Loading