mirror of
https://github.com/samsonjs/media.git
synced 2026-04-27 15:07:40 +00:00
Remove more classes from nullness blacklist
PiperOrigin-RevId: 249431027
This commit is contained in:
parent
d836957138
commit
10ee7d8e86
7 changed files with 71 additions and 42 deletions
|
|
@ -27,6 +27,7 @@ import android.os.Parcel;
|
||||||
import android.os.Parcelable;
|
import android.os.Parcelable;
|
||||||
import android.os.PowerManager;
|
import android.os.PowerManager;
|
||||||
import androidx.annotation.IntDef;
|
import androidx.annotation.IntDef;
|
||||||
|
import androidx.annotation.Nullable;
|
||||||
import com.google.android.exoplayer2.util.Util;
|
import com.google.android.exoplayer2.util.Util;
|
||||||
import java.lang.annotation.Documented;
|
import java.lang.annotation.Documented;
|
||||||
import java.lang.annotation.Retention;
|
import java.lang.annotation.Retention;
|
||||||
|
|
@ -179,7 +180,7 @@ public final class Requirements implements Parcelable {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean equals(Object o) {
|
public boolean equals(@Nullable Object o) {
|
||||||
if (this == o) {
|
if (this == o) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -27,7 +27,9 @@ import android.net.NetworkRequest;
|
||||||
import android.os.Handler;
|
import android.os.Handler;
|
||||||
import android.os.Looper;
|
import android.os.Looper;
|
||||||
import android.os.PowerManager;
|
import android.os.PowerManager;
|
||||||
|
import androidx.annotation.Nullable;
|
||||||
import androidx.annotation.RequiresApi;
|
import androidx.annotation.RequiresApi;
|
||||||
|
import com.google.android.exoplayer2.util.Assertions;
|
||||||
import com.google.android.exoplayer2.util.Util;
|
import com.google.android.exoplayer2.util.Util;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -57,10 +59,10 @@ public final class RequirementsWatcher {
|
||||||
private final Requirements requirements;
|
private final Requirements requirements;
|
||||||
private final Handler handler;
|
private final Handler handler;
|
||||||
|
|
||||||
private DeviceStatusChangeReceiver receiver;
|
@Nullable private DeviceStatusChangeReceiver receiver;
|
||||||
|
|
||||||
@Requirements.RequirementFlags private int notMetRequirements;
|
@Requirements.RequirementFlags private int notMetRequirements;
|
||||||
private CapabilityValidatedCallback networkCallback;
|
@Nullable private CapabilityValidatedCallback networkCallback;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param context Any context.
|
* @param context Any context.
|
||||||
|
|
@ -111,7 +113,7 @@ public final class RequirementsWatcher {
|
||||||
|
|
||||||
/** Stops watching for changes. */
|
/** Stops watching for changes. */
|
||||||
public void stop() {
|
public void stop() {
|
||||||
context.unregisterReceiver(receiver);
|
context.unregisterReceiver(Assertions.checkNotNull(receiver));
|
||||||
receiver = null;
|
receiver = null;
|
||||||
if (networkCallback != null) {
|
if (networkCallback != null) {
|
||||||
unregisterNetworkCallback();
|
unregisterNetworkCallback();
|
||||||
|
|
@ -139,7 +141,7 @@ public final class RequirementsWatcher {
|
||||||
if (Util.SDK_INT >= 21) {
|
if (Util.SDK_INT >= 21) {
|
||||||
ConnectivityManager connectivityManager =
|
ConnectivityManager connectivityManager =
|
||||||
(ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
|
(ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
|
||||||
connectivityManager.unregisterNetworkCallback(networkCallback);
|
connectivityManager.unregisterNetworkCallback(Assertions.checkNotNull(networkCallback));
|
||||||
networkCallback = null;
|
networkCallback = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -19,6 +19,7 @@ import android.annotation.TargetApi;
|
||||||
import android.graphics.Color;
|
import android.graphics.Color;
|
||||||
import android.graphics.Typeface;
|
import android.graphics.Typeface;
|
||||||
import androidx.annotation.IntDef;
|
import androidx.annotation.IntDef;
|
||||||
|
import androidx.annotation.Nullable;
|
||||||
import android.view.accessibility.CaptioningManager;
|
import android.view.accessibility.CaptioningManager;
|
||||||
import android.view.accessibility.CaptioningManager.CaptionStyle;
|
import android.view.accessibility.CaptioningManager.CaptionStyle;
|
||||||
import com.google.android.exoplayer2.util.Util;
|
import com.google.android.exoplayer2.util.Util;
|
||||||
|
|
@ -72,11 +73,15 @@ public final class CaptionStyleCompat {
|
||||||
*/
|
*/
|
||||||
public static final int USE_TRACK_COLOR_SETTINGS = 1;
|
public static final int USE_TRACK_COLOR_SETTINGS = 1;
|
||||||
|
|
||||||
/**
|
/** Default caption style. */
|
||||||
* Default caption style.
|
public static final CaptionStyleCompat DEFAULT =
|
||||||
*/
|
new CaptionStyleCompat(
|
||||||
public static final CaptionStyleCompat DEFAULT = new CaptionStyleCompat(
|
Color.WHITE,
|
||||||
Color.WHITE, Color.BLACK, Color.TRANSPARENT, EDGE_TYPE_NONE, Color.WHITE, null);
|
Color.BLACK,
|
||||||
|
Color.TRANSPARENT,
|
||||||
|
EDGE_TYPE_NONE,
|
||||||
|
Color.WHITE,
|
||||||
|
/* typeface= */ null);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The preferred foreground color.
|
* The preferred foreground color.
|
||||||
|
|
@ -110,10 +115,8 @@ public final class CaptionStyleCompat {
|
||||||
*/
|
*/
|
||||||
public final int edgeColor;
|
public final int edgeColor;
|
||||||
|
|
||||||
/**
|
/** The preferred typeface, or {@code null} if unspecified. */
|
||||||
* The preferred typeface.
|
@Nullable public final Typeface typeface;
|
||||||
*/
|
|
||||||
public final Typeface typeface;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a {@link CaptionStyleCompat} equivalent to a provided {@link CaptionStyle}.
|
* Creates a {@link CaptionStyleCompat} equivalent to a provided {@link CaptionStyle}.
|
||||||
|
|
@ -141,8 +144,13 @@ public final class CaptionStyleCompat {
|
||||||
* @param edgeColor See {@link #edgeColor}.
|
* @param edgeColor See {@link #edgeColor}.
|
||||||
* @param typeface See {@link #typeface}.
|
* @param typeface See {@link #typeface}.
|
||||||
*/
|
*/
|
||||||
public CaptionStyleCompat(int foregroundColor, int backgroundColor, int windowColor,
|
public CaptionStyleCompat(
|
||||||
@EdgeType int edgeType, int edgeColor, Typeface typeface) {
|
int foregroundColor,
|
||||||
|
int backgroundColor,
|
||||||
|
int windowColor,
|
||||||
|
@EdgeType int edgeType,
|
||||||
|
int edgeColor,
|
||||||
|
@Nullable Typeface typeface) {
|
||||||
this.foregroundColor = foregroundColor;
|
this.foregroundColor = foregroundColor;
|
||||||
this.backgroundColor = backgroundColor;
|
this.backgroundColor = backgroundColor;
|
||||||
this.windowColor = windowColor;
|
this.windowColor = windowColor;
|
||||||
|
|
|
||||||
|
|
@ -18,6 +18,7 @@ package com.google.android.exoplayer2.text;
|
||||||
import android.graphics.Bitmap;
|
import android.graphics.Bitmap;
|
||||||
import android.graphics.Color;
|
import android.graphics.Color;
|
||||||
import androidx.annotation.IntDef;
|
import androidx.annotation.IntDef;
|
||||||
|
import androidx.annotation.Nullable;
|
||||||
import android.text.Layout.Alignment;
|
import android.text.Layout.Alignment;
|
||||||
import java.lang.annotation.Documented;
|
import java.lang.annotation.Documented;
|
||||||
import java.lang.annotation.Retention;
|
import java.lang.annotation.Retention;
|
||||||
|
|
@ -111,17 +112,13 @@ public class Cue {
|
||||||
* The cue text, or null if this is an image cue. Note the {@link CharSequence} may be decorated
|
* The cue text, or null if this is an image cue. Note the {@link CharSequence} may be decorated
|
||||||
* with styling spans.
|
* with styling spans.
|
||||||
*/
|
*/
|
||||||
public final CharSequence text;
|
@Nullable public final CharSequence text;
|
||||||
|
|
||||||
/**
|
/** The alignment of the cue text within the cue box, or null if the alignment is undefined. */
|
||||||
* The alignment of the cue text within the cue box, or null if the alignment is undefined.
|
@Nullable public final Alignment textAlignment;
|
||||||
*/
|
|
||||||
public final Alignment textAlignment;
|
|
||||||
|
|
||||||
/**
|
/** The cue image, or null if this is a text cue. */
|
||||||
* The cue image, or null if this is a text cue.
|
@Nullable public final Bitmap bitmap;
|
||||||
*/
|
|
||||||
public final Bitmap bitmap;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The position of the {@link #lineAnchor} of the cue box within the viewport in the direction
|
* The position of the {@link #lineAnchor} of the cue box within the viewport in the direction
|
||||||
|
|
@ -298,7 +295,7 @@ public class Cue {
|
||||||
*/
|
*/
|
||||||
public Cue(
|
public Cue(
|
||||||
CharSequence text,
|
CharSequence text,
|
||||||
Alignment textAlignment,
|
@Nullable Alignment textAlignment,
|
||||||
float line,
|
float line,
|
||||||
@LineType int lineType,
|
@LineType int lineType,
|
||||||
@AnchorType int lineAnchor,
|
@AnchorType int lineAnchor,
|
||||||
|
|
@ -376,7 +373,7 @@ public class Cue {
|
||||||
*/
|
*/
|
||||||
public Cue(
|
public Cue(
|
||||||
CharSequence text,
|
CharSequence text,
|
||||||
Alignment textAlignment,
|
@Nullable Alignment textAlignment,
|
||||||
float line,
|
float line,
|
||||||
@LineType int lineType,
|
@LineType int lineType,
|
||||||
@AnchorType int lineAnchor,
|
@AnchorType int lineAnchor,
|
||||||
|
|
@ -403,9 +400,9 @@ public class Cue {
|
||||||
}
|
}
|
||||||
|
|
||||||
private Cue(
|
private Cue(
|
||||||
CharSequence text,
|
@Nullable CharSequence text,
|
||||||
Alignment textAlignment,
|
@Nullable Alignment textAlignment,
|
||||||
Bitmap bitmap,
|
@Nullable Bitmap bitmap,
|
||||||
float line,
|
float line,
|
||||||
@LineType int lineType,
|
@LineType int lineType,
|
||||||
@AnchorType int lineAnchor,
|
@AnchorType int lineAnchor,
|
||||||
|
|
|
||||||
|
|
@ -15,6 +15,7 @@
|
||||||
*/
|
*/
|
||||||
package com.google.android.exoplayer2.text;
|
package com.google.android.exoplayer2.text;
|
||||||
|
|
||||||
|
import androidx.annotation.Nullable;
|
||||||
import com.google.android.exoplayer2.Format;
|
import com.google.android.exoplayer2.Format;
|
||||||
import com.google.android.exoplayer2.decoder.OutputBuffer;
|
import com.google.android.exoplayer2.decoder.OutputBuffer;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
@ -24,7 +25,7 @@ import java.util.List;
|
||||||
*/
|
*/
|
||||||
public abstract class SubtitleOutputBuffer extends OutputBuffer implements Subtitle {
|
public abstract class SubtitleOutputBuffer extends OutputBuffer implements Subtitle {
|
||||||
|
|
||||||
private Subtitle subtitle;
|
@Nullable private Subtitle subtitle;
|
||||||
private long subsampleOffsetUs;
|
private long subsampleOffsetUs;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -15,11 +15,11 @@
|
||||||
*/
|
*/
|
||||||
package com.google.android.exoplayer2.text.webvtt;
|
package com.google.android.exoplayer2.text.webvtt;
|
||||||
|
|
||||||
|
import androidx.annotation.Nullable;
|
||||||
import android.text.TextUtils;
|
import android.text.TextUtils;
|
||||||
import com.google.android.exoplayer2.util.ColorParser;
|
import com.google.android.exoplayer2.util.ColorParser;
|
||||||
import com.google.android.exoplayer2.util.ParsableByteArray;
|
import com.google.android.exoplayer2.util.ParsableByteArray;
|
||||||
import com.google.android.exoplayer2.util.Util;
|
import com.google.android.exoplayer2.util.Util;
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.regex.Matcher;
|
import java.util.regex.Matcher;
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
|
|
@ -52,13 +52,15 @@ import java.util.regex.Pattern;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Takes a CSS style block and consumes up to the first empty line found. Attempts to parse the
|
* Takes a CSS style block and consumes up to the first empty line. Attempts to parse the contents
|
||||||
* contents of the style block and returns a {@link WebvttCssStyle} instance if successful, or
|
* of the style block and returns a {@link WebvttCssStyle} instance if successful, or {@code null}
|
||||||
* {@code null} otherwise.
|
* otherwise.
|
||||||
*
|
*
|
||||||
* @param input The input from which the style block should be read.
|
* @param input The input from which the style block should be read.
|
||||||
* @return A {@link WebvttCssStyle} that represents the parsed block.
|
* @return A {@link WebvttCssStyle} that represents the parsed block, or {@code null} if parsing
|
||||||
|
* failed.
|
||||||
*/
|
*/
|
||||||
|
@Nullable
|
||||||
public WebvttCssStyle parseBlock(ParsableByteArray input) {
|
public WebvttCssStyle parseBlock(ParsableByteArray input) {
|
||||||
stringBuilder.setLength(0);
|
stringBuilder.setLength(0);
|
||||||
int initialInputPosition = input.getPosition();
|
int initialInputPosition = input.getPosition();
|
||||||
|
|
@ -86,13 +88,14 @@ import java.util.regex.Pattern;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns a string containing the selector. The input is expected to have the form
|
* Returns a string containing the selector. The input is expected to have the form {@code
|
||||||
* {@code ::cue(tag#id.class1.class2[voice="someone"]}, where every element is optional.
|
* ::cue(tag#id.class1.class2[voice="someone"]}, where every element is optional.
|
||||||
*
|
*
|
||||||
* @param input From which the selector is obtained.
|
* @param input From which the selector is obtained.
|
||||||
* @return A string containing the target, empty string if the selector is universal
|
* @return A string containing the target, empty string if the selector is universal (targets all
|
||||||
* (targets all cues) or null if an error was encountered.
|
* cues) or null if an error was encountered.
|
||||||
*/
|
*/
|
||||||
|
@Nullable
|
||||||
private static String parseSelector(ParsableByteArray input, StringBuilder stringBuilder) {
|
private static String parseSelector(ParsableByteArray input, StringBuilder stringBuilder) {
|
||||||
skipWhitespaceAndComments(input);
|
skipWhitespaceAndComments(input);
|
||||||
if (input.bytesLeft() < 5) {
|
if (input.bytesLeft() < 5) {
|
||||||
|
|
@ -116,7 +119,7 @@ import java.util.regex.Pattern;
|
||||||
target = readCueTarget(input);
|
target = readCueTarget(input);
|
||||||
}
|
}
|
||||||
token = parseNextToken(input, stringBuilder);
|
token = parseNextToken(input, stringBuilder);
|
||||||
if (!")".equals(token) || token == null) {
|
if (!")".equals(token)) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
return target;
|
return target;
|
||||||
|
|
@ -196,6 +199,7 @@ import java.util.regex.Pattern;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Visible for testing.
|
// Visible for testing.
|
||||||
|
@Nullable
|
||||||
/* package */ static String parseNextToken(ParsableByteArray input, StringBuilder stringBuilder) {
|
/* package */ static String parseNextToken(ParsableByteArray input, StringBuilder stringBuilder) {
|
||||||
skipWhitespaceAndComments(input);
|
skipWhitespaceAndComments(input);
|
||||||
if (input.bytesLeft() == 0) {
|
if (input.bytesLeft() == 0) {
|
||||||
|
|
@ -237,6 +241,7 @@ import java.util.regex.Pattern;
|
||||||
return (char) input.data[position];
|
return (char) input.data[position];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Nullable
|
||||||
private static String parsePropertyValue(ParsableByteArray input, StringBuilder stringBuilder) {
|
private static String parsePropertyValue(ParsableByteArray input, StringBuilder stringBuilder) {
|
||||||
StringBuilder expressionBuilder = new StringBuilder();
|
StringBuilder expressionBuilder = new StringBuilder();
|
||||||
String token;
|
String token;
|
||||||
|
|
@ -325,7 +330,7 @@ import java.util.regex.Pattern;
|
||||||
style.setTargetTagName(tagAndIdDivision);
|
style.setTargetTagName(tagAndIdDivision);
|
||||||
}
|
}
|
||||||
if (classDivision.length > 1) {
|
if (classDivision.length > 1) {
|
||||||
style.setTargetClasses(Arrays.copyOfRange(classDivision, 1, classDivision.length));
|
style.setTargetClasses(Util.nullSafeArrayCopyOfRange(classDivision, 1, classDivision.length));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -315,6 +315,21 @@ public final class Util {
|
||||||
return Arrays.copyOf(input, length);
|
return Arrays.copyOf(input, length);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Copies a subset of an array.
|
||||||
|
*
|
||||||
|
* @param input The input array.
|
||||||
|
* @param from The start the range to be copied, inclusive
|
||||||
|
* @param to The end of the range to be copied, exclusive.
|
||||||
|
* @return The copied array.
|
||||||
|
*/
|
||||||
|
@SuppressWarnings({"nullness:argument.type.incompatible", "nullness:return.type.incompatible"})
|
||||||
|
public static <T> T[] nullSafeArrayCopyOfRange(T[] input, int from, int to) {
|
||||||
|
Assertions.checkArgument(0 <= from);
|
||||||
|
Assertions.checkArgument(to <= input.length);
|
||||||
|
return Arrays.copyOfRange(input, from, to);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Concatenates two non-null type arrays.
|
* Concatenates two non-null type arrays.
|
||||||
*
|
*
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue