mirror of
https://github.com/samsonjs/media.git
synced 2026-04-13 12:35:48 +00:00
Fix util nullness warnings.
------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=212276150
This commit is contained in:
parent
09aaec6b01
commit
bf0a7937e2
10 changed files with 38 additions and 31 deletions
|
|
@ -1409,10 +1409,8 @@ public final class Format implements Parcelable {
|
|||
|
||||
// Utility methods
|
||||
|
||||
/**
|
||||
* Returns a prettier {@link String} than {@link #toString()}, intended for logging.
|
||||
*/
|
||||
public static String toLogString(Format format) {
|
||||
/** Returns a prettier {@link String} than {@link #toString()}, intended for logging. */
|
||||
public static String toLogString(@Nullable Format format) {
|
||||
if (format == null) {
|
||||
return "null";
|
||||
}
|
||||
|
|
|
|||
|
|
@ -19,6 +19,7 @@ import com.google.android.exoplayer2.C;
|
|||
import com.google.android.exoplayer2.metadata.Metadata;
|
||||
import com.google.android.exoplayer2.metadata.MetadataDecoder;
|
||||
import com.google.android.exoplayer2.metadata.MetadataInputBuffer;
|
||||
import com.google.android.exoplayer2.util.Assertions;
|
||||
import com.google.android.exoplayer2.util.ParsableByteArray;
|
||||
import com.google.android.exoplayer2.util.Util;
|
||||
import java.nio.ByteBuffer;
|
||||
|
|
@ -39,8 +40,8 @@ public final class EventMessageDecoder implements MetadataDecoder {
|
|||
byte[] data = buffer.array();
|
||||
int size = buffer.limit();
|
||||
ParsableByteArray emsgData = new ParsableByteArray(data, size);
|
||||
String schemeIdUri = emsgData.readNullTerminatedString();
|
||||
String value = emsgData.readNullTerminatedString();
|
||||
String schemeIdUri = Assertions.checkNotNull(emsgData.readNullTerminatedString());
|
||||
String value = Assertions.checkNotNull(emsgData.readNullTerminatedString());
|
||||
long timescale = emsgData.readUnsignedInt();
|
||||
long presentationTimeUs = Util.scaleLargeTimestamp(emsgData.readUnsignedInt(),
|
||||
C.MICROS_PER_SECOND, timescale);
|
||||
|
|
|
|||
|
|
@ -103,7 +103,7 @@ public final class AtomicFile {
|
|||
str = new AtomicFileOutputStream(baseName);
|
||||
} catch (FileNotFoundException e) {
|
||||
File parent = baseName.getParentFile();
|
||||
if (!parent.mkdirs()) {
|
||||
if (parent == null || !parent.mkdirs()) {
|
||||
throw new IOException("Couldn't create directory " + baseName, e);
|
||||
}
|
||||
try {
|
||||
|
|
|
|||
|
|
@ -42,6 +42,7 @@ import java.text.NumberFormat;
|
|||
import java.util.Locale;
|
||||
|
||||
/** Logs events from {@link Player} and other core components using {@link Log}. */
|
||||
@SuppressWarnings("UngroupedOverloads")
|
||||
public class EventLogger implements AnalyticsListener {
|
||||
|
||||
private static final String DEFAULT_TAG = "EventLogger";
|
||||
|
|
@ -435,7 +436,7 @@ public class EventLogger implements AnalyticsListener {
|
|||
* @param msg The message to log.
|
||||
* @param tr The exception to log.
|
||||
*/
|
||||
protected void loge(String msg, Throwable tr) {
|
||||
protected void loge(String msg, @Nullable Throwable tr) {
|
||||
Log.e(tag, msg, tr);
|
||||
}
|
||||
|
||||
|
|
@ -449,12 +450,15 @@ public class EventLogger implements AnalyticsListener {
|
|||
logd(getEventString(eventTime, eventName, eventDescription));
|
||||
}
|
||||
|
||||
private void loge(EventTime eventTime, String eventName, Throwable throwable) {
|
||||
private void loge(EventTime eventTime, String eventName, @Nullable Throwable throwable) {
|
||||
loge(getEventString(eventTime, eventName), throwable);
|
||||
}
|
||||
|
||||
private void loge(
|
||||
EventTime eventTime, String eventName, String eventDescription, Throwable throwable) {
|
||||
EventTime eventTime,
|
||||
String eventName,
|
||||
String eventDescription,
|
||||
@Nullable Throwable throwable) {
|
||||
loge(getEventString(eventTime, eventName, eventDescription), throwable);
|
||||
}
|
||||
|
||||
|
|
@ -548,8 +552,8 @@ public class EventLogger implements AnalyticsListener {
|
|||
// Suppressing reference equality warning because the track group stored in the track selection
|
||||
// must point to the exact track group object to be considered part of it.
|
||||
@SuppressWarnings("ReferenceEquality")
|
||||
private static String getTrackStatusString(TrackSelection selection, TrackGroup group,
|
||||
int trackIndex) {
|
||||
private static String getTrackStatusString(
|
||||
@Nullable TrackSelection selection, TrackGroup group, int trackIndex) {
|
||||
return getTrackStatusString(selection != null && selection.getTrackGroup() == group
|
||||
&& selection.indexOf(trackIndex) != C.INDEX_UNSET);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -28,10 +28,10 @@ public final class ParsableBitArray {
|
|||
private int bitOffset;
|
||||
private int byteLimit;
|
||||
|
||||
/**
|
||||
* Creates a new instance that initially has no backing data.
|
||||
*/
|
||||
public ParsableBitArray() {}
|
||||
/** Creates a new instance that initially has no backing data. */
|
||||
public ParsableBitArray() {
|
||||
data = Util.EMPTY_BYTE_ARRAY;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new instance that wraps an existing array.
|
||||
|
|
|
|||
|
|
@ -15,6 +15,7 @@
|
|||
*/
|
||||
package com.google.android.exoplayer2.util;
|
||||
|
||||
import android.support.annotation.Nullable;
|
||||
import com.google.android.exoplayer2.C;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.charset.Charset;
|
||||
|
|
@ -30,10 +31,10 @@ public final class ParsableByteArray {
|
|||
private int position;
|
||||
private int limit;
|
||||
|
||||
/**
|
||||
* Creates a new instance that initially has no backing data.
|
||||
*/
|
||||
public ParsableByteArray() {}
|
||||
/** Creates a new instance that initially has no backing data. */
|
||||
public ParsableByteArray() {
|
||||
data = Util.EMPTY_BYTE_ARRAY;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new instance with {@code limit} bytes and sets the limit.
|
||||
|
|
@ -131,7 +132,7 @@ public final class ParsableByteArray {
|
|||
* Returns the capacity of the array, which may be larger than the limit.
|
||||
*/
|
||||
public int capacity() {
|
||||
return data == null ? 0 : data.length;
|
||||
return data.length;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -481,7 +482,7 @@ public final class ParsableByteArray {
|
|||
* @return The string not including any terminating NUL byte, or null if the end of the data has
|
||||
* already been reached.
|
||||
*/
|
||||
public String readNullTerminatedString() {
|
||||
public @Nullable String readNullTerminatedString() {
|
||||
if (bytesLeft() == 0) {
|
||||
return null;
|
||||
}
|
||||
|
|
@ -507,7 +508,7 @@ public final class ParsableByteArray {
|
|||
* @return The line not including any line-termination characters, or null if the end of the data
|
||||
* has already been reached.
|
||||
*/
|
||||
public String readLine() {
|
||||
public @Nullable String readLine() {
|
||||
if (bytesLeft() == 0) {
|
||||
return null;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -35,6 +35,7 @@ public final class ParsableNalUnitBitArray {
|
|||
* @param offset The byte offset in {@code data} to start reading from.
|
||||
* @param limit The byte offset of the end of the bitstream in {@code data}.
|
||||
*/
|
||||
@SuppressWarnings({"initialization.fields.uninitialized", "method.invocation.invalid"})
|
||||
public ParsableNalUnitBitArray(byte[] data, int offset, int limit) {
|
||||
reset(data, offset, limit);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -111,7 +111,7 @@ public final class PriorityTaskManager {
|
|||
public void remove(int priority) {
|
||||
synchronized (lock) {
|
||||
queue.remove(priority);
|
||||
highestPriority = queue.isEmpty() ? Integer.MIN_VALUE : queue.peek();
|
||||
highestPriority = queue.isEmpty() ? Integer.MIN_VALUE : Util.castNonNull(queue.peek());
|
||||
lock.notifyAll();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1678,9 +1678,9 @@ public final class Util {
|
|||
*
|
||||
* @param input Wraps the compressed input data.
|
||||
* @param output Wraps an output buffer to be used to store the uncompressed data. If {@code
|
||||
* output.data} is null or it isn't big enough to hold the uncompressed data, a new array is
|
||||
* created. If {@code true} is returned then the output's position will be set to 0 and its
|
||||
* limit will be set to the length of the uncompressed data.
|
||||
* output.data} isn't big enough to hold the uncompressed data, a new array is created. If
|
||||
* {@code true} is returned then the output's position will be set to 0 and its limit will be
|
||||
* set to the length of the uncompressed data.
|
||||
* @param inflater If not null, used to uncompressed the input. Otherwise a new {@link Inflater}
|
||||
* is created.
|
||||
* @return Whether the input is uncompressed successfully.
|
||||
|
|
@ -1691,8 +1691,8 @@ public final class Util {
|
|||
return false;
|
||||
}
|
||||
byte[] outputData = output.data;
|
||||
if (outputData == null) {
|
||||
outputData = new byte[input.bytesLeft()];
|
||||
if (outputData.length < input.bytesLeft()) {
|
||||
outputData = new byte[2 * input.bytesLeft()];
|
||||
}
|
||||
if (inflater == null) {
|
||||
inflater = new Inflater();
|
||||
|
|
|
|||
|
|
@ -15,6 +15,7 @@
|
|||
*/
|
||||
package com.google.android.exoplayer2.util;
|
||||
|
||||
import android.support.annotation.Nullable;
|
||||
import org.xmlpull.v1.XmlPullParser;
|
||||
import org.xmlpull.v1.XmlPullParserException;
|
||||
|
||||
|
|
@ -93,7 +94,7 @@ public final class XmlPullParserUtil {
|
|||
* @return The value of the attribute, or null if the current event is not a start tag or if no
|
||||
* such attribute was found.
|
||||
*/
|
||||
public static String getAttributeValue(XmlPullParser xpp, String attributeName) {
|
||||
public static @Nullable String getAttributeValue(XmlPullParser xpp, String attributeName) {
|
||||
int attributeCount = xpp.getAttributeCount();
|
||||
for (int i = 0; i < attributeCount; i++) {
|
||||
if (xpp.getAttributeName(i).equals(attributeName)) {
|
||||
|
|
@ -112,7 +113,8 @@ public final class XmlPullParserUtil {
|
|||
* @return The value of the attribute, or null if the current event is not a start tag or if no
|
||||
* such attribute was found.
|
||||
*/
|
||||
public static String getAttributeValueIgnorePrefix(XmlPullParser xpp, String attributeName) {
|
||||
public static @Nullable String getAttributeValueIgnorePrefix(
|
||||
XmlPullParser xpp, String attributeName) {
|
||||
int attributeCount = xpp.getAttributeCount();
|
||||
for (int i = 0; i < attributeCount; i++) {
|
||||
if (stripPrefix(xpp.getAttributeName(i)).equals(attributeName)) {
|
||||
|
|
|
|||
Loading…
Reference in a new issue