package android.support.v4.media.session; import android.annotation.SuppressLint; import android.media.session.PlaybackState; import android.os.Bundle; import android.os.Parcel; import android.os.Parcelable; import android.os.SystemClock; import android.text.TextUtils; import androidx.annotation.Nullable; import androidx.annotation.RestrictTo; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; import java.util.ArrayList; import java.util.Iterator; import java.util.List; @SuppressLint({"BanParcelableUsage"}) /* 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_PLAYBACK_SPEED = 4194304; 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 CREATOR = new Parcelable.Creator() { // 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 mCustomActions; final int mErrorCode; final CharSequence mErrorMessage; final Bundle mExtras; final long mPosition; final float mSpeed; final int mState; private PlaybackState mStateFwk; final long mUpdateTime; @Retention(RetentionPolicy.SOURCE) @RestrictTo({RestrictTo.Scope.LIBRARY_GROUP_PREFIX}) public @interface Actions { } @Retention(RetentionPolicy.SOURCE) @RestrictTo({RestrictTo.Scope.LIBRARY}) public @interface MediaKeyAction { } @Retention(RetentionPolicy.SOURCE) @RestrictTo({RestrictTo.Scope.LIBRARY_GROUP_PREFIX}) public @interface RepeatMode { } @Retention(RetentionPolicy.SOURCE) @RestrictTo({RestrictTo.Scope.LIBRARY_GROUP_PREFIX}) public @interface ShuffleMode { } @Retention(RetentionPolicy.SOURCE) @RestrictTo({RestrictTo.Scope.LIBRARY_GROUP_PREFIX}) public @interface State { } public static int toKeyCode(long j) { if (j == 4) { return 126; } if (j == 2) { return 127; } 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 List getCustomActions() { return this.mCustomActions; } public int getErrorCode() { return this.mErrorCode; } public CharSequence getErrorMessage() { return this.mErrorMessage; } @Nullable public Bundle getExtras() { return this.mExtras; } public long getLastPositionUpdateTime() { return this.mUpdateTime; } public float getPlaybackSpeed() { return this.mSpeed; } public long getPosition() { return this.mPosition; } public int getState() { return this.mState; } public PlaybackStateCompat(int i, long j, long j2, float f, long j3, int i2, CharSequence charSequence, long j4, List 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 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(); } 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); } @RestrictTo({RestrictTo.Scope.LIBRARY_GROUP_PREFIX}) public long getCurrentPosition(Long l) { return Math.max(0L, this.mPosition + ((long) (this.mSpeed * (l != null ? l.longValue() : SystemClock.elapsedRealtime() - this.mUpdateTime)))); } public static PlaybackStateCompat fromPlaybackState(Object obj) { ArrayList arrayList = null; if (obj == null) { return null; } PlaybackState playbackState = (PlaybackState) obj; List customActions = playbackState.getCustomActions(); if (customActions != null) { arrayList = new ArrayList(customActions.size()); Iterator it = customActions.iterator(); while (it.hasNext()) { arrayList.add(CustomAction.fromCustomAction(it.next())); } } Bundle extras = playbackState.getExtras(); MediaSessionCompat.ensureClassLoader(extras); PlaybackStateCompat playbackStateCompat = new PlaybackStateCompat(playbackState.getState(), playbackState.getPosition(), playbackState.getBufferedPosition(), playbackState.getPlaybackSpeed(), playbackState.getActions(), 0, playbackState.getErrorMessage(), playbackState.getLastPositionUpdateTime(), arrayList, playbackState.getActiveQueueItemId(), extras); playbackStateCompat.mStateFwk = playbackState; return playbackStateCompat; } public Object getPlaybackState() { if (this.mStateFwk == null) { PlaybackState.Builder builder = new PlaybackState.Builder(); builder.setState(this.mState, this.mPosition, this.mSpeed, this.mUpdateTime); builder.setBufferedPosition(this.mBufferedPosition); builder.setActions(this.mActions); builder.setErrorMessage(this.mErrorMessage); Iterator it = this.mCustomActions.iterator(); while (it.hasNext()) { builder.addCustomAction((PlaybackState.CustomAction) it.next().getCustomAction()); } builder.setActiveQueueItemId(this.mActiveItemId); builder.setExtras(this.mExtras); this.mStateFwk = builder.build(); } return this.mStateFwk; } public static final class CustomAction implements Parcelable { public static final Parcelable.Creator CREATOR = new Parcelable.Creator() { // 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 PlaybackState.CustomAction mCustomActionFwk; private final Bundle mExtras; private final int mIcon; private final CharSequence mName; @Override // android.os.Parcelable public int describeContents() { return 0; } public String getAction() { return this.mAction; } public Bundle getExtras() { return this.mExtras; } public int getIcon() { return this.mIcon; } public CharSequence getName() { return this.mName; } public CustomAction(String str, CharSequence charSequence, int i, Bundle bundle) { this.mAction = str; this.mName = charSequence; this.mIcon = i; this.mExtras = bundle; } public 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()); } @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); } public static CustomAction fromCustomAction(Object obj) { if (obj == null) { return null; } PlaybackState.CustomAction customAction = (PlaybackState.CustomAction) obj; Bundle extras = customAction.getExtras(); MediaSessionCompat.ensureClassLoader(extras); CustomAction customAction2 = new CustomAction(customAction.getAction(), customAction.getName(), customAction.getIcon(), extras); customAction2.mCustomActionFwk = customAction; return customAction2; } public Object getCustomAction() { PlaybackState.CustomAction customAction = this.mCustomActionFwk; if (customAction != null) { return customAction; } PlaybackState.CustomAction.Builder builder = new PlaybackState.CustomAction.Builder(this.mAction, this.mName, this.mIcon); builder.setExtras(this.mExtras); return builder.build(); } public String toString() { return "Action:mName='" + ((Object) this.mName) + ", mIcon=" + this.mIcon + ", mExtras=" + this.mExtras; } public static final class Builder { private final String mAction; private Bundle mExtras; private final int mIcon; private final CharSequence mName; public Builder setExtras(Bundle bundle) { this.mExtras = bundle; return this; } public Builder(String str, CharSequence charSequence, int i) { if (TextUtils.isEmpty(str)) { throw new IllegalArgumentException("You must specify an action to build a CustomAction"); } if (TextUtils.isEmpty(charSequence)) { throw new IllegalArgumentException("You must specify a name to build a CustomAction"); } if (i == 0) { throw new IllegalArgumentException("You must specify an icon resource id to build a CustomAction"); } this.mAction = str; this.mName = charSequence; this.mIcon = i; } public CustomAction build() { return new CustomAction(this.mAction, this.mName, this.mIcon, this.mExtras); } } } public static final class Builder { private long mActions; private long mActiveItemId; private long mBufferedPosition; private final List mCustomActions; private int mErrorCode; private CharSequence mErrorMessage; private Bundle mExtras; private long mPosition; private float mRate; private int mState; private long mUpdateTime; public Builder setActions(long j) { this.mActions = j; return this; } public Builder setActiveQueueItemId(long j) { this.mActiveItemId = j; return this; } public Builder setBufferedPosition(long j) { this.mBufferedPosition = j; return this; } public Builder setErrorMessage(int i, CharSequence charSequence) { this.mErrorCode = i; this.mErrorMessage = charSequence; return this; } @Deprecated public Builder setErrorMessage(CharSequence charSequence) { this.mErrorMessage = charSequence; return this; } public Builder setExtras(Bundle bundle) { this.mExtras = bundle; return this; } public Builder setState(int i, long j, float f, long j2) { this.mState = i; this.mPosition = j; this.mUpdateTime = j2; this.mRate = f; return this; } public Builder() { this.mCustomActions = new ArrayList(); this.mActiveItemId = -1L; } public Builder(PlaybackStateCompat playbackStateCompat) { ArrayList arrayList = new ArrayList(); this.mCustomActions = arrayList; this.mActiveItemId = -1L; this.mState = playbackStateCompat.mState; this.mPosition = playbackStateCompat.mPosition; this.mRate = playbackStateCompat.mSpeed; this.mUpdateTime = playbackStateCompat.mUpdateTime; this.mBufferedPosition = playbackStateCompat.mBufferedPosition; this.mActions = playbackStateCompat.mActions; this.mErrorCode = playbackStateCompat.mErrorCode; this.mErrorMessage = playbackStateCompat.mErrorMessage; List list = playbackStateCompat.mCustomActions; if (list != null) { arrayList.addAll(list); } this.mActiveItemId = playbackStateCompat.mActiveItemId; this.mExtras = playbackStateCompat.mExtras; } public Builder setState(int i, long j, float f) { return setState(i, j, f, SystemClock.elapsedRealtime()); } public Builder addCustomAction(String str, String str2, int i) { return addCustomAction(new CustomAction(str, str2, i, null)); } public Builder addCustomAction(CustomAction customAction) { if (customAction == null) { throw new IllegalArgumentException("You may not add a null CustomAction to PlaybackStateCompat"); } this.mCustomActions.add(customAction); return this; } public PlaybackStateCompat build() { return new PlaybackStateCompat(this.mState, this.mPosition, this.mBufferedPosition, this.mRate, this.mActions, this.mErrorCode, this.mErrorMessage, this.mUpdateTime, this.mCustomActions, this.mActiveItemId, this.mExtras); } } }