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

Commit c1267074 authored by Marie Janssen's avatar Marie Janssen Committed by Andre Eisenbach
Browse files

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
parent beaec3e8
Loading
Loading
Loading
Loading
+0 −6
Original line number Diff line number Diff line
@@ -267,13 +267,8 @@ public class AddressedMediaPlayer {
            /* for any item associated with NowPlaying, uid is queueId */
            if (state != null) qid = state.getActiveQueueItemId();
        }
        if (!requesting && qid == mLastTrackIdSent) {
            if (DEBUG) Log.d(TAG, "not sending duplicate track changed id " + qid);
            return false;
        }
        track = ByteBuffer.allocate(AvrcpConstants.UID_SIZE).putLong(qid).array();
        if (DEBUG) Log.d(TAG, "trackChangedRsp: 0x" + Utils.byteArrayToString(track));

        int trackChangedNT = AvrcpConstants.NOTIFICATION_TYPE_CHANGED;
        if (requesting) trackChangedNT = AvrcpConstants.NOTIFICATION_TYPE_INTERIM;
        mMediaInterface.trackChangedRsp(trackChangedNT, track);
@@ -488,7 +483,6 @@ public class AddressedMediaPlayer {
        /* variables to temperorily add attrs */
        ArrayList<String> attrArray = new ArrayList<String>();
        ArrayList<Integer> attrId = new ArrayList<Integer>();

        ArrayList<Integer> attrTempId = new ArrayList<Integer>();

        /* check if remote device has requested for attributes */
+13 −9
Original line number Diff line number Diff line
@@ -1583,6 +1583,9 @@ public final class Avrcp {
                            getMediaControllers();
                    for (android.media.session.MediaController controller : currentControllers) {
                        if (!newControllers.contains(controller)) {
                            if (DEBUG)
                                Log.v(TAG, "Removing gone controller for "
                                                + controller.getPackageName());
                            removeMediaController(controller);
                        }
                    }
@@ -2215,17 +2218,18 @@ public final class Avrcp {
            if (mCurrAddrPlayerID == NO_PLAYER_ID) {
                getItemAttrRspNative(
                        itemAttr.mAddress, AvrcpConstants.RSP_NO_AVBL_PLAY, (byte) 0, null, null);
            } else {
                return;
            }
            mAddressedMediaPlayer.getItemAttr(itemAttr.mAddress, itemAttr, mMediaController);
            return;
        }
        } else {
        // All other scopes use browsed player
        if (mAvrcpBrowseManager.getBrowsedMediaPlayer(itemAttr.mAddress) != null) {
            mAvrcpBrowseManager.getBrowsedMediaPlayer(itemAttr.mAddress).getItemAttr(itemAttr);
        } else {
            Log.e(TAG, "Could not get attributes. mBrowsedMediaPlayer is null");
                getItemAttrRspNative(itemAttr.mAddress, AvrcpConstants.RSP_INTERNAL_ERR,
                        (byte) 0, null, null);
            }
            getItemAttrRspNative(
                    itemAttr.mAddress, AvrcpConstants.RSP_INTERNAL_ERR, (byte) 0, null, null);
        }
    }