Suppress warnings in preparation for Checker Framework 3.7.1 upgrade.

PiperOrigin-RevId: 342952746
This commit is contained in:
olly 2020-11-17 22:57:17 +00:00 committed by Ian Baker
parent eb8a57ee46
commit 0abdfe94a6
23 changed files with 124 additions and 13 deletions

View File

@ -103,6 +103,8 @@ public final class AudioCapabilities {
* supported.
* @param maxChannelCount The maximum number of audio channels that can be played simultaneously.
*/
// nullness annotations are not applicable to primitive types
@SuppressWarnings("nullness:nullness.on.primitive")
public AudioCapabilities(@Nullable int[] supportedEncodings, int maxChannelCount) {
if (supportedEncodings != null) {
this.supportedEncodings = Arrays.copyOf(supportedEncodings, supportedEncodings.length);

View File

@ -288,6 +288,8 @@ public interface AudioSink {
* is applied the audio data will have {@code outputChannels.length} channels.
* @throws ConfigurationException If an error occurs configuring the sink.
*/
// nullness annotations are not applicable to primitive types
@SuppressWarnings("nullness:nullness.on.primitive")
void configure(Format inputFormat, int specifiedBufferSize, @Nullable int[] outputChannels)
throws ConfigurationException;

View File

@ -26,8 +26,14 @@ import java.nio.ByteBuffer;
*/
/* package */ final class ChannelMappingAudioProcessor extends BaseAudioProcessor {
@Nullable private int[] pendingOutputChannels;
@Nullable private int[] outputChannels;
// nullness annotations are not applicable to primitive types
@SuppressWarnings("nullness:nullness.on.primitive")
@Nullable
private int[] pendingOutputChannels;
// nullness annotations are not applicable to primitive types
@SuppressWarnings("nullness:nullness.on.primitive")
@Nullable
private int[] outputChannels;
/**
* Resets the channel mapping. After calling this method, call {@link #configure(AudioFormat)} to
@ -37,6 +43,8 @@ import java.nio.ByteBuffer;
* leave the input unchanged.
* @see AudioSink#configure(com.google.android.exoplayer2.Format, int, int[])
*/
// nullness annotations are not applicable to primitive types
@SuppressWarnings("nullness:nullness.on.primitive")
public void setChannelMap(@Nullable int[] outputChannels) {
pendingOutputChannels = outputChannels;
}
@ -44,7 +52,10 @@ import java.nio.ByteBuffer;
@Override
public AudioFormat onConfigure(AudioFormat inputAudioFormat)
throws UnhandledAudioFormatException {
@Nullable int[] outputChannels = pendingOutputChannels;
// nullness annotations are not applicable to primitive types
@SuppressWarnings("nullness:nullness.on.primitive")
@Nullable
int[] outputChannels = pendingOutputChannels;
if (outputChannels == null) {
return AudioFormat.NOT_SET;
}

View File

@ -50,6 +50,8 @@ public class ForwardingAudioSink implements AudioSink {
return sink.getCurrentPositionUs(sourceEnded);
}
// nullness annotations are not applicable to primitive types
@SuppressWarnings("nullness:nullness.on.primitive")
@Override
public void configure(Format inputFormat, int specifiedBufferSize, @Nullable int[] outputChannels)
throws ConfigurationException {

View File

@ -335,6 +335,8 @@ class AsynchronousMediaCodecBufferEnqueuer {
* @param dst The destination array, which will be reused if it's at least as long as {@code src}.
* @return The copy, which may be {@code dst} if it was reused.
*/
// nullness annotations are not applicable to primitive types
@SuppressWarnings("nullness:nullness.on.primitive")
@Nullable
private static int[] copy(@Nullable int[] src, @Nullable int[] dst) {
if (src == null) {
@ -356,6 +358,8 @@ class AsynchronousMediaCodecBufferEnqueuer {
* @param dst The destination array, which will be reused if it's at least as long as {@code src}.
* @return The copy, which may be {@code dst} if it was reused.
*/
// nullness annotations are not applicable to primitive types
@SuppressWarnings("nullness:nullness.on.primitive")
@Nullable
private static byte[] copy(@Nullable byte[] src, @Nullable byte[] dst) {
if (src == null) {

View File

@ -59,6 +59,8 @@ import org.checkerframework.checker.nullness.qual.MonotonicNonNull;
@Nullable
private MediaFormat pendingOutputFormat;
// nullness annotations are not applicable to outer types
@SuppressWarnings("nullness:nullness.on.outer")
@GuardedBy("lock")
@Nullable
private MediaCodec.CodecException mediaCodecException;
@ -212,6 +214,8 @@ import org.checkerframework.checker.nullness.qual.MonotonicNonNull;
}
}
// nullness annotations are not applicable to outer types
@SuppressWarnings("nullness:nullness.on.outer")
@Override
public void onOutputBufferAvailable(
@NonNull MediaCodec codec, int index, @NonNull MediaCodec.BufferInfo info) {
@ -225,6 +229,8 @@ import org.checkerframework.checker.nullness.qual.MonotonicNonNull;
}
}
// nullness annotations are not applicable to outer types
@SuppressWarnings("nullness:nullness.on.outer")
@Override
public void onError(@NonNull MediaCodec codec, @NonNull MediaCodec.CodecException e) {
synchronized (lock) {

View File

@ -935,7 +935,10 @@ public final class MediaCodecUtil {
private final int codecKind;
@Nullable private android.media.MediaCodecInfo[] mediaCodecInfos;
// nullness annotations are not applicable to outer types
@SuppressWarnings("nullness:nullness.on.outer")
@Nullable
private android.media.MediaCodecInfo[] mediaCodecInfos;
public MediaCodecListCompatV21(boolean includeSecure, boolean includeTunneling) {
codecKind =

View File

@ -85,6 +85,8 @@ public final class MediaFormatUtil {
* @param key The key to set.
* @param value The byte array that will be wrapped to obtain the value.
*/
// nullness annotations are not applicable to primitive types
@SuppressWarnings("nullness:nullness.on.primitive")
public static void maybeSetByteBuffer(MediaFormat format, String key, @Nullable byte[] value) {
if (value != null) {
format.setByteBuffer(key, ByteBuffer.wrap(value));

View File

@ -104,7 +104,10 @@ import java.util.List;
boolean isRemoveAction = input.readBoolean();
int dataLength = input.readInt();
@Nullable byte[] data;
// nullness annotations are not applicable to primitive types
@SuppressWarnings("nullness:nullness.on.primitive")
@Nullable
byte[] data;
if (dataLength != 0) {
data = new byte[dataLength];
input.readFully(data);

View File

@ -345,6 +345,8 @@ public final class DownloadHelper {
* SmoothStreaming media items.
* @throws IllegalArgumentException If the {@code dataSourceFactory} is null for adaptive streams.
*/
// nullness annotations are not applicable to outer types
@SuppressWarnings("nullness:nullness.on.outer")
public static DownloadHelper forMediaItem(
Context context,
MediaItem mediaItem,
@ -374,6 +376,8 @@ public final class DownloadHelper {
* SmoothStreaming media items.
* @throws IllegalArgumentException If the {@code dataSourceFactory} is null for adaptive streams.
*/
// nullness annotations are not applicable to outer types
@SuppressWarnings("nullness:nullness.on.outer")
public static DownloadHelper forMediaItem(
MediaItem mediaItem,
DefaultTrackSelector.Parameters trackSelectorParameters,
@ -405,6 +409,8 @@ public final class DownloadHelper {
* SmoothStreaming media items.
* @throws IllegalArgumentException If the {@code dataSourceFactory} is null for adaptive streams.
*/
// nullness annotations are not applicable to outer types
@SuppressWarnings("nullness:nullness.on.outer")
public static DownloadHelper forMediaItem(
MediaItem mediaItem,
DefaultTrackSelector.Parameters trackSelectorParameters,
@ -724,6 +730,8 @@ public final class DownloadHelper {
* @param data Application provided data to store in {@link DownloadRequest#data}.
* @return The built {@link DownloadRequest}.
*/
// nullness annotations are not applicable to primitive types
@SuppressWarnings("nullness:nullness.on.primitive")
public DownloadRequest getDownloadRequest(@Nullable byte[] data) {
return getDownloadRequest(playbackProperties.uri.toString(), data);
}
@ -736,6 +744,8 @@ public final class DownloadHelper {
* @param data Application provided data to store in {@link DownloadRequest#data}.
* @return The built {@link DownloadRequest}.
*/
// nullness annotations are not applicable to primitive types
@SuppressWarnings("nullness:nullness.on.primitive")
public DownloadRequest getDownloadRequest(String id, @Nullable byte[] data) {
DownloadRequest.Builder requestBuilder =
new DownloadRequest.Builder(id, playbackProperties.uri)

View File

@ -44,9 +44,16 @@ public final class DownloadRequest implements Parcelable {
private final Uri uri;
@Nullable private String mimeType;
@Nullable private List<StreamKey> streamKeys;
@Nullable private byte[] keySetId;
// nullness annotations are not applicable to primitive types
@SuppressWarnings("nullness:nullness.on.primitive")
@Nullable
private byte[] keySetId;
@Nullable private String customCacheKey;
@Nullable private byte[] data;
// nullness annotations are not applicable to primitive types
@SuppressWarnings("nullness:nullness.on.primitive")
@Nullable
private byte[] data;
/** Creates a new instance with the specified id and uri. */
public Builder(String id, Uri uri) {
@ -67,6 +74,8 @@ public final class DownloadRequest implements Parcelable {
}
/** Sets the {@link DownloadRequest#keySetId}. */
// nullness annotations are not applicable to primitive types
@SuppressWarnings("nullness:nullness.on.primitive")
public Builder setKeySetId(@Nullable byte[] keySetId) {
this.keySetId = keySetId;
return this;
@ -79,6 +88,8 @@ public final class DownloadRequest implements Parcelable {
}
/** Sets the {@link DownloadRequest#data}. */
// nullness annotations are not applicable to primitive types
@SuppressWarnings("nullness:nullness.on.primitive")
public Builder setData(@Nullable byte[] data) {
this.data = data;
return this;
@ -109,7 +120,10 @@ public final class DownloadRequest implements Parcelable {
/** Stream keys to be downloaded. If empty, all streams will be downloaded. */
public final List<StreamKey> streamKeys;
/** The key set id of the offline licence if the content is protected with DRM. */
@Nullable public final byte[] keySetId;
// nullness annotations are not applicable to primitive types
@SuppressWarnings("nullness:nullness.on.primitive")
@Nullable
public final byte[] keySetId;
/**
* Custom key for cache indexing, or null. Must be null for DASH, HLS and SmoothStreaming
* downloads.
@ -126,6 +140,8 @@ public final class DownloadRequest implements Parcelable {
* @param customCacheKey See {@link #customCacheKey}.
* @param data See {@link #data}.
*/
// nullness annotations are not applicable to primitive types
@SuppressWarnings("nullness:nullness.on.primitive")
private DownloadRequest(
String id,
Uri uri,
@ -181,6 +197,8 @@ public final class DownloadRequest implements Parcelable {
* @param keySetId The key set ID of the copy.
* @return The copy with the specified key set ID.
*/
// nullness annotations are not applicable to primitive types
@SuppressWarnings("nullness:nullness.on.primitive")
public DownloadRequest copyWithKeySetId(@Nullable byte[] keySetId) {
return new DownloadRequest(id, uri, mimeType, streamKeys, keySetId, customCacheKey, data);
}

View File

@ -114,6 +114,8 @@ public class ChunkSampleStream<T extends ChunkSource> implements SampleStream, S
* @param mediaSourceEventDispatcher A dispatcher to notify of {@link MediaSourceEventListener}
* events.
*/
// nullness annotations are not applicable to primitive types
@SuppressWarnings("nullness:nullness.on.primitive")
public ChunkSampleStream(
int primaryTrackType,
@Nullable int[] embeddedTrackTypes,

View File

@ -45,6 +45,8 @@ public abstract class DataChunk extends Chunk {
* @param trackSelectionData See {@link #trackSelectionData}.
* @param data An optional recycled array that can be used as a holder for the data.
*/
// nullness annotations are not applicable to primitive types
@SuppressWarnings("nullness:nullness.on.primitive")
public DataChunk(
DataSource dataSource,
DataSpec dataSpec,

View File

@ -138,7 +138,10 @@ public final class MediaParserChunkExtractor implements ChunkExtractor {
// Internal methods.
private void maybeExecutePendingSeek() {
@Nullable MediaParser.SeekMap dummySeekMap = outputConsumerAdapter.getDummySeekMap();
// nullness annotations are not applicable to outer types
@SuppressWarnings("nullness:nullness.on.outer")
@Nullable
MediaParser.SeekMap dummySeekMap = outputConsumerAdapter.getDummySeekMap();
if (pendingSeekUs != C.TIME_UNSET && dummySeekMap != null) {
mediaParser.seek(dummySeekMap.getSeekPoints(pendingSeekUs).first);
pendingSeekUs = C.TIME_UNSET;

View File

@ -55,6 +55,8 @@ public final class ByteArrayDataSink implements DataSink {
* Returns the data written to the sink since the last call to {@link #open(DataSpec)}, or null if
* {@link #open(DataSpec)} has never been called.
*/
// nullness annotations are not applicable to primitive types
@SuppressWarnings("nullness:nullness.on.primitive")
@Nullable
public byte[] getData() {
return stream == null ? null : stream.toByteArray();

View File

@ -34,7 +34,11 @@ public final class DataSchemeDataSource extends BaseDataSource {
public static final String SCHEME_DATA = "data";
@Nullable private DataSpec dataSpec;
@Nullable private byte[] data;
// nullness annotations are not applicable to primitive types
@SuppressWarnings("nullness:nullness.on.primitive")
@Nullable
private byte[] data;
private int endPosition;
private int readPosition;

View File

@ -32,7 +32,11 @@ public final class DefaultAllocator implements Allocator {
private final boolean trimOnReset;
private final int individualAllocationSize;
@Nullable private final byte[] initialAllocationBlock;
// nullness annotations are not applicable to primitive types
@SuppressWarnings("nullness:nullness.on.primitive")
@Nullable
private final byte[] initialAllocationBlock;
private final Allocation[] singleAllocationReleaseHolder;
private int targetBufferSize;

View File

@ -334,7 +334,11 @@ public final class Loader implements LoaderErrorThrower {
private final T loadable;
private final long startTimeMs;
@Nullable private Loader.Callback<T> callback;
// nullness annotations are not applicable to outer types
@SuppressWarnings("nullness:nullness.on.outer")
@Nullable
private Loader.Callback<T> callback;
@Nullable private IOException currentError;
private int errorCount;

View File

@ -45,6 +45,8 @@ import java.util.Map;
* Returns the {@code encryptionKey} cached against this {@code uri}, or null if {@code uri} is
* null or not present in the cache.
*/
// nullness annotations are not applicable to primitive types
@SuppressWarnings("nullness:nullness.on.primitive")
@Nullable
public byte[] get(@Nullable Uri uri) {
if (uri == null) {
@ -58,6 +60,8 @@ import java.util.Map;
*
* @throws NullPointerException if {@code uri} or {@code encryptionKey} are null.
*/
// nullness annotations are not applicable to primitive types
@SuppressWarnings("nullness:nullness.on.primitive")
@Nullable
public byte[] put(Uri uri, byte[] encryptionKey) {
return backingMap.put(Assertions.checkNotNull(uri), Assertions.checkNotNull(encryptionKey));
@ -78,6 +82,8 @@ import java.util.Map;
*
* @throws NullPointerException if {@code uri} is null.
*/
// nullness annotations are not applicable to primitive types
@SuppressWarnings("nullness:nullness.on.primitive")
@Nullable
public byte[] remove(Uri uri) {
return backingMap.remove(Assertions.checkNotNull(uri));

View File

@ -669,7 +669,10 @@ import org.checkerframework.checker.nullness.qual.MonotonicNonNull;
return null;
}
@Nullable byte[] encryptionKey = keyCache.remove(keyUri);
// nullness annotations are not applicable to primitive types
@SuppressWarnings("nullness:nullness.on.primitive")
@Nullable
byte[] encryptionKey = keyCache.remove(keyUri);
if (encryptionKey != null) {
// The key was present in the key cache. We re-insert it to prevent it from being evicted by
// the following key addition. Note that removal of the key is necessary to affect the
@ -688,6 +691,8 @@ import org.checkerframework.checker.nullness.qual.MonotonicNonNull;
scratchSpace);
}
// nullness annotations are not applicable to outer types
@SuppressWarnings("nullness:nullness.on.outer")
@Nullable
private static Uri getFullEncryptionKeyUri(
HlsMediaPlaylist playlist, @Nullable HlsMediaPlaylist.SegmentBase segmentBase) {
@ -791,6 +796,8 @@ import org.checkerframework.checker.nullness.qual.MonotonicNonNull;
}
/** Return the result of this chunk, or null if loading is not complete. */
// nullness annotations are not applicable to primitive types
@SuppressWarnings("nullness:nullness.on.primitive")
@Nullable
public byte[] getResult() {
return result;

View File

@ -73,6 +73,8 @@ import org.checkerframework.checker.nullness.qual.RequiresNonNull;
* @param initSegmentKey The initialization segment decryption key, if fully encrypted. Null
* otherwise.
*/
// nullness annotations are not applicable to primitive types
@SuppressWarnings("nullness:nullness.on.primitive")
public static HlsMediaChunk createInstance(
HlsExtractorFactory extractorFactory,
DataSource dataSource,
@ -97,6 +99,8 @@ import org.checkerframework.checker.nullness.qual.RequiresNonNull;
mediaSegment.byteRangeOffset,
mediaSegment.byteRangeLength);
boolean mediaSegmentEncrypted = mediaSegmentKey != null;
// nullness annotations are not applicable to primitive types
@SuppressWarnings("nullness:nullness.on.primitive")
@Nullable
byte[] mediaSegmentIv =
mediaSegmentEncrypted
@ -111,6 +115,8 @@ import org.checkerframework.checker.nullness.qual.RequiresNonNull;
@Nullable DataSource initDataSource = null;
if (initSegment != null) {
initSegmentEncrypted = initSegmentKey != null;
// nullness annotations are not applicable to primitive types
@SuppressWarnings("nullness:nullness.on.primitive")
@Nullable
byte[] initSegmentIv =
initSegmentEncrypted
@ -536,6 +542,8 @@ import org.checkerframework.checker.nullness.qual.RequiresNonNull;
*
* <p>{@code fullSegmentEncryptionKey} & {@code encryptionIv} can either both be null, or neither.
*/
// nullness annotations are not applicable to primitive types
@SuppressWarnings("nullness:nullness.on.primitive")
private static DataSource buildDataSource(
DataSource dataSource,
@Nullable byte[] fullSegmentEncryptionKey,

View File

@ -211,6 +211,8 @@ public final class HlsMediaSource extends BaseMediaSource
* @param playlistTrackerFactory A factory for {@link HlsPlaylistTracker} instances.
* @return This factory, for convenience.
*/
// nullness annotations are not applicable to outer types
@SuppressWarnings("nullness:nullness.on.outer")
public Factory setPlaylistTrackerFactory(
@Nullable HlsPlaylistTracker.Factory playlistTrackerFactory) {
this.playlistTrackerFactory =
@ -295,6 +297,8 @@ public final class HlsMediaSource extends BaseMediaSource
return this;
}
// nullness annotations are not applicable to outer types
@SuppressWarnings("nullness:nullness.on.outer")
@Override
public Factory setDrmHttpDataSourceFactory(
@Nullable HttpDataSource.Factory drmHttpDataSourceFactory) {

View File

@ -255,6 +255,8 @@ public final class MediaParserHlsMediaChunkExtractor implements HlsMediaChunkExt
this.extractorInput = extractorInput;
}
// nullness annotations are not applicable to primitive types
@SuppressWarnings("nullness:nullness.on.primitive")
@Override
public int read(@NonNull byte[] buffer, int offset, int readLength) throws IOException {
int peekedBytes = extractorInput.peek(buffer, offset, readLength);