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

Commit fa1e5561 authored by Mike Lockwood's avatar Mike Lockwood Committed by Android Git Automerger
Browse files

am 53b988ba: am 5a79cfd7: am 27ac64ec: Merge "StorageVolume: Add...

am 53b988ba: am 5a79cfd7: am 27ac64ec: Merge "StorageVolume: Add getStorageId() accessor" into honeycomb-mr2

* commit '53b988ba':
  StorageVolume: Add getStorageId() accessor
parents 74bafe40 53b988ba
Loading
Loading
Loading
Loading
+36 −3
Original line number Original line Diff line number Diff line
@@ -34,10 +34,10 @@ public class StorageVolume implements Parcelable {
    private final boolean mRemovable;
    private final boolean mRemovable;
    private final boolean mEmulated;
    private final boolean mEmulated;
    private final int mMtpReserveSpace;
    private final int mMtpReserveSpace;
    private int mStorageId;


    public StorageVolume(String path, String description,
    public StorageVolume(String path, String description,
            boolean removable, boolean emulated,
            boolean removable, boolean emulated, int mtpReserveSpace) {
            int mtpReserveSpace) {
        mPath = path;
        mPath = path;
        mDescription = description;
        mDescription = description;
        mRemovable = removable;
        mRemovable = removable;
@@ -45,6 +45,17 @@ public class StorageVolume implements Parcelable {
        mMtpReserveSpace = mtpReserveSpace;
        mMtpReserveSpace = mtpReserveSpace;
    }
    }


    // for parcelling only
    private StorageVolume(String path, String description,
            boolean removable, boolean emulated, int mtpReserveSpace, int storageId) {
        mPath = path;
        mDescription = description;
        mRemovable = removable;
        mEmulated = emulated;
        mMtpReserveSpace = mtpReserveSpace;
        mStorageId = storageId;
    }

    /**
    /**
     * Returns the mount path for the volume.
     * Returns the mount path for the volume.
     *
     *
@@ -81,6 +92,25 @@ public class StorageVolume implements Parcelable {
        return mEmulated;
        return mEmulated;
    }
    }


    /**
     * Returns the MTP storage ID for the volume.
     * this is also used for the storage_id column in the media provider.
     *
     * @return MTP storage ID
     */
    public int getStorageId() {
        return mStorageId;
    }

    /**
     * Do not call this unless you are MountService
     */
    public void setStorageId(int index) {
        // storage ID is 0x00010001 for primary storage,
        // then 0x00020001, 0x00030001, etc. for secondary storages
        mStorageId = ((index + 1) << 16) + 1;
    }

    /**
    /**
     * Number of megabytes of space to leave unallocated by MTP.
     * Number of megabytes of space to leave unallocated by MTP.
     * MTP will subtract this value from the free space it reports back
     * MTP will subtract this value from the free space it reports back
@@ -123,9 +153,11 @@ public class StorageVolume implements Parcelable {
            String description = in.readString();
            String description = in.readString();
            int removable = in.readInt();
            int removable = in.readInt();
            int emulated = in.readInt();
            int emulated = in.readInt();
            int storageId = in.readInt();
            int mtpReserveSpace = in.readInt();
            int mtpReserveSpace = in.readInt();
            return new StorageVolume(path, description,
            return new StorageVolume(path, description,
                    removable == 1, emulated == 1, mtpReserveSpace);
                    removable == 1, emulated == 1,
                    mtpReserveSpace, storageId);
        }
        }


        public StorageVolume[] newArray(int size) {
        public StorageVolume[] newArray(int size) {
@@ -142,6 +174,7 @@ public class StorageVolume implements Parcelable {
        parcel.writeString(mDescription);
        parcel.writeString(mDescription);
        parcel.writeInt(mRemovable ? 1 : 0);
        parcel.writeInt(mRemovable ? 1 : 0);
        parcel.writeInt(mEmulated ? 1 : 0);
        parcel.writeInt(mEmulated ? 1 : 0);
        parcel.writeInt(mStorageId);
        parcel.writeInt(mMtpReserveSpace);
        parcel.writeInt(mMtpReserveSpace);
    }
    }
}
}
+8 −7
Original line number Original line Diff line number Diff line
@@ -16,6 +16,8 @@


package android.mtp;
package android.mtp;


import android.os.storage.StorageVolume;

/**
/**
 * This class represents a storage unit on an MTP device.
 * This class represents a storage unit on an MTP device.
 * Used only for MTP support in USB responder mode.
 * Used only for MTP support in USB responder mode.
@@ -31,13 +33,12 @@ public class MtpStorage {
    private final long mReserveSpace;
    private final long mReserveSpace;
    private final boolean mRemovable;
    private final boolean mRemovable;


    public MtpStorage(int id, String path, String description,
    public MtpStorage(StorageVolume volume) {
            long reserveSpace, boolean removable) {
        mStorageId = volume.getStorageId();
        mStorageId = id;
        mPath = volume.getPath();
        mPath = path;
        mDescription = volume.getDescription();
        mDescription = description;
        mReserveSpace = volume.getMtpReserveSpace();
        mReserveSpace = reserveSpace;
        mRemovable = volume.isRemovable();
        mRemovable = removable;
    }
    }


    /**
    /**
+5 −0
Original line number Original line Diff line number Diff line
@@ -1148,6 +1148,11 @@ class MountService extends IMountService.Stub implements INativeDaemonConnectorC
        } catch (IOException e) {
        } catch (IOException e) {
            throw new RuntimeException(e);
            throw new RuntimeException(e);
        } finally {
        } finally {
            // compute storage ID for each volume
            int length = mVolumes.size();
            for (int i = 0; i < length; i++) {
                mVolumes.get(i).setStorageId(i);
            }
            parser.close();
            parser.close();
        }
        }
    }
    }