diff options
author | Mike Lockwood <lockwood@android.com> | 2010-09-09 14:16:22 -0400 |
---|---|---|
committer | Mike Lockwood <lockwood@android.com> | 2010-09-09 16:00:22 -0400 |
commit | 8490e66f57506d4e4b05e7c987c7ca34295843e6 (patch) | |
tree | 3313a9ecd898a5ebad11345519fc83e8555afde7 | |
parent | 792ec849e5bc27c090c62f578846b888fa43e0d6 (diff) | |
download | frameworks_base-8490e66f57506d4e4b05e7c987c7ca34295843e6.zip frameworks_base-8490e66f57506d4e4b05e7c987c7ca34295843e6.tar.gz frameworks_base-8490e66f57506d4e4b05e7c987c7ca34295843e6.tar.bz2 |
Use separate Uris for MTP to the media provider files table
Separating the Uris for local and MTP access to the database will
allow us to handle MTP originated queries differently in the provider.
Change-Id: I78d1c0a0e656eddee1e17212a79157f67ca46b38
Signed-off-by: Mike Lockwood <lockwood@android.com>
-rw-r--r-- | core/java/android/provider/MediaStore.java | 21 | ||||
-rw-r--r-- | media/java/android/media/MtpDatabase.java | 8 |
2 files changed, 21 insertions, 8 deletions
diff --git a/core/java/android/provider/MediaStore.java b/core/java/android/provider/MediaStore.java index 2b8a8e6..d3718f8 100644 --- a/core/java/android/provider/MediaStore.java +++ b/core/java/android/provider/MediaStore.java @@ -273,7 +273,9 @@ public final class MediaStore { } /** - * Media provider interface used by MTP implementation. + * Media provider table containing an index of all files in the storage. + * This can be used by applications to find all documents of a particular type + * and is also used internally by the device side MTP implementation. * @hide */ public static final class Files { @@ -289,11 +291,22 @@ public final class MediaStore { + "/file/" + fileId); } - // used for MTP GetObjectReferences and SetObjectReferences - public static final Uri getReferencesUri(String volumeName, + public static Uri getMtpObjectsUri(String volumeName) { + return Uri.parse(CONTENT_AUTHORITY_SLASH + volumeName + + "/object"); + } + + public static final Uri getMtpObjectsUri(String volumeName, + long fileId) { + return Uri.parse(CONTENT_AUTHORITY_SLASH + volumeName + + "/object/" + fileId); + } + + // Used to implement the MTP GetObjectReferences and SetObjectReferences commands. + public static final Uri getMtpReferencesUri(String volumeName, long fileId) { return Uri.parse(CONTENT_AUTHORITY_SLASH + volumeName - + "/file/" + fileId + "/references"); + + "/object/" + fileId + "/references"); } /** diff --git a/media/java/android/media/MtpDatabase.java b/media/java/android/media/MtpDatabase.java index 536d49f..ad029a6 100644 --- a/media/java/android/media/MtpDatabase.java +++ b/media/java/android/media/MtpDatabase.java @@ -89,7 +89,7 @@ public class MtpDatabase { mContext = context; mMediaProvider = context.getContentResolver().acquireProvider("media"); mVolumeName = volumeName; - mObjectsUri = Files.getContentUri(volumeName); + mObjectsUri = Files.getMtpObjectsUri(volumeName); mMediaScanner = new MediaScanner(context); openDevicePropertiesDatabase(context); } @@ -481,7 +481,7 @@ public class MtpDatabase { private int deleteFile(int handle) { Log.d(TAG, "deleteFile: " + handle); mDatabaseModified = true; - Uri uri = Files.getContentUri(mVolumeName, handle); + Uri uri = Files.getMtpObjectsUri(mVolumeName, handle); try { if (mMediaProvider.delete(uri, null, null) == 1) { return MtpConstants.RESPONSE_OK; @@ -496,7 +496,7 @@ public class MtpDatabase { private int[] getObjectReferences(int handle) { Log.d(TAG, "getObjectReferences for: " + handle); - Uri uri = Files.getReferencesUri(mVolumeName, handle); + Uri uri = Files.getMtpReferencesUri(mVolumeName, handle); Cursor c = null; try { c = mMediaProvider.query(uri, ID_PROJECTION, null, null, null); @@ -524,7 +524,7 @@ public class MtpDatabase { private int setObjectReferences(int handle, int[] references) { mDatabaseModified = true; - Uri uri = Files.getReferencesUri(mVolumeName, handle); + Uri uri = Files.getMtpReferencesUri(mVolumeName, handle); int count = references.length; ContentValues[] valuesList = new ContentValues[count]; for (int i = 0; i < count; i++) { |