285 lines
10 KiB
Java
285 lines
10 KiB
Java
package android.support.v4.media.session;
|
|
|
|
import android.os.Build;
|
|
import android.os.Bundle;
|
|
import android.os.IBinder;
|
|
import android.os.Parcel;
|
|
import android.os.Parcelable;
|
|
import android.os.ResultReceiver;
|
|
import android.support.v4.media.MediaDescriptionCompat;
|
|
import android.support.v4.media.session.IMediaSession;
|
|
import android.support.v4.media.session.MediaSessionCompatApi21;
|
|
import androidx.core.app.BundleCompat;
|
|
import java.util.ArrayList;
|
|
import java.util.Iterator;
|
|
import java.util.List;
|
|
|
|
/* loaded from: classes.dex */
|
|
public class MediaSessionCompat {
|
|
|
|
public static final class QueueItem implements Parcelable {
|
|
public static final Parcelable.Creator<QueueItem> CREATOR = new Parcelable.Creator<QueueItem>() { // from class: android.support.v4.media.session.MediaSessionCompat.QueueItem.1
|
|
/* JADX WARN: Can't rename method to resolve collision */
|
|
@Override // android.os.Parcelable.Creator
|
|
public QueueItem createFromParcel(Parcel parcel) {
|
|
return new QueueItem(parcel);
|
|
}
|
|
|
|
/* JADX WARN: Can't rename method to resolve collision */
|
|
@Override // android.os.Parcelable.Creator
|
|
public QueueItem[] newArray(int i) {
|
|
return new QueueItem[i];
|
|
}
|
|
};
|
|
public static final int UNKNOWN_ID = -1;
|
|
private final MediaDescriptionCompat mDescription;
|
|
private final long mId;
|
|
private Object mItem;
|
|
|
|
public QueueItem(MediaDescriptionCompat mediaDescriptionCompat, long j) {
|
|
this(null, mediaDescriptionCompat, j);
|
|
}
|
|
|
|
public static QueueItem fromQueueItem(Object obj) {
|
|
if (obj == null || Build.VERSION.SDK_INT < 21) {
|
|
return null;
|
|
}
|
|
return new QueueItem(obj, MediaDescriptionCompat.fromMediaDescription(MediaSessionCompatApi21.QueueItem.a(obj)), MediaSessionCompatApi21.QueueItem.b(obj));
|
|
}
|
|
|
|
public static List<QueueItem> fromQueueItemList(List<?> list) {
|
|
if (list == null || Build.VERSION.SDK_INT < 21) {
|
|
return null;
|
|
}
|
|
ArrayList arrayList = new ArrayList();
|
|
Iterator<?> it = list.iterator();
|
|
while (it.hasNext()) {
|
|
arrayList.add(fromQueueItem(it.next()));
|
|
}
|
|
return arrayList;
|
|
}
|
|
|
|
@Override // android.os.Parcelable
|
|
public int describeContents() {
|
|
return 0;
|
|
}
|
|
|
|
public MediaDescriptionCompat getDescription() {
|
|
return this.mDescription;
|
|
}
|
|
|
|
public long getQueueId() {
|
|
return this.mId;
|
|
}
|
|
|
|
public Object getQueueItem() {
|
|
if (this.mItem != null || Build.VERSION.SDK_INT < 21) {
|
|
return this.mItem;
|
|
}
|
|
this.mItem = MediaSessionCompatApi21.QueueItem.a(this.mDescription.getMediaDescription(), this.mId);
|
|
return this.mItem;
|
|
}
|
|
|
|
public String toString() {
|
|
return "MediaSession.QueueItem {Description=" + this.mDescription + ", Id=" + this.mId + " }";
|
|
}
|
|
|
|
@Override // android.os.Parcelable
|
|
public void writeToParcel(Parcel parcel, int i) {
|
|
this.mDescription.writeToParcel(parcel, i);
|
|
parcel.writeLong(this.mId);
|
|
}
|
|
|
|
private QueueItem(Object obj, MediaDescriptionCompat mediaDescriptionCompat, long j) {
|
|
if (mediaDescriptionCompat == null) {
|
|
throw new IllegalArgumentException("Description cannot be null.");
|
|
}
|
|
if (j == -1) {
|
|
throw new IllegalArgumentException("Id cannot be QueueItem.UNKNOWN_ID");
|
|
}
|
|
this.mDescription = mediaDescriptionCompat;
|
|
this.mId = j;
|
|
this.mItem = obj;
|
|
}
|
|
|
|
QueueItem(Parcel parcel) {
|
|
this.mDescription = MediaDescriptionCompat.CREATOR.createFromParcel(parcel);
|
|
this.mId = parcel.readLong();
|
|
}
|
|
}
|
|
|
|
public static final class Token implements Parcelable {
|
|
public static final Parcelable.Creator<Token> CREATOR = new Parcelable.Creator<Token>() { // from class: android.support.v4.media.session.MediaSessionCompat.Token.1
|
|
/* JADX WARN: Can't rename method to resolve collision */
|
|
@Override // android.os.Parcelable.Creator
|
|
public Token createFromParcel(Parcel parcel) {
|
|
return new Token(Build.VERSION.SDK_INT >= 21 ? parcel.readParcelable(null) : parcel.readStrongBinder());
|
|
}
|
|
|
|
/* JADX WARN: Can't rename method to resolve collision */
|
|
@Override // android.os.Parcelable.Creator
|
|
public Token[] newArray(int i) {
|
|
return new Token[i];
|
|
}
|
|
};
|
|
private IMediaSession mExtraBinder;
|
|
private final Object mInner;
|
|
private Bundle mSessionToken2Bundle;
|
|
|
|
Token(Object obj) {
|
|
this(obj, null, null);
|
|
}
|
|
|
|
public static Token fromBundle(Bundle bundle) {
|
|
if (bundle == null) {
|
|
return null;
|
|
}
|
|
IMediaSession a = IMediaSession.Stub.a(BundleCompat.a(bundle, "android.support.v4.media.session.EXTRA_BINDER"));
|
|
Bundle bundle2 = bundle.getBundle("android.support.v4.media.session.SESSION_TOKEN2_BUNDLE");
|
|
Token token = (Token) bundle.getParcelable("android.support.v4.media.session.TOKEN");
|
|
if (token == null) {
|
|
return null;
|
|
}
|
|
return new Token(token.mInner, a, bundle2);
|
|
}
|
|
|
|
public static Token fromToken(Object obj) {
|
|
return fromToken(obj, null);
|
|
}
|
|
|
|
@Override // android.os.Parcelable
|
|
public int describeContents() {
|
|
return 0;
|
|
}
|
|
|
|
public boolean equals(Object obj) {
|
|
if (this == obj) {
|
|
return true;
|
|
}
|
|
if (!(obj instanceof Token)) {
|
|
return false;
|
|
}
|
|
Token token = (Token) obj;
|
|
Object obj2 = this.mInner;
|
|
if (obj2 == null) {
|
|
return token.mInner == null;
|
|
}
|
|
Object obj3 = token.mInner;
|
|
if (obj3 == null) {
|
|
return false;
|
|
}
|
|
return obj2.equals(obj3);
|
|
}
|
|
|
|
public IMediaSession getExtraBinder() {
|
|
return this.mExtraBinder;
|
|
}
|
|
|
|
public Bundle getSessionToken2Bundle() {
|
|
return this.mSessionToken2Bundle;
|
|
}
|
|
|
|
public Object getToken() {
|
|
return this.mInner;
|
|
}
|
|
|
|
public int hashCode() {
|
|
Object obj = this.mInner;
|
|
if (obj == null) {
|
|
return 0;
|
|
}
|
|
return obj.hashCode();
|
|
}
|
|
|
|
public void setExtraBinder(IMediaSession iMediaSession) {
|
|
this.mExtraBinder = iMediaSession;
|
|
}
|
|
|
|
public void setSessionToken2Bundle(Bundle bundle) {
|
|
this.mSessionToken2Bundle = bundle;
|
|
}
|
|
|
|
public Bundle toBundle() {
|
|
Bundle bundle = new Bundle();
|
|
bundle.putParcelable("android.support.v4.media.session.TOKEN", this);
|
|
IMediaSession iMediaSession = this.mExtraBinder;
|
|
if (iMediaSession != null) {
|
|
BundleCompat.a(bundle, "android.support.v4.media.session.EXTRA_BINDER", iMediaSession.asBinder());
|
|
}
|
|
Bundle bundle2 = this.mSessionToken2Bundle;
|
|
if (bundle2 != null) {
|
|
bundle.putBundle("android.support.v4.media.session.SESSION_TOKEN2_BUNDLE", bundle2);
|
|
}
|
|
return bundle;
|
|
}
|
|
|
|
@Override // android.os.Parcelable
|
|
public void writeToParcel(Parcel parcel, int i) {
|
|
if (Build.VERSION.SDK_INT >= 21) {
|
|
parcel.writeParcelable((Parcelable) this.mInner, i);
|
|
} else {
|
|
parcel.writeStrongBinder((IBinder) this.mInner);
|
|
}
|
|
}
|
|
|
|
Token(Object obj, IMediaSession iMediaSession) {
|
|
this(obj, iMediaSession, null);
|
|
}
|
|
|
|
public static Token fromToken(Object obj, IMediaSession iMediaSession) {
|
|
if (obj == null || Build.VERSION.SDK_INT < 21) {
|
|
return null;
|
|
}
|
|
MediaSessionCompatApi21.a(obj);
|
|
return new Token(obj, iMediaSession);
|
|
}
|
|
|
|
Token(Object obj, IMediaSession iMediaSession, Bundle bundle) {
|
|
this.mInner = obj;
|
|
this.mExtraBinder = iMediaSession;
|
|
this.mSessionToken2Bundle = bundle;
|
|
}
|
|
}
|
|
|
|
public static void a(Bundle bundle) {
|
|
if (bundle != null) {
|
|
bundle.setClassLoader(MediaSessionCompat.class.getClassLoader());
|
|
}
|
|
}
|
|
|
|
public static final class ResultReceiverWrapper implements Parcelable {
|
|
public static final Parcelable.Creator<ResultReceiverWrapper> CREATOR = new Parcelable.Creator<ResultReceiverWrapper>() { // from class: android.support.v4.media.session.MediaSessionCompat.ResultReceiverWrapper.1
|
|
/* JADX WARN: Can't rename method to resolve collision */
|
|
@Override // android.os.Parcelable.Creator
|
|
public ResultReceiverWrapper createFromParcel(Parcel parcel) {
|
|
return new ResultReceiverWrapper(parcel);
|
|
}
|
|
|
|
/* JADX WARN: Can't rename method to resolve collision */
|
|
@Override // android.os.Parcelable.Creator
|
|
public ResultReceiverWrapper[] newArray(int i) {
|
|
return new ResultReceiverWrapper[i];
|
|
}
|
|
};
|
|
ResultReceiver mResultReceiver;
|
|
|
|
public ResultReceiverWrapper(ResultReceiver resultReceiver) {
|
|
this.mResultReceiver = resultReceiver;
|
|
}
|
|
|
|
@Override // android.os.Parcelable
|
|
public int describeContents() {
|
|
return 0;
|
|
}
|
|
|
|
@Override // android.os.Parcelable
|
|
public void writeToParcel(Parcel parcel, int i) {
|
|
this.mResultReceiver.writeToParcel(parcel, i);
|
|
}
|
|
|
|
ResultReceiverWrapper(Parcel parcel) {
|
|
this.mResultReceiver = (ResultReceiver) ResultReceiver.CREATOR.createFromParcel(parcel);
|
|
}
|
|
}
|
|
}
|