diff --git a/library/core/src/main/java/com/google/android/exoplayer2/offline/DownloadRequest.java b/library/core/src/main/java/com/google/android/exoplayer2/offline/DownloadRequest.java index 5acefd6f93..7ff43ceacd 100644 --- a/library/core/src/main/java/com/google/android/exoplayer2/offline/DownloadRequest.java +++ b/library/core/src/main/java/com/google/android/exoplayer2/offline/DownloadRequest.java @@ -52,7 +52,10 @@ public final class DownloadRequest implements Parcelable { public final Uri uri; /** Stream keys to be downloaded. If empty, all streams will be downloaded. */ public final List streamKeys; - /** Custom key for cache indexing, or null. */ + /** + * Custom key for cache indexing, or null. Must be null for DASH, HLS and SmoothStreaming + * downloads. + */ @Nullable public final String customCacheKey; /** Application defined data associated with the download. May be empty. */ public final byte[] data; @@ -72,6 +75,10 @@ public final class DownloadRequest implements Parcelable { List streamKeys, @Nullable String customCacheKey, @Nullable byte[] data) { + if (TYPE_DASH.equals(type) || TYPE_HLS.equals(type) || TYPE_SS.equals(type)) { + Assertions.checkArgument( + customCacheKey == null, "customCacheKey must be null for type: " + type); + } this.id = id; this.type = type; this.uri = uri; diff --git a/library/core/src/test/assets/offline/action_file_for_download_index_upgrade.exi b/library/core/src/test/assets/offline/action_file_for_download_index_upgrade.exi index 888ba4af44..0bf49b133a 100644 Binary files a/library/core/src/test/assets/offline/action_file_for_download_index_upgrade.exi and b/library/core/src/test/assets/offline/action_file_for_download_index_upgrade.exi differ diff --git a/library/core/src/test/java/com/google/android/exoplayer2/offline/ActionFileUpgradeUtilTest.java b/library/core/src/test/java/com/google/android/exoplayer2/offline/ActionFileUpgradeUtilTest.java index 5153b53839..96b8ff21bc 100644 --- a/library/core/src/test/java/com/google/android/exoplayer2/offline/ActionFileUpgradeUtilTest.java +++ b/library/core/src/test/java/com/google/android/exoplayer2/offline/ActionFileUpgradeUtilTest.java @@ -15,7 +15,7 @@ */ package com.google.android.exoplayer2.offline; -import static com.google.android.exoplayer2.offline.DownloadRequest.TYPE_DASH; +import static com.google.android.exoplayer2.offline.DownloadRequest.TYPE_PROGRESSIVE; import static com.google.common.truth.Truth.assertThat; import android.net.Uri; @@ -73,7 +73,7 @@ public class ActionFileUpgradeUtilTest { DownloadRequest expectedRequest1 = new DownloadRequest( "key123", - TYPE_DASH, + /* type= */ "test", Uri.parse("https://www.test.com/download1"), asList(expectedStreamKey1), /* customCacheKey= */ "key123", @@ -81,7 +81,7 @@ public class ActionFileUpgradeUtilTest { DownloadRequest expectedRequest2 = new DownloadRequest( "key234", - TYPE_DASH, + /* type= */ "test", Uri.parse("https://www.test.com/download2"), asList(expectedStreamKey2), /* customCacheKey= */ "key234", @@ -100,7 +100,7 @@ public class ActionFileUpgradeUtilTest { DownloadRequest request = new DownloadRequest( "id", - TYPE_DASH, + TYPE_PROGRESSIVE, Uri.parse("https://www.test.com/download"), asList( new StreamKey(/* periodIndex= */ 0, /* groupIndex= */ 1, /* trackIndex= */ 2), @@ -122,7 +122,7 @@ public class ActionFileUpgradeUtilTest { DownloadRequest request1 = new DownloadRequest( "id", - TYPE_DASH, + TYPE_PROGRESSIVE, Uri.parse("https://www.test.com/download1"), asList(streamKey1), /* customCacheKey= */ "key123", @@ -130,7 +130,7 @@ public class ActionFileUpgradeUtilTest { DownloadRequest request2 = new DownloadRequest( "id", - TYPE_DASH, + TYPE_PROGRESSIVE, Uri.parse("https://www.test.com/download2"), asList(streamKey2), /* customCacheKey= */ "key123", diff --git a/library/core/src/test/java/com/google/android/exoplayer2/offline/DownloadRequestTest.java b/library/core/src/test/java/com/google/android/exoplayer2/offline/DownloadRequestTest.java index d298dd58b8..a55b1e1283 100644 --- a/library/core/src/test/java/com/google/android/exoplayer2/offline/DownloadRequestTest.java +++ b/library/core/src/test/java/com/google/android/exoplayer2/offline/DownloadRequestTest.java @@ -17,6 +17,7 @@ package com.google.android.exoplayer2.offline; import static com.google.android.exoplayer2.offline.DownloadRequest.TYPE_DASH; import static com.google.android.exoplayer2.offline.DownloadRequest.TYPE_HLS; +import static com.google.android.exoplayer2.offline.DownloadRequest.TYPE_PROGRESSIVE; import static com.google.common.truth.Truth.assertThat; import static org.junit.Assert.fail; @@ -139,7 +140,7 @@ public class DownloadRequestTest { DownloadRequest request1 = new DownloadRequest( "id1", - TYPE_DASH, + TYPE_PROGRESSIVE, uri1, /* streamKeys= */ Collections.emptyList(), "key1", @@ -147,7 +148,7 @@ public class DownloadRequestTest { DownloadRequest request2 = new DownloadRequest( "id1", - TYPE_DASH, + TYPE_PROGRESSIVE, uri2, /* streamKeys= */ Collections.emptyList(), "key2",