jimu-decompiled/sources/android/support/v4/media/session/PlaybackStateCompat.java
2025-05-13 19:24:51 +02:00

354 lines
14 KiB
Java

package android.support.v4.media.session;
import android.os.Build;
import android.os.Bundle;
import android.os.Parcel;
import android.os.Parcelable;
import android.os.SystemClock;
import android.support.v4.media.session.PlaybackStateCompatApi21;
import android.text.TextUtils;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
/* loaded from: classes.dex */
public final class PlaybackStateCompat implements Parcelable {
public static final long ACTION_FAST_FORWARD = 64;
public static final long ACTION_PAUSE = 2;
public static final long ACTION_PLAY = 4;
public static final long ACTION_PLAY_FROM_MEDIA_ID = 1024;
public static final long ACTION_PLAY_FROM_SEARCH = 2048;
public static final long ACTION_PLAY_FROM_URI = 8192;
public static final long ACTION_PLAY_PAUSE = 512;
public static final long ACTION_PREPARE = 16384;
public static final long ACTION_PREPARE_FROM_MEDIA_ID = 32768;
public static final long ACTION_PREPARE_FROM_SEARCH = 65536;
public static final long ACTION_PREPARE_FROM_URI = 131072;
public static final long ACTION_REWIND = 8;
public static final long ACTION_SEEK_TO = 256;
public static final long ACTION_SET_CAPTIONING_ENABLED = 1048576;
public static final long ACTION_SET_RATING = 128;
public static final long ACTION_SET_REPEAT_MODE = 262144;
public static final long ACTION_SET_SHUFFLE_MODE = 2097152;
@Deprecated
public static final long ACTION_SET_SHUFFLE_MODE_ENABLED = 524288;
public static final long ACTION_SKIP_TO_NEXT = 32;
public static final long ACTION_SKIP_TO_PREVIOUS = 16;
public static final long ACTION_SKIP_TO_QUEUE_ITEM = 4096;
public static final long ACTION_STOP = 1;
public static final Parcelable.Creator<PlaybackStateCompat> CREATOR = new Parcelable.Creator<PlaybackStateCompat>() { // from class: android.support.v4.media.session.PlaybackStateCompat.1
/* JADX WARN: Can't rename method to resolve collision */
@Override // android.os.Parcelable.Creator
public PlaybackStateCompat createFromParcel(Parcel parcel) {
return new PlaybackStateCompat(parcel);
}
/* JADX WARN: Can't rename method to resolve collision */
@Override // android.os.Parcelable.Creator
public PlaybackStateCompat[] newArray(int i) {
return new PlaybackStateCompat[i];
}
};
public static final int ERROR_CODE_ACTION_ABORTED = 10;
public static final int ERROR_CODE_APP_ERROR = 1;
public static final int ERROR_CODE_AUTHENTICATION_EXPIRED = 3;
public static final int ERROR_CODE_CONCURRENT_STREAM_LIMIT = 5;
public static final int ERROR_CODE_CONTENT_ALREADY_PLAYING = 8;
public static final int ERROR_CODE_END_OF_QUEUE = 11;
public static final int ERROR_CODE_NOT_AVAILABLE_IN_REGION = 7;
public static final int ERROR_CODE_NOT_SUPPORTED = 2;
public static final int ERROR_CODE_PARENTAL_CONTROL_RESTRICTED = 6;
public static final int ERROR_CODE_PREMIUM_ACCOUNT_REQUIRED = 4;
public static final int ERROR_CODE_SKIP_LIMIT_REACHED = 9;
public static final int ERROR_CODE_UNKNOWN_ERROR = 0;
private static final int KEYCODE_MEDIA_PAUSE = 127;
private static final int KEYCODE_MEDIA_PLAY = 126;
public static final long PLAYBACK_POSITION_UNKNOWN = -1;
public static final int REPEAT_MODE_ALL = 2;
public static final int REPEAT_MODE_GROUP = 3;
public static final int REPEAT_MODE_INVALID = -1;
public static final int REPEAT_MODE_NONE = 0;
public static final int REPEAT_MODE_ONE = 1;
public static final int SHUFFLE_MODE_ALL = 1;
public static final int SHUFFLE_MODE_GROUP = 2;
public static final int SHUFFLE_MODE_INVALID = -1;
public static final int SHUFFLE_MODE_NONE = 0;
public static final int STATE_BUFFERING = 6;
public static final int STATE_CONNECTING = 8;
public static final int STATE_ERROR = 7;
public static final int STATE_FAST_FORWARDING = 4;
public static final int STATE_NONE = 0;
public static final int STATE_PAUSED = 2;
public static final int STATE_PLAYING = 3;
public static final int STATE_REWINDING = 5;
public static final int STATE_SKIPPING_TO_NEXT = 10;
public static final int STATE_SKIPPING_TO_PREVIOUS = 9;
public static final int STATE_SKIPPING_TO_QUEUE_ITEM = 11;
public static final int STATE_STOPPED = 1;
final long mActions;
final long mActiveItemId;
final long mBufferedPosition;
List<CustomAction> mCustomActions;
final int mErrorCode;
final CharSequence mErrorMessage;
final Bundle mExtras;
final long mPosition;
final float mSpeed;
final int mState;
private Object mStateObj;
final long mUpdateTime;
PlaybackStateCompat(int i, long j, long j2, float f, long j3, int i2, CharSequence charSequence, long j4, List<CustomAction> list, long j5, Bundle bundle) {
this.mState = i;
this.mPosition = j;
this.mBufferedPosition = j2;
this.mSpeed = f;
this.mActions = j3;
this.mErrorCode = i2;
this.mErrorMessage = charSequence;
this.mUpdateTime = j4;
this.mCustomActions = new ArrayList(list);
this.mActiveItemId = j5;
this.mExtras = bundle;
}
public static PlaybackStateCompat fromPlaybackState(Object obj) {
ArrayList arrayList;
if (obj == null || Build.VERSION.SDK_INT < 21) {
return null;
}
List<Object> d = PlaybackStateCompatApi21.d(obj);
if (d != null) {
ArrayList arrayList2 = new ArrayList(d.size());
Iterator<Object> it = d.iterator();
while (it.hasNext()) {
arrayList2.add(CustomAction.fromCustomAction(it.next()));
}
arrayList = arrayList2;
} else {
arrayList = null;
}
PlaybackStateCompat playbackStateCompat = new PlaybackStateCompat(PlaybackStateCompatApi21.i(obj), PlaybackStateCompatApi21.h(obj), PlaybackStateCompatApi21.c(obj), PlaybackStateCompatApi21.g(obj), PlaybackStateCompatApi21.a(obj), 0, PlaybackStateCompatApi21.e(obj), PlaybackStateCompatApi21.f(obj), arrayList, PlaybackStateCompatApi21.b(obj), Build.VERSION.SDK_INT >= 22 ? PlaybackStateCompatApi22.a(obj) : null);
playbackStateCompat.mStateObj = obj;
return playbackStateCompat;
}
public static int toKeyCode(long j) {
if (j == 4) {
return KEYCODE_MEDIA_PLAY;
}
if (j == 2) {
return KEYCODE_MEDIA_PAUSE;
}
if (j == 32) {
return 87;
}
if (j == 16) {
return 88;
}
if (j == 1) {
return 86;
}
if (j == 64) {
return 90;
}
if (j == 8) {
return 89;
}
return j == 512 ? 85 : 0;
}
@Override // android.os.Parcelable
public int describeContents() {
return 0;
}
public long getActions() {
return this.mActions;
}
public long getActiveQueueItemId() {
return this.mActiveItemId;
}
public long getBufferedPosition() {
return this.mBufferedPosition;
}
public long getCurrentPosition(Long l) {
return Math.max(0L, this.mPosition + ((long) (this.mSpeed * (l != null ? l.longValue() : SystemClock.elapsedRealtime() - this.mUpdateTime))));
}
public List<CustomAction> getCustomActions() {
return this.mCustomActions;
}
public int getErrorCode() {
return this.mErrorCode;
}
public CharSequence getErrorMessage() {
return this.mErrorMessage;
}
public Bundle getExtras() {
return this.mExtras;
}
public long getLastPositionUpdateTime() {
return this.mUpdateTime;
}
public float getPlaybackSpeed() {
return this.mSpeed;
}
public Object getPlaybackState() {
if (this.mStateObj == null && Build.VERSION.SDK_INT >= 21) {
ArrayList arrayList = null;
List<CustomAction> list = this.mCustomActions;
if (list != null) {
arrayList = new ArrayList(list.size());
Iterator<CustomAction> it = this.mCustomActions.iterator();
while (it.hasNext()) {
arrayList.add(it.next().getCustomAction());
}
}
ArrayList arrayList2 = arrayList;
if (Build.VERSION.SDK_INT >= 22) {
this.mStateObj = PlaybackStateCompatApi22.a(this.mState, this.mPosition, this.mBufferedPosition, this.mSpeed, this.mActions, this.mErrorMessage, this.mUpdateTime, arrayList2, this.mActiveItemId, this.mExtras);
} else {
this.mStateObj = PlaybackStateCompatApi21.a(this.mState, this.mPosition, this.mBufferedPosition, this.mSpeed, this.mActions, this.mErrorMessage, this.mUpdateTime, arrayList2, this.mActiveItemId);
}
}
return this.mStateObj;
}
public long getPosition() {
return this.mPosition;
}
public int getState() {
return this.mState;
}
public String toString() {
return "PlaybackState {state=" + this.mState + ", position=" + this.mPosition + ", buffered position=" + this.mBufferedPosition + ", speed=" + this.mSpeed + ", updated=" + this.mUpdateTime + ", actions=" + this.mActions + ", error code=" + this.mErrorCode + ", error message=" + this.mErrorMessage + ", custom actions=" + this.mCustomActions + ", active item id=" + this.mActiveItemId + "}";
}
@Override // android.os.Parcelable
public void writeToParcel(Parcel parcel, int i) {
parcel.writeInt(this.mState);
parcel.writeLong(this.mPosition);
parcel.writeFloat(this.mSpeed);
parcel.writeLong(this.mUpdateTime);
parcel.writeLong(this.mBufferedPosition);
parcel.writeLong(this.mActions);
TextUtils.writeToParcel(this.mErrorMessage, parcel, i);
parcel.writeTypedList(this.mCustomActions);
parcel.writeLong(this.mActiveItemId);
parcel.writeBundle(this.mExtras);
parcel.writeInt(this.mErrorCode);
}
public static final class CustomAction implements Parcelable {
public static final Parcelable.Creator<CustomAction> CREATOR = new Parcelable.Creator<CustomAction>() { // from class: android.support.v4.media.session.PlaybackStateCompat.CustomAction.1
/* JADX WARN: Can't rename method to resolve collision */
@Override // android.os.Parcelable.Creator
public CustomAction createFromParcel(Parcel parcel) {
return new CustomAction(parcel);
}
/* JADX WARN: Can't rename method to resolve collision */
@Override // android.os.Parcelable.Creator
public CustomAction[] newArray(int i) {
return new CustomAction[i];
}
};
private final String mAction;
private Object mCustomActionObj;
private final Bundle mExtras;
private final int mIcon;
private final CharSequence mName;
CustomAction(String str, CharSequence charSequence, int i, Bundle bundle) {
this.mAction = str;
this.mName = charSequence;
this.mIcon = i;
this.mExtras = bundle;
}
public static CustomAction fromCustomAction(Object obj) {
if (obj == null || Build.VERSION.SDK_INT < 21) {
return null;
}
CustomAction customAction = new CustomAction(PlaybackStateCompatApi21.CustomAction.a(obj), PlaybackStateCompatApi21.CustomAction.d(obj), PlaybackStateCompatApi21.CustomAction.c(obj), PlaybackStateCompatApi21.CustomAction.b(obj));
customAction.mCustomActionObj = obj;
return customAction;
}
@Override // android.os.Parcelable
public int describeContents() {
return 0;
}
public String getAction() {
return this.mAction;
}
public Object getCustomAction() {
if (this.mCustomActionObj != null || Build.VERSION.SDK_INT < 21) {
return this.mCustomActionObj;
}
this.mCustomActionObj = PlaybackStateCompatApi21.CustomAction.a(this.mAction, this.mName, this.mIcon, this.mExtras);
return this.mCustomActionObj;
}
public Bundle getExtras() {
return this.mExtras;
}
public int getIcon() {
return this.mIcon;
}
public CharSequence getName() {
return this.mName;
}
public String toString() {
return "Action:mName='" + ((Object) this.mName) + ", mIcon=" + this.mIcon + ", mExtras=" + this.mExtras;
}
@Override // android.os.Parcelable
public void writeToParcel(Parcel parcel, int i) {
parcel.writeString(this.mAction);
TextUtils.writeToParcel(this.mName, parcel, i);
parcel.writeInt(this.mIcon);
parcel.writeBundle(this.mExtras);
}
CustomAction(Parcel parcel) {
this.mAction = parcel.readString();
this.mName = (CharSequence) TextUtils.CHAR_SEQUENCE_CREATOR.createFromParcel(parcel);
this.mIcon = parcel.readInt();
this.mExtras = parcel.readBundle(MediaSessionCompat.class.getClassLoader());
}
}
PlaybackStateCompat(Parcel parcel) {
this.mState = parcel.readInt();
this.mPosition = parcel.readLong();
this.mSpeed = parcel.readFloat();
this.mUpdateTime = parcel.readLong();
this.mBufferedPosition = parcel.readLong();
this.mActions = parcel.readLong();
this.mErrorMessage = (CharSequence) TextUtils.CHAR_SEQUENCE_CREATOR.createFromParcel(parcel);
this.mCustomActions = parcel.createTypedArrayList(CustomAction.CREATOR);
this.mActiveItemId = parcel.readLong();
this.mExtras = parcel.readBundle(MediaSessionCompat.class.getClassLoader());
this.mErrorCode = parcel.readInt();
}
}