Replace most usages of @TargetApi with @RequiresApi

We keep @TargetApi where the method is a safe no-op on
older versions due to an in-line version check.

PiperOrigin-RevId: 292878727
This commit is contained in:
ibaker 2020-02-03 10:30:40 +00:00 committed by Oliver Woodman
parent dd10d96a3f
commit b6bd57ab12
29 changed files with 102 additions and 110 deletions

View File

@ -15,9 +15,9 @@
*/ */
package com.google.android.exoplayer2.ext.workmanager; package com.google.android.exoplayer2.ext.workmanager;
import android.annotation.TargetApi;
import android.content.Context; import android.content.Context;
import android.content.Intent; import android.content.Intent;
import androidx.annotation.RequiresApi;
import androidx.work.Constraints; import androidx.work.Constraints;
import androidx.work.Data; import androidx.work.Data;
import androidx.work.ExistingWorkPolicy; import androidx.work.ExistingWorkPolicy;
@ -92,7 +92,7 @@ public final class WorkManagerScheduler implements Scheduler {
return builder.build(); return builder.build();
} }
@TargetApi(23) @RequiresApi(23)
private static void setRequiresDeviceIdle(Constraints.Builder builder) { private static void setRequiresDeviceIdle(Constraints.Builder builder) {
builder.setRequiresDeviceIdle(true); builder.setRequiresDeviceIdle(true);
} }

View File

@ -15,7 +15,6 @@
*/ */
package com.google.android.exoplayer2; package com.google.android.exoplayer2;
import android.annotation.TargetApi;
import android.content.Context; import android.content.Context;
import android.media.AudioAttributes; import android.media.AudioAttributes;
import android.media.AudioFormat; import android.media.AudioFormat;
@ -23,6 +22,7 @@ import android.media.AudioManager;
import android.media.MediaCodec; import android.media.MediaCodec;
import android.media.MediaFormat; import android.media.MediaFormat;
import androidx.annotation.IntDef; import androidx.annotation.IntDef;
import androidx.annotation.RequiresApi;
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;
@ -1047,7 +1047,7 @@ public final class C {
* *
* @see AudioManager#generateAudioSessionId() * @see AudioManager#generateAudioSessionId()
*/ */
@TargetApi(21) @RequiresApi(21)
public static int generateAudioSessionIdV21(Context context) { public static int generateAudioSessionIdV21(Context context) {
return ((AudioManager) context.getSystemService(Context.AUDIO_SERVICE)) return ((AudioManager) context.getSystemService(Context.AUDIO_SERVICE))
.generateAudioSessionId(); .generateAudioSessionId();

View File

@ -15,7 +15,7 @@
*/ */
package com.google.android.exoplayer2.decoder; package com.google.android.exoplayer2.decoder;
import android.annotation.TargetApi; import androidx.annotation.RequiresApi;
import com.google.android.exoplayer2.C; import com.google.android.exoplayer2.C;
import com.google.android.exoplayer2.util.Util; import com.google.android.exoplayer2.util.Util;
@ -111,7 +111,7 @@ public final class CryptoInfo {
return getFrameworkCryptoInfo(); return getFrameworkCryptoInfo();
} }
@TargetApi(24) @RequiresApi(24)
private static final class PatternHolderV24 { private static final class PatternHolderV24 {
private final android.media.MediaCodec.CryptoInfo frameworkCryptoInfo; private final android.media.MediaCodec.CryptoInfo frameworkCryptoInfo;

View File

@ -15,7 +15,7 @@
*/ */
package com.google.android.exoplayer2.util; package com.google.android.exoplayer2.util;
import android.annotation.TargetApi; import androidx.annotation.RequiresApi;
import com.google.android.exoplayer2.ExoPlayerLibraryInfo; import com.google.android.exoplayer2.ExoPlayerLibraryInfo;
/** /**
@ -49,12 +49,12 @@ public final class TraceUtil {
} }
} }
@TargetApi(18) @RequiresApi(18)
private static void beginSectionV18(String sectionName) { private static void beginSectionV18(String sectionName) {
android.os.Trace.beginSection(sectionName); android.os.Trace.beginSection(sectionName);
} }
@TargetApi(18) @RequiresApi(18)
private static void endSectionV18() { private static void endSectionV18() {
android.os.Trace.endSection(); android.os.Trace.endSection();
} }

View File

@ -47,6 +47,7 @@ import android.view.Display;
import android.view.SurfaceView; import android.view.SurfaceView;
import android.view.WindowManager; import android.view.WindowManager;
import androidx.annotation.Nullable; import androidx.annotation.Nullable;
import androidx.annotation.RequiresApi;
import com.google.android.exoplayer2.C; import com.google.android.exoplayer2.C;
import com.google.android.exoplayer2.ExoPlayerLibraryInfo; import com.google.android.exoplayer2.ExoPlayerLibraryInfo;
import com.google.android.exoplayer2.Format; import com.google.android.exoplayer2.Format;
@ -2058,14 +2059,14 @@ public final class Util {
} }
} }
@TargetApi(23) @RequiresApi(23)
private static void getDisplaySizeV23(Display display, Point outSize) { private static void getDisplaySizeV23(Display display, Point outSize) {
Display.Mode mode = display.getMode(); Display.Mode mode = display.getMode();
outSize.x = mode.getPhysicalWidth(); outSize.x = mode.getPhysicalWidth();
outSize.y = mode.getPhysicalHeight(); outSize.y = mode.getPhysicalHeight();
} }
@TargetApi(17) @RequiresApi(17)
private static void getDisplaySizeV17(Display display, Point outSize) { private static void getDisplaySizeV17(Display display, Point outSize) {
display.getRealSize(outSize); display.getRealSize(outSize);
} }
@ -2081,12 +2082,12 @@ public final class Util {
: new String[] {getLocaleLanguageTag(config.locale)}; : new String[] {getLocaleLanguageTag(config.locale)};
} }
@TargetApi(24) @RequiresApi(24)
private static String[] getSystemLocalesV24(Configuration config) { private static String[] getSystemLocalesV24(Configuration config) {
return Util.split(config.getLocales().toLanguageTags(), ","); return Util.split(config.getLocales().toLanguageTags(), ",");
} }
@TargetApi(21) @RequiresApi(21)
private static String getLocaleLanguageTagV21(Locale locale) { private static String getLocaleLanguageTagV21(Locale locale) {
return locale.toLanguageTag(); return locale.toLanguageTag();
} }

View File

@ -15,7 +15,6 @@
*/ */
package com.google.android.exoplayer2; package com.google.android.exoplayer2;
import android.annotation.TargetApi;
import android.content.Context; import android.content.Context;
import android.graphics.Rect; import android.graphics.Rect;
import android.graphics.SurfaceTexture; import android.graphics.SurfaceTexture;
@ -28,6 +27,7 @@ import android.view.SurfaceHolder;
import android.view.SurfaceView; import android.view.SurfaceView;
import android.view.TextureView; import android.view.TextureView;
import androidx.annotation.Nullable; import androidx.annotation.Nullable;
import androidx.annotation.RequiresApi;
import androidx.annotation.VisibleForTesting; import androidx.annotation.VisibleForTesting;
import com.google.android.exoplayer2.analytics.AnalyticsCollector; import com.google.android.exoplayer2.analytics.AnalyticsCollector;
import com.google.android.exoplayer2.analytics.AnalyticsListener; import com.google.android.exoplayer2.analytics.AnalyticsListener;
@ -852,7 +852,7 @@ public class SimpleExoPlayer extends BasePlayer
* @param params The {@link PlaybackParams}, or null to clear any previously set parameters. * @param params The {@link PlaybackParams}, or null to clear any previously set parameters.
*/ */
@Deprecated @Deprecated
@TargetApi(23) @RequiresApi(23)
public void setPlaybackParams(@Nullable PlaybackParams params) { public void setPlaybackParams(@Nullable PlaybackParams params) {
PlaybackParameters playbackParameters; PlaybackParameters playbackParameters;
if (params != null) { if (params != null) {

View File

@ -15,8 +15,8 @@
*/ */
package com.google.android.exoplayer2.audio; package com.google.android.exoplayer2.audio;
import android.annotation.TargetApi;
import androidx.annotation.Nullable; import androidx.annotation.Nullable;
import androidx.annotation.RequiresApi;
import com.google.android.exoplayer2.C; import com.google.android.exoplayer2.C;
import com.google.android.exoplayer2.util.Util; import com.google.android.exoplayer2.util.Util;
@ -118,7 +118,7 @@ public final class AudioAttributes {
* *
* <p>Field {@link AudioAttributes#allowedCapturePolicy} is ignored for API levels prior to 29. * <p>Field {@link AudioAttributes#allowedCapturePolicy} is ignored for API levels prior to 29.
*/ */
@TargetApi(21) @RequiresApi(21)
public android.media.AudioAttributes getAudioAttributesV21() { public android.media.AudioAttributes getAudioAttributesV21() {
if (audioAttributesV21 == null) { if (audioAttributesV21 == null) {
android.media.AudioAttributes.Builder builder = android.media.AudioAttributes.Builder builder =

View File

@ -16,7 +16,6 @@
package com.google.android.exoplayer2.audio; package com.google.android.exoplayer2.audio;
import android.annotation.SuppressLint; import android.annotation.SuppressLint;
import android.annotation.TargetApi;
import android.content.Context; import android.content.Context;
import android.content.Intent; import android.content.Intent;
import android.content.IntentFilter; import android.content.IntentFilter;
@ -29,7 +28,6 @@ import com.google.android.exoplayer2.util.Util;
import java.util.Arrays; import java.util.Arrays;
/** Represents the set of audio formats that a device is capable of playing. */ /** Represents the set of audio formats that a device is capable of playing. */
@TargetApi(21)
public final class AudioCapabilities { public final class AudioCapabilities {
private static final int DEFAULT_MAX_CHANNEL_COUNT = 8; private static final int DEFAULT_MAX_CHANNEL_COUNT = 8;

View File

@ -15,11 +15,11 @@
*/ */
package com.google.android.exoplayer2.audio; package com.google.android.exoplayer2.audio;
import android.annotation.TargetApi;
import android.media.AudioTimestamp; import android.media.AudioTimestamp;
import android.media.AudioTrack; import android.media.AudioTrack;
import androidx.annotation.IntDef; import androidx.annotation.IntDef;
import androidx.annotation.Nullable; import androidx.annotation.Nullable;
import androidx.annotation.RequiresApi;
import com.google.android.exoplayer2.C; import com.google.android.exoplayer2.C;
import com.google.android.exoplayer2.util.Util; import com.google.android.exoplayer2.util.Util;
import java.lang.annotation.Documented; import java.lang.annotation.Documented;
@ -257,7 +257,7 @@ import java.lang.annotation.RetentionPolicy;
} }
} }
@TargetApi(19) @RequiresApi(19)
private static final class AudioTimestampV19 { private static final class AudioTimestampV19 {
private final AudioTrack audioTrack; private final AudioTrack audioTrack;

View File

@ -16,13 +16,13 @@
package com.google.android.exoplayer2.audio; package com.google.android.exoplayer2.audio;
import android.annotation.SuppressLint; import android.annotation.SuppressLint;
import android.annotation.TargetApi;
import android.media.AudioFormat; import android.media.AudioFormat;
import android.media.AudioManager; import android.media.AudioManager;
import android.media.AudioTrack; import android.media.AudioTrack;
import android.os.ConditionVariable; import android.os.ConditionVariable;
import android.os.SystemClock; import android.os.SystemClock;
import androidx.annotation.Nullable; import androidx.annotation.Nullable;
import androidx.annotation.RequiresApi;
import com.google.android.exoplayer2.C; import com.google.android.exoplayer2.C;
import com.google.android.exoplayer2.Format; import com.google.android.exoplayer2.Format;
import com.google.android.exoplayer2.PlaybackParameters; import com.google.android.exoplayer2.PlaybackParameters;
@ -1169,14 +1169,14 @@ public final class DefaultAudioSink implements AudioSink {
} }
} }
@TargetApi(21) @RequiresApi(21)
private static int writeNonBlockingV21(AudioTrack audioTrack, ByteBuffer buffer, int size) { private static int writeNonBlockingV21(AudioTrack audioTrack, ByteBuffer buffer, int size) {
return audioTrack.write(buffer, size, WRITE_NON_BLOCKING); return audioTrack.write(buffer, size, WRITE_NON_BLOCKING);
} }
@TargetApi(21) @RequiresApi(21)
private int writeNonBlockingWithAvSyncV21(AudioTrack audioTrack, ByteBuffer buffer, int size, private int writeNonBlockingWithAvSyncV21(
long presentationTimeUs) { AudioTrack audioTrack, ByteBuffer buffer, int size, long presentationTimeUs) {
if (Util.SDK_INT >= 26) { if (Util.SDK_INT >= 26) {
// The underlying platform AudioTrack writes AV sync headers directly. // The underlying platform AudioTrack writes AV sync headers directly.
return audioTrack.write(buffer, size, WRITE_NON_BLOCKING, presentationTimeUs * 1000); return audioTrack.write(buffer, size, WRITE_NON_BLOCKING, presentationTimeUs * 1000);
@ -1212,7 +1212,7 @@ public final class DefaultAudioSink implements AudioSink {
return result; return result;
} }
@TargetApi(21) @RequiresApi(21)
private static void setVolumeInternalV21(AudioTrack audioTrack, float volume) { private static void setVolumeInternalV21(AudioTrack audioTrack, float volume) {
audioTrack.setVolume(volume); audioTrack.setVolume(volume);
} }
@ -1416,7 +1416,7 @@ public final class DefaultAudioSink implements AudioSink {
return audioTrack; return audioTrack;
} }
@TargetApi(21) @RequiresApi(21)
private AudioTrack createAudioTrackV21( private AudioTrack createAudioTrackV21(
boolean tunneling, AudioAttributes audioAttributes, int audioSessionId) { boolean tunneling, AudioAttributes audioAttributes, int audioSessionId) {
android.media.AudioAttributes attributes; android.media.AudioAttributes attributes;

View File

@ -16,7 +16,6 @@
package com.google.android.exoplayer2.drm; package com.google.android.exoplayer2.drm;
import android.annotation.SuppressLint; import android.annotation.SuppressLint;
import android.annotation.TargetApi;
import android.media.NotProvisionedException; import android.media.NotProvisionedException;
import android.os.Handler; import android.os.Handler;
import android.os.HandlerThread; import android.os.HandlerThread;
@ -25,6 +24,7 @@ import android.os.Message;
import android.os.SystemClock; import android.os.SystemClock;
import android.util.Pair; import android.util.Pair;
import androidx.annotation.Nullable; import androidx.annotation.Nullable;
import androidx.annotation.RequiresApi;
import com.google.android.exoplayer2.C; import com.google.android.exoplayer2.C;
import com.google.android.exoplayer2.drm.DrmInitData.SchemeData; import com.google.android.exoplayer2.drm.DrmInitData.SchemeData;
import com.google.android.exoplayer2.drm.ExoMediaDrm.KeyRequest; import com.google.android.exoplayer2.drm.ExoMediaDrm.KeyRequest;
@ -46,7 +46,7 @@ import org.checkerframework.checker.nullness.qual.MonotonicNonNull;
import org.checkerframework.checker.nullness.qual.RequiresNonNull; import org.checkerframework.checker.nullness.qual.RequiresNonNull;
/** A {@link DrmSession} that supports playbacks using {@link ExoMediaDrm}. */ /** A {@link DrmSession} that supports playbacks using {@link ExoMediaDrm}. */
@TargetApi(18) @RequiresApi(18)
/* package */ class DefaultDrmSession<T extends ExoMediaCrypto> implements DrmSession<T> { /* package */ class DefaultDrmSession<T extends ExoMediaCrypto> implements DrmSession<T> {
/** Thrown when an unexpected exception or error is thrown during provisioning or key requests. */ /** Thrown when an unexpected exception or error is thrown during provisioning or key requests. */

View File

@ -16,12 +16,12 @@
package com.google.android.exoplayer2.drm; package com.google.android.exoplayer2.drm;
import android.annotation.SuppressLint; import android.annotation.SuppressLint;
import android.annotation.TargetApi;
import android.os.Handler; import android.os.Handler;
import android.os.Looper; import android.os.Looper;
import android.os.Message; import android.os.Message;
import androidx.annotation.IntDef; import androidx.annotation.IntDef;
import androidx.annotation.Nullable; import androidx.annotation.Nullable;
import androidx.annotation.RequiresApi;
import com.google.android.exoplayer2.C; import com.google.android.exoplayer2.C;
import com.google.android.exoplayer2.drm.DrmInitData.SchemeData; import com.google.android.exoplayer2.drm.DrmInitData.SchemeData;
import com.google.android.exoplayer2.drm.DrmSession.DrmSessionException; import com.google.android.exoplayer2.drm.DrmSession.DrmSessionException;
@ -43,7 +43,7 @@ import java.util.Map;
import java.util.UUID; import java.util.UUID;
/** A {@link DrmSessionManager} that supports playbacks using {@link ExoMediaDrm}. */ /** A {@link DrmSessionManager} that supports playbacks using {@link ExoMediaDrm}. */
@TargetApi(18) @RequiresApi(18)
public class DefaultDrmSessionManager<T extends ExoMediaCrypto> implements DrmSessionManager<T> { public class DefaultDrmSessionManager<T extends ExoMediaCrypto> implements DrmSessionManager<T> {
/** /**

View File

@ -15,10 +15,10 @@
*/ */
package com.google.android.exoplayer2.drm; package com.google.android.exoplayer2.drm;
import android.annotation.TargetApi;
import android.net.Uri; import android.net.Uri;
import android.text.TextUtils; import android.text.TextUtils;
import androidx.annotation.Nullable; import androidx.annotation.Nullable;
import androidx.annotation.RequiresApi;
import com.google.android.exoplayer2.C; import com.google.android.exoplayer2.C;
import com.google.android.exoplayer2.drm.ExoMediaDrm.KeyRequest; import com.google.android.exoplayer2.drm.ExoMediaDrm.KeyRequest;
import com.google.android.exoplayer2.drm.ExoMediaDrm.ProvisionRequest; import com.google.android.exoplayer2.drm.ExoMediaDrm.ProvisionRequest;
@ -34,10 +34,8 @@ import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.UUID; import java.util.UUID;
/** /** A {@link MediaDrmCallback} that makes requests using {@link HttpDataSource} instances. */
* A {@link MediaDrmCallback} that makes requests using {@link HttpDataSource} instances. @RequiresApi(18)
*/
@TargetApi(18)
public final class HttpMediaDrmCallback implements MediaDrmCallback { public final class HttpMediaDrmCallback implements MediaDrmCallback {
private static final int MAX_MANUAL_REDIRECTS = 5; private static final int MAX_MANUAL_REDIRECTS = 5;

View File

@ -15,7 +15,6 @@
*/ */
package com.google.android.exoplayer2.drm; package com.google.android.exoplayer2.drm;
import android.annotation.TargetApi;
import android.media.MediaDrm; import android.media.MediaDrm;
import android.os.ConditionVariable; import android.os.ConditionVariable;
import android.os.Handler; import android.os.Handler;
@ -34,7 +33,6 @@ import java.util.Map;
import java.util.UUID; import java.util.UUID;
/** Helper class to download, renew and release offline licenses. */ /** Helper class to download, renew and release offline licenses. */
@TargetApi(18)
@RequiresApi(18) @RequiresApi(18)
public final class OfflineLicenseHelper<T extends ExoMediaCrypto> { public final class OfflineLicenseHelper<T extends ExoMediaCrypto> {

View File

@ -15,7 +15,6 @@
*/ */
package com.google.android.exoplayer2.mediacodec; package com.google.android.exoplayer2.mediacodec;
import android.annotation.TargetApi;
import android.graphics.Point; import android.graphics.Point;
import android.media.MediaCodec; import android.media.MediaCodec;
import android.media.MediaCodecInfo.AudioCapabilities; import android.media.MediaCodecInfo.AudioCapabilities;
@ -24,6 +23,7 @@ import android.media.MediaCodecInfo.CodecProfileLevel;
import android.media.MediaCodecInfo.VideoCapabilities; import android.media.MediaCodecInfo.VideoCapabilities;
import android.util.Pair; import android.util.Pair;
import androidx.annotation.Nullable; import androidx.annotation.Nullable;
import androidx.annotation.RequiresApi;
import com.google.android.exoplayer2.Format; import com.google.android.exoplayer2.Format;
import com.google.android.exoplayer2.util.Assertions; import com.google.android.exoplayer2.util.Assertions;
import com.google.android.exoplayer2.util.Log; import com.google.android.exoplayer2.util.Log;
@ -393,7 +393,7 @@ public final class MediaCodecInfo {
* Format#NO_VALUE} or any value less than or equal to 0. * Format#NO_VALUE} or any value less than or equal to 0.
* @return Whether the decoder supports video with the given width, height and frame rate. * @return Whether the decoder supports video with the given width, height and frame rate.
*/ */
@TargetApi(21) @RequiresApi(21)
public boolean isVideoSizeAndRateSupportedV21(int width, int height, double frameRate) { public boolean isVideoSizeAndRateSupportedV21(int width, int height, double frameRate) {
if (capabilities == null) { if (capabilities == null) {
logNoSupport("sizeAndRate.caps"); logNoSupport("sizeAndRate.caps");
@ -419,8 +419,8 @@ public final class MediaCodecInfo {
/** /**
* Returns the smallest video size greater than or equal to a specified size that also satisfies * Returns the smallest video size greater than or equal to a specified size that also satisfies
* the {@link MediaCodec}'s width and height alignment requirements. * the {@link MediaCodec}'s width and height alignment requirements.
* <p> *
* Must not be called if the device SDK version is less than 21. * <p>Must not be called if the device SDK version is less than 21.
* *
* @param width Width in pixels. * @param width Width in pixels.
* @param height Height in pixels. * @param height Height in pixels.
@ -428,7 +428,7 @@ public final class MediaCodecInfo {
* the {@link MediaCodec}'s width and height alignment requirements, or null if not a video * the {@link MediaCodec}'s width and height alignment requirements, or null if not a video
* codec. * codec.
*/ */
@TargetApi(21) @RequiresApi(21)
public Point alignVideoSizeV21(int width, int height) { public Point alignVideoSizeV21(int width, int height) {
if (capabilities == null) { if (capabilities == null) {
return null; return null;
@ -442,13 +442,13 @@ public final class MediaCodecInfo {
/** /**
* Whether the decoder supports audio with a given sample rate. * Whether the decoder supports audio with a given sample rate.
* <p> *
* Must not be called if the device SDK version is less than 21. * <p>Must not be called if the device SDK version is less than 21.
* *
* @param sampleRate The sample rate in Hz. * @param sampleRate The sample rate in Hz.
* @return Whether the decoder supports audio with the given sample rate. * @return Whether the decoder supports audio with the given sample rate.
*/ */
@TargetApi(21) @RequiresApi(21)
public boolean isAudioSampleRateSupportedV21(int sampleRate) { public boolean isAudioSampleRateSupportedV21(int sampleRate) {
if (capabilities == null) { if (capabilities == null) {
logNoSupport("sampleRate.caps"); logNoSupport("sampleRate.caps");
@ -468,13 +468,13 @@ public final class MediaCodecInfo {
/** /**
* Whether the decoder supports audio with a given channel count. * Whether the decoder supports audio with a given channel count.
* <p> *
* Must not be called if the device SDK version is less than 21. * <p>Must not be called if the device SDK version is less than 21.
* *
* @param channelCount The channel count. * @param channelCount The channel count.
* @return Whether the decoder supports audio with the given channel count. * @return Whether the decoder supports audio with the given channel count.
*/ */
@TargetApi(21) @RequiresApi(21)
public boolean isAudioChannelCountSupportedV21(int channelCount) { public boolean isAudioChannelCountSupportedV21(int channelCount) {
if (capabilities == null) { if (capabilities == null) {
logNoSupport("channelCount.caps"); logNoSupport("channelCount.caps");
@ -542,7 +542,7 @@ public final class MediaCodecInfo {
return Util.SDK_INT >= 19 && isAdaptiveV19(capabilities); return Util.SDK_INT >= 19 && isAdaptiveV19(capabilities);
} }
@TargetApi(19) @RequiresApi(19)
private static boolean isAdaptiveV19(CodecCapabilities capabilities) { private static boolean isAdaptiveV19(CodecCapabilities capabilities) {
return capabilities.isFeatureSupported(CodecCapabilities.FEATURE_AdaptivePlayback); return capabilities.isFeatureSupported(CodecCapabilities.FEATURE_AdaptivePlayback);
} }
@ -551,7 +551,7 @@ public final class MediaCodecInfo {
return Util.SDK_INT >= 21 && isTunnelingV21(capabilities); return Util.SDK_INT >= 21 && isTunnelingV21(capabilities);
} }
@TargetApi(21) @RequiresApi(21)
private static boolean isTunnelingV21(CodecCapabilities capabilities) { private static boolean isTunnelingV21(CodecCapabilities capabilities) {
return capabilities.isFeatureSupported(CodecCapabilities.FEATURE_TunneledPlayback); return capabilities.isFeatureSupported(CodecCapabilities.FEATURE_TunneledPlayback);
} }
@ -560,14 +560,14 @@ public final class MediaCodecInfo {
return Util.SDK_INT >= 21 && isSecureV21(capabilities); return Util.SDK_INT >= 21 && isSecureV21(capabilities);
} }
@TargetApi(21) @RequiresApi(21)
private static boolean isSecureV21(CodecCapabilities capabilities) { private static boolean isSecureV21(CodecCapabilities capabilities) {
return capabilities.isFeatureSupported(CodecCapabilities.FEATURE_SecurePlayback); return capabilities.isFeatureSupported(CodecCapabilities.FEATURE_SecurePlayback);
} }
@TargetApi(21) @RequiresApi(21)
private static boolean areSizeAndRateSupportedV21(VideoCapabilities capabilities, int width, private static boolean areSizeAndRateSupportedV21(
int height, double frameRate) { VideoCapabilities capabilities, int width, int height, double frameRate) {
// Don't ever fail due to alignment. See: https://github.com/google/ExoPlayer/issues/6551. // Don't ever fail due to alignment. See: https://github.com/google/ExoPlayer/issues/6551.
Point alignedSize = alignVideoSizeV21(capabilities, width, height); Point alignedSize = alignVideoSizeV21(capabilities, width, height);
width = alignedSize.x; width = alignedSize.x;
@ -584,7 +584,7 @@ public final class MediaCodecInfo {
} }
} }
@TargetApi(21) @RequiresApi(21)
private static Point alignVideoSizeV21(VideoCapabilities capabilities, int width, int height) { private static Point alignVideoSizeV21(VideoCapabilities capabilities, int width, int height) {
int widthAlignment = capabilities.getWidthAlignment(); int widthAlignment = capabilities.getWidthAlignment();
int heightAlignment = capabilities.getHeightAlignment(); int heightAlignment = capabilities.getHeightAlignment();
@ -593,7 +593,7 @@ public final class MediaCodecInfo {
Util.ceilDivide(height, heightAlignment) * heightAlignment); Util.ceilDivide(height, heightAlignment) * heightAlignment);
} }
@TargetApi(23) @RequiresApi(23)
private static int getMaxSupportedInstancesV23(CodecCapabilities capabilities) { private static int getMaxSupportedInstancesV23(CodecCapabilities capabilities) {
return capabilities.getMaxSupportedInstances(); return capabilities.getMaxSupportedInstances();
} }

View File

@ -15,7 +15,6 @@
*/ */
package com.google.android.exoplayer2.mediacodec; package com.google.android.exoplayer2.mediacodec;
import android.annotation.TargetApi;
import android.media.MediaCodec; import android.media.MediaCodec;
import android.media.MediaCodec.CodecException; import android.media.MediaCodec.CodecException;
import android.media.MediaCodec.CryptoException; import android.media.MediaCodec.CryptoException;
@ -28,6 +27,7 @@ import androidx.annotation.CallSuper;
import androidx.annotation.CheckResult; import androidx.annotation.CheckResult;
import androidx.annotation.IntDef; import androidx.annotation.IntDef;
import androidx.annotation.Nullable; import androidx.annotation.Nullable;
import androidx.annotation.RequiresApi;
import com.google.android.exoplayer2.BaseRenderer; import com.google.android.exoplayer2.BaseRenderer;
import com.google.android.exoplayer2.C; import com.google.android.exoplayer2.C;
import com.google.android.exoplayer2.ExoPlaybackException; import com.google.android.exoplayer2.ExoPlaybackException;
@ -192,7 +192,7 @@ public abstract class MediaCodecRenderer extends BaseRenderer {
fallbackException); fallbackException);
} }
@TargetApi(21) @RequiresApi(21)
private static String getDiagnosticInfoV21(Throwable cause) { private static String getDiagnosticInfoV21(Throwable cause) {
if (cause instanceof CodecException) { if (cause instanceof CodecException) {
return ((CodecException) cause).getDiagnosticInfo(); return ((CodecException) cause).getDiagnosticInfo();
@ -223,7 +223,7 @@ public abstract class MediaCodecRenderer extends BaseRenderer {
diagnosticInfo = Util.SDK_INT >= 21 ? getDiagnosticInfoV21(cause) : null; diagnosticInfo = Util.SDK_INT >= 21 ? getDiagnosticInfoV21(cause) : null;
} }
@TargetApi(21) @RequiresApi(21)
private static String getDiagnosticInfoV21(Throwable cause) { private static String getDiagnosticInfoV21(Throwable cause) {
if (cause instanceof CodecException) { if (cause instanceof CodecException) {
return ((CodecException) cause).getDiagnosticInfo(); return ((CodecException) cause).getDiagnosticInfo();
@ -1794,7 +1794,7 @@ public abstract class MediaCodecRenderer extends BaseRenderer {
maybeInitCodec(); maybeInitCodec();
} }
@TargetApi(23) @RequiresApi(23)
private void updateDrmSessionOrReinitializeCodecV23() throws ExoPlaybackException { private void updateDrmSessionOrReinitializeCodecV23() throws ExoPlaybackException {
FrameworkMediaCrypto sessionMediaCrypto = sourceDrmSession.getMediaCrypto(); FrameworkMediaCrypto sessionMediaCrypto = sourceDrmSession.getMediaCrypto();
if (sessionMediaCrypto == null) { if (sessionMediaCrypto == null) {
@ -1867,7 +1867,7 @@ public abstract class MediaCodecRenderer extends BaseRenderer {
return stackTrace.length > 0 && stackTrace[0].getClassName().equals("android.media.MediaCodec"); return stackTrace.length > 0 && stackTrace[0].getClassName().equals("android.media.MediaCodec");
} }
@TargetApi(21) @RequiresApi(21)
private static boolean isMediaCodecExceptionV21(IllegalStateException error) { private static boolean isMediaCodecExceptionV21(IllegalStateException error) {
return error instanceof MediaCodec.CodecException; return error instanceof MediaCodec.CodecException;
} }

View File

@ -16,7 +16,6 @@
package com.google.android.exoplayer2.mediacodec; package com.google.android.exoplayer2.mediacodec;
import android.annotation.SuppressLint; import android.annotation.SuppressLint;
import android.annotation.TargetApi;
import android.media.MediaCodecInfo.CodecCapabilities; import android.media.MediaCodecInfo.CodecCapabilities;
import android.media.MediaCodecInfo.CodecProfileLevel; import android.media.MediaCodecInfo.CodecProfileLevel;
import android.media.MediaCodecList; import android.media.MediaCodecList;
@ -25,6 +24,7 @@ import android.util.Pair;
import android.util.SparseIntArray; import android.util.SparseIntArray;
import androidx.annotation.CheckResult; import androidx.annotation.CheckResult;
import androidx.annotation.Nullable; import androidx.annotation.Nullable;
import androidx.annotation.RequiresApi;
import com.google.android.exoplayer2.C; import com.google.android.exoplayer2.C;
import com.google.android.exoplayer2.Format; import com.google.android.exoplayer2.Format;
import com.google.android.exoplayer2.util.Log; import com.google.android.exoplayer2.util.Log;
@ -604,7 +604,7 @@ public final class MediaCodecUtil {
return !isSoftwareOnly(codecInfo); return !isSoftwareOnly(codecInfo);
} }
@TargetApi(29) @RequiresApi(29)
private static boolean isHardwareAcceleratedV29(android.media.MediaCodecInfo codecInfo) { private static boolean isHardwareAcceleratedV29(android.media.MediaCodecInfo codecInfo) {
return codecInfo.isHardwareAccelerated(); return codecInfo.isHardwareAccelerated();
} }
@ -630,7 +630,7 @@ public final class MediaCodecUtil {
|| (!codecName.startsWith("omx.") && !codecName.startsWith("c2.")); || (!codecName.startsWith("omx.") && !codecName.startsWith("c2."));
} }
@TargetApi(29) @RequiresApi(29)
private static boolean isSoftwareOnlyV29(android.media.MediaCodecInfo codecInfo) { private static boolean isSoftwareOnlyV29(android.media.MediaCodecInfo codecInfo) {
return codecInfo.isSoftwareOnly(); return codecInfo.isSoftwareOnly();
} }
@ -649,7 +649,7 @@ public final class MediaCodecUtil {
&& !codecName.startsWith("c2.google."); && !codecName.startsWith("c2.google.");
} }
@TargetApi(29) @RequiresApi(29)
private static boolean isVendorV29(android.media.MediaCodecInfo codecInfo) { private static boolean isVendorV29(android.media.MediaCodecInfo codecInfo) {
return codecInfo.isVendor(); return codecInfo.isVendor();
} }
@ -947,7 +947,7 @@ public final class MediaCodecUtil {
boolean isFeatureRequired(String feature, String mimeType, CodecCapabilities capabilities); boolean isFeatureRequired(String feature, String mimeType, CodecCapabilities capabilities);
} }
@TargetApi(21) @RequiresApi(21)
private static final class MediaCodecListCompatV21 implements MediaCodecListCompat { private static final class MediaCodecListCompatV21 implements MediaCodecListCompat {
private final int codecKind; private final int codecKind;

View File

@ -15,7 +15,6 @@
*/ */
package com.google.android.exoplayer2.scheduler; package com.google.android.exoplayer2.scheduler;
import android.annotation.TargetApi;
import android.app.job.JobInfo; import android.app.job.JobInfo;
import android.app.job.JobParameters; import android.app.job.JobParameters;
import android.app.job.JobScheduler; import android.app.job.JobScheduler;
@ -24,6 +23,7 @@ import android.content.ComponentName;
import android.content.Context; import android.content.Context;
import android.content.Intent; import android.content.Intent;
import android.os.PersistableBundle; import android.os.PersistableBundle;
import androidx.annotation.RequiresApi;
import androidx.annotation.RequiresPermission; import androidx.annotation.RequiresPermission;
import com.google.android.exoplayer2.util.Assertions; import com.google.android.exoplayer2.util.Assertions;
import com.google.android.exoplayer2.util.Log; import com.google.android.exoplayer2.util.Log;
@ -42,7 +42,7 @@ import com.google.android.exoplayer2.util.Util;
* android:exported="true"/> * android:exported="true"/>
* }</pre> * }</pre>
*/ */
@TargetApi(21) @RequiresApi(21)
public final class PlatformScheduler implements Scheduler { public final class PlatformScheduler implements Scheduler {
private static final boolean DEBUG = false; private static final boolean DEBUG = false;

View File

@ -15,7 +15,6 @@
*/ */
package com.google.android.exoplayer2.scheduler; package com.google.android.exoplayer2.scheduler;
import android.annotation.TargetApi;
import android.content.BroadcastReceiver; import android.content.BroadcastReceiver;
import android.content.Context; import android.content.Context;
import android.content.Intent; import android.content.Intent;
@ -124,7 +123,7 @@ public final class RequirementsWatcher {
return requirements; return requirements;
} }
@TargetApi(24) @RequiresApi(24)
private void registerNetworkCallbackV24() { private void registerNetworkCallbackV24() {
ConnectivityManager connectivityManager = ConnectivityManager connectivityManager =
Assertions.checkNotNull( Assertions.checkNotNull(
@ -133,7 +132,7 @@ public final class RequirementsWatcher {
connectivityManager.registerDefaultNetworkCallback(networkCallback); connectivityManager.registerDefaultNetworkCallback(networkCallback);
} }
@TargetApi(24) @RequiresApi(24)
private void unregisterNetworkCallbackV24() { private void unregisterNetworkCallbackV24() {
ConnectivityManager connectivityManager = ConnectivityManager connectivityManager =
(ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE); (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);

View File

@ -15,13 +15,13 @@
*/ */
package com.google.android.exoplayer2.text; package com.google.android.exoplayer2.text;
import android.annotation.TargetApi;
import android.graphics.Color; import android.graphics.Color;
import android.graphics.Typeface; import android.graphics.Typeface;
import android.view.accessibility.CaptioningManager; import android.view.accessibility.CaptioningManager;
import android.view.accessibility.CaptioningManager.CaptionStyle; import android.view.accessibility.CaptioningManager.CaptionStyle;
import androidx.annotation.IntDef; import androidx.annotation.IntDef;
import androidx.annotation.Nullable; import androidx.annotation.Nullable;
import androidx.annotation.RequiresApi;
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;
@ -124,7 +124,7 @@ public final class CaptionStyleCompat {
* @param captionStyle A {@link CaptionStyle}. * @param captionStyle A {@link CaptionStyle}.
* @return The equivalent {@link CaptionStyleCompat}. * @return The equivalent {@link CaptionStyleCompat}.
*/ */
@TargetApi(19) @RequiresApi(19)
public static CaptionStyleCompat createFromCaptionStyle( public static CaptionStyleCompat createFromCaptionStyle(
CaptioningManager.CaptionStyle captionStyle) { CaptioningManager.CaptionStyle captionStyle) {
if (Util.SDK_INT >= 21) { if (Util.SDK_INT >= 21) {
@ -159,7 +159,7 @@ public final class CaptionStyleCompat {
this.typeface = typeface; this.typeface = typeface;
} }
@TargetApi(19) @RequiresApi(19)
@SuppressWarnings("ResourceType") @SuppressWarnings("ResourceType")
private static CaptionStyleCompat createFromCaptionStyleV19( private static CaptionStyleCompat createFromCaptionStyleV19(
CaptioningManager.CaptionStyle captionStyle) { CaptioningManager.CaptionStyle captionStyle) {
@ -168,7 +168,7 @@ public final class CaptionStyleCompat {
captionStyle.edgeType, captionStyle.edgeColor, captionStyle.getTypeface()); captionStyle.edgeType, captionStyle.edgeColor, captionStyle.getTypeface());
} }
@TargetApi(21) @RequiresApi(21)
@SuppressWarnings("ResourceType") @SuppressWarnings("ResourceType")
private static CaptionStyleCompat createFromCaptionStyleV21( private static CaptionStyleCompat createFromCaptionStyleV21(
CaptioningManager.CaptionStyle captionStyle) { CaptioningManager.CaptionStyle captionStyle) {

View File

@ -15,7 +15,6 @@
*/ */
package com.google.android.exoplayer2.trackselection; package com.google.android.exoplayer2.trackselection;
import android.annotation.TargetApi;
import android.content.Context; import android.content.Context;
import android.os.Looper; import android.os.Looper;
import android.os.Parcel; import android.os.Parcel;
@ -23,6 +22,7 @@ import android.os.Parcelable;
import android.text.TextUtils; import android.text.TextUtils;
import android.view.accessibility.CaptioningManager; import android.view.accessibility.CaptioningManager;
import androidx.annotation.Nullable; import androidx.annotation.Nullable;
import androidx.annotation.RequiresApi;
import com.google.android.exoplayer2.C; import com.google.android.exoplayer2.C;
import com.google.android.exoplayer2.util.Util; import com.google.android.exoplayer2.util.Util;
import java.util.Locale; import java.util.Locale;
@ -169,7 +169,7 @@ public class TrackSelectionParameters implements Parcelable {
disabledTextTrackSelectionFlags); disabledTextTrackSelectionFlags);
} }
@TargetApi(19) @RequiresApi(19)
private void setPreferredTextLanguageAndRoleFlagsToCaptioningManagerSettingsV19( private void setPreferredTextLanguageAndRoleFlagsToCaptioningManagerSettingsV19(
Context context) { Context context) {
if (Util.SDK_INT < 23 && Looper.myLooper() == null) { if (Util.SDK_INT < 23 && Looper.myLooper() == null) {

View File

@ -15,7 +15,6 @@
*/ */
package com.google.android.exoplayer2.util; package com.google.android.exoplayer2.util;
import android.annotation.TargetApi;
import android.graphics.SurfaceTexture; import android.graphics.SurfaceTexture;
import android.opengl.EGL14; import android.opengl.EGL14;
import android.opengl.EGLConfig; import android.opengl.EGLConfig;
@ -26,12 +25,13 @@ import android.opengl.GLES20;
import android.os.Handler; import android.os.Handler;
import androidx.annotation.IntDef; import androidx.annotation.IntDef;
import androidx.annotation.Nullable; import androidx.annotation.Nullable;
import androidx.annotation.RequiresApi;
import java.lang.annotation.Documented; import java.lang.annotation.Documented;
import java.lang.annotation.Retention; import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy; import java.lang.annotation.RetentionPolicy;
/** Generates a {@link SurfaceTexture} using EGL/GLES functions. */ /** Generates a {@link SurfaceTexture} using EGL/GLES functions. */
@TargetApi(17) @RequiresApi(17)
public final class EGLSurfaceTexture implements SurfaceTexture.OnFrameAvailableListener, Runnable { public final class EGLSurfaceTexture implements SurfaceTexture.OnFrameAvailableListener, Runnable {
/** Listener to be called when the texture image on {@link SurfaceTexture} has been updated. */ /** Listener to be called when the texture image on {@link SurfaceTexture} has been updated. */

View File

@ -19,7 +19,6 @@ import static com.google.android.exoplayer2.util.EGLSurfaceTexture.SECURE_MODE_N
import static com.google.android.exoplayer2.util.EGLSurfaceTexture.SECURE_MODE_PROTECTED_PBUFFER; import static com.google.android.exoplayer2.util.EGLSurfaceTexture.SECURE_MODE_PROTECTED_PBUFFER;
import static com.google.android.exoplayer2.util.EGLSurfaceTexture.SECURE_MODE_SURFACELESS_CONTEXT; import static com.google.android.exoplayer2.util.EGLSurfaceTexture.SECURE_MODE_SURFACELESS_CONTEXT;
import android.annotation.TargetApi;
import android.content.Context; import android.content.Context;
import android.content.pm.PackageManager; import android.content.pm.PackageManager;
import android.graphics.SurfaceTexture; import android.graphics.SurfaceTexture;
@ -31,6 +30,7 @@ import android.os.HandlerThread;
import android.os.Message; import android.os.Message;
import android.view.Surface; import android.view.Surface;
import androidx.annotation.Nullable; import androidx.annotation.Nullable;
import androidx.annotation.RequiresApi;
import com.google.android.exoplayer2.util.Assertions; import com.google.android.exoplayer2.util.Assertions;
import com.google.android.exoplayer2.util.EGLSurfaceTexture; import com.google.android.exoplayer2.util.EGLSurfaceTexture;
import com.google.android.exoplayer2.util.EGLSurfaceTexture.SecureMode; import com.google.android.exoplayer2.util.EGLSurfaceTexture.SecureMode;
@ -39,10 +39,8 @@ import com.google.android.exoplayer2.util.Util;
import javax.microedition.khronos.egl.EGL10; import javax.microedition.khronos.egl.EGL10;
import org.checkerframework.checker.nullness.qual.MonotonicNonNull; import org.checkerframework.checker.nullness.qual.MonotonicNonNull;
/** /** A dummy {@link Surface}. */
* A dummy {@link Surface}. @RequiresApi(17)
*/
@TargetApi(17)
public final class DummySurface extends Surface { public final class DummySurface extends Surface {
private static final String TAG = "DummySurface"; private static final String TAG = "DummySurface";
@ -121,7 +119,7 @@ public final class DummySurface extends Surface {
} }
} }
@TargetApi(24) @RequiresApi(24)
private static @SecureMode int getSecureModeV24(Context context) { private static @SecureMode int getSecureModeV24(Context context) {
if (Util.SDK_INT < 26 && ("samsung".equals(Util.MANUFACTURER) || "XT1650".equals(Util.MODEL))) { if (Util.SDK_INT < 26 && ("samsung".equals(Util.MANUFACTURER) || "XT1650".equals(Util.MODEL))) {
// Samsung devices running Nougat are known to be broken. See // Samsung devices running Nougat are known to be broken. See

View File

@ -16,7 +16,6 @@
package com.google.android.exoplayer2.video; package com.google.android.exoplayer2.video;
import android.annotation.SuppressLint; import android.annotation.SuppressLint;
import android.annotation.TargetApi;
import android.content.Context; import android.content.Context;
import android.graphics.Point; import android.graphics.Point;
import android.media.MediaCodec; import android.media.MediaCodec;
@ -32,6 +31,7 @@ import android.util.Pair;
import android.view.Surface; import android.view.Surface;
import androidx.annotation.CallSuper; import androidx.annotation.CallSuper;
import androidx.annotation.Nullable; import androidx.annotation.Nullable;
import androidx.annotation.RequiresApi;
import com.google.android.exoplayer2.C; import com.google.android.exoplayer2.C;
import com.google.android.exoplayer2.ExoPlaybackException; import com.google.android.exoplayer2.ExoPlaybackException;
import com.google.android.exoplayer2.ExoPlayer; import com.google.android.exoplayer2.ExoPlayer;
@ -1180,7 +1180,7 @@ public class MediaCodecVideoRenderer extends MediaCodecRenderer {
* @param presentationTimeUs The presentation time of the output buffer, in microseconds. * @param presentationTimeUs The presentation time of the output buffer, in microseconds.
* @param releaseTimeNs The wallclock time at which the frame should be displayed, in nanoseconds. * @param releaseTimeNs The wallclock time at which the frame should be displayed, in nanoseconds.
*/ */
@TargetApi(21) @RequiresApi(21)
protected void renderOutputBufferV21( protected void renderOutputBufferV21(
MediaCodec codec, int index, long presentationTimeUs, long releaseTimeNs) { MediaCodec codec, int index, long presentationTimeUs, long releaseTimeNs) {
maybeNotifyVideoSizeChanged(); maybeNotifyVideoSizeChanged();
@ -1281,19 +1281,19 @@ public class MediaCodecVideoRenderer extends MediaCodecRenderer {
return earlyUs < -500000; return earlyUs < -500000;
} }
@TargetApi(29) @RequiresApi(29)
private static void setHdr10PlusInfoV29(MediaCodec codec, byte[] hdr10PlusInfo) { private static void setHdr10PlusInfoV29(MediaCodec codec, byte[] hdr10PlusInfo) {
Bundle codecParameters = new Bundle(); Bundle codecParameters = new Bundle();
codecParameters.putByteArray(MediaCodec.PARAMETER_KEY_HDR10_PLUS_INFO, hdr10PlusInfo); codecParameters.putByteArray(MediaCodec.PARAMETER_KEY_HDR10_PLUS_INFO, hdr10PlusInfo);
codec.setParameters(codecParameters); codec.setParameters(codecParameters);
} }
@TargetApi(23) @RequiresApi(23)
private static void setOutputSurfaceV23(MediaCodec codec, Surface surface) { private static void setOutputSurfaceV23(MediaCodec codec, Surface surface) {
codec.setOutputSurface(surface); codec.setOutputSurface(surface);
} }
@TargetApi(21) @RequiresApi(21)
private static void configureTunnelingV21(MediaFormat mediaFormat, int tunnelingAudioSessionId) { private static void configureTunnelingV21(MediaFormat mediaFormat, int tunnelingAudioSessionId) {
mediaFormat.setFeatureEnabled(CodecCapabilities.FEATURE_TunneledPlayback, true); mediaFormat.setFeatureEnabled(CodecCapabilities.FEATURE_TunneledPlayback, true);
mediaFormat.setInteger(MediaFormat.KEY_AUDIO_SESSION_ID, tunnelingAudioSessionId); mediaFormat.setInteger(MediaFormat.KEY_AUDIO_SESSION_ID, tunnelingAudioSessionId);
@ -1797,7 +1797,7 @@ public class MediaCodecVideoRenderer extends MediaCodecRenderer {
} }
@TargetApi(23) @RequiresApi(23)
private final class OnFrameRenderedListenerV23 private final class OnFrameRenderedListenerV23
implements MediaCodec.OnFrameRenderedListener, Handler.Callback { implements MediaCodec.OnFrameRenderedListener, Handler.Callback {

View File

@ -15,7 +15,6 @@
*/ */
package com.google.android.exoplayer2.video; package com.google.android.exoplayer2.video;
import android.annotation.TargetApi;
import android.content.Context; import android.content.Context;
import android.hardware.display.DisplayManager; import android.hardware.display.DisplayManager;
import android.os.Handler; import android.os.Handler;
@ -26,6 +25,7 @@ import android.view.Choreographer.FrameCallback;
import android.view.Display; import android.view.Display;
import android.view.WindowManager; import android.view.WindowManager;
import androidx.annotation.Nullable; import androidx.annotation.Nullable;
import androidx.annotation.RequiresApi;
import com.google.android.exoplayer2.C; import com.google.android.exoplayer2.C;
import com.google.android.exoplayer2.util.Util; import com.google.android.exoplayer2.util.Util;
@ -187,7 +187,7 @@ public final class VideoFrameReleaseTimeHelper {
return snappedTimeNs - vsyncOffsetNs; return snappedTimeNs - vsyncOffsetNs;
} }
@TargetApi(17) @RequiresApi(17)
private DefaultDisplayListener maybeBuildDefaultDisplayListenerV17(Context context) { private DefaultDisplayListener maybeBuildDefaultDisplayListenerV17(Context context) {
DisplayManager manager = (DisplayManager) context.getSystemService(Context.DISPLAY_SERVICE); DisplayManager manager = (DisplayManager) context.getSystemService(Context.DISPLAY_SERVICE);
return manager == null ? null : new DefaultDisplayListener(manager); return manager == null ? null : new DefaultDisplayListener(manager);
@ -226,7 +226,7 @@ public final class VideoFrameReleaseTimeHelper {
return snappedAfterDiff < snappedBeforeDiff ? snappedAfterNs : snappedBeforeNs; return snappedAfterDiff < snappedBeforeDiff ? snappedAfterNs : snappedBeforeNs;
} }
@TargetApi(17) @RequiresApi(17)
private final class DefaultDisplayListener implements DisplayManager.DisplayListener { private final class DefaultDisplayListener implements DisplayManager.DisplayListener {
private final DisplayManager displayManager; private final DisplayManager displayManager;

View File

@ -16,7 +16,6 @@
package com.google.android.exoplayer2.ui; package com.google.android.exoplayer2.ui;
import android.annotation.SuppressLint; import android.annotation.SuppressLint;
import android.annotation.TargetApi;
import android.content.Context; import android.content.Context;
import android.content.res.Resources; import android.content.res.Resources;
import android.content.res.TypedArray; import android.content.res.TypedArray;
@ -40,6 +39,7 @@ import android.widget.ImageView;
import android.widget.TextView; import android.widget.TextView;
import androidx.annotation.IntDef; import androidx.annotation.IntDef;
import androidx.annotation.Nullable; import androidx.annotation.Nullable;
import androidx.annotation.RequiresApi;
import androidx.core.content.ContextCompat; import androidx.core.content.ContextCompat;
import com.google.android.exoplayer2.C; import com.google.android.exoplayer2.C;
import com.google.android.exoplayer2.ControlDispatcher; import com.google.android.exoplayer2.ControlDispatcher;
@ -1419,7 +1419,7 @@ public class PlayerView extends FrameLayout implements AdsLoader.AdViewProvider
} }
} }
@TargetApi(23) @RequiresApi(23)
private static void configureEditModeLogoV23(Resources resources, ImageView logo) { private static void configureEditModeLogoV23(Resources resources, ImageView logo) {
logo.setImageDrawable(resources.getDrawable(R.drawable.exo_edit_mode_logo, null)); logo.setImageDrawable(resources.getDrawable(R.drawable.exo_edit_mode_logo, null));
logo.setBackgroundColor(resources.getColor(R.color.exo_edit_mode_background_color, null)); logo.setBackgroundColor(resources.getColor(R.color.exo_edit_mode_background_color, null));

View File

@ -18,7 +18,6 @@ package com.google.android.exoplayer2.ui;
import static java.lang.annotation.RetentionPolicy.SOURCE; import static java.lang.annotation.RetentionPolicy.SOURCE;
import android.annotation.TargetApi;
import android.content.Context; import android.content.Context;
import android.content.res.Resources; import android.content.res.Resources;
import android.util.AttributeSet; import android.util.AttributeSet;
@ -29,6 +28,7 @@ import android.view.accessibility.CaptioningManager;
import androidx.annotation.Dimension; import androidx.annotation.Dimension;
import androidx.annotation.IntDef; import androidx.annotation.IntDef;
import androidx.annotation.Nullable; import androidx.annotation.Nullable;
import androidx.annotation.RequiresApi;
import com.google.android.exoplayer2.text.CaptionStyleCompat; import com.google.android.exoplayer2.text.CaptionStyleCompat;
import com.google.android.exoplayer2.text.Cue; import com.google.android.exoplayer2.text.Cue;
import com.google.android.exoplayer2.text.TextOutput; import com.google.android.exoplayer2.text.TextOutput;
@ -266,21 +266,21 @@ public final class SubtitleView extends ViewGroup implements TextOutput {
output.setBottomPaddingFraction(bottomPaddingFraction); output.setBottomPaddingFraction(bottomPaddingFraction);
} }
@TargetApi(19) @RequiresApi(19)
private boolean isCaptionManagerEnabled() { private boolean isCaptionManagerEnabled() {
CaptioningManager captioningManager = CaptioningManager captioningManager =
(CaptioningManager) getContext().getSystemService(Context.CAPTIONING_SERVICE); (CaptioningManager) getContext().getSystemService(Context.CAPTIONING_SERVICE);
return captioningManager.isEnabled(); return captioningManager.isEnabled();
} }
@TargetApi(19) @RequiresApi(19)
private float getUserCaptionFontScaleV19() { private float getUserCaptionFontScaleV19() {
CaptioningManager captioningManager = CaptioningManager captioningManager =
(CaptioningManager) getContext().getSystemService(Context.CAPTIONING_SERVICE); (CaptioningManager) getContext().getSystemService(Context.CAPTIONING_SERVICE);
return captioningManager.getFontScale(); return captioningManager.getFontScale();
} }
@TargetApi(19) @RequiresApi(19)
private CaptionStyleCompat getUserCaptionStyleV19() { private CaptionStyleCompat getUserCaptionStyleV19() {
CaptioningManager captioningManager = CaptioningManager captioningManager =
(CaptioningManager) getContext().getSystemService(Context.CAPTIONING_SERVICE); (CaptioningManager) getContext().getSystemService(Context.CAPTIONING_SERVICE);

View File

@ -17,11 +17,11 @@ package com.google.android.exoplayer2.playbacktests.gts;
import static com.google.android.exoplayer2.C.WIDEVINE_UUID; import static com.google.android.exoplayer2.C.WIDEVINE_UUID;
import android.annotation.TargetApi;
import android.media.MediaDrm; import android.media.MediaDrm;
import android.media.UnsupportedSchemeException; import android.media.UnsupportedSchemeException;
import android.net.Uri; import android.net.Uri;
import android.view.Surface; import android.view.Surface;
import androidx.annotation.RequiresApi;
import com.google.android.exoplayer2.C; import com.google.android.exoplayer2.C;
import com.google.android.exoplayer2.Format; import com.google.android.exoplayer2.Format;
import com.google.android.exoplayer2.RendererCapabilities; import com.google.android.exoplayer2.RendererCapabilities;
@ -458,10 +458,10 @@ import java.util.List;
} }
/** /**
* Creates a new {@code MediaDrm} object. The encapsulation ensures that the tests can be * Creates a new {@code MediaDrm} object. The encapsulation ensures that the tests can be executed
* executed for API level < 18. * for API level < 18.
*/ */
@TargetApi(18) @RequiresApi(18)
private static final class MediaDrmBuilder { private static final class MediaDrmBuilder {
public static MediaDrm build () { public static MediaDrm build () {

View File

@ -15,12 +15,12 @@
*/ */
package com.google.android.exoplayer2.playbacktests.gts; package com.google.android.exoplayer2.playbacktests.gts;
import android.annotation.TargetApi;
import android.content.Context; import android.content.Context;
import android.media.MediaCodec; import android.media.MediaCodec;
import android.media.MediaCrypto; import android.media.MediaCrypto;
import android.os.Handler; import android.os.Handler;
import androidx.annotation.Nullable; import androidx.annotation.Nullable;
import androidx.annotation.RequiresApi;
import com.google.android.exoplayer2.DefaultRenderersFactory; import com.google.android.exoplayer2.DefaultRenderersFactory;
import com.google.android.exoplayer2.ExoPlaybackException; import com.google.android.exoplayer2.ExoPlaybackException;
import com.google.android.exoplayer2.Format; import com.google.android.exoplayer2.Format;
@ -189,10 +189,10 @@ import java.util.ArrayList;
super.renderOutputBuffer(codec, index, presentationTimeUs); super.renderOutputBuffer(codec, index, presentationTimeUs);
} }
@TargetApi(21) @RequiresApi(21)
@Override @Override
protected void renderOutputBufferV21(MediaCodec codec, int index, long presentationTimeUs, protected void renderOutputBufferV21(
long releaseTimeNs) { MediaCodec codec, int index, long presentationTimeUs, long releaseTimeNs) {
skipToPositionBeforeRenderingFirstFrame = false; skipToPositionBeforeRenderingFirstFrame = false;
super.renderOutputBufferV21(codec, index, presentationTimeUs, releaseTimeNs); super.renderOutputBufferV21(codec, index, presentationTimeUs, releaseTimeNs);
} }