Merge pull request #7010 from dbrain:fix_nullability

PiperOrigin-RevId: 297187116
This commit is contained in:
Oliver Woodman 2020-02-25 21:24:27 +00:00
commit 46ebaff965
2 changed files with 21 additions and 17 deletions

View File

@ -270,8 +270,8 @@ public final class DownloadHelper {
* @param dataSourceFactory A {@link DataSource.Factory} used to load the manifest.
* @param renderersFactory A {@link RenderersFactory} creating the renderers for which tracks are
* selected.
* @param drmSessionManager An optional {@link DrmSessionManager} used by the renderers created by
* {@code renderersFactory}.
* @param drmSessionManager An optional {@link DrmSessionManager}. Used to help determine which
* tracks can be selected.
* @param trackSelectorParameters {@link DefaultTrackSelector.Parameters} for selecting tracks for
* downloading.
* @return A {@link DownloadHelper} for DASH streams.
@ -340,8 +340,8 @@ public final class DownloadHelper {
* @param dataSourceFactory A {@link DataSource.Factory} used to load the playlist.
* @param renderersFactory A {@link RenderersFactory} creating the renderers for which tracks are
* selected.
* @param drmSessionManager An optional {@link DrmSessionManager} used by the renderers created by
* {@code renderersFactory}.
* @param drmSessionManager An optional {@link DrmSessionManager}. Used to help determine which
* tracks can be selected.
* @param trackSelectorParameters {@link DefaultTrackSelector.Parameters} for selecting tracks for
* downloading.
* @return A {@link DownloadHelper} for HLS streams.
@ -410,8 +410,8 @@ public final class DownloadHelper {
* @param dataSourceFactory A {@link DataSource.Factory} used to load the manifest.
* @param renderersFactory A {@link RenderersFactory} creating the renderers for which tracks are
* selected.
* @param drmSessionManager An optional {@link DrmSessionManager} used by the renderers created by
* {@code renderersFactory}.
* @param drmSessionManager An optional {@link DrmSessionManager}. Used to help determine which
* tracks can be selected.
* @param trackSelectorParameters {@link DefaultTrackSelector.Parameters} for selecting tracks for
* downloading.
* @return A {@link DownloadHelper} for SmoothStreaming streams.
@ -439,27 +439,27 @@ public final class DownloadHelper {
/**
* Equivalent to {@link #createMediaSource(DownloadRequest, Factory, DrmSessionManager)
* createMediaSource(downloadRequest, dataSourceFactory,
* DrmSessionManager.getDummyDrmSessionManager())}.
* createMediaSource(downloadRequest, dataSourceFactory, null)}.
*/
public static MediaSource createMediaSource(
DownloadRequest downloadRequest, DataSource.Factory dataSourceFactory) {
return createMediaSource(
downloadRequest, dataSourceFactory, DrmSessionManager.getDummyDrmSessionManager());
return createMediaSource(downloadRequest, dataSourceFactory, /* drmSessionManager= */ null);
}
/**
* Utility method to create a MediaSource which only contains the tracks defined in {@code
* Utility method to create a {@link MediaSource} that only exposes the tracks defined in {@code
* downloadRequest}.
*
* @param downloadRequest A {@link DownloadRequest}.
* @param dataSourceFactory A factory for {@link DataSource}s to read the media.
* @return A MediaSource which only contains the tracks defined in {@code downloadRequest}.
* @param drmSessionManager An optional {@link DrmSessionManager} to be passed to the {@link
* MediaSource}.
* @return A {@link MediaSource} that only exposes the tracks defined in {@code downloadRequest}.
*/
public static MediaSource createMediaSource(
DownloadRequest downloadRequest,
DataSource.Factory dataSourceFactory,
DrmSessionManager<?> drmSessionManager) {
@Nullable DrmSessionManager<?> drmSessionManager) {
@Nullable Constructor<? extends MediaSourceFactory> constructor;
switch (downloadRequest.type) {
case DownloadRequest.TYPE_DASH:

View File

@ -595,7 +595,7 @@ public abstract class DownloadService extends Service {
}
@Override
public int onStartCommand(Intent intent, int flags, int startId) {
public int onStartCommand(@Nullable Intent intent, int flags, int startId) {
lastStartId = startId;
taskRemoved = false;
@Nullable String intentAction = null;
@ -617,7 +617,9 @@ public abstract class DownloadService extends Service {
// Do nothing.
break;
case ACTION_ADD_DOWNLOAD:
@Nullable DownloadRequest downloadRequest = intent.getParcelableExtra(KEY_DOWNLOAD_REQUEST);
@Nullable
DownloadRequest downloadRequest =
Assertions.checkNotNull(intent).getParcelableExtra(KEY_DOWNLOAD_REQUEST);
if (downloadRequest == null) {
Log.e(TAG, "Ignored ADD_DOWNLOAD: Missing " + KEY_DOWNLOAD_REQUEST + " extra");
} else {
@ -642,7 +644,7 @@ public abstract class DownloadService extends Service {
downloadManager.pauseDownloads();
break;
case ACTION_SET_STOP_REASON:
if (!intent.hasExtra(KEY_STOP_REASON)) {
if (!Assertions.checkNotNull(intent).hasExtra(KEY_STOP_REASON)) {
Log.e(TAG, "Ignored SET_STOP_REASON: Missing " + KEY_STOP_REASON + " extra");
} else {
int stopReason = intent.getIntExtra(KEY_STOP_REASON, /* defaultValue= */ 0);
@ -650,7 +652,9 @@ public abstract class DownloadService extends Service {
}
break;
case ACTION_SET_REQUIREMENTS:
@Nullable Requirements requirements = intent.getParcelableExtra(KEY_REQUIREMENTS);
@Nullable
Requirements requirements =
Assertions.checkNotNull(intent).getParcelableExtra(KEY_REQUIREMENTS);
if (requirements == null) {
Log.e(TAG, "Ignored SET_REQUIREMENTS: Missing " + KEY_REQUIREMENTS + " extra");
} else {