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

Commit a78601dc authored by RoboErik's avatar RoboErik Committed by Android (Google) Code Review
Browse files

Merge "Ensure metadata bundles are unparceled before making them available" into lmp-dev

parents c0a30bcf 82df2c08
Loading
Loading
Loading
Loading
+11 −7
Original line number Diff line number Diff line
@@ -625,13 +625,13 @@ public class MediaSessionRecord implements IBinder.DeathRecipient {

    private PlaybackState getStateWithUpdatedPosition() {
        PlaybackState state;
        long duration = -1;
        synchronized (mLock) {
            state = mPlaybackState;
        }
        long duration = -1;
            if (mMetadata != null && mMetadata.containsKey(MediaMetadata.METADATA_KEY_DURATION)) {
                duration = mMetadata.getLong(MediaMetadata.METADATA_KEY_DURATION);
            }
        }
        PlaybackState result = null;
        if (state != null) {
            if (state.getState() == PlaybackState.STATE_PLAYING
@@ -725,10 +725,14 @@ public class MediaSessionRecord implements IBinder.DeathRecipient {

        @Override
        public void setMetadata(MediaMetadata metadata) {
            // Make a copy of the metadata as the underlying bundle may be
            // modified on this thread.
            synchronized (mLock) {
                mMetadata = metadata == null ? null : new MediaMetadata.Builder(metadata).build();
                MediaMetadata temp = metadata == null ? null : new MediaMetadata.Builder(metadata)
                        .build();
                // This is to guarantee that the underlying bundle is unparceled
                // before we set it to prevent concurrent reads from throwing an
                // exception
                temp.size();
                mMetadata = temp;
            }
            mHandler.post(MessageHandler.MSG_UPDATE_METADATA);
        }