diff options
author | Mike Lockwood <lockwood@android.com> | 2011-06-17 13:44:24 -0400 |
---|---|---|
committer | Mike Lockwood <lockwood@android.com> | 2011-06-17 19:49:05 -0400 |
commit | 6acc90fc216530f0a5bbf7339066af9b415cbb02 (patch) | |
tree | d394f890708081eacd5f17de0389a3f75fc8511d /media/java/android/mtp | |
parent | 5787a2d5b4e5bd60087eb7fbb13c97c7d0ba113e (diff) | |
download | frameworks_base-6acc90fc216530f0a5bbf7339066af9b415cbb02.zip frameworks_base-6acc90fc216530f0a5bbf7339066af9b415cbb02.tar.gz frameworks_base-6acc90fc216530f0a5bbf7339066af9b415cbb02.tar.bz2 |
MTP: Fix some problems with GetObjectHandles and GetNumObjects commands
These calls did not correctly handle some variants of the arguments,
which showed up when running in PTP mode.
Change-Id: Iedbaefebfa39111c8bcaee7c6cc3820a65d6c98f
Signed-off-by: Mike Lockwood <lockwood@android.com>
Diffstat (limited to 'media/java/android/mtp')
-rw-r--r-- | media/java/android/mtp/MtpDatabase.java | 90 |
1 files changed, 68 insertions, 22 deletions
diff --git a/media/java/android/mtp/MtpDatabase.java b/media/java/android/mtp/MtpDatabase.java index c9e0f6f..4e271c7 100644 --- a/media/java/android/mtp/MtpDatabase.java +++ b/media/java/android/mtp/MtpDatabase.java @@ -92,13 +92,18 @@ public class MtpDatabase { }; private static final String ID_WHERE = Files.FileColumns._ID + "=?"; private static final String PATH_WHERE = Files.FileColumns.DATA + "=?"; - private static final String PARENT_WHERE = Files.FileColumns.PARENT + "=?"; - private static final String PARENT_FORMAT_WHERE = PARENT_WHERE + " AND " - + Files.FileColumns.FORMAT + "=?"; - private static final String PARENT_STORAGE_WHERE = PARENT_WHERE + " AND " - + Files.FileColumns.STORAGE_ID + "=?"; - private static final String PARENT_STORAGE_FORMAT_WHERE = PARENT_STORAGE_WHERE + " AND " + + private static final String STORAGE_WHERE = Files.FileColumns.STORAGE_ID + "=?"; + private static final String FORMAT_WHERE = Files.FileColumns.PARENT + "=?"; + private static final String PARENT_WHERE = Files.FileColumns.FORMAT + "=?"; + private static final String STORAGE_FORMAT_WHERE = STORAGE_WHERE + " AND " + Files.FileColumns.FORMAT + "=?"; + private static final String STORAGE_PARENT_WHERE = STORAGE_WHERE + " AND " + + Files.FileColumns.PARENT + "=?"; + private static final String FORMAT_PARENT_WHERE = FORMAT_WHERE + " AND " + + Files.FileColumns.PARENT + "=?"; + private static final String STORAGE_FORMAT_PARENT_WHERE = STORAGE_FORMAT_WHERE + " AND " + + Files.FileColumns.PARENT + "=?"; private final MediaScanner mMediaScanner; @@ -249,26 +254,67 @@ public class MtpDatabase { } private Cursor createObjectQuery(int storageID, int format, int parent) throws RemoteException { - if (storageID != 0) { - if (format != 0) { - return mMediaProvider.query(mObjectsUri, ID_PROJECTION, - PARENT_STORAGE_FORMAT_WHERE, - new String[] { Integer.toString(parent), Integer.toString(storageID), - Integer.toString(format) }, null); + if (storageID == 0xFFFFFFFF) { + // query all stores + if (format == 0) { + // query all formats + if (parent == 0) { + // query all objects + return mMediaProvider.query(mObjectsUri, ID_PROJECTION, null, null, null); + } + if (parent == 0xFFFFFFFF) { + // all objects in root of store + parent = 0; + } + return mMediaProvider.query(mObjectsUri, ID_PROJECTION, PARENT_WHERE, + new String[] { Integer.toString(parent) }, null); } else { - return mMediaProvider.query(mObjectsUri, ID_PROJECTION, - PARENT_STORAGE_WHERE, new String[] - { Integer.toString(parent), Integer.toString(storageID) }, null); + // query specific format + if (parent == 0) { + // query all objects + return mMediaProvider.query(mObjectsUri, ID_PROJECTION, FORMAT_WHERE, + new String[] { Integer.toString(format) }, null); + } + if (parent == 0xFFFFFFFF) { + // all objects in root of store + parent = 0; + } + return mMediaProvider.query(mObjectsUri, ID_PROJECTION, FORMAT_PARENT_WHERE, + new String[] { Integer.toString(format), Integer.toString(parent) }, null); } } else { - if (format != 0) { - return mMediaProvider.query(mObjectsUri, ID_PROJECTION, - PARENT_FORMAT_WHERE, - new String[] { Integer.toString(parent), Integer.toString(format) }, - null); + // query specific store + if (format == 0) { + // query all formats + if (parent == 0) { + // query all objects + return mMediaProvider.query(mObjectsUri, ID_PROJECTION, STORAGE_WHERE, + new String[] { Integer.toString(storageID) }, null); + } + if (parent == 0xFFFFFFFF) { + // all objects in root of store + parent = 0; + } + return mMediaProvider.query(mObjectsUri, ID_PROJECTION, STORAGE_PARENT_WHERE, + new String[] { Integer.toString(storageID), Integer.toString(parent) }, + null); } else { - return mMediaProvider.query(mObjectsUri, ID_PROJECTION, - PARENT_WHERE, new String[] { Integer.toString(parent) }, null); + // query specific format + if (parent == 0) { + // query all objects + return mMediaProvider.query(mObjectsUri, ID_PROJECTION, STORAGE_FORMAT_WHERE, + new String[] { Integer.toString(storageID), Integer.toString(format) }, + null); + } + if (parent == 0xFFFFFFFF) { + // all objects in root of store + parent = 0; + } + return mMediaProvider.query(mObjectsUri, ID_PROJECTION, STORAGE_FORMAT_PARENT_WHERE, + new String[] { Integer.toString(storageID), + Integer.toString(format), + Integer.toString(parent) }, + null); } } } |