Files
rr3-apk/decompiled-community/sources/android/support/v4/media/session/MediaSessionCompat.java
Daniel Elliott c080f0d97f Add Discord community version (64-bit only)
- Added realracing3-community.apk (71.57 MB)
- Removed 32-bit support (armeabi-v7a)
- Only includes arm64-v8a libraries
- Decompiled source code included
- Added README-community.md with analysis
2026-02-18 15:48:36 -08:00

3249 lines
142 KiB
Java

package android.support.v4.media.session;
import android.annotation.SuppressLint;
import android.app.PendingIntent;
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.graphics.Bitmap;
import android.media.AudioAttributes;
import android.media.AudioManager;
import android.media.MediaDescription;
import android.media.MediaMetadata;
import android.media.Rating;
import android.media.RemoteControlClient;
import android.media.VolumeProvider;
import android.media.session.MediaSession;
import android.media.session.MediaSessionManager;
import android.media.session.PlaybackState;
import android.net.Uri;
import android.os.BadParcelableException;
import android.os.Binder;
import android.os.Build;
import android.os.Bundle;
import android.os.Handler;
import android.os.IBinder;
import android.os.Looper;
import android.os.Message;
import android.os.Parcel;
import android.os.Parcelable;
import android.os.RemoteCallbackList;
import android.os.RemoteException;
import android.os.ResultReceiver;
import android.os.SystemClock;
import android.support.v4.media.MediaDescriptionCompat;
import android.support.v4.media.MediaMetadataCompat;
import android.support.v4.media.RatingCompat;
import android.support.v4.media.session.IMediaSession;
import android.support.v4.media.session.PlaybackStateCompat;
import android.text.TextUtils;
import android.util.Log;
import android.util.TypedValue;
import android.view.KeyEvent;
import android.view.ViewConfiguration;
import androidx.annotation.GuardedBy;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.annotation.RequiresApi;
import androidx.annotation.RestrictTo;
import androidx.core.app.BundleCompat;
import androidx.media.MediaSessionManager;
import androidx.media.VolumeProviderCompat;
import androidx.media.session.MediaButtonReceiver;
import androidx.versionedparcelable.ParcelUtils;
import androidx.versionedparcelable.VersionedParcelable;
import com.mbridge.msdk.playercommon.exoplayer2.extractor.ts.TsExtractor;
import java.lang.ref.WeakReference;
import java.lang.reflect.Field;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
/* loaded from: classes.dex */
public class MediaSessionCompat {
@RestrictTo({RestrictTo.Scope.LIBRARY})
public static final String ACTION_ARGUMENT_CAPTIONING_ENABLED = "android.support.v4.media.session.action.ARGUMENT_CAPTIONING_ENABLED";
@RestrictTo({RestrictTo.Scope.LIBRARY})
public static final String ACTION_ARGUMENT_EXTRAS = "android.support.v4.media.session.action.ARGUMENT_EXTRAS";
@RestrictTo({RestrictTo.Scope.LIBRARY})
public static final String ACTION_ARGUMENT_MEDIA_ID = "android.support.v4.media.session.action.ARGUMENT_MEDIA_ID";
@RestrictTo({RestrictTo.Scope.LIBRARY})
public static final String ACTION_ARGUMENT_PLAYBACK_SPEED = "android.support.v4.media.session.action.ARGUMENT_PLAYBACK_SPEED";
@RestrictTo({RestrictTo.Scope.LIBRARY})
public static final String ACTION_ARGUMENT_QUERY = "android.support.v4.media.session.action.ARGUMENT_QUERY";
@RestrictTo({RestrictTo.Scope.LIBRARY})
public static final String ACTION_ARGUMENT_RATING = "android.support.v4.media.session.action.ARGUMENT_RATING";
@RestrictTo({RestrictTo.Scope.LIBRARY})
public static final String ACTION_ARGUMENT_REPEAT_MODE = "android.support.v4.media.session.action.ARGUMENT_REPEAT_MODE";
@RestrictTo({RestrictTo.Scope.LIBRARY})
public static final String ACTION_ARGUMENT_SHUFFLE_MODE = "android.support.v4.media.session.action.ARGUMENT_SHUFFLE_MODE";
@RestrictTo({RestrictTo.Scope.LIBRARY})
public static final String ACTION_ARGUMENT_URI = "android.support.v4.media.session.action.ARGUMENT_URI";
public static final String ACTION_FLAG_AS_INAPPROPRIATE = "android.support.v4.media.session.action.FLAG_AS_INAPPROPRIATE";
public static final String ACTION_FOLLOW = "android.support.v4.media.session.action.FOLLOW";
@RestrictTo({RestrictTo.Scope.LIBRARY})
public static final String ACTION_PLAY_FROM_URI = "android.support.v4.media.session.action.PLAY_FROM_URI";
@RestrictTo({RestrictTo.Scope.LIBRARY})
public static final String ACTION_PREPARE = "android.support.v4.media.session.action.PREPARE";
@RestrictTo({RestrictTo.Scope.LIBRARY})
public static final String ACTION_PREPARE_FROM_MEDIA_ID = "android.support.v4.media.session.action.PREPARE_FROM_MEDIA_ID";
@RestrictTo({RestrictTo.Scope.LIBRARY})
public static final String ACTION_PREPARE_FROM_SEARCH = "android.support.v4.media.session.action.PREPARE_FROM_SEARCH";
@RestrictTo({RestrictTo.Scope.LIBRARY})
public static final String ACTION_PREPARE_FROM_URI = "android.support.v4.media.session.action.PREPARE_FROM_URI";
@RestrictTo({RestrictTo.Scope.LIBRARY})
public static final String ACTION_SET_CAPTIONING_ENABLED = "android.support.v4.media.session.action.SET_CAPTIONING_ENABLED";
@RestrictTo({RestrictTo.Scope.LIBRARY})
public static final String ACTION_SET_PLAYBACK_SPEED = "android.support.v4.media.session.action.SET_PLAYBACK_SPEED";
@RestrictTo({RestrictTo.Scope.LIBRARY})
public static final String ACTION_SET_RATING = "android.support.v4.media.session.action.SET_RATING";
@RestrictTo({RestrictTo.Scope.LIBRARY})
public static final String ACTION_SET_REPEAT_MODE = "android.support.v4.media.session.action.SET_REPEAT_MODE";
@RestrictTo({RestrictTo.Scope.LIBRARY})
public static final String ACTION_SET_SHUFFLE_MODE = "android.support.v4.media.session.action.SET_SHUFFLE_MODE";
public static final String ACTION_SKIP_AD = "android.support.v4.media.session.action.SKIP_AD";
public static final String ACTION_UNFOLLOW = "android.support.v4.media.session.action.UNFOLLOW";
public static final String ARGUMENT_MEDIA_ATTRIBUTE = "android.support.v4.media.session.ARGUMENT_MEDIA_ATTRIBUTE";
public static final String ARGUMENT_MEDIA_ATTRIBUTE_VALUE = "android.support.v4.media.session.ARGUMENT_MEDIA_ATTRIBUTE_VALUE";
private static final String DATA_CALLING_PACKAGE = "data_calling_pkg";
private static final String DATA_CALLING_PID = "data_calling_pid";
private static final String DATA_CALLING_UID = "data_calling_uid";
private static final String DATA_EXTRAS = "data_extras";
@Deprecated
public static final int FLAG_HANDLES_MEDIA_BUTTONS = 1;
public static final int FLAG_HANDLES_QUEUE_COMMANDS = 4;
@Deprecated
public static final int FLAG_HANDLES_TRANSPORT_CONTROLS = 2;
@RestrictTo({RestrictTo.Scope.LIBRARY})
public static final String KEY_EXTRA_BINDER = "android.support.v4.media.session.EXTRA_BINDER";
@RestrictTo({RestrictTo.Scope.LIBRARY})
public static final String KEY_SESSION2_TOKEN = "android.support.v4.media.session.SESSION_TOKEN2";
@RestrictTo({RestrictTo.Scope.LIBRARY})
public static final String KEY_TOKEN = "android.support.v4.media.session.TOKEN";
private static final int MAX_BITMAP_SIZE_IN_DP = 320;
public static final int MEDIA_ATTRIBUTE_ALBUM = 1;
public static final int MEDIA_ATTRIBUTE_ARTIST = 0;
public static final int MEDIA_ATTRIBUTE_PLAYLIST = 2;
@RestrictTo({RestrictTo.Scope.LIBRARY})
public static final int PENDING_INTENT_FLAG_MUTABLE;
static final String TAG = "MediaSessionCompat";
static int sMaxBitmapSize;
private final ArrayList<OnActiveChangeListener> mActiveListeners;
private final MediaControllerCompat mController;
private final MediaSessionImpl mImpl;
public interface MediaSessionImpl {
Callback getCallback();
String getCallingPackage();
MediaSessionManager.RemoteUserInfo getCurrentControllerInfo();
Object getMediaSession();
PlaybackStateCompat getPlaybackState();
Object getRemoteControlClient();
Token getSessionToken();
boolean isActive();
void release();
void sendSessionEvent(String str, Bundle bundle);
void setActive(boolean z);
void setCallback(Callback callback, Handler handler);
void setCaptioningEnabled(boolean z);
void setCurrentControllerInfo(MediaSessionManager.RemoteUserInfo remoteUserInfo);
void setExtras(Bundle bundle);
void setFlags(int i);
void setMediaButtonReceiver(PendingIntent pendingIntent);
void setMetadata(MediaMetadataCompat mediaMetadataCompat);
void setPlaybackState(PlaybackStateCompat playbackStateCompat);
void setPlaybackToLocal(int i);
void setPlaybackToRemote(VolumeProviderCompat volumeProviderCompat);
void setQueue(List<QueueItem> list);
void setQueueTitle(CharSequence charSequence);
void setRatingType(int i);
void setRepeatMode(int i);
void setSessionActivity(PendingIntent pendingIntent);
void setShuffleMode(int i);
}
public interface OnActiveChangeListener {
void onActiveChanged();
}
public MediaControllerCompat getController() {
return this.mController;
}
static {
PENDING_INTENT_FLAG_MUTABLE = Build.VERSION.CODENAME.equals("S") ? 33554432 : 0;
}
public MediaSessionCompat(@NonNull Context context, @NonNull String str) {
this(context, str, null, null);
}
public MediaSessionCompat(@NonNull Context context, @NonNull String str, @Nullable ComponentName componentName, @Nullable PendingIntent pendingIntent) {
this(context, str, componentName, pendingIntent, null);
}
public MediaSessionCompat(@NonNull Context context, @NonNull String str, @Nullable ComponentName componentName, @Nullable PendingIntent pendingIntent, @Nullable Bundle bundle) {
this(context, str, componentName, pendingIntent, bundle, null);
}
@SuppressLint({"WrongConstant"})
@RestrictTo({RestrictTo.Scope.LIBRARY_GROUP_PREFIX})
public MediaSessionCompat(@NonNull Context context, @NonNull String str, @Nullable ComponentName componentName, @Nullable PendingIntent pendingIntent, @Nullable Bundle bundle, @Nullable VersionedParcelable versionedParcelable) {
this.mActiveListeners = new ArrayList<>();
if (context == null) {
throw new IllegalArgumentException("context must not be null");
}
if (TextUtils.isEmpty(str)) {
throw new IllegalArgumentException("tag must not be null or empty");
}
if (componentName == null && (componentName = MediaButtonReceiver.getMediaButtonReceiverComponent(context)) == null) {
Log.w(TAG, "Couldn't find a unique registered media button receiver in the given context.");
}
if (componentName != null && pendingIntent == null) {
Intent intent = new Intent("android.intent.action.MEDIA_BUTTON");
intent.setComponent(componentName);
pendingIntent = PendingIntent.getBroadcast(context, 0, intent, PENDING_INTENT_FLAG_MUTABLE);
}
int i = Build.VERSION.SDK_INT;
MediaSession createFwkMediaSession = createFwkMediaSession(context, str, bundle);
if (i >= 29) {
this.mImpl = new MediaSessionImplApi29(createFwkMediaSession, versionedParcelable, bundle);
} else if (i >= 28) {
this.mImpl = new MediaSessionImplApi28(createFwkMediaSession, versionedParcelable, bundle);
} else {
this.mImpl = new MediaSessionImplApi21(createFwkMediaSession, versionedParcelable, bundle);
}
setCallback(new Callback() { // from class: android.support.v4.media.session.MediaSessionCompat.1
}, new Handler(Looper.myLooper() != null ? Looper.myLooper() : Looper.getMainLooper()));
this.mImpl.setMediaButtonReceiver(pendingIntent);
this.mController = new MediaControllerCompat(context, this);
if (sMaxBitmapSize == 0) {
sMaxBitmapSize = (int) (TypedValue.applyDimension(1, 320.0f, context.getResources().getDisplayMetrics()) + 0.5f);
}
}
private MediaSessionCompat(Context context, MediaSessionImpl mediaSessionImpl) {
this.mActiveListeners = new ArrayList<>();
this.mImpl = mediaSessionImpl;
this.mController = new MediaControllerCompat(context, this);
}
@RequiresApi(21)
private MediaSession createFwkMediaSession(Context context, String str, Bundle bundle) {
if (Build.VERSION.SDK_INT >= 29) {
return MediaSessionCompat$$ExternalSyntheticApiModelOutline0.m(context, str, bundle);
}
return new MediaSession(context, str);
}
public void setCallback(Callback callback) {
setCallback(callback, null);
}
public void setCallback(Callback callback, Handler handler) {
if (callback == null) {
this.mImpl.setCallback(null, null);
return;
}
MediaSessionImpl mediaSessionImpl = this.mImpl;
if (handler == null) {
handler = new Handler();
}
mediaSessionImpl.setCallback(callback, handler);
}
public void setSessionActivity(PendingIntent pendingIntent) {
this.mImpl.setSessionActivity(pendingIntent);
}
public void setMediaButtonReceiver(PendingIntent pendingIntent) {
this.mImpl.setMediaButtonReceiver(pendingIntent);
}
public void setFlags(int i) {
this.mImpl.setFlags(i);
}
public void setPlaybackToLocal(int i) {
this.mImpl.setPlaybackToLocal(i);
}
public void setPlaybackToRemote(VolumeProviderCompat volumeProviderCompat) {
if (volumeProviderCompat == null) {
throw new IllegalArgumentException("volumeProvider may not be null!");
}
this.mImpl.setPlaybackToRemote(volumeProviderCompat);
}
public void setActive(boolean z) {
this.mImpl.setActive(z);
Iterator<OnActiveChangeListener> it = this.mActiveListeners.iterator();
while (it.hasNext()) {
it.next().onActiveChanged();
}
}
public boolean isActive() {
return this.mImpl.isActive();
}
public void sendSessionEvent(String str, Bundle bundle) {
if (TextUtils.isEmpty(str)) {
throw new IllegalArgumentException("event cannot be null or empty");
}
this.mImpl.sendSessionEvent(str, bundle);
}
public void release() {
this.mImpl.release();
}
public Token getSessionToken() {
return this.mImpl.getSessionToken();
}
public void setPlaybackState(PlaybackStateCompat playbackStateCompat) {
this.mImpl.setPlaybackState(playbackStateCompat);
}
public void setMetadata(MediaMetadataCompat mediaMetadataCompat) {
this.mImpl.setMetadata(mediaMetadataCompat);
}
public void setQueue(List<QueueItem> list) {
if (list != null) {
HashSet hashSet = new HashSet();
for (QueueItem queueItem : list) {
if (queueItem == null) {
throw new IllegalArgumentException("queue shouldn't have null items");
}
if (hashSet.contains(Long.valueOf(queueItem.getQueueId()))) {
Log.e(TAG, "Found duplicate queue id: " + queueItem.getQueueId(), new IllegalArgumentException("id of each queue item should be unique"));
}
hashSet.add(Long.valueOf(queueItem.getQueueId()));
}
}
this.mImpl.setQueue(list);
}
public void setQueueTitle(CharSequence charSequence) {
this.mImpl.setQueueTitle(charSequence);
}
public void setRatingType(int i) {
this.mImpl.setRatingType(i);
}
public void setCaptioningEnabled(boolean z) {
this.mImpl.setCaptioningEnabled(z);
}
public void setRepeatMode(int i) {
this.mImpl.setRepeatMode(i);
}
public void setShuffleMode(int i) {
this.mImpl.setShuffleMode(i);
}
public void setExtras(Bundle bundle) {
this.mImpl.setExtras(bundle);
}
public Object getMediaSession() {
return this.mImpl.getMediaSession();
}
public Object getRemoteControlClient() {
return this.mImpl.getRemoteControlClient();
}
@NonNull
public final MediaSessionManager.RemoteUserInfo getCurrentControllerInfo() {
return this.mImpl.getCurrentControllerInfo();
}
@RestrictTo({RestrictTo.Scope.LIBRARY})
public String getCallingPackage() {
return this.mImpl.getCallingPackage();
}
public void addOnActiveChangeListener(OnActiveChangeListener onActiveChangeListener) {
if (onActiveChangeListener == null) {
throw new IllegalArgumentException("Listener may not be null");
}
this.mActiveListeners.add(onActiveChangeListener);
}
public void removeOnActiveChangeListener(OnActiveChangeListener onActiveChangeListener) {
if (onActiveChangeListener == null) {
throw new IllegalArgumentException("Listener may not be null");
}
this.mActiveListeners.remove(onActiveChangeListener);
}
public static MediaSessionCompat fromMediaSession(Context context, Object obj) {
MediaSessionImpl mediaSessionImplApi21;
int i = Build.VERSION.SDK_INT;
if (context == null || obj == null) {
return null;
}
if (i >= 29) {
mediaSessionImplApi21 = new MediaSessionImplApi29(obj);
} else if (i >= 28) {
mediaSessionImplApi21 = new MediaSessionImplApi28(obj);
} else {
mediaSessionImplApi21 = new MediaSessionImplApi21(obj);
}
return new MediaSessionCompat(context, mediaSessionImplApi21);
}
@RestrictTo({RestrictTo.Scope.LIBRARY})
public static void ensureClassLoader(@Nullable Bundle bundle) {
if (bundle != null) {
bundle.setClassLoader(MediaSessionCompat.class.getClassLoader());
}
}
@Nullable
@RestrictTo({RestrictTo.Scope.LIBRARY})
public static Bundle unparcelWithClassLoader(@Nullable Bundle bundle) {
if (bundle == null) {
return null;
}
ensureClassLoader(bundle);
try {
bundle.isEmpty();
return bundle;
} catch (BadParcelableException unused) {
Log.e(TAG, "Could not unparcel the data.");
return null;
}
}
public static PlaybackStateCompat getStateWithUpdatedPosition(PlaybackStateCompat playbackStateCompat, MediaMetadataCompat mediaMetadataCompat) {
if (playbackStateCompat == null) {
return playbackStateCompat;
}
long j = -1;
if (playbackStateCompat.getPosition() == -1) {
return playbackStateCompat;
}
if (playbackStateCompat.getState() != 3 && playbackStateCompat.getState() != 4 && playbackStateCompat.getState() != 5) {
return playbackStateCompat;
}
if (playbackStateCompat.getLastPositionUpdateTime() <= 0) {
return playbackStateCompat;
}
long elapsedRealtime = SystemClock.elapsedRealtime();
long playbackSpeed = ((long) (playbackStateCompat.getPlaybackSpeed() * (elapsedRealtime - r0))) + playbackStateCompat.getPosition();
if (mediaMetadataCompat != null && mediaMetadataCompat.containsKey(MediaMetadataCompat.METADATA_KEY_DURATION)) {
j = mediaMetadataCompat.getLong(MediaMetadataCompat.METADATA_KEY_DURATION);
}
return new PlaybackStateCompat.Builder(playbackStateCompat).setState(playbackStateCompat.getState(), (j < 0 || playbackSpeed <= j) ? playbackSpeed < 0 ? 0L : playbackSpeed : j, playbackStateCompat.getPlaybackSpeed(), elapsedRealtime).build();
}
public static abstract class Callback {
@GuardedBy("mLock")
CallbackHandler mCallbackHandler;
private boolean mMediaPlayPausePendingOnHandler;
final Object mLock = new Object();
final MediaSession.Callback mCallbackFwk = new MediaSessionCallbackApi21();
@GuardedBy("mLock")
WeakReference<MediaSessionImpl> mSessionImpl = new WeakReference<>(null);
public void onAddQueueItem(MediaDescriptionCompat mediaDescriptionCompat) {
}
public void onAddQueueItem(MediaDescriptionCompat mediaDescriptionCompat, int i) {
}
public void onCommand(String str, Bundle bundle, ResultReceiver resultReceiver) {
}
public void onCustomAction(String str, Bundle bundle) {
}
public void onFastForward() {
}
public void onPause() {
}
public void onPlay() {
}
public void onPlayFromMediaId(String str, Bundle bundle) {
}
public void onPlayFromSearch(String str, Bundle bundle) {
}
public void onPlayFromUri(Uri uri, Bundle bundle) {
}
public void onPrepare() {
}
public void onPrepareFromMediaId(String str, Bundle bundle) {
}
public void onPrepareFromSearch(String str, Bundle bundle) {
}
public void onPrepareFromUri(Uri uri, Bundle bundle) {
}
public void onRemoveQueueItem(MediaDescriptionCompat mediaDescriptionCompat) {
}
@Deprecated
public void onRemoveQueueItemAt(int i) {
}
public void onRewind() {
}
public void onSeekTo(long j) {
}
public void onSetCaptioningEnabled(boolean z) {
}
public void onSetPlaybackSpeed(float f) {
}
public void onSetRating(RatingCompat ratingCompat) {
}
public void onSetRating(RatingCompat ratingCompat, Bundle bundle) {
}
public void onSetRepeatMode(int i) {
}
public void onSetShuffleMode(int i) {
}
public void onSkipToNext() {
}
public void onSkipToPrevious() {
}
public void onSkipToQueueItem(long j) {
}
public void onStop() {
}
public void setSessionImpl(MediaSessionImpl mediaSessionImpl, Handler handler) {
synchronized (this.mLock) {
try {
this.mSessionImpl = new WeakReference<>(mediaSessionImpl);
CallbackHandler callbackHandler = this.mCallbackHandler;
CallbackHandler callbackHandler2 = null;
if (callbackHandler != null) {
callbackHandler.removeCallbacksAndMessages(null);
}
if (mediaSessionImpl != null && handler != null) {
callbackHandler2 = new CallbackHandler(handler.getLooper());
}
this.mCallbackHandler = callbackHandler2;
} catch (Throwable th) {
throw th;
}
}
}
public boolean onMediaButtonEvent(Intent intent) {
MediaSessionImpl mediaSessionImpl;
CallbackHandler callbackHandler;
KeyEvent keyEvent;
if (Build.VERSION.SDK_INT >= 27) {
return false;
}
synchronized (this.mLock) {
mediaSessionImpl = this.mSessionImpl.get();
callbackHandler = this.mCallbackHandler;
}
if (mediaSessionImpl == null || callbackHandler == null || (keyEvent = (KeyEvent) intent.getParcelableExtra("android.intent.extra.KEY_EVENT")) == null || keyEvent.getAction() != 0) {
return false;
}
MediaSessionManager.RemoteUserInfo currentControllerInfo = mediaSessionImpl.getCurrentControllerInfo();
int keyCode = keyEvent.getKeyCode();
if (keyCode == 79 || keyCode == 85) {
if (keyEvent.getRepeatCount() != 0) {
handleMediaPlayPauseIfPendingOnHandler(mediaSessionImpl, callbackHandler);
} else if (this.mMediaPlayPausePendingOnHandler) {
callbackHandler.removeMessages(1);
this.mMediaPlayPausePendingOnHandler = false;
PlaybackStateCompat playbackState = mediaSessionImpl.getPlaybackState();
if (((playbackState == null ? 0L : playbackState.getActions()) & 32) != 0) {
onSkipToNext();
}
} else {
this.mMediaPlayPausePendingOnHandler = true;
callbackHandler.sendMessageDelayed(callbackHandler.obtainMessage(1, currentControllerInfo), ViewConfiguration.getDoubleTapTimeout());
}
return true;
}
handleMediaPlayPauseIfPendingOnHandler(mediaSessionImpl, callbackHandler);
return false;
}
public void handleMediaPlayPauseIfPendingOnHandler(MediaSessionImpl mediaSessionImpl, Handler handler) {
if (this.mMediaPlayPausePendingOnHandler) {
this.mMediaPlayPausePendingOnHandler = false;
handler.removeMessages(1);
PlaybackStateCompat playbackState = mediaSessionImpl.getPlaybackState();
long actions = playbackState == null ? 0L : playbackState.getActions();
boolean z = playbackState != null && playbackState.getState() == 3;
boolean z2 = (516 & actions) != 0;
boolean z3 = (actions & 514) != 0;
if (z && z3) {
onPause();
} else {
if (z || !z2) {
return;
}
onPlay();
}
}
}
public class CallbackHandler extends Handler {
private static final int MSG_MEDIA_PLAY_PAUSE_KEY_DOUBLE_TAP_TIMEOUT = 1;
public CallbackHandler(Looper looper) {
super(looper);
}
@Override // android.os.Handler
public void handleMessage(Message message) {
MediaSessionImpl mediaSessionImpl;
Callback callback;
CallbackHandler callbackHandler;
if (message.what == 1) {
synchronized (Callback.this.mLock) {
mediaSessionImpl = Callback.this.mSessionImpl.get();
callback = Callback.this;
callbackHandler = callback.mCallbackHandler;
}
if (mediaSessionImpl == null || callback != mediaSessionImpl.getCallback() || callbackHandler == null) {
return;
}
mediaSessionImpl.setCurrentControllerInfo((MediaSessionManager.RemoteUserInfo) message.obj);
Callback.this.handleMediaPlayPauseIfPendingOnHandler(mediaSessionImpl, callbackHandler);
mediaSessionImpl.setCurrentControllerInfo(null);
}
}
}
@RequiresApi(21)
public class MediaSessionCallbackApi21 extends MediaSession.Callback {
public void onSetRating(Rating rating, Bundle bundle) {
}
public MediaSessionCallbackApi21() {
}
@Override // android.media.session.MediaSession.Callback
public void onCommand(String str, Bundle bundle, ResultReceiver resultReceiver) {
MediaSessionImplApi21 sessionImplIfCallbackIsSet = getSessionImplIfCallbackIsSet();
if (sessionImplIfCallbackIsSet == null) {
return;
}
MediaSessionCompat.ensureClassLoader(bundle);
setCurrentControllerInfo(sessionImplIfCallbackIsSet);
try {
QueueItem queueItem = null;
IBinder asBinder = null;
queueItem = null;
if (str.equals(MediaControllerCompat.COMMAND_GET_EXTRA_BINDER)) {
Bundle bundle2 = new Bundle();
Token sessionToken = sessionImplIfCallbackIsSet.getSessionToken();
IMediaSession extraBinder = sessionToken.getExtraBinder();
if (extraBinder != null) {
asBinder = extraBinder.asBinder();
}
BundleCompat.putBinder(bundle2, MediaSessionCompat.KEY_EXTRA_BINDER, asBinder);
ParcelUtils.putVersionedParcelable(bundle2, MediaSessionCompat.KEY_SESSION2_TOKEN, sessionToken.getSession2Token());
resultReceiver.send(0, bundle2);
} else if (str.equals(MediaControllerCompat.COMMAND_ADD_QUEUE_ITEM)) {
Callback.this.onAddQueueItem((MediaDescriptionCompat) bundle.getParcelable(MediaControllerCompat.COMMAND_ARGUMENT_MEDIA_DESCRIPTION));
} else if (str.equals(MediaControllerCompat.COMMAND_ADD_QUEUE_ITEM_AT)) {
Callback.this.onAddQueueItem((MediaDescriptionCompat) bundle.getParcelable(MediaControllerCompat.COMMAND_ARGUMENT_MEDIA_DESCRIPTION), bundle.getInt(MediaControllerCompat.COMMAND_ARGUMENT_INDEX));
} else if (str.equals(MediaControllerCompat.COMMAND_REMOVE_QUEUE_ITEM)) {
Callback.this.onRemoveQueueItem((MediaDescriptionCompat) bundle.getParcelable(MediaControllerCompat.COMMAND_ARGUMENT_MEDIA_DESCRIPTION));
} else if (str.equals(MediaControllerCompat.COMMAND_REMOVE_QUEUE_ITEM_AT)) {
if (sessionImplIfCallbackIsSet.mQueue != null) {
int i = bundle.getInt(MediaControllerCompat.COMMAND_ARGUMENT_INDEX, -1);
if (i >= 0 && i < sessionImplIfCallbackIsSet.mQueue.size()) {
queueItem = sessionImplIfCallbackIsSet.mQueue.get(i);
}
if (queueItem != null) {
Callback.this.onRemoveQueueItem(queueItem.getDescription());
}
}
} else {
Callback.this.onCommand(str, bundle, resultReceiver);
}
} catch (BadParcelableException unused) {
Log.e(MediaSessionCompat.TAG, "Could not unparcel the extra data.");
}
clearCurrentControllerInfo(sessionImplIfCallbackIsSet);
}
@Override // android.media.session.MediaSession.Callback
public boolean onMediaButtonEvent(Intent intent) {
MediaSessionImplApi21 sessionImplIfCallbackIsSet = getSessionImplIfCallbackIsSet();
if (sessionImplIfCallbackIsSet == null) {
return false;
}
setCurrentControllerInfo(sessionImplIfCallbackIsSet);
boolean onMediaButtonEvent = Callback.this.onMediaButtonEvent(intent);
clearCurrentControllerInfo(sessionImplIfCallbackIsSet);
return onMediaButtonEvent || super.onMediaButtonEvent(intent);
}
@Override // android.media.session.MediaSession.Callback
public void onPlay() {
MediaSessionImplApi21 sessionImplIfCallbackIsSet = getSessionImplIfCallbackIsSet();
if (sessionImplIfCallbackIsSet == null) {
return;
}
setCurrentControllerInfo(sessionImplIfCallbackIsSet);
Callback.this.onPlay();
clearCurrentControllerInfo(sessionImplIfCallbackIsSet);
}
@Override // android.media.session.MediaSession.Callback
public void onPlayFromMediaId(String str, Bundle bundle) {
MediaSessionImplApi21 sessionImplIfCallbackIsSet = getSessionImplIfCallbackIsSet();
if (sessionImplIfCallbackIsSet == null) {
return;
}
MediaSessionCompat.ensureClassLoader(bundle);
setCurrentControllerInfo(sessionImplIfCallbackIsSet);
Callback.this.onPlayFromMediaId(str, bundle);
clearCurrentControllerInfo(sessionImplIfCallbackIsSet);
}
@Override // android.media.session.MediaSession.Callback
public void onPlayFromSearch(String str, Bundle bundle) {
MediaSessionImplApi21 sessionImplIfCallbackIsSet = getSessionImplIfCallbackIsSet();
if (sessionImplIfCallbackIsSet == null) {
return;
}
MediaSessionCompat.ensureClassLoader(bundle);
setCurrentControllerInfo(sessionImplIfCallbackIsSet);
Callback.this.onPlayFromSearch(str, bundle);
clearCurrentControllerInfo(sessionImplIfCallbackIsSet);
}
@Override // android.media.session.MediaSession.Callback
@RequiresApi(23)
public void onPlayFromUri(Uri uri, Bundle bundle) {
MediaSessionImplApi21 sessionImplIfCallbackIsSet = getSessionImplIfCallbackIsSet();
if (sessionImplIfCallbackIsSet == null) {
return;
}
MediaSessionCompat.ensureClassLoader(bundle);
setCurrentControllerInfo(sessionImplIfCallbackIsSet);
Callback.this.onPlayFromUri(uri, bundle);
clearCurrentControllerInfo(sessionImplIfCallbackIsSet);
}
@Override // android.media.session.MediaSession.Callback
public void onSkipToQueueItem(long j) {
MediaSessionImplApi21 sessionImplIfCallbackIsSet = getSessionImplIfCallbackIsSet();
if (sessionImplIfCallbackIsSet == null) {
return;
}
setCurrentControllerInfo(sessionImplIfCallbackIsSet);
Callback.this.onSkipToQueueItem(j);
clearCurrentControllerInfo(sessionImplIfCallbackIsSet);
}
@Override // android.media.session.MediaSession.Callback
public void onPause() {
MediaSessionImplApi21 sessionImplIfCallbackIsSet = getSessionImplIfCallbackIsSet();
if (sessionImplIfCallbackIsSet == null) {
return;
}
setCurrentControllerInfo(sessionImplIfCallbackIsSet);
Callback.this.onPause();
clearCurrentControllerInfo(sessionImplIfCallbackIsSet);
}
@Override // android.media.session.MediaSession.Callback
public void onSkipToNext() {
MediaSessionImplApi21 sessionImplIfCallbackIsSet = getSessionImplIfCallbackIsSet();
if (sessionImplIfCallbackIsSet == null) {
return;
}
setCurrentControllerInfo(sessionImplIfCallbackIsSet);
Callback.this.onSkipToNext();
clearCurrentControllerInfo(sessionImplIfCallbackIsSet);
}
@Override // android.media.session.MediaSession.Callback
public void onSkipToPrevious() {
MediaSessionImplApi21 sessionImplIfCallbackIsSet = getSessionImplIfCallbackIsSet();
if (sessionImplIfCallbackIsSet == null) {
return;
}
setCurrentControllerInfo(sessionImplIfCallbackIsSet);
Callback.this.onSkipToPrevious();
clearCurrentControllerInfo(sessionImplIfCallbackIsSet);
}
@Override // android.media.session.MediaSession.Callback
public void onFastForward() {
MediaSessionImplApi21 sessionImplIfCallbackIsSet = getSessionImplIfCallbackIsSet();
if (sessionImplIfCallbackIsSet == null) {
return;
}
setCurrentControllerInfo(sessionImplIfCallbackIsSet);
Callback.this.onFastForward();
clearCurrentControllerInfo(sessionImplIfCallbackIsSet);
}
@Override // android.media.session.MediaSession.Callback
public void onRewind() {
MediaSessionImplApi21 sessionImplIfCallbackIsSet = getSessionImplIfCallbackIsSet();
if (sessionImplIfCallbackIsSet == null) {
return;
}
setCurrentControllerInfo(sessionImplIfCallbackIsSet);
Callback.this.onRewind();
clearCurrentControllerInfo(sessionImplIfCallbackIsSet);
}
@Override // android.media.session.MediaSession.Callback
public void onStop() {
MediaSessionImplApi21 sessionImplIfCallbackIsSet = getSessionImplIfCallbackIsSet();
if (sessionImplIfCallbackIsSet == null) {
return;
}
setCurrentControllerInfo(sessionImplIfCallbackIsSet);
Callback.this.onStop();
clearCurrentControllerInfo(sessionImplIfCallbackIsSet);
}
@Override // android.media.session.MediaSession.Callback
public void onSeekTo(long j) {
MediaSessionImplApi21 sessionImplIfCallbackIsSet = getSessionImplIfCallbackIsSet();
if (sessionImplIfCallbackIsSet == null) {
return;
}
setCurrentControllerInfo(sessionImplIfCallbackIsSet);
Callback.this.onSeekTo(j);
clearCurrentControllerInfo(sessionImplIfCallbackIsSet);
}
@Override // android.media.session.MediaSession.Callback
public void onSetRating(Rating rating) {
MediaSessionImplApi21 sessionImplIfCallbackIsSet = getSessionImplIfCallbackIsSet();
if (sessionImplIfCallbackIsSet == null) {
return;
}
setCurrentControllerInfo(sessionImplIfCallbackIsSet);
Callback.this.onSetRating(RatingCompat.fromRating(rating));
clearCurrentControllerInfo(sessionImplIfCallbackIsSet);
}
@Override // android.media.session.MediaSession.Callback
public void onCustomAction(String str, Bundle bundle) {
MediaSessionImplApi21 sessionImplIfCallbackIsSet = getSessionImplIfCallbackIsSet();
if (sessionImplIfCallbackIsSet == null) {
return;
}
MediaSessionCompat.ensureClassLoader(bundle);
setCurrentControllerInfo(sessionImplIfCallbackIsSet);
try {
if (str.equals(MediaSessionCompat.ACTION_PLAY_FROM_URI)) {
Uri uri = (Uri) bundle.getParcelable(MediaSessionCompat.ACTION_ARGUMENT_URI);
Bundle bundle2 = bundle.getBundle(MediaSessionCompat.ACTION_ARGUMENT_EXTRAS);
MediaSessionCompat.ensureClassLoader(bundle2);
Callback.this.onPlayFromUri(uri, bundle2);
} else if (str.equals(MediaSessionCompat.ACTION_PREPARE)) {
Callback.this.onPrepare();
} else if (str.equals(MediaSessionCompat.ACTION_PREPARE_FROM_MEDIA_ID)) {
String string = bundle.getString(MediaSessionCompat.ACTION_ARGUMENT_MEDIA_ID);
Bundle bundle3 = bundle.getBundle(MediaSessionCompat.ACTION_ARGUMENT_EXTRAS);
MediaSessionCompat.ensureClassLoader(bundle3);
Callback.this.onPrepareFromMediaId(string, bundle3);
} else if (str.equals(MediaSessionCompat.ACTION_PREPARE_FROM_SEARCH)) {
String string2 = bundle.getString(MediaSessionCompat.ACTION_ARGUMENT_QUERY);
Bundle bundle4 = bundle.getBundle(MediaSessionCompat.ACTION_ARGUMENT_EXTRAS);
MediaSessionCompat.ensureClassLoader(bundle4);
Callback.this.onPrepareFromSearch(string2, bundle4);
} else if (str.equals(MediaSessionCompat.ACTION_PREPARE_FROM_URI)) {
Uri uri2 = (Uri) bundle.getParcelable(MediaSessionCompat.ACTION_ARGUMENT_URI);
Bundle bundle5 = bundle.getBundle(MediaSessionCompat.ACTION_ARGUMENT_EXTRAS);
MediaSessionCompat.ensureClassLoader(bundle5);
Callback.this.onPrepareFromUri(uri2, bundle5);
} else if (str.equals(MediaSessionCompat.ACTION_SET_CAPTIONING_ENABLED)) {
Callback.this.onSetCaptioningEnabled(bundle.getBoolean(MediaSessionCompat.ACTION_ARGUMENT_CAPTIONING_ENABLED));
} else if (str.equals(MediaSessionCompat.ACTION_SET_REPEAT_MODE)) {
Callback.this.onSetRepeatMode(bundle.getInt(MediaSessionCompat.ACTION_ARGUMENT_REPEAT_MODE));
} else if (str.equals(MediaSessionCompat.ACTION_SET_SHUFFLE_MODE)) {
Callback.this.onSetShuffleMode(bundle.getInt(MediaSessionCompat.ACTION_ARGUMENT_SHUFFLE_MODE));
} else if (str.equals(MediaSessionCompat.ACTION_SET_RATING)) {
RatingCompat ratingCompat = (RatingCompat) bundle.getParcelable(MediaSessionCompat.ACTION_ARGUMENT_RATING);
Bundle bundle6 = bundle.getBundle(MediaSessionCompat.ACTION_ARGUMENT_EXTRAS);
MediaSessionCompat.ensureClassLoader(bundle6);
Callback.this.onSetRating(ratingCompat, bundle6);
} else if (str.equals(MediaSessionCompat.ACTION_SET_PLAYBACK_SPEED)) {
Callback.this.onSetPlaybackSpeed(bundle.getFloat(MediaSessionCompat.ACTION_ARGUMENT_PLAYBACK_SPEED, 1.0f));
} else {
Callback.this.onCustomAction(str, bundle);
}
} catch (BadParcelableException unused) {
Log.e(MediaSessionCompat.TAG, "Could not unparcel the data.");
}
clearCurrentControllerInfo(sessionImplIfCallbackIsSet);
}
@Override // android.media.session.MediaSession.Callback
@RequiresApi(24)
public void onPrepare() {
MediaSessionImplApi21 sessionImplIfCallbackIsSet = getSessionImplIfCallbackIsSet();
if (sessionImplIfCallbackIsSet == null) {
return;
}
setCurrentControllerInfo(sessionImplIfCallbackIsSet);
Callback.this.onPrepare();
clearCurrentControllerInfo(sessionImplIfCallbackIsSet);
}
@Override // android.media.session.MediaSession.Callback
@RequiresApi(24)
public void onPrepareFromMediaId(String str, Bundle bundle) {
MediaSessionImplApi21 sessionImplIfCallbackIsSet = getSessionImplIfCallbackIsSet();
if (sessionImplIfCallbackIsSet == null) {
return;
}
MediaSessionCompat.ensureClassLoader(bundle);
setCurrentControllerInfo(sessionImplIfCallbackIsSet);
Callback.this.onPrepareFromMediaId(str, bundle);
clearCurrentControllerInfo(sessionImplIfCallbackIsSet);
}
@Override // android.media.session.MediaSession.Callback
@RequiresApi(24)
public void onPrepareFromSearch(String str, Bundle bundle) {
MediaSessionImplApi21 sessionImplIfCallbackIsSet = getSessionImplIfCallbackIsSet();
if (sessionImplIfCallbackIsSet == null) {
return;
}
MediaSessionCompat.ensureClassLoader(bundle);
setCurrentControllerInfo(sessionImplIfCallbackIsSet);
Callback.this.onPrepareFromSearch(str, bundle);
clearCurrentControllerInfo(sessionImplIfCallbackIsSet);
}
@Override // android.media.session.MediaSession.Callback
@RequiresApi(24)
public void onPrepareFromUri(Uri uri, Bundle bundle) {
MediaSessionImplApi21 sessionImplIfCallbackIsSet = getSessionImplIfCallbackIsSet();
if (sessionImplIfCallbackIsSet == null) {
return;
}
MediaSessionCompat.ensureClassLoader(bundle);
setCurrentControllerInfo(sessionImplIfCallbackIsSet);
Callback.this.onPrepareFromUri(uri, bundle);
clearCurrentControllerInfo(sessionImplIfCallbackIsSet);
}
@Override // android.media.session.MediaSession.Callback
@RequiresApi(29)
public void onSetPlaybackSpeed(float f) {
MediaSessionImplApi21 sessionImplIfCallbackIsSet = getSessionImplIfCallbackIsSet();
if (sessionImplIfCallbackIsSet == null) {
return;
}
setCurrentControllerInfo(sessionImplIfCallbackIsSet);
Callback.this.onSetPlaybackSpeed(f);
clearCurrentControllerInfo(sessionImplIfCallbackIsSet);
}
private void setCurrentControllerInfo(MediaSessionImpl mediaSessionImpl) {
if (Build.VERSION.SDK_INT >= 28) {
return;
}
String callingPackage = mediaSessionImpl.getCallingPackage();
if (TextUtils.isEmpty(callingPackage)) {
callingPackage = MediaSessionManager.RemoteUserInfo.LEGACY_CONTROLLER;
}
mediaSessionImpl.setCurrentControllerInfo(new MediaSessionManager.RemoteUserInfo(callingPackage, -1, -1));
}
private void clearCurrentControllerInfo(MediaSessionImpl mediaSessionImpl) {
mediaSessionImpl.setCurrentControllerInfo(null);
}
private MediaSessionImplApi21 getSessionImplIfCallbackIsSet() {
MediaSessionImplApi21 mediaSessionImplApi21;
synchronized (Callback.this.mLock) {
mediaSessionImplApi21 = (MediaSessionImplApi21) Callback.this.mSessionImpl.get();
}
if (mediaSessionImplApi21 == null || Callback.this != mediaSessionImplApi21.getCallback()) {
return null;
}
return mediaSessionImplApi21;
}
}
}
@SuppressLint({"BanParcelableUsage"})
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(parcel.readParcelable(null));
}
/* JADX WARN: Can't rename method to resolve collision */
@Override // android.os.Parcelable.Creator
public Token[] newArray(int i) {
return new Token[i];
}
};
@GuardedBy("mLock")
private IMediaSession mExtraBinder;
private final Object mInner;
private final Object mLock;
@GuardedBy("mLock")
private VersionedParcelable mSession2Token;
@Override // android.os.Parcelable
public int describeContents() {
return 0;
}
public Object getToken() {
return this.mInner;
}
public Token(Object obj) {
this(obj, null, null);
}
public Token(Object obj, IMediaSession iMediaSession) {
this(obj, iMediaSession, null);
}
public Token(Object obj, IMediaSession iMediaSession, VersionedParcelable versionedParcelable) {
this.mLock = new Object();
this.mInner = obj;
this.mExtraBinder = iMediaSession;
this.mSession2Token = versionedParcelable;
}
public static Token fromToken(Object obj) {
return fromToken(obj, null);
}
@RestrictTo({RestrictTo.Scope.LIBRARY})
public static Token fromToken(Object obj, IMediaSession iMediaSession) {
if (obj == null) {
return null;
}
if (!(obj instanceof MediaSession.Token)) {
throw new IllegalArgumentException("token is not a valid MediaSession.Token object");
}
return new Token(obj, iMediaSession);
}
@Override // android.os.Parcelable
public void writeToParcel(Parcel parcel, int i) {
parcel.writeParcelable((Parcelable) this.mInner, i);
}
public int hashCode() {
Object obj = this.mInner;
if (obj == null) {
return 0;
}
return obj.hashCode();
}
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);
}
@RestrictTo({RestrictTo.Scope.LIBRARY})
public IMediaSession getExtraBinder() {
IMediaSession iMediaSession;
synchronized (this.mLock) {
iMediaSession = this.mExtraBinder;
}
return iMediaSession;
}
@RestrictTo({RestrictTo.Scope.LIBRARY})
public void setExtraBinder(IMediaSession iMediaSession) {
synchronized (this.mLock) {
this.mExtraBinder = iMediaSession;
}
}
@RestrictTo({RestrictTo.Scope.LIBRARY_GROUP_PREFIX})
public VersionedParcelable getSession2Token() {
VersionedParcelable versionedParcelable;
synchronized (this.mLock) {
versionedParcelable = this.mSession2Token;
}
return versionedParcelable;
}
@RestrictTo({RestrictTo.Scope.LIBRARY_GROUP_PREFIX})
public void setSession2Token(VersionedParcelable versionedParcelable) {
synchronized (this.mLock) {
this.mSession2Token = versionedParcelable;
}
}
@RestrictTo({RestrictTo.Scope.LIBRARY_GROUP_PREFIX})
public Bundle toBundle() {
Bundle bundle = new Bundle();
bundle.putParcelable(MediaSessionCompat.KEY_TOKEN, this);
synchronized (this.mLock) {
try {
IMediaSession iMediaSession = this.mExtraBinder;
if (iMediaSession != null) {
BundleCompat.putBinder(bundle, MediaSessionCompat.KEY_EXTRA_BINDER, iMediaSession.asBinder());
}
VersionedParcelable versionedParcelable = this.mSession2Token;
if (versionedParcelable != null) {
ParcelUtils.putVersionedParcelable(bundle, MediaSessionCompat.KEY_SESSION2_TOKEN, versionedParcelable);
}
} catch (Throwable th) {
throw th;
}
}
return bundle;
}
@RestrictTo({RestrictTo.Scope.LIBRARY_GROUP_PREFIX})
public static Token fromBundle(Bundle bundle) {
if (bundle == null) {
return null;
}
IMediaSession asInterface = IMediaSession.Stub.asInterface(BundleCompat.getBinder(bundle, MediaSessionCompat.KEY_EXTRA_BINDER));
VersionedParcelable versionedParcelable = ParcelUtils.getVersionedParcelable(bundle, MediaSessionCompat.KEY_SESSION2_TOKEN);
Token token = (Token) bundle.getParcelable(MediaSessionCompat.KEY_TOKEN);
if (token == null) {
return null;
}
return new Token(token.mInner, asInterface, versionedParcelable);
}
}
@SuppressLint({"BanParcelableUsage"})
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 MediaSession.QueueItem mItemFwk;
@Override // android.os.Parcelable
public int describeContents() {
return 0;
}
public MediaDescriptionCompat getDescription() {
return this.mDescription;
}
public long getQueueId() {
return this.mId;
}
public QueueItem(MediaDescriptionCompat mediaDescriptionCompat, long j) {
this(null, mediaDescriptionCompat, j);
}
private QueueItem(MediaSession.QueueItem queueItem, 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.mItemFwk = queueItem;
}
public QueueItem(Parcel parcel) {
this.mDescription = MediaDescriptionCompat.CREATOR.createFromParcel(parcel);
this.mId = parcel.readLong();
}
@Override // android.os.Parcelable
public void writeToParcel(Parcel parcel, int i) {
this.mDescription.writeToParcel(parcel, i);
parcel.writeLong(this.mId);
}
public Object getQueueItem() {
MediaSession.QueueItem queueItem = this.mItemFwk;
if (queueItem != null) {
return queueItem;
}
MediaSession.QueueItem queueItem2 = new MediaSession.QueueItem((MediaDescription) this.mDescription.getMediaDescription(), this.mId);
this.mItemFwk = queueItem2;
return queueItem2;
}
public static QueueItem fromQueueItem(Object obj) {
if (obj == null) {
return null;
}
MediaSession.QueueItem queueItem = (MediaSession.QueueItem) obj;
return new QueueItem(queueItem, MediaDescriptionCompat.fromMediaDescription(queueItem.getDescription()), queueItem.getQueueId());
}
public static List<QueueItem> fromQueueItemList(List<?> list) {
if (list == null) {
return null;
}
ArrayList arrayList = new ArrayList();
Iterator<?> it = list.iterator();
while (it.hasNext()) {
arrayList.add(fromQueueItem(it.next()));
}
return arrayList;
}
public String toString() {
return "MediaSession.QueueItem {Description=" + this.mDescription + ", Id=" + this.mId + " }";
}
}
@SuppressLint({"BanParcelableUsage"})
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;
@Override // android.os.Parcelable
public int describeContents() {
return 0;
}
public ResultReceiverWrapper(@NonNull ResultReceiver resultReceiver) {
this.mResultReceiver = resultReceiver;
}
public ResultReceiverWrapper(Parcel parcel) {
this.mResultReceiver = (ResultReceiver) ResultReceiver.CREATOR.createFromParcel(parcel);
}
@Override // android.os.Parcelable
public void writeToParcel(Parcel parcel, int i) {
this.mResultReceiver.writeToParcel(parcel, i);
}
}
public static class MediaSessionImplBase implements MediaSessionImpl {
static final int RCC_PLAYSTATE_NONE = 0;
final AudioManager mAudioManager;
volatile Callback mCallback;
boolean mCaptioningEnabled;
private final Context mContext;
Bundle mExtras;
private MessageHandler mHandler;
int mLocalStream;
private final ComponentName mMediaButtonReceiverComponentName;
private final PendingIntent mMediaButtonReceiverIntent;
MediaMetadataCompat mMetadata;
final String mPackageName;
List<QueueItem> mQueue;
CharSequence mQueueTitle;
int mRatingType;
final RemoteControlClient mRcc;
private MediaSessionManager.RemoteUserInfo mRemoteUserInfo;
int mRepeatMode;
PendingIntent mSessionActivity;
final Bundle mSessionInfo;
int mShuffleMode;
PlaybackStateCompat mState;
private final MediaSessionStub mStub;
final String mTag;
private final Token mToken;
VolumeProviderCompat mVolumeProvider;
int mVolumeType;
final Object mLock = new Object();
final RemoteCallbackList<IMediaControllerCallback> mControllerCallbacks = new RemoteCallbackList<>();
boolean mDestroyed = false;
boolean mIsActive = false;
int mFlags = 3;
private VolumeProviderCompat.Callback mVolumeCallback = new VolumeProviderCompat.Callback() { // from class: android.support.v4.media.session.MediaSessionCompat.MediaSessionImplBase.1
@Override // androidx.media.VolumeProviderCompat.Callback
public void onVolumeChanged(VolumeProviderCompat volumeProviderCompat) {
if (MediaSessionImplBase.this.mVolumeProvider != volumeProviderCompat) {
return;
}
MediaSessionImplBase mediaSessionImplBase = MediaSessionImplBase.this;
MediaSessionImplBase.this.sendVolumeInfoChanged(new ParcelableVolumeInfo(mediaSessionImplBase.mVolumeType, mediaSessionImplBase.mLocalStream, volumeProviderCompat.getVolumeControl(), volumeProviderCompat.getMaxVolume(), volumeProviderCompat.getCurrentVolume()));
}
};
@Override // android.support.v4.media.session.MediaSessionCompat.MediaSessionImpl
public String getCallingPackage() {
return null;
}
@Override // android.support.v4.media.session.MediaSessionCompat.MediaSessionImpl
public Object getMediaSession() {
return null;
}
public int getRccStateFromState(int i) {
switch (i) {
case 0:
return 0;
case 1:
return 1;
case 2:
return 2;
case 3:
return 3;
case 4:
return 4;
case 5:
return 5;
case 6:
case 8:
return 8;
case 7:
return 9;
case 9:
return 7;
case 10:
case 11:
return 6;
default:
return -1;
}
}
public int getRccTransportControlFlagsFromActions(long j) {
int i = (1 & j) != 0 ? 32 : 0;
if ((2 & j) != 0) {
i |= 16;
}
if ((4 & j) != 0) {
i |= 4;
}
if ((8 & j) != 0) {
i |= 2;
}
if ((16 & j) != 0) {
i |= 1;
}
if ((32 & j) != 0) {
i |= 128;
}
if ((64 & j) != 0) {
i |= 64;
}
return (j & 512) != 0 ? i | 8 : i;
}
@Override // android.support.v4.media.session.MediaSessionCompat.MediaSessionImpl
public Object getRemoteControlClient() {
return null;
}
@Override // android.support.v4.media.session.MediaSessionCompat.MediaSessionImpl
public Token getSessionToken() {
return this.mToken;
}
@Override // android.support.v4.media.session.MediaSessionCompat.MediaSessionImpl
public boolean isActive() {
return this.mIsActive;
}
@Override // android.support.v4.media.session.MediaSessionCompat.MediaSessionImpl
public void setMediaButtonReceiver(PendingIntent pendingIntent) {
}
@Override // android.support.v4.media.session.MediaSessionCompat.MediaSessionImpl
public void setRatingType(int i) {
this.mRatingType = i;
}
public MediaSessionImplBase(Context context, String str, ComponentName componentName, PendingIntent pendingIntent, VersionedParcelable versionedParcelable, Bundle bundle) {
if (componentName == null) {
throw new IllegalArgumentException("MediaButtonReceiver component may not be null");
}
this.mContext = context;
this.mPackageName = context.getPackageName();
this.mSessionInfo = bundle;
this.mAudioManager = (AudioManager) context.getSystemService("audio");
this.mTag = str;
this.mMediaButtonReceiverComponentName = componentName;
this.mMediaButtonReceiverIntent = pendingIntent;
MediaSessionStub mediaSessionStub = new MediaSessionStub();
this.mStub = mediaSessionStub;
this.mToken = new Token(mediaSessionStub, null, versionedParcelable);
this.mRatingType = 0;
this.mVolumeType = 1;
this.mLocalStream = 3;
this.mRcc = new RemoteControlClient(pendingIntent);
}
/* JADX WARN: Removed duplicated region for block: B:18:0x0033 A[Catch: all -> 0x000c, TryCatch #0 {all -> 0x000c, blocks: (B:4:0x0003, B:6:0x0008, B:10:0x0013, B:11:0x001e, B:13:0x0024, B:15:0x0028, B:16:0x002d, B:18:0x0033, B:19:0x0038), top: B:3:0x0003 }] */
@Override // android.support.v4.media.session.MediaSessionCompat.MediaSessionImpl
/*
Code decompiled incorrectly, please refer to instructions dump.
To view partially-correct add '--show-bad-code' argument
*/
public void setCallback(android.support.v4.media.session.MediaSessionCompat.Callback r5, android.os.Handler r6) {
/*
r4 = this;
java.lang.Object r0 = r4.mLock
monitor-enter(r0)
android.support.v4.media.session.MediaSessionCompat$MediaSessionImplBase$MessageHandler r1 = r4.mHandler // Catch: java.lang.Throwable -> Lc
r2 = 0
if (r1 == 0) goto Le
r1.removeCallbacksAndMessages(r2) // Catch: java.lang.Throwable -> Lc
goto Le
Lc:
r5 = move-exception
goto L3a
Le:
if (r5 == 0) goto L1d
if (r6 != 0) goto L13
goto L1d
L13:
android.support.v4.media.session.MediaSessionCompat$MediaSessionImplBase$MessageHandler r1 = new android.support.v4.media.session.MediaSessionCompat$MediaSessionImplBase$MessageHandler // Catch: java.lang.Throwable -> Lc
android.os.Looper r3 = r6.getLooper() // Catch: java.lang.Throwable -> Lc
r1.<init>(r3) // Catch: java.lang.Throwable -> Lc
goto L1e
L1d:
r1 = r2
L1e:
r4.mHandler = r1 // Catch: java.lang.Throwable -> Lc
android.support.v4.media.session.MediaSessionCompat$Callback r1 = r4.mCallback // Catch: java.lang.Throwable -> Lc
if (r1 == r5) goto L2d
android.support.v4.media.session.MediaSessionCompat$Callback r1 = r4.mCallback // Catch: java.lang.Throwable -> Lc
if (r1 == 0) goto L2d
android.support.v4.media.session.MediaSessionCompat$Callback r1 = r4.mCallback // Catch: java.lang.Throwable -> Lc
r1.setSessionImpl(r2, r2) // Catch: java.lang.Throwable -> Lc
L2d:
r4.mCallback = r5 // Catch: java.lang.Throwable -> Lc
android.support.v4.media.session.MediaSessionCompat$Callback r5 = r4.mCallback // Catch: java.lang.Throwable -> Lc
if (r5 == 0) goto L38
android.support.v4.media.session.MediaSessionCompat$Callback r5 = r4.mCallback // Catch: java.lang.Throwable -> Lc
r5.setSessionImpl(r4, r6) // Catch: java.lang.Throwable -> Lc
L38:
monitor-exit(r0) // Catch: java.lang.Throwable -> Lc
return
L3a:
monitor-exit(r0) // Catch: java.lang.Throwable -> Lc
throw r5
*/
throw new UnsupportedOperationException("Method not decompiled: android.support.v4.media.session.MediaSessionCompat.MediaSessionImplBase.setCallback(android.support.v4.media.session.MediaSessionCompat$Callback, android.os.Handler):void");
}
public void postToHandler(int i, int i2, int i3, Object obj, Bundle bundle) {
synchronized (this.mLock) {
try {
MessageHandler messageHandler = this.mHandler;
if (messageHandler != null) {
Message obtainMessage = messageHandler.obtainMessage(i, i2, i3, obj);
Bundle bundle2 = new Bundle();
int callingUid = Binder.getCallingUid();
bundle2.putInt("data_calling_uid", callingUid);
bundle2.putString(MediaSessionCompat.DATA_CALLING_PACKAGE, getPackageNameForUid(callingUid));
int callingPid = Binder.getCallingPid();
if (callingPid > 0) {
bundle2.putInt("data_calling_pid", callingPid);
} else {
bundle2.putInt("data_calling_pid", -1);
}
if (bundle != null) {
bundle2.putBundle(MediaSessionCompat.DATA_EXTRAS, bundle);
}
obtainMessage.setData(bundle2);
obtainMessage.sendToTarget();
}
} catch (Throwable th) {
throw th;
}
}
}
public String getPackageNameForUid(int i) {
String nameForUid = this.mContext.getPackageManager().getNameForUid(i);
return TextUtils.isEmpty(nameForUid) ? MediaSessionManager.RemoteUserInfo.LEGACY_CONTROLLER : nameForUid;
}
@Override // android.support.v4.media.session.MediaSessionCompat.MediaSessionImpl
public void setFlags(int i) {
synchronized (this.mLock) {
this.mFlags = i | 3;
}
}
@Override // android.support.v4.media.session.MediaSessionCompat.MediaSessionImpl
public void setPlaybackToLocal(int i) {
VolumeProviderCompat volumeProviderCompat = this.mVolumeProvider;
if (volumeProviderCompat != null) {
volumeProviderCompat.setCallback(null);
}
this.mLocalStream = i;
this.mVolumeType = 1;
int i2 = this.mVolumeType;
int i3 = this.mLocalStream;
sendVolumeInfoChanged(new ParcelableVolumeInfo(i2, i3, 2, this.mAudioManager.getStreamMaxVolume(i3), this.mAudioManager.getStreamVolume(this.mLocalStream)));
}
@Override // android.support.v4.media.session.MediaSessionCompat.MediaSessionImpl
public void setPlaybackToRemote(VolumeProviderCompat volumeProviderCompat) {
if (volumeProviderCompat == null) {
throw new IllegalArgumentException("volumeProvider may not be null");
}
VolumeProviderCompat volumeProviderCompat2 = this.mVolumeProvider;
if (volumeProviderCompat2 != null) {
volumeProviderCompat2.setCallback(null);
}
this.mVolumeType = 2;
this.mVolumeProvider = volumeProviderCompat;
sendVolumeInfoChanged(new ParcelableVolumeInfo(this.mVolumeType, this.mLocalStream, this.mVolumeProvider.getVolumeControl(), this.mVolumeProvider.getMaxVolume(), this.mVolumeProvider.getCurrentVolume()));
volumeProviderCompat.setCallback(this.mVolumeCallback);
}
@Override // android.support.v4.media.session.MediaSessionCompat.MediaSessionImpl
public void setActive(boolean z) {
if (z == this.mIsActive) {
return;
}
this.mIsActive = z;
updateMbrAndRcc();
}
@Override // android.support.v4.media.session.MediaSessionCompat.MediaSessionImpl
public void sendSessionEvent(String str, Bundle bundle) {
sendEvent(str, bundle);
}
@Override // android.support.v4.media.session.MediaSessionCompat.MediaSessionImpl
public void release() {
this.mIsActive = false;
this.mDestroyed = true;
updateMbrAndRcc();
sendSessionDestroyed();
setCallback(null, null);
}
@Override // android.support.v4.media.session.MediaSessionCompat.MediaSessionImpl
public void setPlaybackState(PlaybackStateCompat playbackStateCompat) {
synchronized (this.mLock) {
this.mState = playbackStateCompat;
}
sendState(playbackStateCompat);
if (this.mIsActive) {
if (playbackStateCompat == null) {
this.mRcc.setPlaybackState(0);
this.mRcc.setTransportControlFlags(0);
} else {
setRccState(playbackStateCompat);
this.mRcc.setTransportControlFlags(getRccTransportControlFlagsFromActions(playbackStateCompat.getActions()));
}
}
}
@Override // android.support.v4.media.session.MediaSessionCompat.MediaSessionImpl
public PlaybackStateCompat getPlaybackState() {
PlaybackStateCompat playbackStateCompat;
synchronized (this.mLock) {
playbackStateCompat = this.mState;
}
return playbackStateCompat;
}
public void setRccState(PlaybackStateCompat playbackStateCompat) {
this.mRcc.setPlaybackState(getRccStateFromState(playbackStateCompat.getState()));
}
@Override // android.support.v4.media.session.MediaSessionCompat.MediaSessionImpl
public void setMetadata(MediaMetadataCompat mediaMetadataCompat) {
if (mediaMetadataCompat != null) {
mediaMetadataCompat = new MediaMetadataCompat.Builder(mediaMetadataCompat, MediaSessionCompat.sMaxBitmapSize).build();
}
synchronized (this.mLock) {
this.mMetadata = mediaMetadataCompat;
}
sendMetadata(mediaMetadataCompat);
if (this.mIsActive) {
buildRccMetadata(mediaMetadataCompat == null ? null : mediaMetadataCompat.getBundle()).apply();
}
}
public RemoteControlClient.MetadataEditor buildRccMetadata(Bundle bundle) {
RemoteControlClient.MetadataEditor editMetadata = this.mRcc.editMetadata(true);
if (bundle == null) {
return editMetadata;
}
if (bundle.containsKey(MediaMetadataCompat.METADATA_KEY_ART)) {
Bitmap bitmap = (Bitmap) bundle.getParcelable(MediaMetadataCompat.METADATA_KEY_ART);
if (bitmap != null) {
bitmap = bitmap.copy(bitmap.getConfig(), false);
}
editMetadata.putBitmap(100, bitmap);
} else if (bundle.containsKey(MediaMetadataCompat.METADATA_KEY_ALBUM_ART)) {
Bitmap bitmap2 = (Bitmap) bundle.getParcelable(MediaMetadataCompat.METADATA_KEY_ALBUM_ART);
if (bitmap2 != null) {
bitmap2 = bitmap2.copy(bitmap2.getConfig(), false);
}
editMetadata.putBitmap(100, bitmap2);
}
if (bundle.containsKey(MediaMetadataCompat.METADATA_KEY_ALBUM)) {
editMetadata.putString(1, bundle.getString(MediaMetadataCompat.METADATA_KEY_ALBUM));
}
if (bundle.containsKey(MediaMetadataCompat.METADATA_KEY_ALBUM_ARTIST)) {
editMetadata.putString(13, bundle.getString(MediaMetadataCompat.METADATA_KEY_ALBUM_ARTIST));
}
if (bundle.containsKey(MediaMetadataCompat.METADATA_KEY_ARTIST)) {
editMetadata.putString(2, bundle.getString(MediaMetadataCompat.METADATA_KEY_ARTIST));
}
if (bundle.containsKey(MediaMetadataCompat.METADATA_KEY_AUTHOR)) {
editMetadata.putString(3, bundle.getString(MediaMetadataCompat.METADATA_KEY_AUTHOR));
}
if (bundle.containsKey(MediaMetadataCompat.METADATA_KEY_COMPILATION)) {
editMetadata.putString(15, bundle.getString(MediaMetadataCompat.METADATA_KEY_COMPILATION));
}
if (bundle.containsKey(MediaMetadataCompat.METADATA_KEY_COMPOSER)) {
editMetadata.putString(4, bundle.getString(MediaMetadataCompat.METADATA_KEY_COMPOSER));
}
if (bundle.containsKey(MediaMetadataCompat.METADATA_KEY_DATE)) {
editMetadata.putString(5, bundle.getString(MediaMetadataCompat.METADATA_KEY_DATE));
}
if (bundle.containsKey(MediaMetadataCompat.METADATA_KEY_DISC_NUMBER)) {
editMetadata.putLong(14, bundle.getLong(MediaMetadataCompat.METADATA_KEY_DISC_NUMBER));
}
if (bundle.containsKey(MediaMetadataCompat.METADATA_KEY_DURATION)) {
editMetadata.putLong(9, bundle.getLong(MediaMetadataCompat.METADATA_KEY_DURATION));
}
if (bundle.containsKey(MediaMetadataCompat.METADATA_KEY_GENRE)) {
editMetadata.putString(6, bundle.getString(MediaMetadataCompat.METADATA_KEY_GENRE));
}
if (bundle.containsKey(MediaMetadataCompat.METADATA_KEY_TITLE)) {
editMetadata.putString(7, bundle.getString(MediaMetadataCompat.METADATA_KEY_TITLE));
}
if (bundle.containsKey(MediaMetadataCompat.METADATA_KEY_TRACK_NUMBER)) {
editMetadata.putLong(0, bundle.getLong(MediaMetadataCompat.METADATA_KEY_TRACK_NUMBER));
}
if (bundle.containsKey(MediaMetadataCompat.METADATA_KEY_WRITER)) {
editMetadata.putString(11, bundle.getString(MediaMetadataCompat.METADATA_KEY_WRITER));
}
return editMetadata;
}
@Override // android.support.v4.media.session.MediaSessionCompat.MediaSessionImpl
public void setSessionActivity(PendingIntent pendingIntent) {
synchronized (this.mLock) {
this.mSessionActivity = pendingIntent;
}
}
@Override // android.support.v4.media.session.MediaSessionCompat.MediaSessionImpl
public void setQueue(List<QueueItem> list) {
this.mQueue = list;
sendQueue(list);
}
@Override // android.support.v4.media.session.MediaSessionCompat.MediaSessionImpl
public void setQueueTitle(CharSequence charSequence) {
this.mQueueTitle = charSequence;
sendQueueTitle(charSequence);
}
@Override // android.support.v4.media.session.MediaSessionCompat.MediaSessionImpl
public void setCaptioningEnabled(boolean z) {
if (this.mCaptioningEnabled != z) {
this.mCaptioningEnabled = z;
sendCaptioningEnabled(z);
}
}
@Override // android.support.v4.media.session.MediaSessionCompat.MediaSessionImpl
public void setRepeatMode(int i) {
if (this.mRepeatMode != i) {
this.mRepeatMode = i;
sendRepeatMode(i);
}
}
@Override // android.support.v4.media.session.MediaSessionCompat.MediaSessionImpl
public void setShuffleMode(int i) {
if (this.mShuffleMode != i) {
this.mShuffleMode = i;
sendShuffleMode(i);
}
}
@Override // android.support.v4.media.session.MediaSessionCompat.MediaSessionImpl
public void setExtras(Bundle bundle) {
this.mExtras = bundle;
sendExtras(bundle);
}
@Override // android.support.v4.media.session.MediaSessionCompat.MediaSessionImpl
public MediaSessionManager.RemoteUserInfo getCurrentControllerInfo() {
MediaSessionManager.RemoteUserInfo remoteUserInfo;
synchronized (this.mLock) {
remoteUserInfo = this.mRemoteUserInfo;
}
return remoteUserInfo;
}
@Override // android.support.v4.media.session.MediaSessionCompat.MediaSessionImpl
public void setCurrentControllerInfo(MediaSessionManager.RemoteUserInfo remoteUserInfo) {
synchronized (this.mLock) {
this.mRemoteUserInfo = remoteUserInfo;
}
}
@Override // android.support.v4.media.session.MediaSessionCompat.MediaSessionImpl
public Callback getCallback() {
Callback callback;
synchronized (this.mLock) {
callback = this.mCallback;
}
return callback;
}
public void updateMbrAndRcc() {
if (this.mIsActive) {
registerMediaButtonEventReceiver(this.mMediaButtonReceiverIntent, this.mMediaButtonReceiverComponentName);
this.mAudioManager.registerRemoteControlClient(this.mRcc);
setMetadata(this.mMetadata);
setPlaybackState(this.mState);
return;
}
unregisterMediaButtonEventReceiver(this.mMediaButtonReceiverIntent, this.mMediaButtonReceiverComponentName);
this.mRcc.setPlaybackState(0);
this.mAudioManager.unregisterRemoteControlClient(this.mRcc);
}
public void registerMediaButtonEventReceiver(PendingIntent pendingIntent, ComponentName componentName) {
this.mAudioManager.registerMediaButtonEventReceiver(componentName);
}
public void unregisterMediaButtonEventReceiver(PendingIntent pendingIntent, ComponentName componentName) {
this.mAudioManager.unregisterMediaButtonEventReceiver(componentName);
}
public void adjustVolume(int i, int i2) {
if (this.mVolumeType != 2) {
this.mAudioManager.adjustStreamVolume(this.mLocalStream, i, i2);
return;
}
VolumeProviderCompat volumeProviderCompat = this.mVolumeProvider;
if (volumeProviderCompat != null) {
volumeProviderCompat.onAdjustVolume(i);
}
}
public void setVolumeTo(int i, int i2) {
if (this.mVolumeType != 2) {
this.mAudioManager.setStreamVolume(this.mLocalStream, i, i2);
return;
}
VolumeProviderCompat volumeProviderCompat = this.mVolumeProvider;
if (volumeProviderCompat != null) {
volumeProviderCompat.onSetVolumeTo(i);
}
}
public void sendVolumeInfoChanged(ParcelableVolumeInfo parcelableVolumeInfo) {
for (int beginBroadcast = this.mControllerCallbacks.beginBroadcast() - 1; beginBroadcast >= 0; beginBroadcast--) {
try {
this.mControllerCallbacks.getBroadcastItem(beginBroadcast).onVolumeInfoChanged(parcelableVolumeInfo);
} catch (RemoteException unused) {
}
}
this.mControllerCallbacks.finishBroadcast();
}
private void sendSessionDestroyed() {
for (int beginBroadcast = this.mControllerCallbacks.beginBroadcast() - 1; beginBroadcast >= 0; beginBroadcast--) {
try {
this.mControllerCallbacks.getBroadcastItem(beginBroadcast).onSessionDestroyed();
} catch (RemoteException unused) {
}
}
this.mControllerCallbacks.finishBroadcast();
this.mControllerCallbacks.kill();
}
private void sendEvent(String str, Bundle bundle) {
for (int beginBroadcast = this.mControllerCallbacks.beginBroadcast() - 1; beginBroadcast >= 0; beginBroadcast--) {
try {
this.mControllerCallbacks.getBroadcastItem(beginBroadcast).onEvent(str, bundle);
} catch (RemoteException unused) {
}
}
this.mControllerCallbacks.finishBroadcast();
}
private void sendState(PlaybackStateCompat playbackStateCompat) {
for (int beginBroadcast = this.mControllerCallbacks.beginBroadcast() - 1; beginBroadcast >= 0; beginBroadcast--) {
try {
this.mControllerCallbacks.getBroadcastItem(beginBroadcast).onPlaybackStateChanged(playbackStateCompat);
} catch (RemoteException unused) {
}
}
this.mControllerCallbacks.finishBroadcast();
}
private void sendMetadata(MediaMetadataCompat mediaMetadataCompat) {
for (int beginBroadcast = this.mControllerCallbacks.beginBroadcast() - 1; beginBroadcast >= 0; beginBroadcast--) {
try {
this.mControllerCallbacks.getBroadcastItem(beginBroadcast).onMetadataChanged(mediaMetadataCompat);
} catch (RemoteException unused) {
}
}
this.mControllerCallbacks.finishBroadcast();
}
private void sendQueue(List<QueueItem> list) {
for (int beginBroadcast = this.mControllerCallbacks.beginBroadcast() - 1; beginBroadcast >= 0; beginBroadcast--) {
try {
this.mControllerCallbacks.getBroadcastItem(beginBroadcast).onQueueChanged(list);
} catch (RemoteException unused) {
}
}
this.mControllerCallbacks.finishBroadcast();
}
private void sendQueueTitle(CharSequence charSequence) {
for (int beginBroadcast = this.mControllerCallbacks.beginBroadcast() - 1; beginBroadcast >= 0; beginBroadcast--) {
try {
this.mControllerCallbacks.getBroadcastItem(beginBroadcast).onQueueTitleChanged(charSequence);
} catch (RemoteException unused) {
}
}
this.mControllerCallbacks.finishBroadcast();
}
private void sendCaptioningEnabled(boolean z) {
for (int beginBroadcast = this.mControllerCallbacks.beginBroadcast() - 1; beginBroadcast >= 0; beginBroadcast--) {
try {
this.mControllerCallbacks.getBroadcastItem(beginBroadcast).onCaptioningEnabledChanged(z);
} catch (RemoteException unused) {
}
}
this.mControllerCallbacks.finishBroadcast();
}
private void sendRepeatMode(int i) {
for (int beginBroadcast = this.mControllerCallbacks.beginBroadcast() - 1; beginBroadcast >= 0; beginBroadcast--) {
try {
this.mControllerCallbacks.getBroadcastItem(beginBroadcast).onRepeatModeChanged(i);
} catch (RemoteException unused) {
}
}
this.mControllerCallbacks.finishBroadcast();
}
private void sendShuffleMode(int i) {
for (int beginBroadcast = this.mControllerCallbacks.beginBroadcast() - 1; beginBroadcast >= 0; beginBroadcast--) {
try {
this.mControllerCallbacks.getBroadcastItem(beginBroadcast).onShuffleModeChanged(i);
} catch (RemoteException unused) {
}
}
this.mControllerCallbacks.finishBroadcast();
}
private void sendExtras(Bundle bundle) {
for (int beginBroadcast = this.mControllerCallbacks.beginBroadcast() - 1; beginBroadcast >= 0; beginBroadcast--) {
try {
this.mControllerCallbacks.getBroadcastItem(beginBroadcast).onExtrasChanged(bundle);
} catch (RemoteException unused) {
}
}
this.mControllerCallbacks.finishBroadcast();
}
public class MediaSessionStub extends IMediaSession.Stub {
@Override // android.support.v4.media.session.IMediaSession
public boolean isShuffleModeEnabledRemoved() {
return false;
}
@Override // android.support.v4.media.session.IMediaSession
public boolean isTransportControlEnabled() {
return true;
}
@Override // android.support.v4.media.session.IMediaSession
public void setShuffleModeEnabledRemoved(boolean z) throws RemoteException {
}
public MediaSessionStub() {
}
@Override // android.support.v4.media.session.IMediaSession
public void sendCommand(String str, Bundle bundle, ResultReceiverWrapper resultReceiverWrapper) {
postToHandler(1, new Command(str, bundle, resultReceiverWrapper == null ? null : resultReceiverWrapper.mResultReceiver));
}
@Override // android.support.v4.media.session.IMediaSession
public boolean sendMediaButton(KeyEvent keyEvent) {
postToHandler(21, keyEvent);
return true;
}
@Override // android.support.v4.media.session.IMediaSession
public void registerCallbackListener(IMediaControllerCallback iMediaControllerCallback) {
if (MediaSessionImplBase.this.mDestroyed) {
try {
iMediaControllerCallback.onSessionDestroyed();
} catch (Exception unused) {
}
} else {
MediaSessionImplBase.this.mControllerCallbacks.register(iMediaControllerCallback, new MediaSessionManager.RemoteUserInfo(MediaSessionImplBase.this.getPackageNameForUid(Binder.getCallingUid()), Binder.getCallingPid(), Binder.getCallingUid()));
}
}
@Override // android.support.v4.media.session.IMediaSession
public void unregisterCallbackListener(IMediaControllerCallback iMediaControllerCallback) {
MediaSessionImplBase.this.mControllerCallbacks.unregister(iMediaControllerCallback);
}
@Override // android.support.v4.media.session.IMediaSession
public String getPackageName() {
return MediaSessionImplBase.this.mPackageName;
}
@Override // android.support.v4.media.session.IMediaSession
public Bundle getSessionInfo() {
if (MediaSessionImplBase.this.mSessionInfo == null) {
return null;
}
return new Bundle(MediaSessionImplBase.this.mSessionInfo);
}
@Override // android.support.v4.media.session.IMediaSession
public String getTag() {
return MediaSessionImplBase.this.mTag;
}
@Override // android.support.v4.media.session.IMediaSession
public PendingIntent getLaunchPendingIntent() {
PendingIntent pendingIntent;
synchronized (MediaSessionImplBase.this.mLock) {
pendingIntent = MediaSessionImplBase.this.mSessionActivity;
}
return pendingIntent;
}
@Override // android.support.v4.media.session.IMediaSession
public long getFlags() {
long j;
synchronized (MediaSessionImplBase.this.mLock) {
j = MediaSessionImplBase.this.mFlags;
}
return j;
}
@Override // android.support.v4.media.session.IMediaSession
public ParcelableVolumeInfo getVolumeAttributes() {
int i;
int i2;
int i3;
int streamMaxVolume;
int streamVolume;
synchronized (MediaSessionImplBase.this.mLock) {
try {
MediaSessionImplBase mediaSessionImplBase = MediaSessionImplBase.this;
i = mediaSessionImplBase.mVolumeType;
i2 = mediaSessionImplBase.mLocalStream;
VolumeProviderCompat volumeProviderCompat = mediaSessionImplBase.mVolumeProvider;
i3 = 2;
if (i == 2) {
int volumeControl = volumeProviderCompat.getVolumeControl();
int maxVolume = volumeProviderCompat.getMaxVolume();
streamVolume = volumeProviderCompat.getCurrentVolume();
streamMaxVolume = maxVolume;
i3 = volumeControl;
} else {
streamMaxVolume = mediaSessionImplBase.mAudioManager.getStreamMaxVolume(i2);
streamVolume = MediaSessionImplBase.this.mAudioManager.getStreamVolume(i2);
}
} catch (Throwable th) {
throw th;
}
}
return new ParcelableVolumeInfo(i, i2, i3, streamMaxVolume, streamVolume);
}
@Override // android.support.v4.media.session.IMediaSession
public void adjustVolume(int i, int i2, String str) {
MediaSessionImplBase.this.adjustVolume(i, i2);
}
@Override // android.support.v4.media.session.IMediaSession
public void setVolumeTo(int i, int i2, String str) {
MediaSessionImplBase.this.setVolumeTo(i, i2);
}
@Override // android.support.v4.media.session.IMediaSession
public void prepare() throws RemoteException {
postToHandler(3);
}
@Override // android.support.v4.media.session.IMediaSession
public void prepareFromMediaId(String str, Bundle bundle) throws RemoteException {
postToHandler(4, str, bundle);
}
@Override // android.support.v4.media.session.IMediaSession
public void prepareFromSearch(String str, Bundle bundle) throws RemoteException {
postToHandler(5, str, bundle);
}
@Override // android.support.v4.media.session.IMediaSession
public void prepareFromUri(Uri uri, Bundle bundle) throws RemoteException {
postToHandler(6, uri, bundle);
}
@Override // android.support.v4.media.session.IMediaSession
public void play() throws RemoteException {
postToHandler(7);
}
@Override // android.support.v4.media.session.IMediaSession
public void playFromMediaId(String str, Bundle bundle) throws RemoteException {
postToHandler(8, str, bundle);
}
@Override // android.support.v4.media.session.IMediaSession
public void playFromSearch(String str, Bundle bundle) throws RemoteException {
postToHandler(9, str, bundle);
}
@Override // android.support.v4.media.session.IMediaSession
public void playFromUri(Uri uri, Bundle bundle) throws RemoteException {
postToHandler(10, uri, bundle);
}
@Override // android.support.v4.media.session.IMediaSession
public void skipToQueueItem(long j) {
postToHandler(11, Long.valueOf(j));
}
@Override // android.support.v4.media.session.IMediaSession
public void pause() throws RemoteException {
postToHandler(12);
}
@Override // android.support.v4.media.session.IMediaSession
public void stop() throws RemoteException {
postToHandler(13);
}
@Override // android.support.v4.media.session.IMediaSession
public void next() throws RemoteException {
postToHandler(14);
}
@Override // android.support.v4.media.session.IMediaSession
public void previous() throws RemoteException {
postToHandler(15);
}
@Override // android.support.v4.media.session.IMediaSession
public void fastForward() throws RemoteException {
postToHandler(16);
}
@Override // android.support.v4.media.session.IMediaSession
public void rewind() throws RemoteException {
postToHandler(17);
}
@Override // android.support.v4.media.session.IMediaSession
public void seekTo(long j) throws RemoteException {
postToHandler(18, Long.valueOf(j));
}
@Override // android.support.v4.media.session.IMediaSession
public void rate(RatingCompat ratingCompat) throws RemoteException {
postToHandler(19, ratingCompat);
}
@Override // android.support.v4.media.session.IMediaSession
public void rateWithExtras(RatingCompat ratingCompat, Bundle bundle) throws RemoteException {
postToHandler(31, ratingCompat, bundle);
}
@Override // android.support.v4.media.session.IMediaSession
public void setPlaybackSpeed(float f) throws RemoteException {
postToHandler(32, Float.valueOf(f));
}
@Override // android.support.v4.media.session.IMediaSession
public void setCaptioningEnabled(boolean z) throws RemoteException {
postToHandler(29, Boolean.valueOf(z));
}
@Override // android.support.v4.media.session.IMediaSession
public void setRepeatMode(int i) throws RemoteException {
postToHandler(23, i);
}
@Override // android.support.v4.media.session.IMediaSession
public void setShuffleMode(int i) throws RemoteException {
postToHandler(30, i);
}
@Override // android.support.v4.media.session.IMediaSession
public void sendCustomAction(String str, Bundle bundle) throws RemoteException {
postToHandler(20, str, bundle);
}
@Override // android.support.v4.media.session.IMediaSession
public MediaMetadataCompat getMetadata() {
return MediaSessionImplBase.this.mMetadata;
}
@Override // android.support.v4.media.session.IMediaSession
public PlaybackStateCompat getPlaybackState() {
PlaybackStateCompat playbackStateCompat;
MediaMetadataCompat mediaMetadataCompat;
synchronized (MediaSessionImplBase.this.mLock) {
MediaSessionImplBase mediaSessionImplBase = MediaSessionImplBase.this;
playbackStateCompat = mediaSessionImplBase.mState;
mediaMetadataCompat = mediaSessionImplBase.mMetadata;
}
return MediaSessionCompat.getStateWithUpdatedPosition(playbackStateCompat, mediaMetadataCompat);
}
@Override // android.support.v4.media.session.IMediaSession
public List<QueueItem> getQueue() {
List<QueueItem> list;
synchronized (MediaSessionImplBase.this.mLock) {
list = MediaSessionImplBase.this.mQueue;
}
return list;
}
@Override // android.support.v4.media.session.IMediaSession
public void addQueueItem(MediaDescriptionCompat mediaDescriptionCompat) {
postToHandler(25, mediaDescriptionCompat);
}
@Override // android.support.v4.media.session.IMediaSession
public void addQueueItemAt(MediaDescriptionCompat mediaDescriptionCompat, int i) {
postToHandler(26, mediaDescriptionCompat, i);
}
@Override // android.support.v4.media.session.IMediaSession
public void removeQueueItem(MediaDescriptionCompat mediaDescriptionCompat) {
postToHandler(27, mediaDescriptionCompat);
}
@Override // android.support.v4.media.session.IMediaSession
public void removeQueueItemAt(int i) {
postToHandler(28, i);
}
@Override // android.support.v4.media.session.IMediaSession
public CharSequence getQueueTitle() {
return MediaSessionImplBase.this.mQueueTitle;
}
@Override // android.support.v4.media.session.IMediaSession
public Bundle getExtras() {
Bundle bundle;
synchronized (MediaSessionImplBase.this.mLock) {
bundle = MediaSessionImplBase.this.mExtras;
}
return bundle;
}
@Override // android.support.v4.media.session.IMediaSession
public int getRatingType() {
return MediaSessionImplBase.this.mRatingType;
}
@Override // android.support.v4.media.session.IMediaSession
public boolean isCaptioningEnabled() {
return MediaSessionImplBase.this.mCaptioningEnabled;
}
@Override // android.support.v4.media.session.IMediaSession
public int getRepeatMode() {
return MediaSessionImplBase.this.mRepeatMode;
}
@Override // android.support.v4.media.session.IMediaSession
public int getShuffleMode() {
return MediaSessionImplBase.this.mShuffleMode;
}
public void postToHandler(int i) {
MediaSessionImplBase.this.postToHandler(i, 0, 0, null, null);
}
public void postToHandler(int i, int i2) {
MediaSessionImplBase.this.postToHandler(i, i2, 0, null, null);
}
public void postToHandler(int i, Object obj) {
MediaSessionImplBase.this.postToHandler(i, 0, 0, obj, null);
}
public void postToHandler(int i, Object obj, int i2) {
MediaSessionImplBase.this.postToHandler(i, i2, 0, obj, null);
}
public void postToHandler(int i, Object obj, Bundle bundle) {
MediaSessionImplBase.this.postToHandler(i, 0, 0, obj, bundle);
}
}
public static final class Command {
public final String command;
public final Bundle extras;
public final ResultReceiver stub;
public Command(String str, Bundle bundle, ResultReceiver resultReceiver) {
this.command = str;
this.extras = bundle;
this.stub = resultReceiver;
}
}
public class MessageHandler extends Handler {
private static final int KEYCODE_MEDIA_PAUSE = 127;
private static final int KEYCODE_MEDIA_PLAY = 126;
private static final int MSG_ADD_QUEUE_ITEM = 25;
private static final int MSG_ADD_QUEUE_ITEM_AT = 26;
private static final int MSG_ADJUST_VOLUME = 2;
private static final int MSG_COMMAND = 1;
private static final int MSG_CUSTOM_ACTION = 20;
private static final int MSG_FAST_FORWARD = 16;
private static final int MSG_MEDIA_BUTTON = 21;
private static final int MSG_NEXT = 14;
private static final int MSG_PAUSE = 12;
private static final int MSG_PLAY = 7;
private static final int MSG_PLAY_MEDIA_ID = 8;
private static final int MSG_PLAY_SEARCH = 9;
private static final int MSG_PLAY_URI = 10;
private static final int MSG_PREPARE = 3;
private static final int MSG_PREPARE_MEDIA_ID = 4;
private static final int MSG_PREPARE_SEARCH = 5;
private static final int MSG_PREPARE_URI = 6;
private static final int MSG_PREVIOUS = 15;
private static final int MSG_RATE = 19;
private static final int MSG_RATE_EXTRA = 31;
private static final int MSG_REMOVE_QUEUE_ITEM = 27;
private static final int MSG_REMOVE_QUEUE_ITEM_AT = 28;
private static final int MSG_REWIND = 17;
private static final int MSG_SEEK_TO = 18;
private static final int MSG_SET_CAPTIONING_ENABLED = 29;
private static final int MSG_SET_PLAYBACK_SPEED = 32;
private static final int MSG_SET_REPEAT_MODE = 23;
private static final int MSG_SET_SHUFFLE_MODE = 30;
private static final int MSG_SET_VOLUME = 22;
private static final int MSG_SKIP_TO_ITEM = 11;
private static final int MSG_STOP = 13;
public MessageHandler(Looper looper) {
super(looper);
}
@Override // android.os.Handler
public void handleMessage(Message message) {
Callback callback = MediaSessionImplBase.this.mCallback;
if (callback == null) {
return;
}
Bundle data = message.getData();
MediaSessionCompat.ensureClassLoader(data);
MediaSessionImplBase.this.setCurrentControllerInfo(new MediaSessionManager.RemoteUserInfo(data.getString(MediaSessionCompat.DATA_CALLING_PACKAGE), data.getInt("data_calling_pid"), data.getInt("data_calling_uid")));
Bundle bundle = data.getBundle(MediaSessionCompat.DATA_EXTRAS);
MediaSessionCompat.ensureClassLoader(bundle);
try {
switch (message.what) {
case 1:
Command command = (Command) message.obj;
callback.onCommand(command.command, command.extras, command.stub);
break;
case 2:
MediaSessionImplBase.this.adjustVolume(message.arg1, 0);
break;
case 3:
callback.onPrepare();
break;
case 4:
callback.onPrepareFromMediaId((String) message.obj, bundle);
break;
case 5:
callback.onPrepareFromSearch((String) message.obj, bundle);
break;
case 6:
callback.onPrepareFromUri((Uri) message.obj, bundle);
break;
case 7:
callback.onPlay();
break;
case 8:
callback.onPlayFromMediaId((String) message.obj, bundle);
break;
case 9:
callback.onPlayFromSearch((String) message.obj, bundle);
break;
case 10:
callback.onPlayFromUri((Uri) message.obj, bundle);
break;
case 11:
callback.onSkipToQueueItem(((Long) message.obj).longValue());
break;
case 12:
callback.onPause();
break;
case 13:
callback.onStop();
break;
case 14:
callback.onSkipToNext();
break;
case 15:
callback.onSkipToPrevious();
break;
case 16:
callback.onFastForward();
break;
case 17:
callback.onRewind();
break;
case 18:
callback.onSeekTo(((Long) message.obj).longValue());
break;
case 19:
callback.onSetRating((RatingCompat) message.obj);
break;
case 20:
callback.onCustomAction((String) message.obj, bundle);
break;
case 21:
KeyEvent keyEvent = (KeyEvent) message.obj;
Intent intent = new Intent("android.intent.action.MEDIA_BUTTON");
intent.putExtra("android.intent.extra.KEY_EVENT", keyEvent);
if (!callback.onMediaButtonEvent(intent)) {
onMediaButtonEvent(keyEvent, callback);
break;
}
break;
case 22:
MediaSessionImplBase.this.setVolumeTo(message.arg1, 0);
break;
case 23:
callback.onSetRepeatMode(message.arg1);
break;
case 25:
callback.onAddQueueItem((MediaDescriptionCompat) message.obj);
break;
case 26:
callback.onAddQueueItem((MediaDescriptionCompat) message.obj, message.arg1);
break;
case 27:
callback.onRemoveQueueItem((MediaDescriptionCompat) message.obj);
break;
case 28:
List<QueueItem> list = MediaSessionImplBase.this.mQueue;
if (list != null) {
int i = message.arg1;
QueueItem queueItem = (i < 0 || i >= list.size()) ? null : MediaSessionImplBase.this.mQueue.get(message.arg1);
if (queueItem != null) {
callback.onRemoveQueueItem(queueItem.getDescription());
break;
}
}
break;
case 29:
callback.onSetCaptioningEnabled(((Boolean) message.obj).booleanValue());
break;
case 30:
callback.onSetShuffleMode(message.arg1);
break;
case 31:
callback.onSetRating((RatingCompat) message.obj, bundle);
break;
case 32:
callback.onSetPlaybackSpeed(((Float) message.obj).floatValue());
break;
}
} finally {
MediaSessionImplBase.this.setCurrentControllerInfo(null);
}
}
private void onMediaButtonEvent(KeyEvent keyEvent, Callback callback) {
if (keyEvent == null || keyEvent.getAction() != 0) {
return;
}
PlaybackStateCompat playbackStateCompat = MediaSessionImplBase.this.mState;
long actions = playbackStateCompat == null ? 0L : playbackStateCompat.getActions();
int keyCode = keyEvent.getKeyCode();
if (keyCode != 79) {
if (keyCode == 126) {
if ((actions & 4) != 0) {
callback.onPlay();
return;
}
return;
}
if (keyCode == 127) {
if ((actions & 2) != 0) {
callback.onPause();
return;
}
return;
}
switch (keyCode) {
case 86:
if ((actions & 1) != 0) {
callback.onStop();
break;
}
break;
case 87:
if ((actions & 32) != 0) {
callback.onSkipToNext();
break;
}
break;
case 88:
if ((actions & 16) != 0) {
callback.onSkipToPrevious();
break;
}
break;
case TsExtractor.TS_STREAM_TYPE_DVBSUBS /* 89 */:
if ((actions & 8) != 0) {
callback.onRewind();
break;
}
break;
case 90:
if ((actions & 64) != 0) {
callback.onFastForward();
break;
}
break;
}
}
Log.w(MediaSessionCompat.TAG, "KEYCODE_MEDIA_PLAY_PAUSE and KEYCODE_HEADSETHOOK are handled already");
}
}
}
@RequiresApi(18)
public static class MediaSessionImplApi18 extends MediaSessionImplBase {
private static boolean sIsMbrPendingIntentSupported = true;
public MediaSessionImplApi18(Context context, String str, ComponentName componentName, PendingIntent pendingIntent, VersionedParcelable versionedParcelable, Bundle bundle) {
super(context, str, componentName, pendingIntent, versionedParcelable, bundle);
}
@Override // android.support.v4.media.session.MediaSessionCompat.MediaSessionImplBase, android.support.v4.media.session.MediaSessionCompat.MediaSessionImpl
public void setCallback(Callback callback, Handler handler) {
super.setCallback(callback, handler);
if (callback == null) {
this.mRcc.setPlaybackPositionUpdateListener(null);
} else {
this.mRcc.setPlaybackPositionUpdateListener(new RemoteControlClient.OnPlaybackPositionUpdateListener() { // from class: android.support.v4.media.session.MediaSessionCompat.MediaSessionImplApi18.1
@Override // android.media.RemoteControlClient.OnPlaybackPositionUpdateListener
public void onPlaybackPositionUpdate(long j) {
MediaSessionImplApi18.this.postToHandler(18, -1, -1, Long.valueOf(j), null);
}
});
}
}
@Override // android.support.v4.media.session.MediaSessionCompat.MediaSessionImplBase
public void setRccState(PlaybackStateCompat playbackStateCompat) {
long position = playbackStateCompat.getPosition();
float playbackSpeed = playbackStateCompat.getPlaybackSpeed();
long lastPositionUpdateTime = playbackStateCompat.getLastPositionUpdateTime();
long elapsedRealtime = SystemClock.elapsedRealtime();
if (playbackStateCompat.getState() == 3) {
long j = 0;
if (position > 0) {
if (lastPositionUpdateTime > 0) {
j = elapsedRealtime - lastPositionUpdateTime;
if (playbackSpeed > 0.0f && playbackSpeed != 1.0f) {
j = (long) (j * playbackSpeed);
}
}
position += j;
}
}
this.mRcc.setPlaybackState(getRccStateFromState(playbackStateCompat.getState()), position, playbackSpeed);
}
@Override // android.support.v4.media.session.MediaSessionCompat.MediaSessionImplBase
public int getRccTransportControlFlagsFromActions(long j) {
int rccTransportControlFlagsFromActions = super.getRccTransportControlFlagsFromActions(j);
return (j & 256) != 0 ? rccTransportControlFlagsFromActions | 256 : rccTransportControlFlagsFromActions;
}
@Override // android.support.v4.media.session.MediaSessionCompat.MediaSessionImplBase
public void registerMediaButtonEventReceiver(PendingIntent pendingIntent, ComponentName componentName) {
if (sIsMbrPendingIntentSupported) {
try {
this.mAudioManager.registerMediaButtonEventReceiver(pendingIntent);
} catch (NullPointerException unused) {
Log.w(MediaSessionCompat.TAG, "Unable to register media button event receiver with PendingIntent, falling back to ComponentName.");
sIsMbrPendingIntentSupported = false;
}
}
if (sIsMbrPendingIntentSupported) {
return;
}
super.registerMediaButtonEventReceiver(pendingIntent, componentName);
}
@Override // android.support.v4.media.session.MediaSessionCompat.MediaSessionImplBase
public void unregisterMediaButtonEventReceiver(PendingIntent pendingIntent, ComponentName componentName) {
if (sIsMbrPendingIntentSupported) {
this.mAudioManager.unregisterMediaButtonEventReceiver(pendingIntent);
} else {
super.unregisterMediaButtonEventReceiver(pendingIntent, componentName);
}
}
}
@RequiresApi(19)
public static class MediaSessionImplApi19 extends MediaSessionImplApi18 {
public MediaSessionImplApi19(Context context, String str, ComponentName componentName, PendingIntent pendingIntent, VersionedParcelable versionedParcelable, Bundle bundle) {
super(context, str, componentName, pendingIntent, versionedParcelable, bundle);
}
@Override // android.support.v4.media.session.MediaSessionCompat.MediaSessionImplApi18, android.support.v4.media.session.MediaSessionCompat.MediaSessionImplBase, android.support.v4.media.session.MediaSessionCompat.MediaSessionImpl
public void setCallback(Callback callback, Handler handler) {
super.setCallback(callback, handler);
if (callback == null) {
this.mRcc.setMetadataUpdateListener(null);
} else {
this.mRcc.setMetadataUpdateListener(new RemoteControlClient.OnMetadataUpdateListener() { // from class: android.support.v4.media.session.MediaSessionCompat.MediaSessionImplApi19.1
@Override // android.media.RemoteControlClient.OnMetadataUpdateListener
public void onMetadataUpdate(int i, Object obj) {
if (i == 268435457 && (obj instanceof Rating)) {
MediaSessionImplApi19.this.postToHandler(19, -1, -1, RatingCompat.fromRating(obj), null);
}
}
});
}
}
@Override // android.support.v4.media.session.MediaSessionCompat.MediaSessionImplApi18, android.support.v4.media.session.MediaSessionCompat.MediaSessionImplBase
public int getRccTransportControlFlagsFromActions(long j) {
int rccTransportControlFlagsFromActions = super.getRccTransportControlFlagsFromActions(j);
return (j & 128) != 0 ? rccTransportControlFlagsFromActions | 512 : rccTransportControlFlagsFromActions;
}
@Override // android.support.v4.media.session.MediaSessionCompat.MediaSessionImplBase
public RemoteControlClient.MetadataEditor buildRccMetadata(Bundle bundle) {
RemoteControlClient.MetadataEditor buildRccMetadata = super.buildRccMetadata(bundle);
PlaybackStateCompat playbackStateCompat = this.mState;
if (((playbackStateCompat == null ? 0L : playbackStateCompat.getActions()) & 128) != 0) {
buildRccMetadata.addEditableKey(268435457);
}
if (bundle == null) {
return buildRccMetadata;
}
if (bundle.containsKey(MediaMetadataCompat.METADATA_KEY_YEAR)) {
buildRccMetadata.putLong(8, bundle.getLong(MediaMetadataCompat.METADATA_KEY_YEAR));
}
if (bundle.containsKey(MediaMetadataCompat.METADATA_KEY_RATING)) {
buildRccMetadata.putObject(101, (Object) bundle.getParcelable(MediaMetadataCompat.METADATA_KEY_RATING));
}
if (bundle.containsKey(MediaMetadataCompat.METADATA_KEY_USER_RATING)) {
buildRccMetadata.putObject(268435457, (Object) bundle.getParcelable(MediaMetadataCompat.METADATA_KEY_USER_RATING));
}
return buildRccMetadata;
}
}
@RequiresApi(21)
public static class MediaSessionImplApi21 implements MediaSessionImpl {
@GuardedBy("mLock")
Callback mCallback;
boolean mCaptioningEnabled;
MediaMetadataCompat mMetadata;
PlaybackStateCompat mPlaybackState;
List<QueueItem> mQueue;
int mRatingType;
@GuardedBy("mLock")
MediaSessionManager.RemoteUserInfo mRemoteUserInfo;
int mRepeatMode;
final MediaSession mSessionFwk;
Bundle mSessionInfo;
int mShuffleMode;
final Token mToken;
final Object mLock = new Object();
boolean mDestroyed = false;
final RemoteCallbackList<IMediaControllerCallback> mExtraControllerCallbacks = new RemoteCallbackList<>();
@Override // android.support.v4.media.session.MediaSessionCompat.MediaSessionImpl
public Object getMediaSession() {
return this.mSessionFwk;
}
@Override // android.support.v4.media.session.MediaSessionCompat.MediaSessionImpl
public PlaybackStateCompat getPlaybackState() {
return this.mPlaybackState;
}
@Override // android.support.v4.media.session.MediaSessionCompat.MediaSessionImpl
public Object getRemoteControlClient() {
return null;
}
@Override // android.support.v4.media.session.MediaSessionCompat.MediaSessionImpl
public Token getSessionToken() {
return this.mToken;
}
public MediaSessionImplApi21(MediaSession mediaSession, VersionedParcelable versionedParcelable, Bundle bundle) {
this.mSessionFwk = mediaSession;
this.mToken = new Token(mediaSession.getSessionToken(), new ExtraSession(), versionedParcelable);
this.mSessionInfo = bundle;
setFlags(3);
}
public MediaSessionImplApi21(Object obj) {
if (!(obj instanceof MediaSession)) {
throw new IllegalArgumentException("mediaSession is not a valid MediaSession object");
}
MediaSession mediaSession = (MediaSession) obj;
this.mSessionFwk = mediaSession;
this.mToken = new Token(mediaSession.getSessionToken(), new ExtraSession());
this.mSessionInfo = null;
setFlags(3);
}
@Override // android.support.v4.media.session.MediaSessionCompat.MediaSessionImpl
public void setCallback(Callback callback, Handler handler) {
synchronized (this.mLock) {
try {
this.mCallback = callback;
this.mSessionFwk.setCallback(callback == null ? null : callback.mCallbackFwk, handler);
if (callback != null) {
callback.setSessionImpl(this, handler);
}
} catch (Throwable th) {
throw th;
}
}
}
@Override // android.support.v4.media.session.MediaSessionCompat.MediaSessionImpl
@SuppressLint({"WrongConstant"})
public void setFlags(int i) {
this.mSessionFwk.setFlags(i | 3);
}
@Override // android.support.v4.media.session.MediaSessionCompat.MediaSessionImpl
public void setPlaybackToLocal(int i) {
AudioAttributes.Builder builder = new AudioAttributes.Builder();
builder.setLegacyStreamType(i);
this.mSessionFwk.setPlaybackToLocal(builder.build());
}
@Override // android.support.v4.media.session.MediaSessionCompat.MediaSessionImpl
public void setPlaybackToRemote(VolumeProviderCompat volumeProviderCompat) {
this.mSessionFwk.setPlaybackToRemote((VolumeProvider) volumeProviderCompat.getVolumeProvider());
}
@Override // android.support.v4.media.session.MediaSessionCompat.MediaSessionImpl
public void setActive(boolean z) {
this.mSessionFwk.setActive(z);
}
@Override // android.support.v4.media.session.MediaSessionCompat.MediaSessionImpl
public boolean isActive() {
return this.mSessionFwk.isActive();
}
@Override // android.support.v4.media.session.MediaSessionCompat.MediaSessionImpl
public void sendSessionEvent(String str, Bundle bundle) {
this.mSessionFwk.sendSessionEvent(str, bundle);
}
@Override // android.support.v4.media.session.MediaSessionCompat.MediaSessionImpl
public void release() {
this.mDestroyed = true;
this.mExtraControllerCallbacks.kill();
if (Build.VERSION.SDK_INT == 27) {
try {
Field declaredField = this.mSessionFwk.getClass().getDeclaredField("mCallback");
declaredField.setAccessible(true);
Handler handler = (Handler) declaredField.get(this.mSessionFwk);
if (handler != null) {
handler.removeCallbacksAndMessages(null);
}
} catch (Exception e) {
Log.w(MediaSessionCompat.TAG, "Exception happened while accessing MediaSession.mCallback.", e);
}
}
this.mSessionFwk.setCallback(null);
this.mSessionFwk.release();
}
@Override // android.support.v4.media.session.MediaSessionCompat.MediaSessionImpl
public void setPlaybackState(PlaybackStateCompat playbackStateCompat) {
this.mPlaybackState = playbackStateCompat;
for (int beginBroadcast = this.mExtraControllerCallbacks.beginBroadcast() - 1; beginBroadcast >= 0; beginBroadcast--) {
try {
this.mExtraControllerCallbacks.getBroadcastItem(beginBroadcast).onPlaybackStateChanged(playbackStateCompat);
} catch (RemoteException unused) {
}
}
this.mExtraControllerCallbacks.finishBroadcast();
this.mSessionFwk.setPlaybackState(playbackStateCompat == null ? null : (PlaybackState) playbackStateCompat.getPlaybackState());
}
@Override // android.support.v4.media.session.MediaSessionCompat.MediaSessionImpl
public void setMetadata(MediaMetadataCompat mediaMetadataCompat) {
this.mMetadata = mediaMetadataCompat;
this.mSessionFwk.setMetadata(mediaMetadataCompat == null ? null : (MediaMetadata) mediaMetadataCompat.getMediaMetadata());
}
@Override // android.support.v4.media.session.MediaSessionCompat.MediaSessionImpl
public void setSessionActivity(PendingIntent pendingIntent) {
this.mSessionFwk.setSessionActivity(pendingIntent);
}
@Override // android.support.v4.media.session.MediaSessionCompat.MediaSessionImpl
public void setMediaButtonReceiver(PendingIntent pendingIntent) {
this.mSessionFwk.setMediaButtonReceiver(pendingIntent);
}
@Override // android.support.v4.media.session.MediaSessionCompat.MediaSessionImpl
public void setQueue(List<QueueItem> list) {
this.mQueue = list;
if (list == null) {
this.mSessionFwk.setQueue(null);
return;
}
ArrayList arrayList = new ArrayList();
Iterator<QueueItem> it = list.iterator();
while (it.hasNext()) {
arrayList.add((MediaSession.QueueItem) it.next().getQueueItem());
}
this.mSessionFwk.setQueue(arrayList);
}
@Override // android.support.v4.media.session.MediaSessionCompat.MediaSessionImpl
public void setQueueTitle(CharSequence charSequence) {
this.mSessionFwk.setQueueTitle(charSequence);
}
@Override // android.support.v4.media.session.MediaSessionCompat.MediaSessionImpl
public void setRatingType(int i) {
this.mSessionFwk.setRatingType(i);
}
@Override // android.support.v4.media.session.MediaSessionCompat.MediaSessionImpl
public void setCaptioningEnabled(boolean z) {
if (this.mCaptioningEnabled != z) {
this.mCaptioningEnabled = z;
for (int beginBroadcast = this.mExtraControllerCallbacks.beginBroadcast() - 1; beginBroadcast >= 0; beginBroadcast--) {
try {
this.mExtraControllerCallbacks.getBroadcastItem(beginBroadcast).onCaptioningEnabledChanged(z);
} catch (RemoteException unused) {
}
}
this.mExtraControllerCallbacks.finishBroadcast();
}
}
@Override // android.support.v4.media.session.MediaSessionCompat.MediaSessionImpl
public void setRepeatMode(int i) {
if (this.mRepeatMode != i) {
this.mRepeatMode = i;
for (int beginBroadcast = this.mExtraControllerCallbacks.beginBroadcast() - 1; beginBroadcast >= 0; beginBroadcast--) {
try {
this.mExtraControllerCallbacks.getBroadcastItem(beginBroadcast).onRepeatModeChanged(i);
} catch (RemoteException unused) {
}
}
this.mExtraControllerCallbacks.finishBroadcast();
}
}
@Override // android.support.v4.media.session.MediaSessionCompat.MediaSessionImpl
public void setShuffleMode(int i) {
if (this.mShuffleMode != i) {
this.mShuffleMode = i;
for (int beginBroadcast = this.mExtraControllerCallbacks.beginBroadcast() - 1; beginBroadcast >= 0; beginBroadcast--) {
try {
this.mExtraControllerCallbacks.getBroadcastItem(beginBroadcast).onShuffleModeChanged(i);
} catch (RemoteException unused) {
}
}
this.mExtraControllerCallbacks.finishBroadcast();
}
}
@Override // android.support.v4.media.session.MediaSessionCompat.MediaSessionImpl
public void setExtras(Bundle bundle) {
this.mSessionFwk.setExtras(bundle);
}
@Override // android.support.v4.media.session.MediaSessionCompat.MediaSessionImpl
public void setCurrentControllerInfo(MediaSessionManager.RemoteUserInfo remoteUserInfo) {
synchronized (this.mLock) {
this.mRemoteUserInfo = remoteUserInfo;
}
}
@Override // android.support.v4.media.session.MediaSessionCompat.MediaSessionImpl
public String getCallingPackage() {
try {
return (String) this.mSessionFwk.getClass().getMethod("getCallingPackage", new Class[0]).invoke(this.mSessionFwk, new Object[0]);
} catch (Exception e) {
Log.e(MediaSessionCompat.TAG, "Cannot execute MediaSession.getCallingPackage()", e);
return null;
}
}
@Override // android.support.v4.media.session.MediaSessionCompat.MediaSessionImpl
public MediaSessionManager.RemoteUserInfo getCurrentControllerInfo() {
MediaSessionManager.RemoteUserInfo remoteUserInfo;
synchronized (this.mLock) {
remoteUserInfo = this.mRemoteUserInfo;
}
return remoteUserInfo;
}
@Override // android.support.v4.media.session.MediaSessionCompat.MediaSessionImpl
public Callback getCallback() {
Callback callback;
synchronized (this.mLock) {
callback = this.mCallback;
}
return callback;
}
public class ExtraSession extends IMediaSession.Stub {
@Override // android.support.v4.media.session.IMediaSession
public List<QueueItem> getQueue() {
return null;
}
@Override // android.support.v4.media.session.IMediaSession
public boolean isShuffleModeEnabledRemoved() {
return false;
}
@Override // android.support.v4.media.session.IMediaSession
public void setShuffleModeEnabledRemoved(boolean z) throws RemoteException {
}
public ExtraSession() {
}
@Override // android.support.v4.media.session.IMediaSession
public void sendCommand(String str, Bundle bundle, ResultReceiverWrapper resultReceiverWrapper) {
throw new AssertionError();
}
@Override // android.support.v4.media.session.IMediaSession
public boolean sendMediaButton(KeyEvent keyEvent) {
throw new AssertionError();
}
@Override // android.support.v4.media.session.IMediaSession
public void registerCallbackListener(IMediaControllerCallback iMediaControllerCallback) {
if (MediaSessionImplApi21.this.mDestroyed) {
return;
}
MediaSessionImplApi21.this.mExtraControllerCallbacks.register(iMediaControllerCallback, new MediaSessionManager.RemoteUserInfo(MediaSessionManager.RemoteUserInfo.LEGACY_CONTROLLER, Binder.getCallingPid(), Binder.getCallingUid()));
}
@Override // android.support.v4.media.session.IMediaSession
public void unregisterCallbackListener(IMediaControllerCallback iMediaControllerCallback) {
MediaSessionImplApi21.this.mExtraControllerCallbacks.unregister(iMediaControllerCallback);
}
@Override // android.support.v4.media.session.IMediaSession
public String getPackageName() {
throw new AssertionError();
}
@Override // android.support.v4.media.session.IMediaSession
public Bundle getSessionInfo() {
if (MediaSessionImplApi21.this.mSessionInfo == null) {
return null;
}
return new Bundle(MediaSessionImplApi21.this.mSessionInfo);
}
@Override // android.support.v4.media.session.IMediaSession
public String getTag() {
throw new AssertionError();
}
@Override // android.support.v4.media.session.IMediaSession
public PendingIntent getLaunchPendingIntent() {
throw new AssertionError();
}
@Override // android.support.v4.media.session.IMediaSession
public long getFlags() {
throw new AssertionError();
}
@Override // android.support.v4.media.session.IMediaSession
public ParcelableVolumeInfo getVolumeAttributes() {
throw new AssertionError();
}
@Override // android.support.v4.media.session.IMediaSession
public void adjustVolume(int i, int i2, String str) {
throw new AssertionError();
}
@Override // android.support.v4.media.session.IMediaSession
public void setVolumeTo(int i, int i2, String str) {
throw new AssertionError();
}
@Override // android.support.v4.media.session.IMediaSession
public void prepare() throws RemoteException {
throw new AssertionError();
}
@Override // android.support.v4.media.session.IMediaSession
public void prepareFromMediaId(String str, Bundle bundle) throws RemoteException {
throw new AssertionError();
}
@Override // android.support.v4.media.session.IMediaSession
public void prepareFromSearch(String str, Bundle bundle) throws RemoteException {
throw new AssertionError();
}
@Override // android.support.v4.media.session.IMediaSession
public void prepareFromUri(Uri uri, Bundle bundle) throws RemoteException {
throw new AssertionError();
}
@Override // android.support.v4.media.session.IMediaSession
public void play() throws RemoteException {
throw new AssertionError();
}
@Override // android.support.v4.media.session.IMediaSession
public void playFromMediaId(String str, Bundle bundle) throws RemoteException {
throw new AssertionError();
}
@Override // android.support.v4.media.session.IMediaSession
public void playFromSearch(String str, Bundle bundle) throws RemoteException {
throw new AssertionError();
}
@Override // android.support.v4.media.session.IMediaSession
public void playFromUri(Uri uri, Bundle bundle) throws RemoteException {
throw new AssertionError();
}
@Override // android.support.v4.media.session.IMediaSession
public void skipToQueueItem(long j) {
throw new AssertionError();
}
@Override // android.support.v4.media.session.IMediaSession
public void pause() throws RemoteException {
throw new AssertionError();
}
@Override // android.support.v4.media.session.IMediaSession
public void stop() throws RemoteException {
throw new AssertionError();
}
@Override // android.support.v4.media.session.IMediaSession
public void next() throws RemoteException {
throw new AssertionError();
}
@Override // android.support.v4.media.session.IMediaSession
public void previous() throws RemoteException {
throw new AssertionError();
}
@Override // android.support.v4.media.session.IMediaSession
public void fastForward() throws RemoteException {
throw new AssertionError();
}
@Override // android.support.v4.media.session.IMediaSession
public void rewind() throws RemoteException {
throw new AssertionError();
}
@Override // android.support.v4.media.session.IMediaSession
public void seekTo(long j) throws RemoteException {
throw new AssertionError();
}
@Override // android.support.v4.media.session.IMediaSession
public void rate(RatingCompat ratingCompat) throws RemoteException {
throw new AssertionError();
}
@Override // android.support.v4.media.session.IMediaSession
public void rateWithExtras(RatingCompat ratingCompat, Bundle bundle) throws RemoteException {
throw new AssertionError();
}
@Override // android.support.v4.media.session.IMediaSession
public void setPlaybackSpeed(float f) throws RemoteException {
throw new AssertionError();
}
@Override // android.support.v4.media.session.IMediaSession
public void setCaptioningEnabled(boolean z) throws RemoteException {
throw new AssertionError();
}
@Override // android.support.v4.media.session.IMediaSession
public void setRepeatMode(int i) throws RemoteException {
throw new AssertionError();
}
@Override // android.support.v4.media.session.IMediaSession
public void setShuffleMode(int i) throws RemoteException {
throw new AssertionError();
}
@Override // android.support.v4.media.session.IMediaSession
public void sendCustomAction(String str, Bundle bundle) throws RemoteException {
throw new AssertionError();
}
@Override // android.support.v4.media.session.IMediaSession
public MediaMetadataCompat getMetadata() {
throw new AssertionError();
}
@Override // android.support.v4.media.session.IMediaSession
public PlaybackStateCompat getPlaybackState() {
MediaSessionImplApi21 mediaSessionImplApi21 = MediaSessionImplApi21.this;
return MediaSessionCompat.getStateWithUpdatedPosition(mediaSessionImplApi21.mPlaybackState, mediaSessionImplApi21.mMetadata);
}
@Override // android.support.v4.media.session.IMediaSession
public void addQueueItem(MediaDescriptionCompat mediaDescriptionCompat) {
throw new AssertionError();
}
@Override // android.support.v4.media.session.IMediaSession
public void addQueueItemAt(MediaDescriptionCompat mediaDescriptionCompat, int i) {
throw new AssertionError();
}
@Override // android.support.v4.media.session.IMediaSession
public void removeQueueItem(MediaDescriptionCompat mediaDescriptionCompat) {
throw new AssertionError();
}
@Override // android.support.v4.media.session.IMediaSession
public void removeQueueItemAt(int i) {
throw new AssertionError();
}
@Override // android.support.v4.media.session.IMediaSession
public CharSequence getQueueTitle() {
throw new AssertionError();
}
@Override // android.support.v4.media.session.IMediaSession
public Bundle getExtras() {
throw new AssertionError();
}
@Override // android.support.v4.media.session.IMediaSession
public int getRatingType() {
return MediaSessionImplApi21.this.mRatingType;
}
@Override // android.support.v4.media.session.IMediaSession
public boolean isCaptioningEnabled() {
return MediaSessionImplApi21.this.mCaptioningEnabled;
}
@Override // android.support.v4.media.session.IMediaSession
public int getRepeatMode() {
return MediaSessionImplApi21.this.mRepeatMode;
}
@Override // android.support.v4.media.session.IMediaSession
public int getShuffleMode() {
return MediaSessionImplApi21.this.mShuffleMode;
}
@Override // android.support.v4.media.session.IMediaSession
public boolean isTransportControlEnabled() {
throw new AssertionError();
}
}
}
@RequiresApi(28)
public static class MediaSessionImplApi28 extends MediaSessionImplApi21 {
@Override // android.support.v4.media.session.MediaSessionCompat.MediaSessionImplApi21, android.support.v4.media.session.MediaSessionCompat.MediaSessionImpl
public void setCurrentControllerInfo(MediaSessionManager.RemoteUserInfo remoteUserInfo) {
}
public MediaSessionImplApi28(MediaSession mediaSession, VersionedParcelable versionedParcelable, Bundle bundle) {
super(mediaSession, versionedParcelable, bundle);
}
public MediaSessionImplApi28(Object obj) {
super(obj);
}
@Override // android.support.v4.media.session.MediaSessionCompat.MediaSessionImplApi21, android.support.v4.media.session.MediaSessionCompat.MediaSessionImpl
@NonNull
public final MediaSessionManager.RemoteUserInfo getCurrentControllerInfo() {
MediaSessionManager.RemoteUserInfo currentControllerInfo;
currentControllerInfo = this.mSessionFwk.getCurrentControllerInfo();
return new MediaSessionManager.RemoteUserInfo(currentControllerInfo);
}
}
@RequiresApi(29)
public static class MediaSessionImplApi29 extends MediaSessionImplApi28 {
public MediaSessionImplApi29(MediaSession mediaSession, VersionedParcelable versionedParcelable, Bundle bundle) {
super(mediaSession, versionedParcelable, bundle);
}
public MediaSessionImplApi29(Object obj) {
super(obj);
Bundle sessionInfo;
sessionInfo = ((MediaSession) obj).getController().getSessionInfo();
this.mSessionInfo = sessionInfo;
}
}
}