diff options
author | Mike Lockwood <lockwood@android.com> | 2010-11-19 11:20:19 -0500 |
---|---|---|
committer | Mike Lockwood <lockwood@android.com> | 2010-11-19 11:30:10 -0500 |
commit | 954c267725d64a37655d6f3a00de6a5aa00ddaf8 (patch) | |
tree | 9e3681b141c3bc3f6df5c93712bb56067baa06e3 /core | |
parent | a8bbc11afc0f93143c1fd200108a51c95507cc43 (diff) | |
download | frameworks_base-954c267725d64a37655d6f3a00de6a5aa00ddaf8.zip frameworks_base-954c267725d64a37655d6f3a00de6a5aa00ddaf8.tar.gz frameworks_base-954c267725d64a37655d6f3a00de6a5aa00ddaf8.tar.bz2 |
PTP: Improve performance and reliability of file importing
Now the file copy is done completely within the media process
rather than pushing data to the client via ContProvider.openFile().
File system writes are now interleaved with USB reads, which allows us
to copy the data faster and prevents the camera from timing out during transfer.
File is automatically inserted in the media provider after a successful import
and a Uri is returned to the client.
BUG: 2994234
Change-Id: Ie75c63da76f623343d3d966c6a707aa1ae871972
Signed-off-by: Mike Lockwood <lockwood@android.com>
Diffstat (limited to 'core')
-rw-r--r-- | core/java/android/provider/Mtp.java | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/core/java/android/provider/Mtp.java b/core/java/android/provider/Mtp.java index de161e7..78110ef 100644 --- a/core/java/android/provider/Mtp.java +++ b/core/java/android/provider/Mtp.java @@ -113,6 +113,25 @@ public final class Mtp } /** + * Used for copying files from device to host. + * Constructs a Uri based on the ID of the device and object for the source file, + * and the path for the destination file. + * When passed to the ContentProvider.insert() method, the file will be transferred + * to the specified destination directory and insert() will return a content Uri + * for the new file in the MediaProvider. + * ContentProvider.insert() will throw IllegalArgumentException if the destination + * path is not in the external storage or internal media directory. + */ + public static Uri getContentUriForImport(int deviceID, long objectID, String destPath) { + if (destPath.length() == 0 || destPath.charAt(0) != '/') { + throw new IllegalArgumentException( + "destPath must be a full path in getContentUriForImport"); + } + return Uri.parse(CONTENT_AUTHORITY_DEVICE_SLASH + deviceID + + "/import/" + objectID + "?" + destPath); + } + + /** * The following columns correspond to the fields in the ObjectInfo dataset * as described in the MTP specification. */ |