mirror of
https://github.com/androidx/media.git
synced 2025-04-30 06:46:50 +08:00
Fix some Android Studio nullness warning created by new @NonNullApi.
PiperOrigin-RevId: 261888086
This commit is contained in:
parent
3b9288b805
commit
b0330edc0b
@ -558,7 +558,7 @@ public final class MediaSessionConnector {
|
||||
*
|
||||
* @param queueNavigator The queue navigator.
|
||||
*/
|
||||
public void setQueueNavigator(QueueNavigator queueNavigator) {
|
||||
public void setQueueNavigator(@Nullable QueueNavigator queueNavigator) {
|
||||
if (this.queueNavigator != queueNavigator) {
|
||||
unregisterCommandReceiver(this.queueNavigator);
|
||||
this.queueNavigator = queueNavigator;
|
||||
@ -571,7 +571,7 @@ public final class MediaSessionConnector {
|
||||
*
|
||||
* @param queueEditor The queue editor.
|
||||
*/
|
||||
public void setQueueEditor(QueueEditor queueEditor) {
|
||||
public void setQueueEditor(@Nullable QueueEditor queueEditor) {
|
||||
if (this.queueEditor != queueEditor) {
|
||||
unregisterCommandReceiver(this.queueEditor);
|
||||
this.queueEditor = queueEditor;
|
||||
@ -673,7 +673,7 @@ public final class MediaSessionConnector {
|
||||
mediaMetadataProvider != null && player != null
|
||||
? mediaMetadataProvider.getMetadata(player)
|
||||
: METADATA_EMPTY;
|
||||
mediaSession.setMetadata(metadata != null ? metadata : METADATA_EMPTY);
|
||||
mediaSession.setMetadata(metadata);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -684,7 +684,7 @@ public final class MediaSessionConnector {
|
||||
*/
|
||||
public final void invalidateMediaSessionPlaybackState() {
|
||||
PlaybackStateCompat.Builder builder = new PlaybackStateCompat.Builder();
|
||||
Player player = this.player;
|
||||
@Nullable Player player = this.player;
|
||||
if (player == null) {
|
||||
builder.setActions(buildPrepareActions()).setState(PlaybackStateCompat.STATE_NONE, 0, 0, 0);
|
||||
mediaSession.setPlaybackState(builder.build());
|
||||
@ -693,6 +693,7 @@ public final class MediaSessionConnector {
|
||||
|
||||
Map<String, CustomActionProvider> currentActions = new HashMap<>();
|
||||
for (CustomActionProvider customActionProvider : customActionProviders) {
|
||||
@Nullable
|
||||
PlaybackStateCompat.CustomAction customAction = customActionProvider.getCustomAction(player);
|
||||
if (customAction != null) {
|
||||
currentActions.put(customAction.getAction(), customActionProvider);
|
||||
@ -703,6 +704,7 @@ public final class MediaSessionConnector {
|
||||
|
||||
int playbackState = player.getPlaybackState();
|
||||
Bundle extras = new Bundle();
|
||||
@Nullable
|
||||
ExoPlaybackException playbackError =
|
||||
playbackState == Player.STATE_IDLE ? player.getPlaybackError() : null;
|
||||
boolean reportError = playbackError != null || customError != null;
|
||||
@ -949,10 +951,10 @@ public final class MediaSessionConnector {
|
||||
MediaSessionCompat.QueueItem queueItem = queue.get(i);
|
||||
if (queueItem.getQueueId() == activeQueueItemId) {
|
||||
MediaDescriptionCompat description = queueItem.getDescription();
|
||||
Bundle extras = description.getExtras();
|
||||
@Nullable Bundle extras = description.getExtras();
|
||||
if (extras != null) {
|
||||
for (String key : extras.keySet()) {
|
||||
Object value = extras.get(key);
|
||||
@Nullable Object value = extras.get(key);
|
||||
if (value instanceof String) {
|
||||
builder.putString(metadataExtrasPrefix + key, (String) value);
|
||||
} else if (value instanceof CharSequence) {
|
||||
@ -968,37 +970,37 @@ public final class MediaSessionConnector {
|
||||
}
|
||||
}
|
||||
}
|
||||
CharSequence title = description.getTitle();
|
||||
@Nullable CharSequence title = description.getTitle();
|
||||
if (title != null) {
|
||||
String titleString = String.valueOf(title);
|
||||
builder.putString(MediaMetadataCompat.METADATA_KEY_TITLE, titleString);
|
||||
builder.putString(MediaMetadataCompat.METADATA_KEY_DISPLAY_TITLE, titleString);
|
||||
}
|
||||
CharSequence subtitle = description.getSubtitle();
|
||||
@Nullable CharSequence subtitle = description.getSubtitle();
|
||||
if (subtitle != null) {
|
||||
builder.putString(
|
||||
MediaMetadataCompat.METADATA_KEY_DISPLAY_SUBTITLE, String.valueOf(subtitle));
|
||||
}
|
||||
CharSequence displayDescription = description.getDescription();
|
||||
@Nullable CharSequence displayDescription = description.getDescription();
|
||||
if (displayDescription != null) {
|
||||
builder.putString(
|
||||
MediaMetadataCompat.METADATA_KEY_DISPLAY_DESCRIPTION,
|
||||
String.valueOf(displayDescription));
|
||||
}
|
||||
Bitmap iconBitmap = description.getIconBitmap();
|
||||
@Nullable Bitmap iconBitmap = description.getIconBitmap();
|
||||
if (iconBitmap != null) {
|
||||
builder.putBitmap(MediaMetadataCompat.METADATA_KEY_DISPLAY_ICON, iconBitmap);
|
||||
}
|
||||
Uri iconUri = description.getIconUri();
|
||||
@Nullable Uri iconUri = description.getIconUri();
|
||||
if (iconUri != null) {
|
||||
builder.putString(
|
||||
MediaMetadataCompat.METADATA_KEY_DISPLAY_ICON_URI, String.valueOf(iconUri));
|
||||
}
|
||||
String mediaId = description.getMediaId();
|
||||
@Nullable String mediaId = description.getMediaId();
|
||||
if (mediaId != null) {
|
||||
builder.putString(MediaMetadataCompat.METADATA_KEY_MEDIA_ID, mediaId);
|
||||
}
|
||||
Uri mediaUri = description.getMediaUri();
|
||||
@Nullable Uri mediaUri = description.getMediaUri();
|
||||
if (mediaUri != null) {
|
||||
builder.putString(
|
||||
MediaMetadataCompat.METADATA_KEY_MEDIA_URI, String.valueOf(mediaUri));
|
||||
|
@ -166,7 +166,7 @@ public final class TimelineQueueEditor
|
||||
|
||||
@Override
|
||||
public void onAddQueueItem(Player player, MediaDescriptionCompat description, int index) {
|
||||
MediaSource mediaSource = sourceFactory.createMediaSource(description);
|
||||
@Nullable MediaSource mediaSource = sourceFactory.createMediaSource(description);
|
||||
if (mediaSource != null) {
|
||||
queueDataAdapter.add(index, description);
|
||||
queueMediaSource.addMediaSource(index, mediaSource);
|
||||
|
@ -68,7 +68,7 @@ import java.util.List;
|
||||
if (!exists()) {
|
||||
return new DownloadRequest[0];
|
||||
}
|
||||
InputStream inputStream = null;
|
||||
@Nullable InputStream inputStream = null;
|
||||
try {
|
||||
inputStream = atomicFile.openRead();
|
||||
DataInputStream dataInputStream = new DataInputStream(inputStream);
|
||||
@ -99,7 +99,7 @@ import java.util.List;
|
||||
boolean isRemoveAction = input.readBoolean();
|
||||
|
||||
int dataLength = input.readInt();
|
||||
byte[] data;
|
||||
@Nullable byte[] data;
|
||||
if (dataLength != 0) {
|
||||
data = new byte[dataLength];
|
||||
input.readFully(data);
|
||||
@ -123,7 +123,7 @@ import java.util.List;
|
||||
&& (DownloadRequest.TYPE_DASH.equals(type)
|
||||
|| DownloadRequest.TYPE_HLS.equals(type)
|
||||
|| DownloadRequest.TYPE_SS.equals(type));
|
||||
String customCacheKey = null;
|
||||
@Nullable String customCacheKey = null;
|
||||
if (!isLegacySegmented) {
|
||||
customCacheKey = input.readBoolean() ? input.readUTF() : null;
|
||||
}
|
||||
|
@ -97,7 +97,7 @@ public final class ActionFileUpgradeUtil {
|
||||
boolean addNewDownloadAsCompleted,
|
||||
long nowMs)
|
||||
throws IOException {
|
||||
Download download = downloadIndex.getDownload(request.id);
|
||||
@Nullable Download download = downloadIndex.getDownload(request.id);
|
||||
if (download != null) {
|
||||
download = DownloadManager.mergeRequest(download, request, download.stopReason, nowMs);
|
||||
} else {
|
||||
|
@ -390,7 +390,7 @@ public final class DownloadHelper {
|
||||
*/
|
||||
public static MediaSource createMediaSource(
|
||||
DownloadRequest downloadRequest, DataSource.Factory dataSourceFactory) {
|
||||
Constructor<? extends MediaSourceFactory> constructor;
|
||||
@Nullable Constructor<? extends MediaSourceFactory> constructor;
|
||||
switch (downloadRequest.type) {
|
||||
case DownloadRequest.TYPE_DASH:
|
||||
constructor = DASH_FACTORY_CONSTRUCTOR;
|
||||
@ -808,7 +808,7 @@ public final class DownloadHelper {
|
||||
new MediaPeriodId(mediaPreparer.timeline.getUidOfPeriod(periodIndex)),
|
||||
mediaPreparer.timeline);
|
||||
for (int i = 0; i < trackSelectorResult.length; i++) {
|
||||
TrackSelection newSelection = trackSelectorResult.selections.get(i);
|
||||
@Nullable TrackSelection newSelection = trackSelectorResult.selections.get(i);
|
||||
if (newSelection == null) {
|
||||
continue;
|
||||
}
|
||||
|
@ -731,7 +731,7 @@ public final class DownloadManager {
|
||||
Log.e(TAG, "Failed to set manual stop reason", e);
|
||||
}
|
||||
} else {
|
||||
Download download = getDownload(id, /* loadFromIndex= */ false);
|
||||
@Nullable Download download = getDownload(id, /* loadFromIndex= */ false);
|
||||
if (download != null) {
|
||||
setStopReason(download, stopReason);
|
||||
} else {
|
||||
@ -779,7 +779,7 @@ public final class DownloadManager {
|
||||
}
|
||||
|
||||
private void addDownload(DownloadRequest request, int stopReason) {
|
||||
Download download = getDownload(request.id, /* loadFromIndex= */ true);
|
||||
@Nullable Download download = getDownload(request.id, /* loadFromIndex= */ true);
|
||||
long nowMs = System.currentTimeMillis();
|
||||
if (download != null) {
|
||||
putDownload(mergeRequest(download, request, stopReason, nowMs));
|
||||
@ -798,7 +798,7 @@ public final class DownloadManager {
|
||||
}
|
||||
|
||||
private void removeDownload(String id) {
|
||||
Download download = getDownload(id, /* loadFromIndex= */ true);
|
||||
@Nullable Download download = getDownload(id, /* loadFromIndex= */ true);
|
||||
if (download == null) {
|
||||
Log.e(TAG, "Failed to remove nonexistent download: " + id);
|
||||
return;
|
||||
@ -860,7 +860,7 @@ public final class DownloadManager {
|
||||
int accumulatingDownloadTaskCount = 0;
|
||||
for (int i = 0; i < downloads.size(); i++) {
|
||||
Download download = downloads.get(i);
|
||||
Task activeTask = activeTasks.get(download.request.id);
|
||||
@Nullable Task activeTask = activeTasks.get(download.request.id);
|
||||
switch (download.state) {
|
||||
case STATE_STOPPED:
|
||||
syncStoppedDownload(activeTask);
|
||||
@ -999,7 +999,7 @@ public final class DownloadManager {
|
||||
return;
|
||||
}
|
||||
|
||||
Throwable finalError = task.finalError;
|
||||
@Nullable Throwable finalError = task.finalError;
|
||||
if (finalError != null) {
|
||||
Log.e(TAG, "Task failed: " + task.request + ", " + isRemove, finalError);
|
||||
}
|
||||
@ -1176,7 +1176,7 @@ public final class DownloadManager {
|
||||
private final boolean isRemove;
|
||||
private final int minRetryCount;
|
||||
|
||||
private volatile InternalHandler internalHandler;
|
||||
@Nullable private volatile InternalHandler internalHandler;
|
||||
private volatile boolean isCanceled;
|
||||
@Nullable private Throwable finalError;
|
||||
|
||||
@ -1246,7 +1246,7 @@ public final class DownloadManager {
|
||||
} catch (Throwable e) {
|
||||
finalError = e;
|
||||
}
|
||||
Handler internalHandler = this.internalHandler;
|
||||
@Nullable Handler internalHandler = this.internalHandler;
|
||||
if (internalHandler != null) {
|
||||
internalHandler.obtainMessage(MSG_TASK_STOPPED, this).sendToTarget();
|
||||
}
|
||||
@ -1258,7 +1258,7 @@ public final class DownloadManager {
|
||||
downloadProgress.percentDownloaded = percentDownloaded;
|
||||
if (contentLength != this.contentLength) {
|
||||
this.contentLength = contentLength;
|
||||
Handler internalHandler = this.internalHandler;
|
||||
@Nullable Handler internalHandler = this.internalHandler;
|
||||
if (internalHandler != null) {
|
||||
internalHandler.obtainMessage(MSG_CONTENT_LENGTH_CHANGED, this).sendToTarget();
|
||||
}
|
||||
|
@ -592,8 +592,8 @@ public abstract class DownloadService extends Service {
|
||||
public int onStartCommand(Intent intent, int flags, int startId) {
|
||||
lastStartId = startId;
|
||||
taskRemoved = false;
|
||||
String intentAction = null;
|
||||
String contentId = null;
|
||||
@Nullable String intentAction = null;
|
||||
@Nullable String contentId = null;
|
||||
if (intent != null) {
|
||||
intentAction = intent.getAction();
|
||||
startedInForeground |=
|
||||
@ -611,7 +611,7 @@ public abstract class DownloadService extends Service {
|
||||
// Do nothing.
|
||||
break;
|
||||
case ACTION_ADD_DOWNLOAD:
|
||||
DownloadRequest downloadRequest = intent.getParcelableExtra(KEY_DOWNLOAD_REQUEST);
|
||||
@Nullable DownloadRequest downloadRequest = intent.getParcelableExtra(KEY_DOWNLOAD_REQUEST);
|
||||
if (downloadRequest == null) {
|
||||
Log.e(TAG, "Ignored ADD_DOWNLOAD: Missing " + KEY_DOWNLOAD_REQUEST + " extra");
|
||||
} else {
|
||||
@ -644,7 +644,7 @@ public abstract class DownloadService extends Service {
|
||||
}
|
||||
break;
|
||||
case ACTION_SET_REQUIREMENTS:
|
||||
Requirements requirements = intent.getParcelableExtra(KEY_REQUIREMENTS);
|
||||
@Nullable Requirements requirements = intent.getParcelableExtra(KEY_REQUIREMENTS);
|
||||
if (requirements == null) {
|
||||
Log.e(TAG, "Ignored SET_REQUIREMENTS: Missing " + KEY_REQUIREMENTS + " extra");
|
||||
} else {
|
||||
|
@ -138,7 +138,7 @@ public abstract class SegmentDownloader<M extends FilterableManifest<M>> impleme
|
||||
Collections.sort(segments);
|
||||
|
||||
// Download the segments.
|
||||
ProgressNotifier progressNotifier = null;
|
||||
@Nullable ProgressNotifier progressNotifier = null;
|
||||
if (progressListener != null) {
|
||||
progressNotifier =
|
||||
new ProgressNotifier(
|
||||
|
Loading…
x
Reference in New Issue
Block a user