From 665f04d70a574e9cb5b6d92d23165dde51b25afc Mon Sep 17 00:00:00 2001 From: bachinger Date: Wed, 30 Nov 2022 12:13:28 +0000 Subject: [PATCH] Use the artist as the subtitle of the legacy media description The Bluetooth AVRCP service expects the metadata of the item currently being played to be in sync with the corresponding media description in the active item of the queue. The comparison expects the metadata values of `METADATA_KEY_TITLE` and `METADATA_KEY_ARTIST` [1] to be equal to the `title` and `subtitle` field of the `MediaDescription` [2] of the corresponding queue item. Hence we need to populate the media description accordingly to avoid the BT service to delay the update for two seconds and log an exception. [1] https://cs.android.com/android/platform/superproject/+/master:packages/modules/Bluetooth/android/app/src/com/android/bluetooth/audio_util/helpers/Metadata.java;l=120 [2] https://cs.android.com/android/platform/superproject/+/master:packages/modules/Bluetooth/android/app/src/com/android/bluetooth/audio_util/MediaPlayerWrapper.java;l=258 Issue: androidx/media#148 PiperOrigin-RevId: 491877806 (cherry picked from commit 2a07a0b44582782b09a96b5819e9899308e79545) --- .../src/main/java/androidx/media3/session/MediaUtils.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/libraries/session/src/main/java/androidx/media3/session/MediaUtils.java b/libraries/session/src/main/java/androidx/media3/session/MediaUtils.java index f58882351d..7caf715ea5 100644 --- a/libraries/session/src/main/java/androidx/media3/session/MediaUtils.java +++ b/libraries/session/src/main/java/androidx/media3/session/MediaUtils.java @@ -351,7 +351,9 @@ import org.checkerframework.checker.nullness.compatqual.NullableType; } return builder .setTitle(metadata.title) - .setSubtitle(metadata.subtitle) + // The BT AVRPC service expects the subtitle of the media description to be the artist + // (see https://github.com/androidx/media/issues/148). + .setSubtitle(metadata.artist != null ? metadata.artist : metadata.subtitle) .setDescription(metadata.description) .setIconUri(metadata.artworkUri) .setMediaUri(item.requestMetadata.mediaUri)