From 12b0537c2f3afabd9b53c234cf922cdebc62a2ed Mon Sep 17 00:00:00 2001 From: olly Date: Fri, 11 Sep 2020 17:27:56 +0100 Subject: [PATCH] Clean up some lint warnings PiperOrigin-RevId: 331162350 --- demos/cast/build.gradle | 2 +- demos/main/build.gradle | 2 +- .../exoplayer2/demo/DownloadTracker.java | 90 ++++++++++--------- demos/main/src/main/res/values/strings.xml | 6 -- extensions/media2/build.gradle | 2 +- extensions/workmanager/build.gradle | 2 +- 6 files changed, 53 insertions(+), 51 deletions(-) diff --git a/demos/cast/build.gradle b/demos/cast/build.gradle index b26112e15a..868e3c7b43 100644 --- a/demos/cast/build.gradle +++ b/demos/cast/build.gradle @@ -60,7 +60,7 @@ dependencies { implementation 'androidx.appcompat:appcompat:' + androidxAppCompatVersion implementation 'androidx.multidex:multidex:' + androidxMultidexVersion implementation 'androidx.recyclerview:recyclerview:1.1.0' - implementation 'com.google.android.material:material:1.1.0' + implementation 'com.google.android.material:material:1.2.1' } apply plugin: 'com.google.android.gms.strict-version-matcher-plugin' diff --git a/demos/main/build.gradle b/demos/main/build.gradle index 3a3b7a4a45..716b3c1f99 100644 --- a/demos/main/build.gradle +++ b/demos/main/build.gradle @@ -69,7 +69,7 @@ dependencies { implementation 'androidx.annotation:annotation:' + androidxAnnotationVersion implementation 'androidx.appcompat:appcompat:' + androidxAppCompatVersion implementation 'androidx.multidex:multidex:' + androidxMultidexVersion - implementation 'com.google.android.material:material:1.2.0' + implementation 'com.google.android.material:material:1.2.1' implementation ('com.google.guava:guava:' + guavaVersion) { exclude group: 'com.google.code.findbugs', module: 'jsr305' exclude group: 'org.checkerframework', module: 'checker-compat-qual' diff --git a/demos/main/src/main/java/com/google/android/exoplayer2/demo/DownloadTracker.java b/demos/main/src/main/java/com/google/android/exoplayer2/demo/DownloadTracker.java index b448dd40de..07f4dd2f6e 100644 --- a/demos/main/src/main/java/com/google/android/exoplayer2/demo/DownloadTracker.java +++ b/demos/main/src/main/java/com/google/android/exoplayer2/demo/DownloadTracker.java @@ -222,7 +222,11 @@ public class DownloadTracker { } widevineOfflineLicenseFetchTask = new WidevineOfflineLicenseFetchTask( - format, mediaItem.playbackProperties.drmConfiguration.licenseUri, this, helper); + format, + mediaItem.playbackProperties.drmConfiguration.licenseUri, + httpDataSourceFactory, + /* dialogHelper= */ this, + helper); widevineOfflineLicenseFetchTask.execute(); } @@ -271,6 +275,32 @@ public class DownloadTracker { // Internal methods. + /** + * Returns the first {@link Format} with a non-null {@link Format#drmInitData} found in the + * content's tracks, or null if none is found. + */ + @Nullable + private Format getFirstFormatWithDrmInitData(DownloadHelper helper) { + for (int periodIndex = 0; periodIndex < helper.getPeriodCount(); periodIndex++) { + MappedTrackInfo mappedTrackInfo = helper.getMappedTrackInfo(periodIndex); + for (int rendererIndex = 0; + rendererIndex < mappedTrackInfo.getRendererCount(); + rendererIndex++) { + TrackGroupArray trackGroups = mappedTrackInfo.getTrackGroups(rendererIndex); + for (int trackGroupIndex = 0; trackGroupIndex < trackGroups.length; trackGroupIndex++) { + TrackGroup trackGroup = trackGroups.get(trackGroupIndex); + for (int formatIndex = 0; formatIndex < trackGroup.length; formatIndex++) { + Format format = trackGroup.getFormat(formatIndex); + if (format.drmInitData != null) { + return format; + } + } + } + } + } + return null; + } + private void onOfflineLicenseFetched(DownloadHelper helper, byte[] keySetId) { this.keySetId = keySetId; onDownloadPrepared(helper); @@ -309,6 +339,19 @@ public class DownloadTracker { trackSelectionDialog.show(fragmentManager, /* tag= */ null); } + /** + * Returns whether any the {@link DrmInitData.SchemeData} contained in {@code drmInitData} has + * non-null {@link DrmInitData.SchemeData#data}. + */ + private boolean hasSchemaData(DrmInitData drmInitData) { + for (int i = 0; i < drmInitData.schemeDataCount; i++) { + if (drmInitData.get(i).hasData()) { + return true; + } + } + return false; + } + private void startDownload() { startDownload(buildDownloadRequest()); } @@ -327,9 +370,11 @@ public class DownloadTracker { /** Downloads a Widevine offline license in a background thread. */ @RequiresApi(18) - private final class WidevineOfflineLicenseFetchTask extends AsyncTask { + private static final class WidevineOfflineLicenseFetchTask extends AsyncTask { + private final Format format; private final Uri licenseUri; + private final HttpDataSource.Factory httpDataSourceFactory; private final StartDownloadDialogHelper dialogHelper; private final DownloadHelper downloadHelper; @@ -339,10 +384,12 @@ public class DownloadTracker { public WidevineOfflineLicenseFetchTask( Format format, Uri licenseUri, + HttpDataSource.Factory httpDataSourceFactory, StartDownloadDialogHelper dialogHelper, DownloadHelper downloadHelper) { this.format = format; this.licenseUri = licenseUri; + this.httpDataSourceFactory = httpDataSourceFactory; this.dialogHelper = dialogHelper; this.downloadHelper = downloadHelper; } @@ -373,43 +420,4 @@ public class DownloadTracker { } } } - - /** - * Returns whether any the {@link DrmInitData.SchemeData} contained in {@code drmInitData} has - * non-null {@link DrmInitData.SchemeData#data}. - */ - private static boolean hasSchemaData(DrmInitData drmInitData) { - for (int i = 0; i < drmInitData.schemeDataCount; i++) { - if (drmInitData.get(i).hasData()) { - return true; - } - } - return false; - } - - /** - * Returns the first {@link Format} with a non-null {@link Format#drmInitData} found in the - * content's tracks, or null if none is found. - */ - @Nullable - private Format getFirstFormatWithDrmInitData(DownloadHelper helper) { - for (int periodIndex = 0; periodIndex < helper.getPeriodCount(); periodIndex++) { - MappedTrackInfo mappedTrackInfo = helper.getMappedTrackInfo(periodIndex); - for (int rendererIndex = 0; - rendererIndex < mappedTrackInfo.getRendererCount(); - rendererIndex++) { - TrackGroupArray trackGroups = mappedTrackInfo.getTrackGroups(rendererIndex); - for (int trackGroupIndex = 0; trackGroupIndex < trackGroups.length; trackGroupIndex++) { - TrackGroup trackGroup = trackGroups.get(trackGroupIndex); - for (int formatIndex = 0; formatIndex < trackGroup.length; formatIndex++) { - Format format = trackGroup.getFormat(formatIndex); - if (format.drmInitData != null) { - return format; - } - } - } - } - } - return null; - } } diff --git a/demos/main/src/main/res/values/strings.xml b/demos/main/src/main/res/values/strings.xml index 3f80b70184..bd5cd63467 100644 --- a/demos/main/src/main/res/values/strings.xml +++ b/demos/main/src/main/res/values/strings.xml @@ -25,16 +25,10 @@ Playback failed - Unrecognized ABR algorithm - - Unrecognized stereo mode - DRM content not supported on API levels below 18 This device does not support the required DRM scheme - An unknown DRM error occurred - This device does not provide a decoder for %1$s This device does not provide a secure decoder for %1$s diff --git a/extensions/media2/build.gradle b/extensions/media2/build.gradle index cedb4cd55f..744d79980b 100644 --- a/extensions/media2/build.gradle +++ b/extensions/media2/build.gradle @@ -18,7 +18,7 @@ android.defaultConfig.minSdkVersion 19 dependencies { implementation project(modulePrefix + 'library-core') implementation 'androidx.collection:collection:' + androidxCollectionVersion - implementation 'androidx.concurrent:concurrent-futures:1.0.0' + implementation 'androidx.concurrent:concurrent-futures:1.1.0' implementation ('com.google.guava:guava:' + guavaVersion) { exclude group: 'com.google.code.findbugs', module: 'jsr305' exclude group: 'org.checkerframework', module: 'checker-compat-qual' diff --git a/extensions/workmanager/build.gradle b/extensions/workmanager/build.gradle index 8eab503d23..1882ebac81 100644 --- a/extensions/workmanager/build.gradle +++ b/extensions/workmanager/build.gradle @@ -17,7 +17,7 @@ apply from: "$gradle.ext.exoplayerSettingsDir/common_library_config.gradle" dependencies { implementation project(modulePrefix + 'library-core') - implementation 'androidx.work:work-runtime:2.3.4' + implementation 'androidx.work:work-runtime:2.4.0' // Guava & Gradle interact badly, and this prevents // "cannot access ListenableFuture" errors [internal b/157225611]. // More info: https://blog.gradle.org/guava