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

Commit 4b249623 authored by Marie Janssen's avatar Marie Janssen
Browse files

AVRCP: Prevent concurrent access of Browser List

Concurrent access to mBrowsePlayerInfoList could happen still.

Test: none - concurrently change sessions and add a player?
Change-Id: Ibb2e1010eb1326387c04dae4ab2413d6aa3b2034
Bug: 37896665
(cherry picked from commit af5bab21)
parent d26e4793
Loading
Loading
Loading
Loading
+6 −9
Original line number Original line Diff line number Diff line
@@ -180,7 +180,7 @@ public final class Avrcp {
    private SortedMap<Integer, MediaPlayerInfo> mMediaPlayerInfoList;
    private SortedMap<Integer, MediaPlayerInfo> mMediaPlayerInfoList;


    /* List of media players which supports browse */
    /* List of media players which supports browse */
    private ArrayList<BrowsePlayerInfo> mBrowsePlayerInfoList;
    private List<BrowsePlayerInfo> mBrowsePlayerInfoList;


    /* Manage browsed players */
    /* Manage browsed players */
    private AvrcpBrowseManager mAvrcpBrowseManager;
    private AvrcpBrowseManager mAvrcpBrowseManager;
@@ -301,7 +301,7 @@ public final class Avrcp {
        mMediaControllerCb = new MediaControllerListener();
        mMediaControllerCb = new MediaControllerListener();
        mAvrcpMediaRsp = new AvrcpMediaRsp();
        mAvrcpMediaRsp = new AvrcpMediaRsp();
        mMediaPlayerInfoList = new TreeMap<Integer, MediaPlayerInfo>();
        mMediaPlayerInfoList = new TreeMap<Integer, MediaPlayerInfo>();
        mBrowsePlayerInfoList = new ArrayList<BrowsePlayerInfo>();
        mBrowsePlayerInfoList = Collections.synchronizedList(new ArrayList<BrowsePlayerInfo>());
        mPassthroughDispatched = 0;
        mPassthroughDispatched = 0;
        mPassthroughLogs = new EvictingQueue<MediaKeyLog>(PASSTHROUGH_LOG_MAX_SIZE);
        mPassthroughLogs = new EvictingQueue<MediaKeyLog>(PASSTHROUGH_LOG_MAX_SIZE);
        mPassthroughPending = Collections.synchronizedList(new ArrayList<MediaKeyLog>());
        mPassthroughPending = Collections.synchronizedList(new ArrayList<MediaKeyLog>());
@@ -1725,13 +1725,10 @@ public final class Avrcp {
            mCurrentBrowser = null;
            mCurrentBrowser = null;
            mBrowsePlayerInfoList.add(mCurrentPlayer);
            mBrowsePlayerInfoList.add(mCurrentPlayer);
            MediaPlayerInfo info = getMediaPlayerInfo(mCurrentPlayer.packageName);
            MediaPlayerInfo info = getMediaPlayerInfo(mCurrentPlayer.packageName);
            if (info != null) {
            MediaController controller = (info == null) ? null : info.getMediaController();
            // Refresh the media player entry so it notices we can browse
            // Refresh the media player entry so it notices we can browse
                MediaController controller = info.getMediaController();
            if (controller != null) {
            if (controller != null) {
                addMediaPlayerController(controller.getWrappedInstance());
                addMediaPlayerController(controller.getWrappedInstance());
                }
                // If there's no controller, the entry is already browsable-only.
            } else {
            } else {
                addMediaPlayerPackage(mCurrentPlayer.packageName);
                addMediaPlayerPackage(mCurrentPlayer.packageName);
            }
            }