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

Commit 637be13d authored by Treehugger Robot's avatar Treehugger Robot Committed by Gerrit Code Review
Browse files

Merge "Extract metadata info from MediaPlayer.Queue added by Google Play Music"

parents 4c3e92d0 f7c56772
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: