History log of /packages/apps/Bluetooth/src/com/android/bluetooth/avrcp/AddressedMediaPlayer.java
Revision Date Author Comments (<<< Hide modified files) (Show modified files >>>)
b8d861656aa343ebec4c099cbf8fb468f2012be5 29-Aug-2017 Ajay Panicker <apanicke@google.com> Use the current item in the existing queue rather than using metadata

GPM adds additional info into the bundle under a specific key which contains
extra metadata. When a carkit (Magneti BMW does this) requests UID 0 with
getItemAttributes, we would construct a queueItem out of the current song.
This breaks with GPM as the metadata returned from getMetadata() from their
MediaController would not be filled or contain this additional bundle. Instead
always use updateNowPlayingList as it can construct a queue with all the info
we have.

Bug: 65166802
Test: Test switching playlists in GPM with Magneti BWM and see that more info
other than the song title shows up.
Change-Id: Ie96b3a5eccb94b86337936c913c3e81b67745362
/packages/apps/Bluetooth/src/com/android/bluetooth/avrcp/AddressedMediaPlayer.java
67c982aed4e67772e155f934c2055c72b83f1f22 24-Aug-2017 Ajay Panicker <apanicke@google.com> Don't reject notifications and wait until new addressed player is ready (1/2)

There are some carkits like the ones found in the 2016 Honda CRZ and some
Audi's that do not follow the spec and do not honor reject pending notification
messages after switching players. This causes an issue whenever you switch
players, the metadata freezes due to the fact that the carkit never re-registers
for new track changed notifications. This patch removes the reject notification
and reorders the current notifications.

Bug: 64142363
Test: Test with Audi S7 and 2016 Honda CRZ and see that switching players works
TestTracker/105391/3975
Change-Id: Ifcc236c54ccbec8e8ec0bd7f16e62e4282361bac
/packages/apps/Bluetooth/src/com/android/bluetooth/avrcp/AddressedMediaPlayer.java
ef56c5471dda0dc624d99a18506f8c9330ed8327 31-Jul-2017 Ajay Panicker <apanicke@google.com> Check if now playing list is updated by comparing the current queue (1/3)

Bug: 64686424
Test: Connect to carkit and see that NowPlayingChanged only gets sent when the queue changes
Change-Id: I5da15e466462eaf88ab4918af38c19231adaeea3
/packages/apps/Bluetooth/src/com/android/bluetooth/avrcp/AddressedMediaPlayer.java
093a2e4d9aeaecb0d51d8b7c74b4466d368c31cf 04-Aug-2017 Ajay Panicker <apanicke@google.com> Remove dependency on delay by ignoring invalid playback states

Remove the dependency on delaying for a media update by instead
using the playback state and current metadata to determine current
song status.

Bug: 34471252
Test: Switch players on BMW carkit
Change-Id: I25532d6e47fbecc1357b78ce189cb9f411ecc256
/packages/apps/Bluetooth/src/com/android/bluetooth/avrcp/AddressedMediaPlayer.java
141eb4655cd1341641326d89bc16d87626baee84 30-Jun-2017 Ajay Panicker <apanicke@google.com> Extract metadata info from MediaPlayer.Queue added by Google Play Music

Bug: 63117921
Test: Test with BMW carkit which grabs next song info and see full metadata
TestTracker: 95441
Change-Id: I78f54e7dd4f9f46c6c5dfc7fbb9400d7214d23cc
/packages/apps/Bluetooth/src/com/android/bluetooth/avrcp/AddressedMediaPlayer.java
d65422f9b47bff59b12162fc51032eb633f0722f 23-Jun-2017 Ajay Panicker <apanicke@google.com> AVRCP: Fix NowPlayingList looping

When a controller requested GetFolderItems, we would sometimes send a
NowPlayingListChanged before responding to GetFolderItems, prompting a
new GetFolderItems request. This put us in an infinite loop.

Test: connect to BMW and note it actually works
Bug: 62775732

Change-Id: Idc669a03f71ed9ec6b211bb5c33fc98548cc9f85
/packages/apps/Bluetooth/src/com/android/bluetooth/avrcp/AddressedMediaPlayer.java
029b34a866c2f4ab132412ec2814fd500813c565 21-Jun-2017 Marie Janssen <jamuraa@google.com> Avrcp: redact media info

Let's redact some of that media info when we're not on debug/eng builds.

Test: play some music, adb logcat and observe
Bug: 62826797
Change-Id: Icf7e926508215eae70cd75bef3cddcc001218c50
(cherry picked from commit cc07ee436d00418ecc69ae3aace986f7fbf0823a)
/packages/apps/Bluetooth/src/com/android/bluetooth/avrcp/AddressedMediaPlayer.java
676768272f84bc3fef9068b6286b6f38cb1e8962 16-Jun-2017 Marie Janssen <jamuraa@google.com> AVRCP: Prevent multithread issues in cleanup

When cleaning up the object in doQuit it was possible to have multiple
threads updating at once, causing NullPointerExceptions in some cases.

Synchronize the startup and shutdown of the Avrcp object to prevent
this.

Test: toggle bluetooth rapidly
Bug: 62676895
Change-Id: I2618c7d7b21acb1f95cb67366d469da2fa88d4a4
(cherry picked from commit 9a5f80a6528d76153a7e97821f114f3370df89a5)
/packages/apps/Bluetooth/src/com/android/bluetooth/avrcp/AddressedMediaPlayer.java
d5b2445ec7ff3809c1c90a9b20784a6a861a037c 13-Jun-2017 Marie Janssen <jamuraa@google.com> AVRCP: Workaround Queue ID & metadata updates

When a player with a queue updates their track, it comes in two separate
parts from MediaController.Callback:
- Queue ID is in onPlaybackStateChanged
- Metadata is in onMetadataChanged

Because the ordering of these two is not specific, both must change
before we have a consistent data state to present the carkit if the
Media client has a queue.

Even though the only thing sent in the Track Changed notification is the
Queue ID, the request for metadata often comes before the Metadata has
been updated after that notification.

Refactor Track Changed notification to keep track of the last data we
sent to the controller, and send new tracks when both Queue ID and
Metadata have changed.

Test: various carkit testing with track skipping
Bug: 37707672
Change-Id: Ibf9f725f6912955a65421786068921489dbf8e45
(cherry picked from commit 5aca05c1d79f3412b6964b3b6335ad6f2d558756)
/packages/apps/Bluetooth/src/com/android/bluetooth/avrcp/AddressedMediaPlayer.java
4ffc87667492e40e448efa2ef5b11ae3de2f449b 06-Jun-2017 Marie Janssen <jamuraa@google.com> AVRCP: fix single item queue Now Playing issues

When queried (and in track change notifications) we previously returned
an item ID not allowed by the spec (0xFFFFFFFFFFFFFFFF) to a controller
when presenting a "single item queue" because the player doesn't provide
one.

Refactor the code so that the single item queue is persisted and send
NOW_PLAYING_CONTENT_CHANGED when the single item queue updates.

Tweak debugging of mediacontrollers for easier player debugging.

Test: check media info on honda carkit w/fm.player app
Bug: 62288178
Change-Id: Ic37d0c4c837436e102e9642e1f8e36e17e0dc254
(cherry picked from commit 3a80469f095e51f9be3965d67fff595eabc00293)
/packages/apps/Bluetooth/src/com/android/bluetooth/avrcp/AddressedMediaPlayer.java
827c417f70082918b965a5213c38395398389811 31-May-2017 Marie Janssen <jamuraa@google.com> AVRCP: Fix issues around trackChanged notification

When the track changes, sometimes the Queue ID changes before the
Metadata, and vice versa. Indicate that the track info has changed in
either case.

Guard against unsolicited responses since we are triggering more often.

Use the MediaController info for GetItemAttributes when the requested
id matches the current id.

Test: connect to Chrysler CK, switch to next track a few times, look for
good data.
Bug: 37707672
Change-Id: I6bffd419e22e1a029e11f9340afde54be00d3efc
/packages/apps/Bluetooth/src/com/android/bluetooth/avrcp/AddressedMediaPlayer.java
978986041010d3d2d72e1057743415e76c6f2ce9 11-May-2017 Hemant Gupta <hemantg@codeaurora.org> AVRCP: Fix GetItemAttributesCommand

Usecase:
1) Connect DUT with remote device supporting AVRCP 1.4
2) Connect browsing channel (if not already connected).
3) Send request to retrieve player list and select browsed player.
3) Send get item attribute commands to retrieve attributes of particular uid.

Expected Result:
Item attributes of particular UID are retrieved successfully.

Observation:
Get Item Attribute command does not return any response.

Root cause:
Media id passed as argument to MediaBrowse.subscribe is of children instead of
parent as required by the API

Fix:
Refactor to encapsulate requested ID in the subscribe callback, call the
MediaBrowser.subscribe with the correct id.

Test: connect to carkit and check if DUT responds correctly to GetItemAttribute
Bug: 37265436
Change-Id: Ifd7e17c600c0142cd29514eedf4ff8150f632570
(cherry picked from commit 3cd52581b21ef8c35382650170c9046119213f28)
/packages/apps/Bluetooth/src/com/android/bluetooth/avrcp/AddressedMediaPlayer.java
303c1c67dbc142822bc37e7c5a89fba82faf2ac0 16-May-2017 Marie Janssen <jamuraa@google.com> AVRCP: increase log info density

AVRCP has a lot of log messages that have little to no info.
Particularly with carkits that poll for data all the time, this makes it hard
to debug anything.

Remove logs where there's no info, add info where it's available with the goal
of making every log message useful.

Remove variables that we don't use anymore.

Print Now Playing Queue data on the dumpsys and when we report it
back to the controller.

Test: connect to a carkit and grab a bugreport
Bug: 37707672
Bug: 36802046
Bug: 38264897
Change-Id: I4fcb5a1c625c2d212685b4df04a0ac42df3d7841
(cherry picked from commit e5384f02ec837a8f274ed59548cb6879849239f5)
/packages/apps/Bluetooth/src/com/android/bluetooth/avrcp/AddressedMediaPlayer.java
0533d66ae0a334789c197cde425d3ad87a84dd7d 17-May-2017 Marie Janssen <jamuraa@google.com> AVRCP: send track changed if queue id is the same

Since metadata lags behind queue id changes, we need to send another
track changed to present the correct media metadata to the controller.

Test: connect to carkit and next track a few times
Bug: 37707672
Change-Id: Ifc6f3219dbffb078e4de247c67083bdbc29c52bc
(cherry picked from commit 89cbf5bfe48e75aee016ffbc7824353ff9ce242e)
/packages/apps/Bluetooth/src/com/android/bluetooth/avrcp/AddressedMediaPlayer.java
d89304c6be6e1c332008dcbeab08889881064454 03-May-2017 Marie Janssen <jamuraa@google.com> AVRCP: Track players without active media sessions

Players can be selected as addressed by MediaSessionService, then
destroy and renew their MediaSession. We want them to continue to
be addressed.

Don't remove players that destroy their MediaSession, and just forget
the controller instead.

Remove players when their package is removed though.

Report "(unknown)" when we are asked for media info for an addressed
player that has no controller.

Fix a bug where we didn't send updated metadata when it changed.
Fix an ordering bug updating the media session.

Make logging more clear when we're adding / updating / removing players.
Add dumpsys log to confirm current mMediaController is correct.

Use @Nullable and @NonNull to help with distinguishing when
MediaController can be null in AddressedMediaPlayer.

Test: send pause / play from headset, look at bugreport to confirm
Change-Id: I083745f8988e67776716db2bec5e67b697e8ee67
Bug: 36357185
Fixes: 37865298
(cherry picked from commit 384011244f5a62ed34f198b8ba91341b4efb4fb6)
/packages/apps/Bluetooth/src/com/android/bluetooth/avrcp/AddressedMediaPlayer.java
93f177151f5b96ce3e06888884da3cd7f7858ecf 25-Apr-2017 Marie Janssen <jamuraa@google.com> AVRCP: update metadata and state more consistently

When we get onMetadata it's not updated quite right, and the
PlaybackState gives the wrong answer for getActiveQueueItemId, which
means that we don't send the correct updated data. Update the metadata
when we get a onPlaybackStateChanged as well, so we refresh the
metadata and notify correctly for EVENT_TRACK_CHANGED.

Keep track of the last queue item we sent and don't send an update if
the queue item has not changed.

Use A2DP streaming state only when we don't have strong signals from
Media framework.

Use PlaybackState.getLastPositionUpdateTime() instead of trying to
figure it out on our own.

Trust MediaAttributes with the track length instead of duplicating it.

Test: connect to BMW kit and skip some tracks, new data will show up
correctly
Bug: 37209435
Bug: 36016671
Bug: 36357185
Bug: 36055995
Change-Id: I332aaadeabcfe8284084a34c964e5f0d07bfeef4

(cherry picked from commit 0a429916782c20980e7f0893c503c633b8341f88)
/packages/apps/Bluetooth/src/com/android/bluetooth/avrcp/AddressedMediaPlayer.java
0f9c79e8afa3e575dfd8c80c2c58b9321e18898d 26-Apr-2017 Marie Janssen <jamuraa@google.com> AVRCP: Gracefully handle missing item attributes

The source of our metadata sometimes doesn't even give us basic title
information, which causes a NullPointerException when we try to fill the
Displayable Name.

Fill it with "<unknown>" when we don't know the data.

Add more useful debugging for GetFolderItems and GetItemAttributes.

Test: Tested with Audi and Porche car kit
Bug: 37657532
Bug: 37718715
Change-Id: I183f2b9c5714ebacabc8093de1c2bc166e323fae
(cherry picked from commit 89728a4d50001ac76d05efa1c916711ef9f9c2b4)
/packages/apps/Bluetooth/src/com/android/bluetooth/avrcp/AddressedMediaPlayer.java
ce0f15c8598a1e570faf80bbc60e0568d2d20d45 15-Feb-2017 Marie Janssen <jamuraa@google.com> AVRCP: Fix getFolderItems with all items request

start item and end item are uint32_t
0xFFFFFFFF is commonly used as an indicator for "all items" end value.

Using a jint (int32_t) doesn't work, use jlong instead.

Test: browse with audi kit
Bug: 35385700
Bug: 36645066
Change-Id: I364f70a8b985796a6bcc83148a4ecc368a0c0493
(cherry picked from commit aabff2d74224e1d122a2ae767330a69b9324779e)
/packages/apps/Bluetooth/src/com/android/bluetooth/avrcp/AddressedMediaPlayer.java
bdcf510515b5b251b0b88ba3c05937661ca5da3f 24-Mar-2017 Marie Janssen <jamuraa@google.com> AVRCP: Passthrough through MediaSessionService

Send passthrough keys through MediaSessionService instead of trying to
interpret them ourselves, and log who they get dispatched to.

Remove the hack around down fast-forward / rewind.

This should result in a lot less confusion about which app is addressed
when the user is sending a command (such as at car connection time).

Test: play / skip, switch app on phone, reboot, start from carkit, dumpsys logs
Bug: 33828042
Bug: 37476911

Change-Id: I8c8c40cb3792254a3720f64707e67fdcc940edaa
(cherry picked from commit 44a4da788f878d1946301dbf297dd7b938dfd730)
/packages/apps/Bluetooth/src/com/android/bluetooth/avrcp/AddressedMediaPlayer.java
b3436e976055f684050be9afdadc73645316806a 07-Apr-2017 Marie Janssen <jamuraa@google.com> AVRCP: Report current playing item for now playing

According to the Bluetooth AVRCP 1.6.1 (p79):
In the case where the media player does not natively support a Now
Playing folder, it may present a folder containing one item, the
currently playing media element, as would be returned by a
GetElementAttributes command with the now playing UID.

Send this one-item list back when we don't have a queue, and try to
refresh the queue from the current player when we need to.

When a browsable player is selected, it's illegal for us to send a
response to EVT_TRACK_CHANGED with the now playing UID, so make up a
fake qid for this one item list in this case, since ids are only valid
within the current folder for database-unaware players anyway.

