Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit f7c56772 authored by Ajay Panicker's avatar Ajay Panicker Committed by Myles Watson
Browse files

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
(cherry picked from commit 9087efa4)
Merged-In: I9d30d162a13fb6416f3b4140aa5238f7e0e928f2
Merged-In: I78f54e7dd4f9f46c6c5dfc7fbb9400d7214d23cc
parent 1fbc8223
Loading
Loading
Loading
Loading
+17 −1
Original line number Diff line number Diff line
@@ -48,6 +48,9 @@ public class AddressedMediaPlayer {
    private static final long SINGLE_QID = 1;
    private static final String UNKNOWN_TITLE = "(unknown)";

    static private final String GPM_BUNDLE_METADATA_KEY =
            "com.google.android.music.mediasession.music_metadata";

    private AvrcpMediaRspInterface mMediaInterface;
    @NonNull private List<MediaSession.QueueItem> mNowPlayingList;

@@ -163,6 +166,7 @@ public class AddressedMediaPlayer {

    private Bundle fillBundle(MediaMetadata metadata, Bundle currentExtras) {
        if (metadata == null) {
            Log.i(TAG, "fillBundle: metadata is null");
            return currentExtras;
        }

@@ -363,10 +367,22 @@ public class AddressedMediaPlayer {
            MediaDescription desc = item.getDescription();
            Bundle extras = desc.getExtras();
            boolean isCurrentTrack = item.getQueueId() == getActiveQueueItemId(mediaController);
            MediaMetadata data = null;
            if (isCurrentTrack) {
                if (DEBUG) Log.d(TAG, "getAttrValue: item is active, using current data");
                extras = fillBundle(mediaController.getMetadata(), extras);
                data = mediaController.getMetadata();
                if (data == null)
                    Log.e(TAG, "getMetadata didn't give us any metadata for the current track");
            }

            if (data == null) {
                // TODO: This code can be removed when b/63117921 is resolved
                data = (MediaMetadata) extras.get(GPM_BUNDLE_METADATA_KEY);
                extras = null; // We no longer need the data in here
            }

            extras = fillBundle(data, extras);

            if (DEBUG) Log.d(TAG, "getAttrValue: item " + item + " : " + desc);
            switch (attr) {
                case AvrcpConstants.ATTRID_TITLE: