Remove unnecessary @RequiresApi
This commit is contained in:
parent
71b8c32a6f
commit
7289764a65
@ -1766,8 +1766,7 @@ public class MediaCodecVideoRenderer extends MediaCodecRenderer
|
||||
}
|
||||
|
||||
/**
|
||||
* Renders the output buffer with the specified index. This method is only called if the platform
|
||||
* API version of the device is 21 or later.
|
||||
* Renders the output buffer with the specified index.
|
||||
*
|
||||
* @param codec The codec that owns the output buffer.
|
||||
* @param index The index of the output buffer to drop.
|
||||
|
@ -111,7 +111,6 @@ public class MediaStyleNotificationHelper {
|
||||
/* package */ final MediaSession session;
|
||||
|
||||
/* package */ int @NullableType [] actionsToShowInCompact;
|
||||
@Nullable /* package */ PendingIntent cancelButtonIntent;
|
||||
/* package */ @MonotonicNonNull CharSequence remoteDeviceName;
|
||||
/* package */ int remoteDeviceIconRes;
|
||||
@Nullable /* package */ PendingIntent remoteDeviceIntent;
|
||||
@ -147,14 +146,11 @@ public class MediaStyleNotificationHelper {
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the pending intent to be sent when the cancel button is pressed. See {@link
|
||||
* #setShowCancelButton}.
|
||||
*
|
||||
* @param pendingIntent the intent to be sent when the cancel button is pressed
|
||||
* @deprecated This method is a no-op and usages can be safely removed. There is no recommended
|
||||
* alternative (it was previously only operational on API ≤ 21).
|
||||
*/
|
||||
@CanIgnoreReturnValue
|
||||
public MediaStyle setCancelButtonIntent(PendingIntent pendingIntent) {
|
||||
cancelButtonIntent = pendingIntent;
|
||||
return this;
|
||||
}
|
||||
|
||||
|
@ -943,7 +943,6 @@ public class AudioAttributesCompat {
|
||||
}
|
||||
}
|
||||
|
||||
@RequiresApi(21)
|
||||
public static class AudioAttributesImplApi21 implements AudioAttributesImpl {
|
||||
|
||||
@Nullable public AudioAttributes mAudioAttributes;
|
||||
@ -1020,7 +1019,6 @@ public class AudioAttributesCompat {
|
||||
return "AudioAttributesCompat: audioattributes=" + mAudioAttributes;
|
||||
}
|
||||
|
||||
@RequiresApi(21)
|
||||
static class Builder implements AudioAttributesImpl.Builder {
|
||||
final AudioAttributes.Builder mFwkBuilder;
|
||||
|
||||
|
@ -56,7 +56,6 @@ import android.content.ComponentName;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.ServiceConnection;
|
||||
import android.media.MediaDescription;
|
||||
import android.media.browse.MediaBrowser;
|
||||
import android.os.BadParcelableException;
|
||||
import android.os.Binder;
|
||||
@ -73,7 +72,6 @@ import android.os.RemoteException;
|
||||
import android.support.v4.os.ResultReceiver;
|
||||
import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
import androidx.annotation.DoNotInline;
|
||||
import androidx.annotation.IntDef;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.annotation.RequiresApi;
|
||||
@ -469,9 +467,9 @@ public final class MediaBrowserCompat {
|
||||
return null;
|
||||
}
|
||||
MediaBrowser.MediaItem itemFwk = (MediaBrowser.MediaItem) itemObj;
|
||||
int flags = Api21Impl.getFlags(itemFwk);
|
||||
int flags = itemFwk.getFlags();
|
||||
MediaDescriptionCompat descriptionCompat =
|
||||
MediaDescriptionCompat.fromMediaDescription(Api21Impl.getDescription(itemFwk));
|
||||
MediaDescriptionCompat.fromMediaDescription(itemFwk.getDescription());
|
||||
return new MediaItem(descriptionCompat, flags);
|
||||
}
|
||||
|
||||
@ -647,7 +645,6 @@ public final class MediaBrowserCompat {
|
||||
void onConnectionFailed();
|
||||
}
|
||||
|
||||
@RequiresApi(21)
|
||||
private class ConnectionCallbackApi21 extends MediaBrowser.ConnectionCallback {
|
||||
ConnectionCallbackApi21() {}
|
||||
|
||||
@ -738,7 +735,6 @@ public final class MediaBrowserCompat {
|
||||
mSubscriptionRef = new WeakReference<>(subscription);
|
||||
}
|
||||
|
||||
@RequiresApi(21)
|
||||
private class SubscriptionCallbackApi21 extends MediaBrowser.SubscriptionCallback {
|
||||
SubscriptionCallbackApi21() {}
|
||||
|
||||
@ -1643,7 +1639,6 @@ public final class MediaBrowserCompat {
|
||||
}
|
||||
}
|
||||
|
||||
@RequiresApi(21)
|
||||
static class MediaBrowserImplApi21
|
||||
implements MediaBrowserImpl,
|
||||
MediaBrowserServiceCallbackImpl,
|
||||
@ -2466,19 +2461,4 @@ public final class MediaBrowserCompat {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@RequiresApi(21)
|
||||
private static class Api21Impl {
|
||||
private Api21Impl() {}
|
||||
|
||||
@DoNotInline
|
||||
static MediaDescription getDescription(MediaBrowser.MediaItem item) {
|
||||
return item.getDescription();
|
||||
}
|
||||
|
||||
@DoNotInline
|
||||
static int getFlags(MediaBrowser.MediaItem item) {
|
||||
return item.getFlags();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -307,7 +307,6 @@ public abstract class MediaBrowserServiceCompat extends Service {
|
||||
}
|
||||
}
|
||||
|
||||
@RequiresApi(21)
|
||||
class MediaBrowserServiceImplApi21 implements MediaBrowserServiceImpl {
|
||||
final List<Bundle> mRootExtrasList = new ArrayList<>();
|
||||
@MonotonicNonNull MediaBrowserService mServiceFwk;
|
||||
@ -520,7 +519,6 @@ public abstract class MediaBrowserServiceCompat extends Service {
|
||||
return mCurConnection.browserInfo;
|
||||
}
|
||||
|
||||
@RequiresApi(21)
|
||||
class MediaBrowserServiceApi21 extends MediaBrowserService {
|
||||
@SuppressWarnings("method.invocation.invalid") // Calling base method from constructor
|
||||
MediaBrowserServiceApi21(Context context) {
|
||||
@ -1268,7 +1266,6 @@ public abstract class MediaBrowserServiceCompat extends Service {
|
||||
}
|
||||
}
|
||||
|
||||
@RequiresApi(21)
|
||||
@SuppressWarnings({"rawtypes", "unchecked"})
|
||||
static class ResultWrapper<T> {
|
||||
MediaBrowserService.Result mResultFwk;
|
||||
|
@ -789,7 +789,6 @@ public final class MediaControllerCompat {
|
||||
}
|
||||
|
||||
// Callback methods in this class are run on handler which was given to registerCallback().
|
||||
@RequiresApi(21)
|
||||
private static class MediaControllerCallbackApi21 extends MediaController.Callback {
|
||||
private final WeakReference<MediaControllerCompat.Callback> mCallback;
|
||||
|
||||
@ -1974,7 +1973,6 @@ public final class MediaControllerCompat {
|
||||
}
|
||||
}
|
||||
|
||||
@RequiresApi(21)
|
||||
static class MediaControllerImplApi21 implements MediaControllerImpl {
|
||||
protected final MediaController mControllerFwk;
|
||||
|
||||
@ -2411,7 +2409,6 @@ public final class MediaControllerCompat {
|
||||
}
|
||||
}
|
||||
|
||||
@RequiresApi(21)
|
||||
static class TransportControlsApi21 extends TransportControls {
|
||||
protected final MediaController.TransportControls mControlsFwk;
|
||||
|
||||
|
@ -316,22 +316,19 @@ public final class MediaDescriptionCompat implements Parcelable {
|
||||
/**
|
||||
* Gets the underlying framework {@link android.media.MediaDescription} object.
|
||||
*
|
||||
* <p>This method is only supported on {@link android.os.Build.VERSION_CODES#LOLLIPOP} and later.
|
||||
*
|
||||
* @return An equivalent {@link android.media.MediaDescription} object, or null if none.
|
||||
*/
|
||||
@RequiresApi(21)
|
||||
public Object getMediaDescription() {
|
||||
if (mDescriptionFwk != null) {
|
||||
return mDescriptionFwk;
|
||||
}
|
||||
MediaDescription.Builder bob = Api21Impl.createBuilder();
|
||||
Api21Impl.setMediaId(bob, mMediaId);
|
||||
Api21Impl.setTitle(bob, mTitle);
|
||||
Api21Impl.setSubtitle(bob, mSubtitle);
|
||||
Api21Impl.setDescription(bob, mDescription);
|
||||
Api21Impl.setIconBitmap(bob, mIcon);
|
||||
Api21Impl.setIconUri(bob, mIconUri);
|
||||
MediaDescription.Builder bob = new MediaDescription.Builder()
|
||||
.setMediaId(mMediaId)
|
||||
.setTitle(mTitle)
|
||||
.setSubtitle(mSubtitle)
|
||||
.setDescription(mDescription)
|
||||
.setIconBitmap(mIcon)
|
||||
.setIconUri(mIconUri);
|
||||
// Media URI was not added until API 23, so add it to the Bundle of extras to
|
||||
// ensure the data is not lost - this ensures that
|
||||
// fromMediaDescription(getMediaDescription(mediaDescriptionCompat)) returns
|
||||
@ -345,14 +342,14 @@ public final class MediaDescriptionCompat implements Parcelable {
|
||||
extras = new Bundle(mExtras);
|
||||
}
|
||||
extras.putParcelable(DESCRIPTION_KEY_MEDIA_URI, mMediaUri);
|
||||
Api21Impl.setExtras(bob, extras);
|
||||
bob.setExtras(extras);
|
||||
} else {
|
||||
Api21Impl.setExtras(bob, mExtras);
|
||||
bob.setExtras(mExtras);
|
||||
}
|
||||
if (Build.VERSION.SDK_INT >= 23) {
|
||||
Api23Impl.setMediaUri(bob, mMediaUri);
|
||||
}
|
||||
mDescriptionFwk = Api21Impl.build(bob);
|
||||
mDescriptionFwk = bob.build();
|
||||
|
||||
return mDescriptionFwk;
|
||||
}
|
||||
@ -371,13 +368,13 @@ public final class MediaDescriptionCompat implements Parcelable {
|
||||
if (descriptionObj != null && Build.VERSION.SDK_INT >= 21) {
|
||||
Builder bob = new Builder();
|
||||
MediaDescription description = (MediaDescription) descriptionObj;
|
||||
bob.setMediaId(Api21Impl.getMediaId(description));
|
||||
bob.setTitle(Api21Impl.getTitle(description));
|
||||
bob.setSubtitle(Api21Impl.getSubtitle(description));
|
||||
bob.setDescription(Api21Impl.getDescription(description));
|
||||
bob.setIconBitmap(Api21Impl.getIconBitmap(description));
|
||||
bob.setIconUri(Api21Impl.getIconUri(description));
|
||||
Bundle extras = Api21Impl.getExtras(description);
|
||||
bob.setMediaId(description.getMediaId());
|
||||
bob.setTitle(description.getTitle());
|
||||
bob.setSubtitle(description.getSubtitle());
|
||||
bob.setDescription(description.getDescription());
|
||||
bob.setIconBitmap(description.getIconBitmap());
|
||||
bob.setIconUri(description.getIconUri());
|
||||
Bundle extras = description.getExtras();
|
||||
extras = MediaSessionCompat.unparcelWithClassLoader(extras);
|
||||
if (extras != null) {
|
||||
extras = new Bundle(extras);
|
||||
@ -546,99 +543,6 @@ public final class MediaDescriptionCompat implements Parcelable {
|
||||
}
|
||||
}
|
||||
|
||||
@RequiresApi(21)
|
||||
private static class Api21Impl {
|
||||
private Api21Impl() {}
|
||||
|
||||
@DoNotInline
|
||||
static MediaDescription.Builder createBuilder() {
|
||||
return new MediaDescription.Builder();
|
||||
}
|
||||
|
||||
@DoNotInline
|
||||
static void setMediaId(MediaDescription.Builder builder, @Nullable String mediaId) {
|
||||
builder.setMediaId(mediaId);
|
||||
}
|
||||
|
||||
@DoNotInline
|
||||
static void setTitle(MediaDescription.Builder builder, @Nullable CharSequence title) {
|
||||
builder.setTitle(title);
|
||||
}
|
||||
|
||||
@DoNotInline
|
||||
static void setSubtitle(MediaDescription.Builder builder, @Nullable CharSequence subtitle) {
|
||||
builder.setSubtitle(subtitle);
|
||||
}
|
||||
|
||||
@DoNotInline
|
||||
static void setDescription(
|
||||
MediaDescription.Builder builder, @Nullable CharSequence description) {
|
||||
builder.setDescription(description);
|
||||
}
|
||||
|
||||
@DoNotInline
|
||||
static void setIconBitmap(MediaDescription.Builder builder, @Nullable Bitmap icon) {
|
||||
builder.setIconBitmap(icon);
|
||||
}
|
||||
|
||||
@DoNotInline
|
||||
static void setIconUri(MediaDescription.Builder builder, @Nullable Uri iconUri) {
|
||||
builder.setIconUri(iconUri);
|
||||
}
|
||||
|
||||
@DoNotInline
|
||||
static void setExtras(MediaDescription.Builder builder, @Nullable Bundle extras) {
|
||||
builder.setExtras(extras);
|
||||
}
|
||||
|
||||
@DoNotInline
|
||||
static MediaDescription build(MediaDescription.Builder builder) {
|
||||
return builder.build();
|
||||
}
|
||||
|
||||
@DoNotInline
|
||||
@Nullable
|
||||
static String getMediaId(MediaDescription description) {
|
||||
return description.getMediaId();
|
||||
}
|
||||
|
||||
@DoNotInline
|
||||
@Nullable
|
||||
static CharSequence getTitle(MediaDescription description) {
|
||||
return description.getTitle();
|
||||
}
|
||||
|
||||
@DoNotInline
|
||||
@Nullable
|
||||
static CharSequence getSubtitle(MediaDescription description) {
|
||||
return description.getSubtitle();
|
||||
}
|
||||
|
||||
@DoNotInline
|
||||
@Nullable
|
||||
static CharSequence getDescription(MediaDescription description) {
|
||||
return description.getDescription();
|
||||
}
|
||||
|
||||
@DoNotInline
|
||||
@Nullable
|
||||
static Bitmap getIconBitmap(MediaDescription description) {
|
||||
return description.getIconBitmap();
|
||||
}
|
||||
|
||||
@DoNotInline
|
||||
@Nullable
|
||||
static Uri getIconUri(MediaDescription description) {
|
||||
return description.getIconUri();
|
||||
}
|
||||
|
||||
@DoNotInline
|
||||
@Nullable
|
||||
static Bundle getExtras(MediaDescription description) {
|
||||
return description.getExtras();
|
||||
}
|
||||
}
|
||||
|
||||
@RequiresApi(23)
|
||||
private static class Api23Impl {
|
||||
private Api23Impl() {}
|
||||
|
@ -29,7 +29,6 @@ import android.os.Parcelable;
|
||||
import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.annotation.RequiresApi;
|
||||
import androidx.annotation.RestrictTo;
|
||||
import androidx.annotation.StringDef;
|
||||
import androidx.collection.ArrayMap;
|
||||
@ -580,11 +579,8 @@ public final class MediaMetadataCompat implements Parcelable {
|
||||
/**
|
||||
* Gets the underlying framework {@link android.media.MediaMetadata} object.
|
||||
*
|
||||
* <p>This method is only supported on {@link android.os.Build.VERSION_CODES#LOLLIPOP} and later.
|
||||
*
|
||||
* @return An equivalent {@link android.media.MediaMetadata} object, or null if none.
|
||||
*/
|
||||
@RequiresApi(21)
|
||||
public Object getMediaMetadata() {
|
||||
if (mMetadataFwk == null) {
|
||||
Parcel p = Parcel.obtain();
|
||||
|
@ -61,7 +61,6 @@ import android.util.Log;
|
||||
import android.util.TypedValue;
|
||||
import android.view.KeyEvent;
|
||||
import android.view.ViewConfiguration;
|
||||
import androidx.annotation.DoNotInline;
|
||||
import androidx.annotation.GuardedBy;
|
||||
import androidx.annotation.IntDef;
|
||||
import androidx.annotation.Nullable;
|
||||
@ -1353,7 +1352,6 @@ public class MediaSessionCompat {
|
||||
}
|
||||
}
|
||||
|
||||
@RequiresApi(21)
|
||||
private class MediaSessionCallbackApi21 extends MediaSession.Callback {
|
||||
MediaSessionCallbackApi21() {}
|
||||
|
||||
@ -1817,13 +1815,9 @@ public class MediaSessionCompat {
|
||||
* Creates a compat Token from a framework {@link android.media.session.MediaSession.Token}
|
||||
* object.
|
||||
*
|
||||
* <p>This method is only supported on {@link android.os.Build.VERSION_CODES#LOLLIPOP} and
|
||||
* later.
|
||||
*
|
||||
* @param token The framework token object.
|
||||
* @return A compat Token for use with {@link MediaControllerCompat}.
|
||||
*/
|
||||
@RequiresApi(21)
|
||||
public static Token fromToken(Object token) {
|
||||
return fromToken(token, null);
|
||||
}
|
||||
@ -1832,14 +1826,10 @@ public class MediaSessionCompat {
|
||||
* Creates a compat Token from a framework {@link android.media.session.MediaSession.Token}
|
||||
* object, and the extra binder.
|
||||
*
|
||||
* <p>This method is only supported on {@link android.os.Build.VERSION_CODES#LOLLIPOP} and
|
||||
* later.
|
||||
*
|
||||
* @param token The framework token object.
|
||||
* @param extraBinder The extra binder.
|
||||
* @return A compat Token for use with {@link MediaControllerCompat}.
|
||||
*/
|
||||
@RequiresApi(21)
|
||||
/* package */ static Token fromToken(Object token, @Nullable IMediaSession extraBinder) {
|
||||
checkState(token != null);
|
||||
if (!(token instanceof MediaSession.Token)) {
|
||||
@ -2068,7 +2058,7 @@ public class MediaSessionCompat {
|
||||
return mItemFwk;
|
||||
}
|
||||
mItemFwk =
|
||||
Api21Impl.createQueueItem((MediaDescription) mDescription.getMediaDescription(), mId);
|
||||
new MediaSession.QueueItem((MediaDescription) mDescription.getMediaDescription(), mId);
|
||||
return mItemFwk;
|
||||
}
|
||||
|
||||
@ -2076,18 +2066,15 @@ public class MediaSessionCompat {
|
||||
* Creates an instance from a framework {@link android.media.session.MediaSession.QueueItem}
|
||||
* object.
|
||||
*
|
||||
* <p>This method is only supported on API 21+.
|
||||
*
|
||||
* @param queueItem A {@link android.media.session.MediaSession.QueueItem} object.
|
||||
* @return An equivalent {@link QueueItem} object.
|
||||
*/
|
||||
@RequiresApi(21)
|
||||
public static QueueItem fromQueueItem(Object queueItem) {
|
||||
MediaSession.QueueItem queueItemObj = (MediaSession.QueueItem) queueItem;
|
||||
Object descriptionObj = Api21Impl.getDescription(queueItemObj);
|
||||
Object descriptionObj = queueItemObj.getDescription();
|
||||
MediaDescriptionCompat description =
|
||||
MediaDescriptionCompat.fromMediaDescription(descriptionObj);
|
||||
long id = Api21Impl.getQueueId(queueItemObj);
|
||||
long id = queueItemObj.getQueueId();
|
||||
return new QueueItem(queueItemObj, description, id);
|
||||
}
|
||||
|
||||
@ -2131,26 +2118,6 @@ public class MediaSessionCompat {
|
||||
public String toString() {
|
||||
return "MediaSession.QueueItem {" + "Description=" + mDescription + ", Id=" + mId + " }";
|
||||
}
|
||||
|
||||
@RequiresApi(21)
|
||||
private static class Api21Impl {
|
||||
private Api21Impl() {}
|
||||
|
||||
@DoNotInline
|
||||
static MediaSession.QueueItem createQueueItem(MediaDescription description, long id) {
|
||||
return new MediaSession.QueueItem(description, id);
|
||||
}
|
||||
|
||||
@DoNotInline
|
||||
static MediaDescription getDescription(MediaSession.QueueItem queueItem) {
|
||||
return queueItem.getDescription();
|
||||
}
|
||||
|
||||
@DoNotInline
|
||||
static long getQueueId(MediaSession.QueueItem queueItem) {
|
||||
return queueItem.getQueueId();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@ -3851,7 +3818,6 @@ public class MediaSessionCompat {
|
||||
}
|
||||
}
|
||||
|
||||
@RequiresApi(21)
|
||||
static class MediaSessionImplApi21 implements MediaSessionImpl {
|
||||
final MediaSession mSessionFwk;
|
||||
final ExtraSession mExtraSession;
|
||||
|
@ -373,7 +373,6 @@ public final class MediaSessionManager {
|
||||
}
|
||||
}
|
||||
|
||||
@RequiresApi(21)
|
||||
private static class MediaSessionManagerImplApi21 extends MediaSessionManagerImplBase {
|
||||
MediaSessionManagerImplApi21(Context context) {
|
||||
super(context);
|
||||
|
@ -849,7 +849,7 @@ public final class PlaybackStateCompat implements Parcelable {
|
||||
public static PlaybackStateCompat fromPlaybackState(@Nullable Object stateObj) {
|
||||
if (stateObj != null && Build.VERSION.SDK_INT >= 21) {
|
||||
PlaybackState stateFwk = (PlaybackState) stateObj;
|
||||
List<PlaybackState.CustomAction> customActionFwks = Api21Impl.getCustomActions(stateFwk);
|
||||
List<PlaybackState.CustomAction> customActionFwks = stateFwk.getCustomActions();
|
||||
List<PlaybackStateCompat.CustomAction> customActions = null;
|
||||
if (customActionFwks != null) {
|
||||
customActions = new ArrayList<>(customActionFwks.size());
|
||||
@ -869,16 +869,16 @@ public final class PlaybackStateCompat implements Parcelable {
|
||||
}
|
||||
PlaybackStateCompat stateCompat =
|
||||
new PlaybackStateCompat(
|
||||
Api21Impl.getState(stateFwk),
|
||||
Api21Impl.getPosition(stateFwk),
|
||||
Api21Impl.getBufferedPosition(stateFwk),
|
||||
Api21Impl.getPlaybackSpeed(stateFwk),
|
||||
Api21Impl.getActions(stateFwk),
|
||||
stateFwk.getState(),
|
||||
stateFwk.getPosition(),
|
||||
stateFwk.getBufferedPosition(),
|
||||
stateFwk.getPlaybackSpeed(),
|
||||
stateFwk.getActions(),
|
||||
ERROR_CODE_UNKNOWN_ERROR,
|
||||
Api21Impl.getErrorMessage(stateFwk),
|
||||
Api21Impl.getLastPositionUpdateTime(stateFwk),
|
||||
stateFwk.getErrorMessage(),
|
||||
stateFwk.getLastPositionUpdateTime(),
|
||||
customActions,
|
||||
Api21Impl.getActiveQueueItemId(stateFwk),
|
||||
stateFwk.getActiveQueueItemId(),
|
||||
extras);
|
||||
stateCompat.mStateFwk = stateFwk;
|
||||
return stateCompat;
|
||||
@ -897,23 +897,23 @@ public final class PlaybackStateCompat implements Parcelable {
|
||||
@Nullable
|
||||
public Object getPlaybackState() {
|
||||
if (mStateFwk == null && Build.VERSION.SDK_INT >= 21) {
|
||||
PlaybackState.Builder builder = Api21Impl.createBuilder();
|
||||
Api21Impl.setState(builder, mState, mPosition, mSpeed, mUpdateTime);
|
||||
Api21Impl.setBufferedPosition(builder, mBufferedPosition);
|
||||
Api21Impl.setActions(builder, mActions);
|
||||
Api21Impl.setErrorMessage(builder, mErrorMessage);
|
||||
PlaybackState.Builder builder = new PlaybackState.Builder()
|
||||
.setState(mState, mPosition, mSpeed, mUpdateTime)
|
||||
.setBufferedPosition(mBufferedPosition)
|
||||
.setActions(mActions)
|
||||
.setErrorMessage(mErrorMessage);
|
||||
for (PlaybackStateCompat.CustomAction customAction : mCustomActions) {
|
||||
PlaybackState.CustomAction action =
|
||||
(PlaybackState.CustomAction) customAction.getCustomAction();
|
||||
if (action != null) {
|
||||
Api21Impl.addCustomAction(builder, action);
|
||||
builder.addCustomAction(action);
|
||||
}
|
||||
}
|
||||
Api21Impl.setActiveQueueItemId(builder, mActiveItemId);
|
||||
builder.setActiveQueueItemId(mActiveItemId);
|
||||
if (Build.VERSION.SDK_INT >= 22) {
|
||||
Api22Impl.setExtras(builder, mExtras);
|
||||
}
|
||||
mStateFwk = Api21Impl.build(builder);
|
||||
mStateFwk = builder.build();
|
||||
}
|
||||
return mStateFwk;
|
||||
}
|
||||
@ -976,22 +976,19 @@ public final class PlaybackStateCompat implements Parcelable {
|
||||
* Creates an instance from a framework {@link android.media.session.PlaybackState.CustomAction}
|
||||
* object.
|
||||
*
|
||||
* <p>This method is only supported on API 21+.
|
||||
*
|
||||
* @param customActionObj A {@link android.media.session.PlaybackState.CustomAction} object, or
|
||||
* null if none.
|
||||
* @return An equivalent {@link PlaybackStateCompat.CustomAction} object, or null if none.
|
||||
*/
|
||||
@RequiresApi(21)
|
||||
public static PlaybackStateCompat.CustomAction fromCustomAction(Object customActionObj) {
|
||||
PlaybackState.CustomAction customActionFwk = (PlaybackState.CustomAction) customActionObj;
|
||||
Bundle extras = Api21Impl.getExtras(customActionFwk);
|
||||
Bundle extras = customActionFwk.getExtras();
|
||||
MediaSessionCompat.ensureClassLoader(extras);
|
||||
PlaybackStateCompat.CustomAction customActionCompat =
|
||||
new PlaybackStateCompat.CustomAction(
|
||||
Api21Impl.getAction(customActionFwk),
|
||||
Api21Impl.getName(customActionFwk),
|
||||
Api21Impl.getIcon(customActionFwk),
|
||||
customActionFwk.getAction(),
|
||||
customActionFwk.getName(),
|
||||
customActionFwk.getIcon(),
|
||||
extras);
|
||||
customActionCompat.mCustomActionFwk = customActionFwk;
|
||||
return customActionCompat;
|
||||
@ -1012,10 +1009,9 @@ public final class PlaybackStateCompat implements Parcelable {
|
||||
return mCustomActionFwk;
|
||||
}
|
||||
|
||||
PlaybackState.CustomAction.Builder builder =
|
||||
Api21Impl.createCustomActionBuilder(mAction, mName, mIcon);
|
||||
Api21Impl.setExtras(builder, mExtras);
|
||||
return Api21Impl.build(builder);
|
||||
return new PlaybackState.CustomAction.Builder(mAction, mName, mIcon)
|
||||
.setExtras(mExtras)
|
||||
.build();
|
||||
}
|
||||
|
||||
public static final Parcelable.Creator<PlaybackStateCompat.CustomAction> CREATOR =
|
||||
@ -1401,142 +1397,6 @@ public final class PlaybackStateCompat implements Parcelable {
|
||||
}
|
||||
}
|
||||
|
||||
@RequiresApi(21)
|
||||
private static class Api21Impl {
|
||||
private Api21Impl() {}
|
||||
|
||||
@DoNotInline
|
||||
static PlaybackState.Builder createBuilder() {
|
||||
return new PlaybackState.Builder();
|
||||
}
|
||||
|
||||
@DoNotInline
|
||||
static void setState(
|
||||
PlaybackState.Builder builder,
|
||||
int state,
|
||||
long position,
|
||||
float playbackSpeed,
|
||||
long updateTime) {
|
||||
builder.setState(state, position, playbackSpeed, updateTime);
|
||||
}
|
||||
|
||||
@DoNotInline
|
||||
static void setBufferedPosition(PlaybackState.Builder builder, long bufferedPosition) {
|
||||
builder.setBufferedPosition(bufferedPosition);
|
||||
}
|
||||
|
||||
@DoNotInline
|
||||
static void setActions(PlaybackState.Builder builder, long actions) {
|
||||
builder.setActions(actions);
|
||||
}
|
||||
|
||||
@SuppressWarnings("argument.type.incompatible") // Platform class not annotated as nullable
|
||||
@DoNotInline
|
||||
static void setErrorMessage(PlaybackState.Builder builder, @Nullable CharSequence error) {
|
||||
builder.setErrorMessage(error);
|
||||
}
|
||||
|
||||
@DoNotInline
|
||||
static void addCustomAction(
|
||||
PlaybackState.Builder builder, PlaybackState.CustomAction customAction) {
|
||||
builder.addCustomAction(customAction);
|
||||
}
|
||||
|
||||
@DoNotInline
|
||||
static void setActiveQueueItemId(PlaybackState.Builder builder, long id) {
|
||||
builder.setActiveQueueItemId(id);
|
||||
}
|
||||
|
||||
@DoNotInline
|
||||
static List<PlaybackState.CustomAction> getCustomActions(PlaybackState state) {
|
||||
return state.getCustomActions();
|
||||
}
|
||||
|
||||
@DoNotInline
|
||||
static PlaybackState build(PlaybackState.Builder builder) {
|
||||
return builder.build();
|
||||
}
|
||||
|
||||
@DoNotInline
|
||||
static int getState(PlaybackState state) {
|
||||
return state.getState();
|
||||
}
|
||||
|
||||
@DoNotInline
|
||||
static long getPosition(PlaybackState state) {
|
||||
return state.getPosition();
|
||||
}
|
||||
|
||||
@DoNotInline
|
||||
static long getBufferedPosition(PlaybackState state) {
|
||||
return state.getBufferedPosition();
|
||||
}
|
||||
|
||||
@DoNotInline
|
||||
static float getPlaybackSpeed(PlaybackState state) {
|
||||
return state.getPlaybackSpeed();
|
||||
}
|
||||
|
||||
@DoNotInline
|
||||
static long getActions(PlaybackState state) {
|
||||
return state.getActions();
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@DoNotInline
|
||||
static CharSequence getErrorMessage(PlaybackState state) {
|
||||
return state.getErrorMessage();
|
||||
}
|
||||
|
||||
@DoNotInline
|
||||
static long getLastPositionUpdateTime(PlaybackState state) {
|
||||
return state.getLastPositionUpdateTime();
|
||||
}
|
||||
|
||||
@DoNotInline
|
||||
static long getActiveQueueItemId(PlaybackState state) {
|
||||
return state.getActiveQueueItemId();
|
||||
}
|
||||
|
||||
@DoNotInline
|
||||
static PlaybackState.CustomAction.Builder createCustomActionBuilder(
|
||||
String action, CharSequence name, int icon) {
|
||||
return new PlaybackState.CustomAction.Builder(action, name, icon);
|
||||
}
|
||||
|
||||
@SuppressWarnings("argument.type.incompatible") // Platform class not annotated as nullable
|
||||
@DoNotInline
|
||||
static void setExtras(PlaybackState.CustomAction.Builder builder, @Nullable Bundle extras) {
|
||||
builder.setExtras(extras);
|
||||
}
|
||||
|
||||
@DoNotInline
|
||||
static PlaybackState.CustomAction build(PlaybackState.CustomAction.Builder builder) {
|
||||
return builder.build();
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@DoNotInline
|
||||
static Bundle getExtras(PlaybackState.CustomAction customAction) {
|
||||
return customAction.getExtras();
|
||||
}
|
||||
|
||||
@DoNotInline
|
||||
static String getAction(PlaybackState.CustomAction customAction) {
|
||||
return customAction.getAction();
|
||||
}
|
||||
|
||||
@DoNotInline
|
||||
static CharSequence getName(PlaybackState.CustomAction customAction) {
|
||||
return customAction.getName();
|
||||
}
|
||||
|
||||
@DoNotInline
|
||||
static int getIcon(PlaybackState.CustomAction customAction) {
|
||||
return customAction.getIcon();
|
||||
}
|
||||
}
|
||||
|
||||
@RequiresApi(22)
|
||||
private static class Api22Impl {
|
||||
private Api22Impl() {}
|
||||
|
@ -19,10 +19,8 @@ import static androidx.annotation.RestrictTo.Scope.LIBRARY;
|
||||
|
||||
import android.media.VolumeProvider;
|
||||
import android.os.Build;
|
||||
import androidx.annotation.DoNotInline;
|
||||
import androidx.annotation.IntDef;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.annotation.RequiresApi;
|
||||
import androidx.annotation.RestrictTo;
|
||||
import androidx.media3.common.util.UnstableApi;
|
||||
import java.lang.annotation.Retention;
|
||||
@ -134,7 +132,7 @@ public abstract class VolumeProviderCompat {
|
||||
mCurrentVolume = currentVolume;
|
||||
if (Build.VERSION.SDK_INT >= 21) {
|
||||
VolumeProvider volumeProviderFwk = (VolumeProvider) getVolumeProvider();
|
||||
Api21Impl.setCurrentVolume(volumeProviderFwk, currentVolume);
|
||||
volumeProviderFwk.setCurrentVolume(currentVolume);
|
||||
}
|
||||
if (mCallback != null) {
|
||||
mCallback.onVolumeChanged(this);
|
||||
@ -178,11 +176,8 @@ public abstract class VolumeProviderCompat {
|
||||
/**
|
||||
* Gets the underlying framework {@link android.media.VolumeProvider} object.
|
||||
*
|
||||
* <p>This method is only supported on API 21+.
|
||||
*
|
||||
* @return An equivalent {@link android.media.VolumeProvider} object, or null if none.
|
||||
*/
|
||||
@RequiresApi(21)
|
||||
public Object getVolumeProvider() {
|
||||
if (mVolumeProviderFwk == null) {
|
||||
if (Build.VERSION.SDK_INT >= 30) {
|
||||
@ -220,14 +215,4 @@ public abstract class VolumeProviderCompat {
|
||||
public abstract static class Callback {
|
||||
public abstract void onVolumeChanged(VolumeProviderCompat volumeProvider);
|
||||
}
|
||||
|
||||
@RequiresApi(21)
|
||||
private static class Api21Impl {
|
||||
private Api21Impl() {}
|
||||
|
||||
@DoNotInline
|
||||
static void setCurrentVolume(VolumeProvider volumeProvider, int currentVolume) {
|
||||
volumeProvider.setCurrentVolume(currentVolume);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -23,7 +23,6 @@ import android.os.Build
|
||||
import android.os.Build.VERSION_CODES
|
||||
import android.os.Bundle
|
||||
import android.service.notification.NotificationListenerService
|
||||
import androidx.annotation.RequiresApi
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
import androidx.appcompat.widget.Toolbar
|
||||
import androidx.core.app.NotificationManagerCompat
|
||||
@ -113,7 +112,6 @@ class LaunchActivity : AppCompatActivity() {
|
||||
* sessions. We only construct an instance of this class if the device is running L or later, to
|
||||
* avoid any ClassNotFoundExceptions due to the use of MediaSession and related classes.
|
||||
*/
|
||||
@RequiresApi(VERSION_CODES.LOLLIPOP)
|
||||
private inner class ActiveSessionListener {
|
||||
private val activeSessionApps: MediaAppListAdapter.Section =
|
||||
mediaAppListAdapter.addSection(R.string.media_app_header_active_session)
|
||||
@ -170,10 +168,8 @@ class LaunchActivity : AppCompatActivity() {
|
||||
|
||||
/**
|
||||
* A notification listener service that allows us to grab active media sessions from their
|
||||
* notifications. This class is only used on API 21+ because the Android media framework added
|
||||
* getActiveSessions in API 21.
|
||||
* notifications.
|
||||
*/
|
||||
@RequiresApi(VERSION_CODES.LOLLIPOP)
|
||||
class NotificationListener : NotificationListenerService() {
|
||||
companion object {
|
||||
// Helper method to check if our notification listener is enabled. In order to get active
|
||||
|
@ -20,9 +20,7 @@ import android.content.pm.PackageManager
|
||||
import android.content.res.Resources
|
||||
import android.graphics.Bitmap
|
||||
import android.media.session.MediaController
|
||||
import android.os.Build
|
||||
import android.os.Bundle
|
||||
import androidx.annotation.RequiresApi
|
||||
import androidx.media3.common.util.Util
|
||||
import androidx.media3.session.SessionToken
|
||||
|
||||
@ -58,7 +56,6 @@ private constructor(
|
||||
)
|
||||
}
|
||||
|
||||
@RequiresApi(Build.VERSION_CODES.LOLLIPOP)
|
||||
fun create(
|
||||
packageManager: PackageManager,
|
||||
resources: Resources,
|
||||
|
@ -21,15 +21,12 @@ import android.content.pm.PackageManager
|
||||
import android.content.res.Resources
|
||||
import android.media.session.MediaController
|
||||
import android.media.session.MediaSessionManager
|
||||
import android.os.Build
|
||||
import androidx.annotation.RequiresApi
|
||||
import androidx.media3.testapp.controller.MediaAppDetails
|
||||
|
||||
/**
|
||||
* Implementation of [FindMediaApps] that uses [MediaSessionManager] to populate the list of active
|
||||
* media session apps.
|
||||
*/
|
||||
@RequiresApi(Build.VERSION_CODES.LOLLIPOP)
|
||||
class FindActiveMediaSessionApps
|
||||
constructor(
|
||||
private val mediaSessionManager: MediaSessionManager,
|
||||
|
Loading…
x
Reference in New Issue
Block a user