Add checkNotNull(uri) to DataSpec constructor

This check is already present in `DataSpec.Builder.build()` but there
are many public constructors which bypass the builder (only some of
which are deprecated), so this adds an additional check.

PiperOrigin-RevId: 613908358
This commit is contained in:
ibaker 2024-03-08 05:56:16 -08:00 committed by Copybara-Service
parent f4c60c52b9
commit f9032a5893
2 changed files with 4 additions and 1 deletions

View File

@ -57,6 +57,8 @@
where `package` is different to the package of the current application.
This wasn't previously documented to work, but is a more efficient way
of accessing resources in another package than by name.
* Eagerly check `url` is non-null in the `DataSpec` constructors. This
parameter was already annotated to be non-null.
* Effect:
* Improved PQ to SDR tone-mapping by converting color spaces.
* Support multiple speed changes within the same `EditedMediaItem` or

View File

@ -15,6 +15,7 @@
*/
package androidx.media3.datasource;
import static androidx.media3.common.util.Assertions.checkNotNull;
import static java.lang.annotation.ElementType.TYPE_USE;
import android.net.Uri;
@ -473,7 +474,7 @@ public final class DataSpec {
Assertions.checkArgument(uriPositionOffset + position >= 0);
Assertions.checkArgument(position >= 0);
Assertions.checkArgument(length > 0 || length == C.LENGTH_UNSET);
this.uri = uri;
this.uri = checkNotNull(uri);
this.uriPositionOffset = uriPositionOffset;
this.httpMethod = httpMethod;
this.httpBody = httpBody != null && httpBody.length != 0 ? httpBody : null;