Never set null as a session meta data object.

Issue: #5810
PiperOrigin-RevId: 245745646
This commit is contained in:
bachinger 2019-04-29 15:56:41 +01:00 committed by Oliver Woodman
parent 1fb128df36
commit 44ad47746a

View file

@ -146,6 +146,9 @@ public final class MediaSessionConnector {
private static final int EDITOR_MEDIA_SESSION_FLAGS = private static final int EDITOR_MEDIA_SESSION_FLAGS =
BASE_MEDIA_SESSION_FLAGS | MediaSessionCompat.FLAG_HANDLES_QUEUE_COMMANDS; BASE_MEDIA_SESSION_FLAGS | MediaSessionCompat.FLAG_HANDLES_QUEUE_COMMANDS;
private static final MediaMetadataCompat METADATA_EMPTY =
new MediaMetadataCompat.Builder().build();
/** Receiver of media commands sent by a media controller. */ /** Receiver of media commands sent by a media controller. */
public interface CommandReceiver { public interface CommandReceiver {
/** /**
@ -639,8 +642,8 @@ public final class MediaSessionConnector {
MediaMetadataCompat metadata = MediaMetadataCompat metadata =
mediaMetadataProvider != null && player != null mediaMetadataProvider != null && player != null
? mediaMetadataProvider.getMetadata(player) ? mediaMetadataProvider.getMetadata(player)
: null; : METADATA_EMPTY;
mediaSession.setMetadata(metadata); mediaSession.setMetadata(metadata != null ? metadata : METADATA_EMPTY);
} }
/** /**
@ -888,7 +891,7 @@ public final class MediaSessionConnector {
@Override @Override
public MediaMetadataCompat getMetadata(Player player) { public MediaMetadataCompat getMetadata(Player player) {
if (player.getCurrentTimeline().isEmpty()) { if (player.getCurrentTimeline().isEmpty()) {
return null; return METADATA_EMPTY;
} }
MediaMetadataCompat.Builder builder = new MediaMetadataCompat.Builder(); MediaMetadataCompat.Builder builder = new MediaMetadataCompat.Builder();
if (player.isPlayingAd()) { if (player.isPlayingAd()) {