diff options
author | Sumit Bajpai <sbajpai@codeaurora.org> | 2015-11-03 11:29:09 +0530 |
---|---|---|
committer | Gerrit - the friendly Code Review server <code-review@localhost> | 2015-11-05 01:16:04 -0800 |
commit | 01e70d1c9f50b304639c8d8a0a26c86e6683f296 (patch) | |
tree | 69a9f69aae4f60c220748e2139d6c824aa839849 | |
parent | 41b66fc0cdcf79b8475e35a1f31d764ef8603a56 (diff) | |
download | android_packages_apps_Bluetooth-01e70d1c9f50b304639c8d8a0a26c86e6683f296.tar.gz android_packages_apps_Bluetooth-01e70d1c9f50b304639c8d8a0a26c86e6683f296.tar.bz2 android_packages_apps_Bluetooth-01e70d1c9f50b304639c8d8a0a26c86e6683f296.zip |
AVRCP1.5: Correct content resolver query for playlist items.
When changepath is requested by remote to playlist items inside
any playlist, we return only single media item count in response.
This is because of incorrect query for content resolver.
This change properly fetches the playlist media items from content
resolver.
Change-Id: I73e1c9ceec611ef806b6f1b4e2d3c5f20509490e
-rw-r--r-- | src/com/android/bluetooth/avrcp/Avrcp.java | 37 |
1 files changed, 21 insertions, 16 deletions
diff --git a/src/com/android/bluetooth/avrcp/Avrcp.java b/src/com/android/bluetooth/avrcp/Avrcp.java index 14ebb71fa..cffb64876 100644 --- a/src/com/android/bluetooth/avrcp/Avrcp.java +++ b/src/com/android/bluetooth/avrcp/Avrcp.java @@ -2418,28 +2418,33 @@ public final class Avrcp { case FOLDER_DOWN: if (deviceFeatures[deviceIndex].mCurrentPathUid == null) { Cursor cursor = null; + String[] playlistMemberCols = new String[] { + MediaStore.Audio.Playlists.Members._ID, + MediaStore.Audio.Media.TITLE, + MediaStore.Audio.Media.DATA, + MediaStore.Audio.Media.ALBUM, + MediaStore.Audio.Media.ARTIST, + MediaStore.Audio.Media.DURATION, + MediaStore.Audio.Playlists.Members.PLAY_ORDER, + MediaStore.Audio.Playlists.Members.AUDIO_ID, + MediaStore.Audio.Media.IS_MUSIC + }; try { - String[] cols = new String[] { - MediaStore.Audio.Playlists._ID, - MediaStore.Audio.Playlists.NAME - }; - + Uri uri = MediaStore.Audio.Playlists.Members.getContentUri("external", + folderUid); StringBuilder where = new StringBuilder(); - where.append(MediaStore.Audio.Playlists.NAME + " != ''"); - - cursor = mContext.getContentResolver().query( - MediaStore.Audio.Playlists.EXTERNAL_CONTENT_URI, - cols, MediaStore.Audio.Playlists._ID + "=" + folderUid, - null, null); - - if ((cursor == null) || (cursor.getCount() == 0)) { - status = DOES_NOT_EXIST; - } else{ - numberOfItems = cursor.getCount(); + where.append(MediaStore.Audio.Media.TITLE + " != ''"); + cursor = mContext.getContentResolver().query(uri, playlistMemberCols, + where.toString(), null, + MediaStore.Audio.Playlists.Members.DEFAULT_SORT_ORDER); + if (cursor != null) { + numberOfItems = cursor.getCount(); deviceFeatures[deviceIndex].mCurrentPathUid = String.valueOf(folderUid); deviceFeatures[deviceIndex].mCurrentPath = PATH_PLAYLISTS; + } else { + status = DOES_NOT_EXIST; } } catch (Exception e) { Log.e(TAG, "Exception " + e); |