Fix some potential Uri nullness violations.

PiperOrigin-RevId: 223476569
This commit is contained in:
tonihei 2018-11-30 08:40:17 +00:00 committed by Oliver Woodman
parent 282cf303a4
commit ea483f8c8e
3 changed files with 7 additions and 3 deletions

View file

@ -228,7 +228,8 @@ public final class DefaultDataSource implements DataSource {
// Choose the correct source for the scheme.
String scheme = dataSpec.uri.getScheme();
if (Util.isLocalFileUri(dataSpec.uri)) {
if (dataSpec.uri.getPath().startsWith("/android_asset/")) {
String uriPath = dataSpec.uri.getPath();
if (uriPath != null && uriPath.startsWith("/android_asset/")) {
dataSource = getAssetDataSource();
} else {
dataSource = getFileDataSource();

View file

@ -204,7 +204,8 @@ public final class Util {
}
for (Uri uri : uris) {
if ("http".equals(uri.getScheme())
&& !NetworkSecurityPolicy.getInstance().isCleartextTrafficPermitted(uri.getHost())) {
&& !NetworkSecurityPolicy.getInstance()
.isCleartextTrafficPermitted(Assertions.checkNotNull(uri.getHost()))) {
// The security policy prevents cleartext traffic.
return false;
}

View file

@ -23,7 +23,9 @@ public final class SsUtil {
/** Returns a fixed SmoothStreaming client manifest {@link Uri}. */
public static Uri fixManifestUri(Uri manifestUri) {
if (Util.toLowerInvariant(manifestUri.getLastPathSegment()).matches("manifest(\\(.+\\))?")) {
String lastPathSegment = manifestUri.getLastPathSegment();
if (lastPathSegment != null
&& Util.toLowerInvariant(lastPathSegment).matches("manifest(\\(.+\\))?")) {
return manifestUri;
}
return Uri.withAppendedPath(manifestUri, "Manifest");