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