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

Commit 9087efa4 authored by Ajay Panicker's avatar Ajay Panicker
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
parent 9fdf6e35
Loading
Loading
Loading
Loading
+17 −1
Original line number Diff line number Diff line
@@ -48,6 +48,9 @@ public class AddressedMediaPlayer {
    static private final long SINGLE_QID = 1;
    static private final String UNKNOWN_TITLE = "(unknown)";

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

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

@@ -186,6 +189,7 @@ public class AddressedMediaPlayer {

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

@@ -391,10 +395,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: