diff options
author | Jeff Sharkey <jsharkey@android.com> | 2019-04-17 11:16:12 -0600 |
---|---|---|
committer | Jeff Sharkey <jsharkey@android.com> | 2019-04-17 11:16:15 -0600 |
commit | 42bf6d8a421c98a171d3e8fc80a4bcd3bbaabddc (patch) | |
tree | 3ba3d8d14099cc9b0a7f075f582c66479a12d77c /media/java/android/mtp/MtpStorage.java | |
parent | 469f1c90ed7a414144c3752ff493722cc1af2904 (diff) |
Adjust MTP to reference by specific volume name.
The MediaStore.VOLUME_EXTERNAL volume is a merged view of all storage
devices, and clients working on a specific volume need to focus on
the volume they're interested in.
Bug: 129840030
Test: atest --test-mapping packages/providers/MediaProvider
Change-Id: I91cee6a96d7f9360e6a93a9a3c389b097b6b9967
Diffstat (limited to 'media/java/android/mtp/MtpStorage.java')
-rw-r--r-- | media/java/android/mtp/MtpStorage.java | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/media/java/android/mtp/MtpStorage.java b/media/java/android/mtp/MtpStorage.java index c714b3cad296..65d0fef74b25 100644 --- a/media/java/android/mtp/MtpStorage.java +++ b/media/java/android/mtp/MtpStorage.java @@ -18,6 +18,7 @@ package android.mtp; import android.annotation.UnsupportedAppUsage; import android.os.storage.StorageVolume; +import android.provider.MediaStore; /** * This class represents a storage unit on an MTP device. @@ -27,12 +28,12 @@ import android.os.storage.StorageVolume; * @hide */ public class MtpStorage { - private final int mStorageId; private final String mPath; private final String mDescription; private final boolean mRemovable; private final long mMaxFileSize; + private final String mVolumeName; public MtpStorage(StorageVolume volume, int storageId) { mStorageId = storageId; @@ -40,6 +41,11 @@ public class MtpStorage { mDescription = volume.getDescription(null); mRemovable = volume.isRemovable(); mMaxFileSize = volume.getMaxFileSize(); + if (volume.isPrimary()) { + mVolumeName = MediaStore.VOLUME_EXTERNAL_PRIMARY; + } else { + mVolumeName = volume.getNormalizedUuid(); + } } /** @@ -88,4 +94,8 @@ public class MtpStorage { public long getMaxFileSize() { return mMaxFileSize; } + + public String getVolumeName() { + return mVolumeName; + } } |