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

Commit c5c75c8b authored by Jerry Zhang's avatar Jerry Zhang Committed by android-build-merger
Browse files

Merge "Access removable volumes through /mnt/media_rw" into pi-dev am: 1e62b676

am: 9e1d1345

Change-Id: I68bf226aaf424c9f0e7e54fe7817050ab6d4208c
parents e54e4adb 9e1d1345
Loading
Loading
Loading
Loading
+17 −2
Original line number Diff line number Diff line
@@ -78,6 +78,7 @@ public final class StorageVolume implements Parcelable {

    private final String mId;
    private final File mPath;
    private final File mInternalPath;
    private final String mDescription;
    private final boolean mPrimary;
    private final boolean mRemovable;
@@ -118,11 +119,12 @@ public final class StorageVolume implements Parcelable {
    public static final int STORAGE_ID_PRIMARY = 0x00010001;

    /** {@hide} */
    public StorageVolume(String id, File path, String description, boolean primary,
            boolean removable, boolean emulated, boolean allowMassStorage,
    public StorageVolume(String id, File path, File internalPath, String description,
            boolean primary, boolean removable, boolean emulated, boolean allowMassStorage,
            long maxFileSize, UserHandle owner, String fsUuid, String state) {
        mId = Preconditions.checkNotNull(id);
        mPath = Preconditions.checkNotNull(path);
        mInternalPath = Preconditions.checkNotNull(internalPath);
        mDescription = Preconditions.checkNotNull(description);
        mPrimary = primary;
        mRemovable = removable;
@@ -137,6 +139,7 @@ public final class StorageVolume implements Parcelable {
    private StorageVolume(Parcel in) {
        mId = in.readString();
        mPath = new File(in.readString());
        mInternalPath = new File(in.readString());
        mDescription = in.readString();
        mPrimary = in.readInt() != 0;
        mRemovable = in.readInt() != 0;
@@ -163,6 +166,16 @@ public final class StorageVolume implements Parcelable {
        return mPath.toString();
    }

    /**
     * Returns the path of the underlying filesystem.
     *
     * @return the internal path
     * @hide
     */
    public String getInternalPath() {
        return mInternalPath.toString();
    }

    /** {@hide} */
    public File getPathFile() {
        return mPath;
@@ -351,6 +364,7 @@ public final class StorageVolume implements Parcelable {
        pw.increaseIndent();
        pw.printPair("mId", mId);
        pw.printPair("mPath", mPath);
        pw.printPair("mInternalPath", mInternalPath);
        pw.printPair("mDescription", mDescription);
        pw.printPair("mPrimary", mPrimary);
        pw.printPair("mRemovable", mRemovable);
@@ -384,6 +398,7 @@ public final class StorageVolume implements Parcelable {
    public void writeToParcel(Parcel parcel, int flags) {
        parcel.writeString(mId);
        parcel.writeString(mPath.toString());
        parcel.writeString(mInternalPath.toString());
        parcel.writeString(mDescription);
        parcel.writeInt(mPrimary ? 1 : 0);
        parcel.writeInt(mRemovable ? 1 : 0);
+5 −1
Original line number Diff line number Diff line
@@ -333,6 +333,10 @@ public class VolumeInfo implements Parcelable {
        if (userPath == null) {
            userPath = new File("/dev/null");
        }
        File internalPath = getInternalPathForUser(userId);
        if (internalPath == null) {
            internalPath = new File("/dev/null");
        }

        String description = null;
        String derivedFsUuid = fsUuid;
@@ -371,7 +375,7 @@ public class VolumeInfo implements Parcelable {
            description = context.getString(android.R.string.unknownName);
        }

        return new StorageVolume(id, userPath, description, isPrimary(), removable,
        return new StorageVolume(id, userPath, internalPath, description, isPrimary(), removable,
                emulated, allowMassStorage, maxFileSize, new UserHandle(userId),
                derivedFsUuid, envState);
    }
+1 −2
Original line number Diff line number Diff line
@@ -16,7 +16,6 @@

package android.mtp;

import android.content.Context;
import android.os.storage.StorageVolume;

/**
@@ -36,7 +35,7 @@ public class MtpStorage {

    public MtpStorage(StorageVolume volume, int storageId) {
        mStorageId = storageId;
        mPath = volume.getPath();
        mPath = volume.getInternalPath();
        mDescription = volume.getDescription(null);
        mRemovable = volume.isRemovable();
        mMaxFileSize = volume.getMaxFileSize();
+1 −1
Original line number Diff line number Diff line
@@ -399,8 +399,8 @@ public class MtpStorageManager {
     */
    public synchronized MtpStorage addMtpStorage(StorageVolume volume) {
        int storageId = ((getNextStorageId() & 0x0000FFFF) << 16) + 1;
        MtpObject root = new MtpObject(volume.getPath(), storageId, null, true);
        MtpStorage storage = new MtpStorage(volume, storageId);
        MtpObject root = new MtpObject(storage.getPath(), storageId, null, true);
        mRoots.put(storageId, root);
        return storage;
    }
+1 −1
Original line number Diff line number Diff line
@@ -2795,7 +2795,7 @@ class StorageManagerService extends IStorageManager.Stub
            final String uuid = null;
            final String state = Environment.MEDIA_REMOVED;

            res.add(0, new StorageVolume(id, path,
            res.add(0, new StorageVolume(id, path, path,
                    description, primary, removable, emulated,
                    allowMassStorage, maxFileSize, owner, uuid, state));
        }