Respond with "no players available" when we actually don't have a
player.

Also fixes a bug where we would try to send the current queue back twice,
and reduces logspam in the main message handler by half.

Test: connect to carkit, test basic playback
Bug: 32800406
Bug: 36645066
Bug: 36055995
Bug: 36645066
Change-Id: Ia16c05bfc849359ca857b03edd5a75e21f13d6fb
(cherry picked from commit 5cbc96dc8da6b455c0d0a142d27274708ac1f208)
/packages/apps/Bluetooth/src/com/android/bluetooth/avrcp/AddressedMediaPlayer.java
e23a886e79f60a3f7f5b8e87f8c5ffc26134bd32 04-Jan-2017 Marie Janssen <jamuraa@google.com> AVRCP: Report no track playing correctly.

If browsing is supported, we cannot use 0x0 (Track selected) as a
generic response per the AVRCP 1.6.1 spec p64.

Rename mTrackNumber => mTracksPlayed to be more accurate, and use media
info to determine if a track is selected instead of whether we've played any.

Test: check with Carkit && PTS: TC_TG_NFY_BV_04_C
Bug: 33414166
Change-Id: I004aa5596ff9aef001ce74c463da0e1ed77b9ff4
/packages/apps/Bluetooth/src/com/android/bluetooth/avrcp/AddressedMediaPlayer.java
417d1b696e6bcf1e22478b93e79aa5936537483a 14-Oct-2016 Ajay Panicker <apanicke@google.com> Define cover art attribute id

Test: Tested manually
Bug: 32081388
Change-Id: Ib9df511a36d19f1bd5197836ad34b19edba73748
/packages/apps/Bluetooth/src/com/android/bluetooth/avrcp/AddressedMediaPlayer.java
d996f17ea97b2c592338bcfbc93056d0224da1cd 21-Oct-2016 Ajay Panicker <apanicke@google.com> Add AVRCP unit tests and switch to using mockable interfaces

Add a mockable interface for MediaController in order to add unit
tests for AddressedMediaPlayer.

Bug: 32416674
Test: Tested manually
Change-Id: I081c37915fc15e58f3de37c3a16e03747503860c
/packages/apps/Bluetooth/src/com/android/bluetooth/avrcp/AddressedMediaPlayer.java
e90c830b72f97189935e99e9e4f5a0c4f216ba72 22-Jun-2016 Avish Shah <avish.shah@broadcom.com> AVRCP 1.6: media browsing support on Target(3/3)

Description:-
This patch provides Media browsing support for AVRCP using
new Media Browsing APIs provided from Android 5.0

Features:-
1) setAddressedPlayer
- Change the control to the specified player
2) setBrowsedPlayer
- Change the player with which fileSystem is being browsed
Browsing commands:
3) getFolderItems scope=MediaPlayers/VFS/NowPlaying
4) changePath
5) getItemAttributes
6) playItem
7) getTotalNumberOfItems

Handling notifications:-
1) ADDRESSED_PLAYER_CHANGED
2) AVAILABLE_PLAYERS_CHANGED
3) NOW_PLAYING_CONTENT_CHANGED

Added support for dual RC

New files added:-
AvrcpHelperClasses.java
- Helper classes used for callback/response of browsing commands.
AvrcpConstants.java
- Group all the constants used in Avrcp.
AddressedMediaPlayer.java
- Interface to communicate with media controller for NowPlayingItems.
BrowseMediaPlayer.java
- Interface to communicate with MediaPlayer for browsing FileSystem.
AvrcpMediaRspInterface.java
- Interface to communicate with the native layer.

Verification:-
AVRCP 1.5/1.6 functionality has been verified with
google MediaBrowserService sample app.

Bug: 19361366
Merged-In: I0ab7f0c7d87c06fe4f454151d20494c56aceae12
Change-Id: I40b9e7aae81d994a709559844928b0749c603ea8
/packages/apps/Bluetooth/src/com/android/bluetooth/avrcp/AddressedMediaPlayer.java