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

Commit 5a3ef424 authored by Terry Heo's avatar Terry Heo Committed by Terry (Woncheol) Heo
Browse files

TIF: Use copied track list for onTracksChanged() callback

In notifyTracksChanged(), the calling onTracksChanged() could be delayed.
To prevent race condition on tracks, we should use the copy of tracks.

Bug: 22436933
Change-Id: I0c595df9d06d5f7bda4a9f8c21a661f7aa7db71f
parent 9349093c
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -385,13 +385,14 @@ public abstract class TvInputService extends Service {
            trackIdSet.clear();

            // TODO: Validate the track list.
            final List<TvTrackInfo> tracksCopy = new ArrayList<>(tracks);
            executeOrPostRunnable(new Runnable() {
                @Override
                public void run() {
                    try {
                        if (DEBUG) Log.d(TAG, "notifyTracksChanged");
                        if (mSessionCallback != null) {
                            mSessionCallback.onTracksChanged(tracks);
                            mSessionCallback.onTracksChanged(tracksCopy);
                        }
                    } catch (RemoteException e) {
                        Log.w(TAG, "error in notifyTracksChanged", e);