Merge pull request #3771 from reudismam/dev-v2

Use the pattern "string literal".equals(something) to prevent NPE …
This commit is contained in:
ojw28 2018-02-27 11:24:29 +00:00 committed by GitHub
commit dc34ff2e6b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 15 additions and 15 deletions

View File

@ -48,7 +48,7 @@ public class DemoApplication extends Application {
} }
public boolean useExtensionRenderers() { public boolean useExtensionRenderers() {
return BuildConfig.FLAVOR.equals("withExtensions"); return "withExtensions".equals(BuildConfig.FLAVOR);
} }
} }

View File

@ -354,15 +354,15 @@ public final class MediaCodecUtil {
// Work around https://github.com/google/ExoPlayer/issues/3249. // Work around https://github.com/google/ExoPlayer/issues/3249.
if (Util.SDK_INT < 24 if (Util.SDK_INT < 24
&& ("OMX.SEC.aac.dec".equals(name) || "OMX.Exynos.AAC.Decoder".equals(name)) && ("OMX.SEC.aac.dec".equals(name) || "OMX.Exynos.AAC.Decoder".equals(name))
&& Util.MANUFACTURER.equals("samsung") && "samsung".equals(Util.MANUFACTURER)
&& (Util.DEVICE.startsWith("zeroflte") // Galaxy S6 && (Util.DEVICE.startsWith("zeroflte") // Galaxy S6
|| Util.DEVICE.startsWith("zerolte") // Galaxy S6 Edge || Util.DEVICE.startsWith("zerolte") // Galaxy S6 Edge
|| Util.DEVICE.startsWith("zenlte") // Galaxy S6 Edge+ || Util.DEVICE.startsWith("zenlte") // Galaxy S6 Edge+
|| Util.DEVICE.equals("SC-05G") // Galaxy S6 || "SC-05G".equals(Util.DEVICE) // Galaxy S6
|| Util.DEVICE.equals("marinelteatt") // Galaxy S6 Active || "marinelteatt".equals(Util.DEVICE) // Galaxy S6 Active
|| Util.DEVICE.equals("404SC") // Galaxy S6 Edge || "404SC".equals(Util.DEVICE) // Galaxy S6 Edge
|| Util.DEVICE.equals("SC-04G") || "SC-04G".equals(Util.DEVICE)
|| Util.DEVICE.equals("SCV31"))) { || "SCV31".equals(Util.DEVICE))) {
return false; return false;
} }
@ -421,7 +421,7 @@ public final class MediaCodecUtil {
*/ */
private static boolean codecNeedsDisableAdaptationWorkaround(String name) { private static boolean codecNeedsDisableAdaptationWorkaround(String name) {
return Util.SDK_INT <= 22 return Util.SDK_INT <= 22
&& (Util.MODEL.equals("ODROID-XU3") || Util.MODEL.equals("Nexus 10")) && ("ODROID-XU3".equals(Util.MODEL) || "Nexus 10".equals(Util.MODEL))
&& ("OMX.Exynos.AVC.Decoder".equals(name) || "OMX.Exynos.AVC.Decoder.secure".equals(name)); && ("OMX.Exynos.AVC.Decoder".equals(name) || "OMX.Exynos.AVC.Decoder.secure".equals(name));
} }

View File

@ -518,7 +518,7 @@ public final class Id3Decoder implements MetadataDecoder {
if (majorVersion == 2) { if (majorVersion == 2) {
mimeTypeEndIndex = 2; mimeTypeEndIndex = 2;
mimeType = "image/" + Util.toLowerInvariant(new String(data, 0, 3, "ISO-8859-1")); mimeType = "image/" + Util.toLowerInvariant(new String(data, 0, 3, "ISO-8859-1"));
if (mimeType.equals("image/jpg")) { if ("image/jpg".equals(mimeType)) {
mimeType = "image/jpeg"; mimeType = "image/jpeg";
} }
} else { } else {

View File

@ -613,9 +613,9 @@ public class DefaultHttpDataSource implements HttpDataSource {
return; return;
} }
String className = inputStream.getClass().getName(); String className = inputStream.getClass().getName();
if (className.equals("com.android.okhttp.internal.http.HttpTransport$ChunkedInputStream") if ("com.android.okhttp.internal.http.HttpTransport$ChunkedInputStream".equals(className)
|| className.equals( || "com.android.okhttp.internal.http.HttpTransport$FixedLengthInputStream".equals(
"com.android.okhttp.internal.http.HttpTransport$FixedLengthInputStream")) { className)) {
Class<?> superclass = inputStream.getClass().getSuperclass(); Class<?> superclass = inputStream.getClass().getSuperclass();
Method unexpectedEndOfInput = superclass.getDeclaredMethod("unexpectedEndOfInput"); Method unexpectedEndOfInput = superclass.getDeclaredMethod("unexpectedEndOfInput");
unexpectedEndOfInput.setAccessible(true); unexpectedEndOfInput.setAccessible(true);

View File

@ -160,7 +160,7 @@ public final class Util {
*/ */
public static boolean isLocalFileUri(Uri uri) { public static boolean isLocalFileUri(Uri uri) {
String scheme = uri.getScheme(); String scheme = uri.getScheme();
return TextUtils.isEmpty(scheme) || scheme.equals("file"); return TextUtils.isEmpty(scheme) || "file".equals(scheme);
} }
/** /**
@ -629,7 +629,7 @@ public final class Util {
} else { } else {
timezoneShift = ((Integer.parseInt(matcher.group(12)) * 60 timezoneShift = ((Integer.parseInt(matcher.group(12)) * 60
+ Integer.parseInt(matcher.group(13)))); + Integer.parseInt(matcher.group(13))));
if (matcher.group(11).equals("-")) { if ("-".equals(matcher.group(11))) {
timezoneShift *= -1; timezoneShift *= -1;
} }
} }

View File

@ -112,7 +112,7 @@ public class DashManifestParser extends DefaultHandler
long durationMs = parseDuration(xpp, "mediaPresentationDuration", C.TIME_UNSET); long durationMs = parseDuration(xpp, "mediaPresentationDuration", C.TIME_UNSET);
long minBufferTimeMs = parseDuration(xpp, "minBufferTime", C.TIME_UNSET); long minBufferTimeMs = parseDuration(xpp, "minBufferTime", C.TIME_UNSET);
String typeString = xpp.getAttributeValue(null, "type"); String typeString = xpp.getAttributeValue(null, "type");
boolean dynamic = typeString != null && typeString.equals("dynamic"); boolean dynamic = typeString != null && "dynamic".equals(typeString);
long minUpdateTimeMs = dynamic ? parseDuration(xpp, "minimumUpdatePeriod", C.TIME_UNSET) long minUpdateTimeMs = dynamic ? parseDuration(xpp, "minimumUpdatePeriod", C.TIME_UNSET)
: C.TIME_UNSET; : C.TIME_UNSET;
long timeShiftBufferDepthMs = dynamic long timeShiftBufferDepthMs = dynamic