Loading core/java/android/os/storage/StorageVolume.java +36 −3 Original line number Original line Diff line number Diff line Loading @@ -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; Loading @@ -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. * * Loading Loading @@ -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 Loading Loading @@ -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) { Loading @@ -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); } } } } media/java/android/mtp/MtpStorage.java +8 −7 Original line number Original line Diff line number Diff line Loading @@ -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. Loading @@ -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; } } /** /** Loading services/java/com/android/server/MountService.java +5 −0 Original line number Original line Diff line number Diff line Loading @@ -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(); } } } } Loading Loading
core/java/android/os/storage/StorageVolume.java +36 −3 Original line number Original line Diff line number Diff line Loading @@ -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; Loading @@ -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. * * Loading Loading @@ -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 Loading Loading @@ -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) { Loading @@ -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); } } } }
media/java/android/mtp/MtpStorage.java +8 −7 Original line number Original line Diff line number Diff line Loading @@ -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. Loading @@ -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; } } /** /** Loading
services/java/com/android/server/MountService.java +5 −0 Original line number Original line Diff line number Diff line Loading @@ -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(); } } } } Loading