summaryrefslogtreecommitdiffstats
path: root/media
diff options
context:
space:
mode:
authorMike Lockwood <lockwood@android.com>2010-10-11 11:22:19 -0400
committerMike Lockwood <lockwood@android.com>2010-10-11 11:22:19 -0400
commit01788562f26f213f63c14483fd3977e23b8314ab (patch)
tree22087cb70faee73df39403f9673133bd272898d3 /media
parent3e13c1b705af78f4fa20a38cb144d2a747894e88 (diff)
downloadframeworks_base-01788562f26f213f63c14483fd3977e23b8314ab.zip
frameworks_base-01788562f26f213f63c14483fd3977e23b8314ab.tar.gz
frameworks_base-01788562f26f213f63c14483fd3977e23b8314ab.tar.bz2
MTP: Fix copying files to root of storage using parent handle = 0
Change-Id: Ie732c5778e9424512b2ddecd87779f8c55668deb Signed-off-by: Mike Lockwood <lockwood@android.com>
Diffstat (limited to 'media')
-rw-r--r--media/java/android/media/MtpDatabase.java11
1 files changed, 10 insertions, 1 deletions
diff --git a/media/java/android/media/MtpDatabase.java b/media/java/android/media/MtpDatabase.java
index 630d7112e..fa015cc 100644
--- a/media/java/android/media/MtpDatabase.java
+++ b/media/java/android/media/MtpDatabase.java
@@ -42,6 +42,7 @@ public class MtpDatabase {
private final IContentProvider mMediaProvider;
private final String mVolumeName;
private final Uri mObjectsUri;
+ private final String mMediaStoragePath;
// true if the database has been modified in the current MTP session
private boolean mDatabaseModified;
@@ -84,12 +85,13 @@ public class MtpDatabase {
System.loadLibrary("media_jni");
}
- public MtpDatabase(Context context, String volumeName) {
+ public MtpDatabase(Context context, String volumeName, String storagePath) {
native_setup();
mContext = context;
mMediaProvider = context.getContentResolver().acquireProvider("media");
mVolumeName = volumeName;
+ mMediaStoragePath = storagePath;
mObjectsUri = Files.getMtpObjectsUri(volumeName);
mMediaScanner = new MediaScanner(context);
openDevicePropertiesDatabase(context);
@@ -701,6 +703,13 @@ public class MtpDatabase {
private int getObjectFilePath(int handle, char[] outFilePath, long[] outFileLength) {
Log.d(TAG, "getObjectFilePath: " + handle);
+ if (handle == 0) {
+ // special case root directory
+ mMediaStoragePath.getChars(0, mMediaStoragePath.length(), outFilePath, 0);
+ outFilePath[mMediaStoragePath.length()] = 0;
+ outFileLength[0] = 0;
+ return MtpConstants.RESPONSE_OK;
+ }
Cursor c = null;
try {
c = mMediaProvider.query(mObjectsUri, PATH_SIZE_PROJECTION,