Commit 3f4cde18 by ibaker Committed by tonihei

Add TYPE_USE to IntDefs used in the media3 stable API

This allows the use of the intdef in parameterized types,
e.g. List<@MyIntDef Integer>

For IntDefs that are already released in ExoPlayer 2.15.1 we add
TYPE_USE in addition to all other reasonable targets, to maintain
backwards compatibility with Kotlin code (where an incorrectly
positioned annotation is a compilation failure). 'reasonable targets'
includes FIELD, METHOD, PARAMETER and LOCAL_VARIABLE but not TYPE,
CONSTRUCTOR, ANNOTATION_TYPE, PACKAGE or MODULE. TYPE_PARAMETER is
implied by TYPE_USE.

For not-yet-released IntDefs we just add TYPE_USE.

#minor-release

PiperOrigin-RevId: 406793413
parent f0be0931
...@@ -15,6 +15,12 @@ ...@@ -15,6 +15,12 @@
*/ */
package com.google.android.exoplayer2; package com.google.android.exoplayer2;
import static java.lang.annotation.ElementType.FIELD;
import static java.lang.annotation.ElementType.LOCAL_VARIABLE;
import static java.lang.annotation.ElementType.METHOD;
import static java.lang.annotation.ElementType.PARAMETER;
import static java.lang.annotation.ElementType.TYPE_USE;
import android.content.Context; import android.content.Context;
import android.media.AudioAttributes; import android.media.AudioAttributes;
import android.media.AudioFormat; import android.media.AudioFormat;
...@@ -29,7 +35,6 @@ import com.google.android.exoplayer2.util.MimeTypes; ...@@ -29,7 +35,6 @@ import com.google.android.exoplayer2.util.MimeTypes;
import com.google.android.exoplayer2.util.Util; import com.google.android.exoplayer2.util.Util;
import com.google.errorprone.annotations.InlineMe; import com.google.errorprone.annotations.InlineMe;
import java.lang.annotation.Documented; import java.lang.annotation.Documented;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention; import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy; import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target; import java.lang.annotation.Target;
...@@ -126,6 +131,7 @@ public final class C { ...@@ -126,6 +131,7 @@ public final class C {
*/ */
@Documented @Documented
@Retention(RetentionPolicy.SOURCE) @Retention(RetentionPolicy.SOURCE)
@Target(TYPE_USE)
@IntDef( @IntDef(
open = true, open = true,
value = { value = {
...@@ -306,6 +312,7 @@ public final class C { ...@@ -306,6 +312,7 @@ public final class C {
*/ */
@Documented @Documented
@Retention(RetentionPolicy.SOURCE) @Retention(RetentionPolicy.SOURCE)
@Target({FIELD, METHOD, PARAMETER, LOCAL_VARIABLE, TYPE_USE})
@IntDef({ @IntDef({
CONTENT_TYPE_MOVIE, CONTENT_TYPE_MOVIE,
CONTENT_TYPE_MUSIC, CONTENT_TYPE_MUSIC,
...@@ -334,6 +341,7 @@ public final class C { ...@@ -334,6 +341,7 @@ public final class C {
*/ */
@Documented @Documented
@Retention(RetentionPolicy.SOURCE) @Retention(RetentionPolicy.SOURCE)
@Target({FIELD, METHOD, PARAMETER, LOCAL_VARIABLE, TYPE_USE})
@IntDef( @IntDef(
flag = true, flag = true,
value = {FLAG_AUDIBILITY_ENFORCED}) value = {FLAG_AUDIBILITY_ENFORCED})
...@@ -354,6 +362,7 @@ public final class C { ...@@ -354,6 +362,7 @@ public final class C {
*/ */
@Documented @Documented
@Retention(RetentionPolicy.SOURCE) @Retention(RetentionPolicy.SOURCE)
@Target({FIELD, METHOD, PARAMETER, LOCAL_VARIABLE, TYPE_USE})
@IntDef({ @IntDef({
USAGE_ALARM, USAGE_ALARM,
USAGE_ASSISTANCE_ACCESSIBILITY, USAGE_ASSISTANCE_ACCESSIBILITY,
...@@ -422,6 +431,7 @@ public final class C { ...@@ -422,6 +431,7 @@ public final class C {
*/ */
@Documented @Documented
@Retention(RetentionPolicy.SOURCE) @Retention(RetentionPolicy.SOURCE)
@Target({FIELD, METHOD, PARAMETER, LOCAL_VARIABLE, TYPE_USE})
@IntDef({ALLOW_CAPTURE_BY_ALL, ALLOW_CAPTURE_BY_NONE, ALLOW_CAPTURE_BY_SYSTEM}) @IntDef({ALLOW_CAPTURE_BY_ALL, ALLOW_CAPTURE_BY_NONE, ALLOW_CAPTURE_BY_SYSTEM})
public @interface AudioAllowedCapturePolicy {} public @interface AudioAllowedCapturePolicy {}
/** See {@link android.media.AudioAttributes#ALLOW_CAPTURE_BY_ALL}. */ /** See {@link android.media.AudioAttributes#ALLOW_CAPTURE_BY_ALL}. */
...@@ -565,6 +575,7 @@ public final class C { ...@@ -565,6 +575,7 @@ public final class C {
*/ */
@Documented @Documented
@Retention(RetentionPolicy.SOURCE) @Retention(RetentionPolicy.SOURCE)
@Target({FIELD, METHOD, PARAMETER, LOCAL_VARIABLE, TYPE_USE})
@IntDef( @IntDef(
flag = true, flag = true,
value = {SELECTION_FLAG_DEFAULT, SELECTION_FLAG_FORCED, SELECTION_FLAG_AUTOSELECT}) value = {SELECTION_FLAG_DEFAULT, SELECTION_FLAG_FORCED, SELECTION_FLAG_AUTOSELECT})
...@@ -680,7 +691,7 @@ public final class C { ...@@ -680,7 +691,7 @@ public final class C {
*/ */
@Documented @Documented
@Retention(RetentionPolicy.SOURCE) @Retention(RetentionPolicy.SOURCE)
@Target({ElementType.TYPE_USE}) @Target(TYPE_USE)
@IntDef( @IntDef(
open = true, open = true,
value = { value = {
...@@ -976,6 +987,7 @@ public final class C { ...@@ -976,6 +987,7 @@ public final class C {
*/ */
@Documented @Documented
@Retention(RetentionPolicy.SOURCE) @Retention(RetentionPolicy.SOURCE)
@Target({FIELD, METHOD, PARAMETER, LOCAL_VARIABLE, TYPE_USE})
@IntDef({WAKE_MODE_NONE, WAKE_MODE_LOCAL, WAKE_MODE_NETWORK}) @IntDef({WAKE_MODE_NONE, WAKE_MODE_LOCAL, WAKE_MODE_NETWORK})
public @interface WakeMode {} public @interface WakeMode {}
/** /**
...@@ -1012,6 +1024,7 @@ public final class C { ...@@ -1012,6 +1024,7 @@ public final class C {
*/ */
@Documented @Documented
@Retention(RetentionPolicy.SOURCE) @Retention(RetentionPolicy.SOURCE)
@Target({FIELD, METHOD, PARAMETER, LOCAL_VARIABLE, TYPE_USE})
@IntDef( @IntDef(
flag = true, flag = true,
value = { value = {
......
...@@ -15,6 +15,12 @@ ...@@ -15,6 +15,12 @@
*/ */
package com.google.android.exoplayer2; package com.google.android.exoplayer2;
import static java.lang.annotation.ElementType.FIELD;
import static java.lang.annotation.ElementType.LOCAL_VARIABLE;
import static java.lang.annotation.ElementType.METHOD;
import static java.lang.annotation.ElementType.PARAMETER;
import static java.lang.annotation.ElementType.TYPE_USE;
import android.net.Uri; import android.net.Uri;
import android.os.Bundle; import android.os.Bundle;
import androidx.annotation.IntDef; import androidx.annotation.IntDef;
...@@ -26,6 +32,7 @@ import com.google.common.base.Objects; ...@@ -26,6 +32,7 @@ import com.google.common.base.Objects;
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;
import java.lang.annotation.Target;
import java.util.Arrays; import java.util.Arrays;
import java.util.List; import java.util.List;
...@@ -500,6 +507,7 @@ public final class MediaMetadata implements Bundleable { ...@@ -500,6 +507,7 @@ public final class MediaMetadata implements Bundleable {
*/ */
@Documented @Documented
@Retention(RetentionPolicy.SOURCE) @Retention(RetentionPolicy.SOURCE)
@Target({FIELD, METHOD, PARAMETER, LOCAL_VARIABLE, TYPE_USE})
@IntDef({ @IntDef({
FOLDER_TYPE_NONE, FOLDER_TYPE_NONE,
FOLDER_TYPE_MIXED, FOLDER_TYPE_MIXED,
...@@ -537,6 +545,7 @@ public final class MediaMetadata implements Bundleable { ...@@ -537,6 +545,7 @@ public final class MediaMetadata implements Bundleable {
*/ */
@Documented @Documented
@Retention(RetentionPolicy.SOURCE) @Retention(RetentionPolicy.SOURCE)
@Target({FIELD, METHOD, PARAMETER, LOCAL_VARIABLE, TYPE_USE})
@IntDef({ @IntDef({
PICTURE_TYPE_OTHER, PICTURE_TYPE_OTHER,
PICTURE_TYPE_FILE_ICON, PICTURE_TYPE_FILE_ICON,
......
...@@ -15,6 +15,12 @@ ...@@ -15,6 +15,12 @@
*/ */
package com.google.android.exoplayer2; package com.google.android.exoplayer2;
import static java.lang.annotation.ElementType.FIELD;
import static java.lang.annotation.ElementType.LOCAL_VARIABLE;
import static java.lang.annotation.ElementType.METHOD;
import static java.lang.annotation.ElementType.PARAMETER;
import static java.lang.annotation.ElementType.TYPE_USE;
import android.net.ConnectivityManager; import android.net.ConnectivityManager;
import android.os.Bundle; import android.os.Bundle;
import android.os.RemoteException; import android.os.RemoteException;
...@@ -28,6 +34,7 @@ import com.google.android.exoplayer2.util.Util; ...@@ -28,6 +34,7 @@ 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;
import java.lang.annotation.RetentionPolicy; import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
/** Thrown when a non locally recoverable playback failure occurs. */ /** Thrown when a non locally recoverable playback failure occurs. */
public class PlaybackException extends Exception implements Bundleable { public class PlaybackException extends Exception implements Bundleable {
...@@ -40,6 +47,7 @@ public class PlaybackException extends Exception implements Bundleable { ...@@ -40,6 +47,7 @@ public class PlaybackException extends Exception implements Bundleable {
*/ */
@Documented @Documented
@Retention(RetentionPolicy.SOURCE) @Retention(RetentionPolicy.SOURCE)
@Target({FIELD, METHOD, PARAMETER, LOCAL_VARIABLE, TYPE_USE})
@IntDef( @IntDef(
open = true, open = true,
value = { value = {
......
...@@ -15,6 +15,12 @@ ...@@ -15,6 +15,12 @@
*/ */
package com.google.android.exoplayer2; package com.google.android.exoplayer2;
import static java.lang.annotation.ElementType.FIELD;
import static java.lang.annotation.ElementType.LOCAL_VARIABLE;
import static java.lang.annotation.ElementType.METHOD;
import static java.lang.annotation.ElementType.PARAMETER;
import static java.lang.annotation.ElementType.TYPE_USE;
import android.os.Bundle; import android.os.Bundle;
import android.os.Looper; import android.os.Looper;
import android.view.Surface; import android.view.Surface;
...@@ -40,6 +46,7 @@ import com.google.common.base.Objects; ...@@ -40,6 +46,7 @@ import com.google.common.base.Objects;
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;
import java.lang.annotation.Target;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
...@@ -1079,6 +1086,7 @@ public interface Player { ...@@ -1079,6 +1086,7 @@ public interface Player {
*/ */
@Documented @Documented
@Retention(RetentionPolicy.SOURCE) @Retention(RetentionPolicy.SOURCE)
@Target({FIELD, METHOD, PARAMETER, LOCAL_VARIABLE, TYPE_USE})
@IntDef({STATE_IDLE, STATE_BUFFERING, STATE_READY, STATE_ENDED}) @IntDef({STATE_IDLE, STATE_BUFFERING, STATE_READY, STATE_ENDED})
@interface State {} @interface State {}
/** The player is idle, and must be {@link #prepare() prepared} before it will play the media. */ /** The player is idle, and must be {@link #prepare() prepared} before it will play the media. */
...@@ -1107,6 +1115,7 @@ public interface Player { ...@@ -1107,6 +1115,7 @@ public interface Player {
*/ */
@Documented @Documented
@Retention(RetentionPolicy.SOURCE) @Retention(RetentionPolicy.SOURCE)
@Target({FIELD, METHOD, PARAMETER, LOCAL_VARIABLE, TYPE_USE})
@IntDef({ @IntDef({
PLAY_WHEN_READY_CHANGE_REASON_USER_REQUEST, PLAY_WHEN_READY_CHANGE_REASON_USER_REQUEST,
PLAY_WHEN_READY_CHANGE_REASON_AUDIO_FOCUS_LOSS, PLAY_WHEN_READY_CHANGE_REASON_AUDIO_FOCUS_LOSS,
...@@ -1133,6 +1142,7 @@ public interface Player { ...@@ -1133,6 +1142,7 @@ public interface Player {
*/ */
@Documented @Documented
@Retention(RetentionPolicy.SOURCE) @Retention(RetentionPolicy.SOURCE)
@Target({FIELD, METHOD, PARAMETER, LOCAL_VARIABLE, TYPE_USE})
@IntDef({ @IntDef({
PLAYBACK_SUPPRESSION_REASON_NONE, PLAYBACK_SUPPRESSION_REASON_NONE,
PLAYBACK_SUPPRESSION_REASON_TRANSIENT_AUDIO_FOCUS_LOSS PLAYBACK_SUPPRESSION_REASON_TRANSIENT_AUDIO_FOCUS_LOSS
...@@ -1149,6 +1159,7 @@ public interface Player { ...@@ -1149,6 +1159,7 @@ public interface Player {
*/ */
@Documented @Documented
@Retention(RetentionPolicy.SOURCE) @Retention(RetentionPolicy.SOURCE)
@Target({FIELD, METHOD, PARAMETER, LOCAL_VARIABLE, TYPE_USE})
@IntDef({REPEAT_MODE_OFF, REPEAT_MODE_ONE, REPEAT_MODE_ALL}) @IntDef({REPEAT_MODE_OFF, REPEAT_MODE_ONE, REPEAT_MODE_ALL})
@interface RepeatMode {} @interface RepeatMode {}
/** /**
...@@ -1180,6 +1191,7 @@ public interface Player { ...@@ -1180,6 +1191,7 @@ public interface Player {
*/ */
@Documented @Documented
@Retention(RetentionPolicy.SOURCE) @Retention(RetentionPolicy.SOURCE)
@Target({FIELD, METHOD, PARAMETER, LOCAL_VARIABLE, TYPE_USE})
@IntDef({ @IntDef({
DISCONTINUITY_REASON_AUTO_TRANSITION, DISCONTINUITY_REASON_AUTO_TRANSITION,
DISCONTINUITY_REASON_SEEK, DISCONTINUITY_REASON_SEEK,
...@@ -1218,6 +1230,7 @@ public interface Player { ...@@ -1218,6 +1230,7 @@ public interface Player {
*/ */
@Documented @Documented
@Retention(RetentionPolicy.SOURCE) @Retention(RetentionPolicy.SOURCE)
@Target({FIELD, METHOD, PARAMETER, LOCAL_VARIABLE, TYPE_USE})
@IntDef({TIMELINE_CHANGE_REASON_PLAYLIST_CHANGED, TIMELINE_CHANGE_REASON_SOURCE_UPDATE}) @IntDef({TIMELINE_CHANGE_REASON_PLAYLIST_CHANGED, TIMELINE_CHANGE_REASON_SOURCE_UPDATE})
@interface TimelineChangeReason {} @interface TimelineChangeReason {}
/** Timeline changed as a result of a change of the playlist items or the order of the items. */ /** Timeline changed as a result of a change of the playlist items or the order of the items. */
...@@ -1238,6 +1251,7 @@ public interface Player { ...@@ -1238,6 +1251,7 @@ public interface Player {
*/ */
@Documented @Documented
@Retention(RetentionPolicy.SOURCE) @Retention(RetentionPolicy.SOURCE)
@Target({FIELD, METHOD, PARAMETER, LOCAL_VARIABLE, TYPE_USE})
@IntDef({ @IntDef({
MEDIA_ITEM_TRANSITION_REASON_REPEAT, MEDIA_ITEM_TRANSITION_REASON_REPEAT,
MEDIA_ITEM_TRANSITION_REASON_AUTO, MEDIA_ITEM_TRANSITION_REASON_AUTO,
...@@ -1270,6 +1284,7 @@ public interface Player { ...@@ -1270,6 +1284,7 @@ public interface Player {
*/ */
@Documented @Documented
@Retention(RetentionPolicy.SOURCE) @Retention(RetentionPolicy.SOURCE)
@Target({FIELD, METHOD, PARAMETER, LOCAL_VARIABLE, TYPE_USE})
@IntDef({ @IntDef({
EVENT_TIMELINE_CHANGED, EVENT_TIMELINE_CHANGED,
EVENT_MEDIA_ITEM_TRANSITION, EVENT_MEDIA_ITEM_TRANSITION,
...@@ -1355,6 +1370,7 @@ public interface Player { ...@@ -1355,6 +1370,7 @@ public interface Player {
*/ */
@Documented @Documented
@Retention(RetentionPolicy.SOURCE) @Retention(RetentionPolicy.SOURCE)
@Target({FIELD, METHOD, PARAMETER, LOCAL_VARIABLE, TYPE_USE})
@IntDef({ @IntDef({
COMMAND_INVALID, COMMAND_INVALID,
COMMAND_PLAY_PAUSE, COMMAND_PLAY_PAUSE,
......
...@@ -15,6 +15,12 @@ ...@@ -15,6 +15,12 @@
*/ */
package com.google.android.exoplayer2.text; package com.google.android.exoplayer2.text;
import static java.lang.annotation.ElementType.FIELD;
import static java.lang.annotation.ElementType.LOCAL_VARIABLE;
import static java.lang.annotation.ElementType.METHOD;
import static java.lang.annotation.ElementType.PARAMETER;
import static java.lang.annotation.ElementType.TYPE_USE;
import android.graphics.Bitmap; import android.graphics.Bitmap;
import android.graphics.Color; import android.graphics.Color;
import android.os.Bundle; import android.os.Bundle;
...@@ -32,6 +38,7 @@ import com.google.common.base.Objects; ...@@ -32,6 +38,7 @@ import com.google.common.base.Objects;
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;
import java.lang.annotation.Target;
import org.checkerframework.dataflow.qual.Pure; import org.checkerframework.dataflow.qual.Pure;
/** Contains information about a specific cue, including textual content and formatting data. */ /** Contains information about a specific cue, including textual content and formatting data. */
...@@ -53,6 +60,7 @@ public final class Cue implements Bundleable { ...@@ -53,6 +60,7 @@ public final class Cue implements Bundleable {
*/ */
@Documented @Documented
@Retention(RetentionPolicy.SOURCE) @Retention(RetentionPolicy.SOURCE)
@Target({FIELD, METHOD, PARAMETER, LOCAL_VARIABLE, TYPE_USE})
@IntDef({TYPE_UNSET, ANCHOR_TYPE_START, ANCHOR_TYPE_MIDDLE, ANCHOR_TYPE_END}) @IntDef({TYPE_UNSET, ANCHOR_TYPE_START, ANCHOR_TYPE_MIDDLE, ANCHOR_TYPE_END})
public @interface AnchorType {} public @interface AnchorType {}
...@@ -80,6 +88,7 @@ public final class Cue implements Bundleable { ...@@ -80,6 +88,7 @@ public final class Cue implements Bundleable {
*/ */
@Documented @Documented
@Retention(RetentionPolicy.SOURCE) @Retention(RetentionPolicy.SOURCE)
@Target({FIELD, METHOD, PARAMETER, LOCAL_VARIABLE, TYPE_USE})
@IntDef({TYPE_UNSET, LINE_TYPE_FRACTION, LINE_TYPE_NUMBER}) @IntDef({TYPE_UNSET, LINE_TYPE_FRACTION, LINE_TYPE_NUMBER})
public @interface LineType {} public @interface LineType {}
...@@ -96,6 +105,7 @@ public final class Cue implements Bundleable { ...@@ -96,6 +105,7 @@ public final class Cue implements Bundleable {
*/ */
@Documented @Documented
@Retention(RetentionPolicy.SOURCE) @Retention(RetentionPolicy.SOURCE)
@Target({FIELD, METHOD, PARAMETER, LOCAL_VARIABLE, TYPE_USE})
@IntDef({ @IntDef({
TYPE_UNSET, TYPE_UNSET,
TEXT_SIZE_TYPE_FRACTIONAL, TEXT_SIZE_TYPE_FRACTIONAL,
...@@ -119,6 +129,7 @@ public final class Cue implements Bundleable { ...@@ -119,6 +129,7 @@ public final class Cue implements Bundleable {
*/ */
@Documented @Documented
@Retention(RetentionPolicy.SOURCE) @Retention(RetentionPolicy.SOURCE)
@Target({FIELD, METHOD, PARAMETER, LOCAL_VARIABLE, TYPE_USE})
@IntDef({ @IntDef({
TYPE_UNSET, TYPE_UNSET,
VERTICAL_TYPE_RL, VERTICAL_TYPE_RL,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment