Fix lint errors

PiperOrigin-RevId: 295953956
This commit is contained in:
olly 2020-02-19 14:21:21 +00:00 committed by Oliver Woodman
parent 1f905434d2
commit 54283746be
15 changed files with 57 additions and 29 deletions

View File

@ -17,7 +17,7 @@ project.ext {
releaseVersionCode = 2011003
minSdkVersion = 16
appTargetSdkVersion = 29
targetSdkVersion = 28 // TODO: Bump once b/143232359 is resolved
targetSdkVersion = 28 // TODO: Bump once b/143232359 is resolved. Also fix TODOs in UtilTest.
compileSdkVersion = 29
dexmakerVersion = '2.21.0'
junitVersion = '4.13-rc-2'

View File

@ -83,6 +83,7 @@ public final class VideoProcessingGLSurfaceView extends GLSurfaceView {
* created, if supported by the device.
* @param videoProcessor Processor that draws to the view.
*/
@SuppressWarnings("InlinedApi")
public VideoProcessingGLSurfaceView(
Context context, boolean requireSecureContext, VideoProcessor videoProcessor) {
super(context);

View File

@ -19,7 +19,6 @@ import static android.content.Context.UI_MODE_SERVICE;
import android.Manifest.permission;
import android.annotation.SuppressLint;
import android.annotation.TargetApi;
import android.app.Activity;
import android.app.UiModeManager;
import android.content.ComponentName;
@ -179,7 +178,6 @@ public final class Util {
* @param uris {@link Uri}s that may require {@link permission#READ_EXTERNAL_STORAGE} to read.
* @return Whether a permission request was made.
*/
@TargetApi(23)
public static boolean maybeRequestReadExternalStoragePermission(Activity activity, Uri... uris) {
if (Util.SDK_INT < 23) {
return false;
@ -204,7 +202,6 @@ public final class Util {
* @param uris A list of URIs that will be loaded.
* @return Whether it may be possible to load the given URIs.
*/
@TargetApi(24)
public static boolean checkCleartextTrafficPermitted(Uri... uris) {
if (Util.SDK_INT < 24) {
// We assume cleartext traffic is permitted.

View File

@ -784,8 +784,9 @@ public class UtilTest {
assertThat(Arrays.copyOf(output.data, output.limit())).isEqualTo(testData);
}
// TODO: Revert to @Config(sdk = Config.ALL_SDKS) once b/143232359 is resolved
@Test
@Config(sdk = Config.ALL_SDKS)
@Config(minSdk = Config.OLDEST_SDK, maxSdk = Config.TARGET_SDK)
public void normalizeLanguageCode_keepsUndefinedTagsUnchanged() {
assertThat(Util.normalizeLanguageCode(null)).isNull();
assertThat(Util.normalizeLanguageCode("")).isEmpty();
@ -793,8 +794,9 @@ public class UtilTest {
assertThat(Util.normalizeLanguageCode("DoesNotExist")).isEqualTo("doesnotexist");
}
// TODO: Revert to @Config(sdk = Config.ALL_SDKS) once b/143232359 is resolved
@Test
@Config(sdk = Config.ALL_SDKS)
@Config(minSdk = Config.OLDEST_SDK, maxSdk = Config.TARGET_SDK)
public void normalizeLanguageCode_normalizesCodeToTwoLetterISOAndLowerCase_keepingAllSubtags() {
assertThat(Util.normalizeLanguageCode("es")).isEqualTo("es");
assertThat(Util.normalizeLanguageCode("spa")).isEqualTo("es");
@ -812,8 +814,9 @@ public class UtilTest {
assertThat(Util.normalizeLanguageCode("sv-illegalSubtag")).isEqualTo("sv-illegalsubtag");
}
// TODO: Revert to @Config(sdk = Config.ALL_SDKS) once b/143232359 is resolved
@Test
@Config(sdk = Config.ALL_SDKS)
@Config(minSdk = Config.OLDEST_SDK, maxSdk = Config.TARGET_SDK)
public void normalizeLanguageCode_iso6392BibliographicalAndTextualCodes_areNormalizedToSameTag() {
// See https://en.wikipedia.org/wiki/List_of_ISO_639-2_codes.
assertThat(Util.normalizeLanguageCode("alb")).isEqualTo(Util.normalizeLanguageCode("sqi"));
@ -839,8 +842,9 @@ public class UtilTest {
assertThat(Util.normalizeLanguageCode("wel")).isEqualTo(Util.normalizeLanguageCode("cym"));
}
// TODO: Revert to @Config(sdk = Config.ALL_SDKS) once b/143232359 is resolved
@Test
@Config(sdk = Config.ALL_SDKS)
@Config(minSdk = Config.OLDEST_SDK, maxSdk = Config.TARGET_SDK)
public void
normalizeLanguageCode_deprecatedLanguageTagsAndModernReplacement_areNormalizedToSameTag() {
// See https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes, "ISO 639:1988"
@ -877,8 +881,9 @@ public class UtilTest {
.isEqualTo(Util.normalizeLanguageCode("zh-hsn"));
}
// TODO: Revert to @Config(sdk = Config.ALL_SDKS) once b/143232359 is resolved
@Test
@Config(sdk = Config.ALL_SDKS)
@Config(minSdk = Config.OLDEST_SDK, maxSdk = Config.TARGET_SDK)
public void normalizeLanguageCode_macrolanguageTags_areFullyMaintained() {
// See https://en.wikipedia.org/wiki/ISO_639_macrolanguage
assertThat(Util.normalizeLanguageCode("zh-cmn")).isEqualTo("zh-cmn");

View File

@ -15,6 +15,7 @@
*/
package com.google.android.exoplayer2.audio;
import android.annotation.TargetApi;
import android.media.AudioTimestamp;
import android.media.AudioTrack;
import androidx.annotation.IntDef;
@ -115,6 +116,7 @@ import java.lang.annotation.RetentionPolicy;
* @param systemTimeUs The current system time, in microseconds.
* @return Whether the timestamp was updated.
*/
@TargetApi(19) // audioTimestamp will be null if Util.SDK_INT < 19.
public boolean maybePollTimestamp(long systemTimeUs) {
if (audioTimestamp == null || (systemTimeUs - lastTimestampSampleTimeUs) < sampleIntervalUs) {
return false;
@ -220,6 +222,7 @@ import java.lang.annotation.RetentionPolicy;
* If {@link #maybePollTimestamp(long)} or {@link #hasTimestamp()} returned {@code true}, returns
* the system time at which the latest timestamp was sampled, in microseconds.
*/
@TargetApi(19) // audioTimestamp will be null if Util.SDK_INT < 19.
public long getTimestampSystemTimeUs() {
return audioTimestamp != null ? audioTimestamp.getTimestampSystemTimeUs() : C.TIME_UNSET;
}
@ -228,6 +231,7 @@ import java.lang.annotation.RetentionPolicy;
* If {@link #maybePollTimestamp(long)} or {@link #hasTimestamp()} returned {@code true}, returns
* the latest timestamp's position in frames.
*/
@TargetApi(19) // audioTimestamp will be null if Util.SDK_INT < 19.
public long getTimestampPositionFrames() {
return audioTimestamp != null ? audioTimestamp.getTimestampPositionFrames() : C.POSITION_UNSET;
}

View File

@ -1122,6 +1122,9 @@ public final class DefaultAudioSink implements AudioSink {
private static int getMaximumEncodedRateBytesPerSecond(@C.Encoding int encoding) {
switch (encoding) {
case C.ENCODING_MP3:
// Maximum bitrate for MPEG-1 layer III: 320 kbit/s.
return 320 * 1000 / 8;
case C.ENCODING_AC3:
return 640 * 1000 / 8;
case C.ENCODING_E_AC3:
@ -1136,12 +1139,13 @@ public final class DefaultAudioSink implements AudioSink {
return 18000 * 1000 / 8;
case C.ENCODING_DOLBY_TRUEHD:
return 24500 * 1000 / 8;
case C.ENCODING_INVALID:
case C.ENCODING_PCM_16BIT:
case C.ENCODING_PCM_16BIT_BIG_ENDIAN:
case C.ENCODING_PCM_24BIT:
case C.ENCODING_PCM_32BIT:
case C.ENCODING_PCM_8BIT:
case C.ENCODING_PCM_FLOAT:
case C.ENCODING_INVALID:
case Format.NO_VALUE:
default:
throw new IllegalArgumentException();
@ -1167,6 +1171,14 @@ public final class DefaultAudioSink implements AudioSink {
? 0
: (Ac3Util.parseTrueHdSyncframeAudioSampleCount(buffer, syncframeOffset)
* Ac3Util.TRUEHD_RECHUNK_SAMPLE_COUNT);
case C.ENCODING_PCM_16BIT:
case C.ENCODING_PCM_16BIT_BIG_ENDIAN:
case C.ENCODING_PCM_24BIT:
case C.ENCODING_PCM_32BIT:
case C.ENCODING_PCM_8BIT:
case C.ENCODING_PCM_FLOAT:
case C.ENCODING_INVALID:
case Format.NO_VALUE:
default:
throw new IllegalStateException("Unexpected audio encoding: " + encoding);
}

View File

@ -28,6 +28,9 @@ import androidx.annotation.VisibleForTesting;
import com.google.android.exoplayer2.C;
import com.google.android.exoplayer2.decoder.CryptoInfo;
import com.google.android.exoplayer2.util.Util;
import java.lang.annotation.Documented;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import org.checkerframework.checker.nullness.qual.MonotonicNonNull;
/**
@ -41,6 +44,8 @@ import org.checkerframework.checker.nullness.qual.MonotonicNonNull;
/* package */ final class DedicatedThreadAsyncMediaCodecAdapter extends MediaCodec.Callback
implements MediaCodecAdapter {
@Documented
@Retention(RetentionPolicy.SOURCE)
@IntDef({STATE_CREATED, STATE_STARTED, STATE_SHUT_DOWN})
private @interface State {}

View File

@ -229,9 +229,10 @@ public final class MediaCodecInfo {
* @see CodecCapabilities#getMaxSupportedInstances()
*/
public int getMaxSupportedInstances() {
return (Util.SDK_INT < 23 || capabilities == null)
? MAX_SUPPORTED_INSTANCES_UNKNOWN
: getMaxSupportedInstancesV23(capabilities);
if (Util.SDK_INT < 23 || capabilities == null) {
return MAX_SUPPORTED_INSTANCES_UNKNOWN;
}
return getMaxSupportedInstancesV23(capabilities);
}
/**

View File

@ -15,6 +15,7 @@
*/
package com.google.android.exoplayer2.mediacodec;
import android.annotation.TargetApi;
import android.media.MediaCodec;
import android.media.MediaCodec.CodecException;
import android.media.MediaCodec.CryptoException;
@ -1842,6 +1843,7 @@ public abstract class MediaCodecRenderer extends BaseRenderer {
*
* @throws ExoPlaybackException If an error occurs processing the signal.
*/
@TargetApi(23) // codecDrainAction == DRAIN_ACTION_UPDATE_DRM_SESSION implies SDK_INT >= 23.
private void processEndOfStream() throws ExoPlaybackException {
switch (codecDrainAction) {
case DRAIN_ACTION_REINITIALIZE:

View File

@ -30,6 +30,9 @@ import com.google.android.exoplayer2.C;
import com.google.android.exoplayer2.decoder.CryptoInfo;
import com.google.android.exoplayer2.util.IntArrayQueue;
import com.google.android.exoplayer2.util.Util;
import java.lang.annotation.Documented;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.util.ArrayDeque;
import org.checkerframework.checker.nullness.qual.MonotonicNonNull;
@ -52,6 +55,8 @@ import org.checkerframework.checker.nullness.qual.MonotonicNonNull;
/* package */ final class MultiLockAsyncMediaCodecAdapter extends MediaCodec.Callback
implements MediaCodecAdapter {
@Documented
@Retention(RetentionPolicy.SOURCE)
@IntDef({STATE_CREATED, STATE_STARTED, STATE_SHUT_DOWN})
private @interface State {}

View File

@ -17,7 +17,6 @@ package com.google.android.exoplayer2.util;
import static android.opengl.GLU.gluErrorString;
import android.annotation.TargetApi;
import android.content.Context;
import android.content.pm.PackageManager;
import android.opengl.EGL14;
@ -208,7 +207,6 @@ public final class GlUtil {
* Returns whether creating a GL context with {@value EXTENSION_PROTECTED_CONTENT} is possible. If
* {@code true}, the device supports a protected output path for DRM content when using GL.
*/
@TargetApi(24)
public static boolean isProtectedContentExtensionSupported(Context context) {
if (Util.SDK_INT < 24) {
return false;
@ -236,7 +234,6 @@ public final class GlUtil {
/**
* Returns whether creating a GL context with {@value EXTENSION_SURFACELESS_CONTEXT} is possible.
*/
@TargetApi(17)
public static boolean isSurfacelessContextExtensionSupported() {
if (Util.SDK_INT < 17) {
return false;

View File

@ -16,6 +16,7 @@
package com.google.android.exoplayer2.video;
import android.annotation.SuppressLint;
import android.annotation.TargetApi;
import android.content.Context;
import android.graphics.Point;
import android.media.MediaCodec;
@ -658,6 +659,7 @@ public class MediaCodecVideoRenderer extends MediaCodecRenderer {
}
@Override
@TargetApi(29) // codecHandlesHdr10PlusOutOfBandMetadata is false if Util.SDK_INT < 29
protected void handleInputBufferSupplementalData(DecoderInputBuffer buffer)
throws ExoPlaybackException {
if (!codecHandlesHdr10PlusOutOfBandMetadata) {
@ -682,7 +684,6 @@ public class MediaCodecVideoRenderer extends MediaCodecRenderer {
byte[] hdr10PlusInfo = new byte[data.remaining()];
data.get(hdr10PlusInfo);
data.position(0);
// If codecHandlesHdr10PlusOutOfBandMetadata is true, this is an API 29 or later build.
setHdr10PlusInfoV29(getCodec(), hdr10PlusInfo);
}
}
@ -1179,6 +1180,7 @@ public class MediaCodecVideoRenderer extends MediaCodecRenderer {
* @return The framework {@link MediaFormat} that should be used to configure the decoder.
*/
@SuppressLint("InlinedApi")
@TargetApi(21) // tunnelingAudioSessionId is unset if Util.SDK_INT < 21
protected MediaFormat getMediaFormat(
Format format,
String codecMimeType,

View File

@ -15,6 +15,7 @@
*/
package com.google.android.exoplayer2.video;
import android.annotation.TargetApi;
import android.content.Context;
import android.hardware.display.DisplayManager;
import android.os.Handler;
@ -40,9 +41,9 @@ public final class VideoFrameReleaseTimeHelper {
private static final long VSYNC_OFFSET_PERCENTAGE = 80;
private static final int MIN_FRAMES_FOR_ADJUSTMENT = 6;
private final WindowManager windowManager;
private final VSyncSampler vsyncSampler;
private final DefaultDisplayListener displayListener;
@Nullable private final WindowManager windowManager;
@Nullable private final VSyncSampler vsyncSampler;
@Nullable private final DefaultDisplayListener displayListener;
private long vsyncDurationNs;
private long vsyncOffsetNs;
@ -88,9 +89,8 @@ public final class VideoFrameReleaseTimeHelper {
vsyncOffsetNs = C.TIME_UNSET;
}
/**
* Enables the helper. Must be called from the playback thread.
*/
/** Enables the helper. Must be called from the playback thread. */
@TargetApi(17) // displayListener is null if Util.SDK_INT < 17.
public void enable() {
haveSync = false;
if (windowManager != null) {
@ -102,9 +102,8 @@ public final class VideoFrameReleaseTimeHelper {
}
}
/**
* Disables the helper. Must be called from the playback thread.
*/
/** Disables the helper. Must be called from the playback thread. */
@TargetApi(17) // displayListener is null if Util.SDK_INT < 17.
public void disable() {
if (windowManager != null) {
if (displayListener != null) {

View File

@ -15,7 +15,6 @@
*/
package com.google.android.exoplayer2.ui;
import android.annotation.TargetApi;
import android.content.Context;
import android.content.res.Resources;
import android.content.res.TypedArray;
@ -638,7 +637,6 @@ public class DefaultTimeBar extends View implements TimeBar {
event.setClassName(ACCESSIBILITY_CLASS_NAME);
}
@TargetApi(21)
@Override
public void onInitializeAccessibilityNodeInfo(AccessibilityNodeInfo info) {
super.onInitializeAccessibilityNodeInfo(info);

View File

@ -59,7 +59,7 @@ public final class FakeExtractorOutput implements ExtractorOutput, Dumper.Dumpab
*/
private static final int WRITE_TO_LOCAL = 1;
/** Write output to folder {@code /storage/emulated/0/Android/data} of device. */
private static final int WRITE_TO_DEVICE = 2;
private static final int WRITE_TO_DEVICE = 1 << 1;
@DumpFilesAction private static final int DUMP_FILE_ACTION = COMPARE_WITH_EXISTING;