* Decompile and recreate Soul Browser v1.4.85 with APK CI builds Co-authored-by: KaKi87 <KaKi87@pm.me> * Fix CI build: include bundled google.jks and remove PR trigger The apktool build failed in CI because app/unknown/.../google.jks was excluded by the *.jks gitignore rule. Whitelist app-bundled JKS files and commit the missing resource. Also remove the redundant pull_request workflow trigger. Co-authored-by: KaKi87 <KaKi87@pm.me> * Change package ID to com.github.kaki87.soulbrowser Rename the application ID so the rebuilt APK can be installed alongside the original Soul Browser from Google Play. - Update AndroidManifest package, permissions, providers, and actions - Update R class references in smali (com/github/kaki87/soulbrowser/R) - Update shortcuts.xml targetPackage - Rename app label to "Soul Rebuild" for easy identification Co-authored-by: KaKi87 <KaKi87@pm.me> * Fix install compatibility: remove split APK metadata and bundle native libs The rebuilt APK still declared requiredSplitTypes and Play Store split metadata, causing Android to reject standalone installs as incompatible. - Remove requiredSplitTypes and split-related manifest meta-data - Merge native libs from all ABI splits with uncompressed storage - Page-align before signing for extractNativeLibs=false - Add .so to apktool doNotCompress list Co-authored-by: KaKi87 <KaKi87@pm.me> * Fix install failure: use apksigner v2/v3 and bundle arm64 native libs Target SDK 36 requires APK Signature Scheme v2+, but jarsigner only produces v1 signatures, causing Android to reject the install. - Sign with apksigner (v1+v2+v3) instead of jarsigner - Add arm64-v8a native libraries from universal Soul Browser 1.4.79 - Set extractNativeLibs=true for reliable sideload installs - Commit stable debug keystore for consistent signatures across builds Co-authored-by: KaKi87 <KaKi87@pm.me> * Add committed debug keystore for consistent APK signatures Co-authored-by: KaKi87 <KaKi87@pm.me> * Fix startup crash: use original classes2.dex desugar libraries Apktool recompiles smali_classes2 into a broken classes2.dex, causing ClassNotFoundException for j$.com.android.tools.r8.a at ML Kit init. Inject the original classes2.dex (Java 8+ desugar libs) after apktool build instead of using the recompiled version. Co-authored-by: KaKi87 <KaKi87@pm.me> * Fix missing drawable resources from density split APKs The base APK is an app bundle module; density-specific drawables like seek_thumb_nor_b live in config.xhdpi.apk and were missing after rebuild, causing Resources$NotFoundException at runtime. - Merge non-9-patch resources from split APKs before apktool build - Sync public.xml IDs from R smali only when backing files exist - Add 713 density-specific resource IDs to public.xml Co-authored-by: KaKi87 <KaKi87@pm.me> --------- Co-authored-by: Cursor Agent <cursoragent@cursor.com>
1769 lines
80 KiB
Java
1769 lines
80 KiB
Java
package android.support.v4.media;
|
|
|
|
import android.annotation.SuppressLint;
|
|
import android.content.ComponentName;
|
|
import android.content.Context;
|
|
import android.content.Intent;
|
|
import android.content.ServiceConnection;
|
|
import android.media.MediaDescription;
|
|
import android.media.browse.MediaBrowser;
|
|
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.Message;
|
|
import android.os.Messenger;
|
|
import android.os.Parcel;
|
|
import android.os.Parcelable;
|
|
import android.os.Process;
|
|
import android.os.RemoteException;
|
|
import android.support.v4.media.session.IMediaSession;
|
|
import android.support.v4.media.session.MediaSessionCompat;
|
|
import android.support.v4.os.ResultReceiver;
|
|
import android.text.TextUtils;
|
|
import android.util.Log;
|
|
import androidx.annotation.DoNotInline;
|
|
import androidx.annotation.NonNull;
|
|
import androidx.annotation.Nullable;
|
|
import androidx.annotation.RequiresApi;
|
|
import androidx.annotation.RestrictTo;
|
|
import androidx.collection.ArrayMap;
|
|
import androidx.collection.SimpleArrayMap;
|
|
import androidx.media.MediaBrowserCompatUtils;
|
|
import java.lang.ref.WeakReference;
|
|
import java.util.ArrayList;
|
|
import java.util.Collections;
|
|
import java.util.Iterator;
|
|
import java.util.List;
|
|
import java.util.Map;
|
|
|
|
/* loaded from: classes.dex */
|
|
public final class MediaBrowserCompat {
|
|
public static final String CUSTOM_ACTION_DOWNLOAD = "android.support.v4.media.action.DOWNLOAD";
|
|
public static final String CUSTOM_ACTION_REMOVE_DOWNLOADED_FILE = "android.support.v4.media.action.REMOVE_DOWNLOADED_FILE";
|
|
public static final String EXTRA_DOWNLOAD_PROGRESS = "android.media.browse.extra.DOWNLOAD_PROGRESS";
|
|
public static final String EXTRA_MEDIA_ID = "android.media.browse.extra.MEDIA_ID";
|
|
public static final String EXTRA_PAGE = "android.media.browse.extra.PAGE";
|
|
public static final String EXTRA_PAGE_SIZE = "android.media.browse.extra.PAGE_SIZE";
|
|
private final MediaBrowserImpl mImpl;
|
|
static final String TAG = "MediaBrowserCompat";
|
|
static final boolean DEBUG = Log.isLoggable(TAG, 3);
|
|
|
|
@RequiresApi
|
|
/* loaded from: classes.dex */
|
|
public static class Api21Impl {
|
|
private Api21Impl() {
|
|
}
|
|
|
|
@DoNotInline
|
|
public static MediaDescription getDescription(MediaBrowser.MediaItem mediaItem) {
|
|
return mediaItem.getDescription();
|
|
}
|
|
|
|
@DoNotInline
|
|
public static int getFlags(MediaBrowser.MediaItem mediaItem) {
|
|
return mediaItem.getFlags();
|
|
}
|
|
}
|
|
|
|
/* loaded from: classes.dex */
|
|
public static class CallbackHandler extends Handler {
|
|
private final WeakReference<MediaBrowserServiceCallbackImpl> mCallbackImplRef;
|
|
private WeakReference<Messenger> mCallbacksMessengerRef;
|
|
|
|
public CallbackHandler(MediaBrowserServiceCallbackImpl mediaBrowserServiceCallbackImpl) {
|
|
this.mCallbackImplRef = new WeakReference<>(mediaBrowserServiceCallbackImpl);
|
|
}
|
|
|
|
@Override // android.os.Handler
|
|
public void handleMessage(@NonNull Message message) {
|
|
WeakReference<Messenger> weakReference = this.mCallbacksMessengerRef;
|
|
if (weakReference != null && weakReference.get() != null && this.mCallbackImplRef.get() != null) {
|
|
Bundle data = message.getData();
|
|
MediaSessionCompat.ensureClassLoader(data);
|
|
MediaBrowserServiceCallbackImpl mediaBrowserServiceCallbackImpl = this.mCallbackImplRef.get();
|
|
Messenger messenger = this.mCallbacksMessengerRef.get();
|
|
try {
|
|
int i = message.what;
|
|
if (i != 1) {
|
|
if (i != 2) {
|
|
if (i != 3) {
|
|
Log.w(MediaBrowserCompat.TAG, "Unhandled message: " + message + "\n Client version: 1\n Service version: " + message.arg1);
|
|
return;
|
|
}
|
|
Bundle bundle = data.getBundle("data_options");
|
|
MediaSessionCompat.ensureClassLoader(bundle);
|
|
Bundle bundle2 = data.getBundle("data_notify_children_changed_options");
|
|
MediaSessionCompat.ensureClassLoader(bundle2);
|
|
mediaBrowserServiceCallbackImpl.onLoadChildren(messenger, data.getString("data_media_item_id"), data.getParcelableArrayList("data_media_item_list"), bundle, bundle2);
|
|
return;
|
|
}
|
|
mediaBrowserServiceCallbackImpl.onConnectionFailed(messenger);
|
|
return;
|
|
}
|
|
Bundle bundle3 = data.getBundle("data_root_hints");
|
|
MediaSessionCompat.ensureClassLoader(bundle3);
|
|
mediaBrowserServiceCallbackImpl.onServiceConnected(messenger, data.getString("data_media_item_id"), (MediaSessionCompat.Token) data.getParcelable("data_media_session_token"), bundle3);
|
|
} catch (BadParcelableException unused) {
|
|
Log.e(MediaBrowserCompat.TAG, "Could not unparcel the data.");
|
|
if (message.what == 1) {
|
|
mediaBrowserServiceCallbackImpl.onConnectionFailed(messenger);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
public void setCallbacksMessenger(Messenger messenger) {
|
|
this.mCallbacksMessengerRef = new WeakReference<>(messenger);
|
|
}
|
|
}
|
|
|
|
/* loaded from: classes.dex */
|
|
public static class ConnectionCallback {
|
|
final MediaBrowser.ConnectionCallback mConnectionCallbackFwk = new ConnectionCallbackApi21();
|
|
ConnectionCallbackInternal mConnectionCallbackInternal;
|
|
|
|
@RequiresApi
|
|
/* loaded from: classes.dex */
|
|
public class ConnectionCallbackApi21 extends MediaBrowser.ConnectionCallback {
|
|
public ConnectionCallbackApi21() {
|
|
}
|
|
|
|
@Override // android.media.browse.MediaBrowser.ConnectionCallback
|
|
public void onConnected() {
|
|
ConnectionCallbackInternal connectionCallbackInternal = ConnectionCallback.this.mConnectionCallbackInternal;
|
|
if (connectionCallbackInternal != null) {
|
|
connectionCallbackInternal.onConnected();
|
|
}
|
|
ConnectionCallback.this.onConnected();
|
|
}
|
|
|
|
@Override // android.media.browse.MediaBrowser.ConnectionCallback
|
|
public void onConnectionFailed() {
|
|
ConnectionCallbackInternal connectionCallbackInternal = ConnectionCallback.this.mConnectionCallbackInternal;
|
|
if (connectionCallbackInternal != null) {
|
|
connectionCallbackInternal.onConnectionFailed();
|
|
}
|
|
ConnectionCallback.this.onConnectionFailed();
|
|
}
|
|
|
|
@Override // android.media.browse.MediaBrowser.ConnectionCallback
|
|
public void onConnectionSuspended() {
|
|
ConnectionCallbackInternal connectionCallbackInternal = ConnectionCallback.this.mConnectionCallbackInternal;
|
|
if (connectionCallbackInternal != null) {
|
|
connectionCallbackInternal.onConnectionSuspended();
|
|
}
|
|
ConnectionCallback.this.onConnectionSuspended();
|
|
}
|
|
}
|
|
|
|
/* loaded from: classes.dex */
|
|
public interface ConnectionCallbackInternal {
|
|
void onConnected();
|
|
|
|
void onConnectionFailed();
|
|
|
|
void onConnectionSuspended();
|
|
}
|
|
|
|
public void onConnected() {
|
|
}
|
|
|
|
public void onConnectionFailed() {
|
|
}
|
|
|
|
public void onConnectionSuspended() {
|
|
}
|
|
|
|
public void setInternalConnectionCallback(ConnectionCallbackInternal connectionCallbackInternal) {
|
|
this.mConnectionCallbackInternal = connectionCallbackInternal;
|
|
}
|
|
}
|
|
|
|
/* loaded from: classes.dex */
|
|
public static abstract class CustomActionCallback {
|
|
public void onError(String str, Bundle bundle, Bundle bundle2) {
|
|
}
|
|
|
|
public void onProgressUpdate(String str, Bundle bundle, Bundle bundle2) {
|
|
}
|
|
|
|
public void onResult(String str, Bundle bundle, Bundle bundle2) {
|
|
}
|
|
}
|
|
|
|
/* loaded from: classes.dex */
|
|
public static class CustomActionResultReceiver extends ResultReceiver {
|
|
private final String mAction;
|
|
private final CustomActionCallback mCallback;
|
|
private final Bundle mExtras;
|
|
|
|
public CustomActionResultReceiver(String str, Bundle bundle, CustomActionCallback customActionCallback, Handler handler) {
|
|
super(handler);
|
|
this.mAction = str;
|
|
this.mExtras = bundle;
|
|
this.mCallback = customActionCallback;
|
|
}
|
|
|
|
@Override // android.support.v4.os.ResultReceiver
|
|
public void onReceiveResult(int i, Bundle bundle) {
|
|
if (this.mCallback == null) {
|
|
return;
|
|
}
|
|
MediaSessionCompat.ensureClassLoader(bundle);
|
|
if (i != -1) {
|
|
if (i != 0) {
|
|
if (i != 1) {
|
|
StringBuilder s = a.s(i, "Unknown result code: ", " (extras=");
|
|
s.append(this.mExtras);
|
|
s.append(", resultData=");
|
|
s.append(bundle);
|
|
s.append(")");
|
|
Log.w(MediaBrowserCompat.TAG, s.toString());
|
|
return;
|
|
}
|
|
this.mCallback.onProgressUpdate(this.mAction, this.mExtras, bundle);
|
|
return;
|
|
}
|
|
this.mCallback.onResult(this.mAction, this.mExtras, bundle);
|
|
return;
|
|
}
|
|
this.mCallback.onError(this.mAction, this.mExtras, bundle);
|
|
}
|
|
}
|
|
|
|
/* loaded from: classes.dex */
|
|
public static abstract class ItemCallback {
|
|
final MediaBrowser.ItemCallback mItemCallbackFwk = new ItemCallbackApi23();
|
|
|
|
@RequiresApi
|
|
/* loaded from: classes.dex */
|
|
public class ItemCallbackApi23 extends MediaBrowser.ItemCallback {
|
|
public ItemCallbackApi23() {
|
|
}
|
|
|
|
@Override // android.media.browse.MediaBrowser.ItemCallback
|
|
public void onError(@NonNull String str) {
|
|
ItemCallback.this.onError(str);
|
|
}
|
|
|
|
@Override // android.media.browse.MediaBrowser.ItemCallback
|
|
public void onItemLoaded(MediaBrowser.MediaItem mediaItem) {
|
|
ItemCallback.this.onItemLoaded(MediaItem.fromMediaItem(mediaItem));
|
|
}
|
|
}
|
|
|
|
public void onError(@NonNull String str) {
|
|
}
|
|
|
|
public void onItemLoaded(MediaItem mediaItem) {
|
|
}
|
|
}
|
|
|
|
/* loaded from: classes.dex */
|
|
public static class ItemReceiver extends ResultReceiver {
|
|
private final ItemCallback mCallback;
|
|
private final String mMediaId;
|
|
|
|
public ItemReceiver(String str, ItemCallback itemCallback, Handler handler) {
|
|
super(handler);
|
|
this.mMediaId = str;
|
|
this.mCallback = itemCallback;
|
|
}
|
|
|
|
@Override // android.support.v4.os.ResultReceiver
|
|
public void onReceiveResult(int i, Bundle bundle) {
|
|
if (bundle != null) {
|
|
bundle = MediaSessionCompat.unparcelWithClassLoader(bundle);
|
|
}
|
|
if (i == 0 && bundle != null && bundle.containsKey("media_item")) {
|
|
Parcelable parcelable = bundle.getParcelable("media_item");
|
|
if (parcelable != null && !(parcelable instanceof MediaItem)) {
|
|
this.mCallback.onError(this.mMediaId);
|
|
return;
|
|
} else {
|
|
this.mCallback.onItemLoaded((MediaItem) parcelable);
|
|
return;
|
|
}
|
|
}
|
|
this.mCallback.onError(this.mMediaId);
|
|
}
|
|
}
|
|
|
|
/* loaded from: classes.dex */
|
|
public interface MediaBrowserImpl {
|
|
void connect();
|
|
|
|
void disconnect();
|
|
|
|
@Nullable
|
|
Bundle getExtras();
|
|
|
|
void getItem(@NonNull String str, @NonNull ItemCallback itemCallback);
|
|
|
|
@Nullable
|
|
Bundle getNotifyChildrenChangedOptions();
|
|
|
|
@NonNull
|
|
String getRoot();
|
|
|
|
ComponentName getServiceComponent();
|
|
|
|
@NonNull
|
|
MediaSessionCompat.Token getSessionToken();
|
|
|
|
boolean isConnected();
|
|
|
|
void search(@NonNull String str, Bundle bundle, @NonNull SearchCallback searchCallback);
|
|
|
|
void sendCustomAction(@NonNull String str, Bundle bundle, @Nullable CustomActionCallback customActionCallback);
|
|
|
|
void subscribe(@NonNull String str, @Nullable Bundle bundle, @NonNull SubscriptionCallback subscriptionCallback);
|
|
|
|
void unsubscribe(@NonNull String str, SubscriptionCallback subscriptionCallback);
|
|
}
|
|
|
|
@RequiresApi
|
|
/* loaded from: classes.dex */
|
|
public static class MediaBrowserImplApi21 implements MediaBrowserImpl, MediaBrowserServiceCallbackImpl, ConnectionCallback.ConnectionCallbackInternal {
|
|
protected final MediaBrowser mBrowserFwk;
|
|
protected Messenger mCallbacksMessenger;
|
|
final Context mContext;
|
|
private MediaSessionCompat.Token mMediaSessionToken;
|
|
private Bundle mNotifyChildrenChangedOptions;
|
|
protected final Bundle mRootHints;
|
|
protected ServiceBinderWrapper mServiceBinderWrapper;
|
|
protected int mServiceVersion;
|
|
protected final CallbackHandler mHandler = new CallbackHandler(this);
|
|
private final ArrayMap<String, Subscription> mSubscriptions = new SimpleArrayMap(0);
|
|
|
|
/* JADX WARN: Type inference failed for: r0v1, types: [androidx.collection.ArrayMap<java.lang.String, android.support.v4.media.MediaBrowserCompat$Subscription>, androidx.collection.SimpleArrayMap] */
|
|
public MediaBrowserImplApi21(Context context, ComponentName componentName, ConnectionCallback connectionCallback, Bundle bundle) {
|
|
Bundle bundle2;
|
|
this.mContext = context;
|
|
if (bundle != null) {
|
|
bundle2 = new Bundle(bundle);
|
|
} else {
|
|
bundle2 = new Bundle();
|
|
}
|
|
this.mRootHints = bundle2;
|
|
bundle2.putInt("extra_client_version", 1);
|
|
bundle2.putInt("extra_calling_pid", Process.myPid());
|
|
connectionCallback.setInternalConnectionCallback(this);
|
|
this.mBrowserFwk = new MediaBrowser(context, componentName, connectionCallback.mConnectionCallbackFwk, bundle2);
|
|
}
|
|
|
|
@Override // android.support.v4.media.MediaBrowserCompat.MediaBrowserImpl
|
|
public void connect() {
|
|
this.mBrowserFwk.connect();
|
|
}
|
|
|
|
@Override // android.support.v4.media.MediaBrowserCompat.MediaBrowserImpl
|
|
public void disconnect() {
|
|
Messenger messenger;
|
|
ServiceBinderWrapper serviceBinderWrapper = this.mServiceBinderWrapper;
|
|
if (serviceBinderWrapper != null && (messenger = this.mCallbacksMessenger) != null) {
|
|
try {
|
|
serviceBinderWrapper.unregisterCallbackMessenger(messenger);
|
|
} catch (RemoteException unused) {
|
|
Log.i(MediaBrowserCompat.TAG, "Remote error unregistering client messenger.");
|
|
}
|
|
}
|
|
this.mBrowserFwk.disconnect();
|
|
}
|
|
|
|
@Override // android.support.v4.media.MediaBrowserCompat.MediaBrowserImpl
|
|
@Nullable
|
|
public Bundle getExtras() {
|
|
return this.mBrowserFwk.getExtras();
|
|
}
|
|
|
|
@Override // android.support.v4.media.MediaBrowserCompat.MediaBrowserImpl
|
|
public void getItem(@NonNull final String str, @NonNull final ItemCallback itemCallback) {
|
|
if (!TextUtils.isEmpty(str)) {
|
|
if (itemCallback != null) {
|
|
if (!this.mBrowserFwk.isConnected()) {
|
|
Log.i(MediaBrowserCompat.TAG, "Not connected, unable to retrieve the MediaItem.");
|
|
this.mHandler.post(new Runnable() { // from class: android.support.v4.media.MediaBrowserCompat.MediaBrowserImplApi21.1
|
|
@Override // java.lang.Runnable
|
|
public void run() {
|
|
itemCallback.onError(str);
|
|
}
|
|
});
|
|
return;
|
|
} else {
|
|
if (this.mServiceBinderWrapper == null) {
|
|
this.mHandler.post(new Runnable() { // from class: android.support.v4.media.MediaBrowserCompat.MediaBrowserImplApi21.2
|
|
@Override // java.lang.Runnable
|
|
public void run() {
|
|
itemCallback.onError(str);
|
|
}
|
|
});
|
|
return;
|
|
}
|
|
try {
|
|
this.mServiceBinderWrapper.getMediaItem(str, new ItemReceiver(str, itemCallback, this.mHandler), this.mCallbacksMessenger);
|
|
return;
|
|
} catch (RemoteException unused) {
|
|
Log.i(MediaBrowserCompat.TAG, "Remote error getting media item: " + str);
|
|
this.mHandler.post(new Runnable() { // from class: android.support.v4.media.MediaBrowserCompat.MediaBrowserImplApi21.3
|
|
@Override // java.lang.Runnable
|
|
public void run() {
|
|
itemCallback.onError(str);
|
|
}
|
|
});
|
|
return;
|
|
}
|
|
}
|
|
}
|
|
throw new IllegalArgumentException("cb is null");
|
|
}
|
|
throw new IllegalArgumentException("mediaId is empty");
|
|
}
|
|
|
|
@Override // android.support.v4.media.MediaBrowserCompat.MediaBrowserImpl
|
|
public Bundle getNotifyChildrenChangedOptions() {
|
|
return this.mNotifyChildrenChangedOptions;
|
|
}
|
|
|
|
@Override // android.support.v4.media.MediaBrowserCompat.MediaBrowserImpl
|
|
@NonNull
|
|
public String getRoot() {
|
|
return this.mBrowserFwk.getRoot();
|
|
}
|
|
|
|
@Override // android.support.v4.media.MediaBrowserCompat.MediaBrowserImpl
|
|
public ComponentName getServiceComponent() {
|
|
return this.mBrowserFwk.getServiceComponent();
|
|
}
|
|
|
|
@Override // android.support.v4.media.MediaBrowserCompat.MediaBrowserImpl
|
|
@NonNull
|
|
public MediaSessionCompat.Token getSessionToken() {
|
|
if (this.mMediaSessionToken == null) {
|
|
this.mMediaSessionToken = MediaSessionCompat.Token.fromToken(this.mBrowserFwk.getSessionToken());
|
|
}
|
|
return this.mMediaSessionToken;
|
|
}
|
|
|
|
@Override // android.support.v4.media.MediaBrowserCompat.MediaBrowserImpl
|
|
public boolean isConnected() {
|
|
return this.mBrowserFwk.isConnected();
|
|
}
|
|
|
|
@Override // android.support.v4.media.MediaBrowserCompat.ConnectionCallback.ConnectionCallbackInternal
|
|
public void onConnected() {
|
|
try {
|
|
Bundle extras = this.mBrowserFwk.getExtras();
|
|
if (extras != null) {
|
|
this.mServiceVersion = extras.getInt("extra_service_version", 0);
|
|
IBinder binder = extras.getBinder("extra_messenger");
|
|
if (binder != null) {
|
|
this.mServiceBinderWrapper = new ServiceBinderWrapper(binder, this.mRootHints);
|
|
Messenger messenger = new Messenger(this.mHandler);
|
|
this.mCallbacksMessenger = messenger;
|
|
this.mHandler.setCallbacksMessenger(messenger);
|
|
try {
|
|
this.mServiceBinderWrapper.registerCallbackMessenger(this.mContext, this.mCallbacksMessenger);
|
|
} catch (RemoteException unused) {
|
|
Log.i(MediaBrowserCompat.TAG, "Remote error registering client messenger.");
|
|
}
|
|
}
|
|
IMediaSession asInterface = IMediaSession.Stub.asInterface(extras.getBinder("extra_session_binder"));
|
|
if (asInterface != null) {
|
|
this.mMediaSessionToken = MediaSessionCompat.Token.fromToken(this.mBrowserFwk.getSessionToken(), asInterface);
|
|
}
|
|
}
|
|
} catch (IllegalStateException e) {
|
|
Log.e(MediaBrowserCompat.TAG, "Unexpected IllegalStateException", e);
|
|
}
|
|
}
|
|
|
|
@Override // android.support.v4.media.MediaBrowserCompat.ConnectionCallback.ConnectionCallbackInternal
|
|
public void onConnectionFailed() {
|
|
}
|
|
|
|
@Override // android.support.v4.media.MediaBrowserCompat.ConnectionCallback.ConnectionCallbackInternal
|
|
public void onConnectionSuspended() {
|
|
this.mServiceBinderWrapper = null;
|
|
this.mCallbacksMessenger = null;
|
|
this.mMediaSessionToken = null;
|
|
this.mHandler.setCallbacksMessenger(null);
|
|
}
|
|
|
|
@Override // android.support.v4.media.MediaBrowserCompat.MediaBrowserServiceCallbackImpl
|
|
public void onLoadChildren(Messenger messenger, String str, List<MediaItem> list, Bundle bundle, Bundle bundle2) {
|
|
if (this.mCallbacksMessenger == messenger) {
|
|
Subscription subscription = (Subscription) this.mSubscriptions.get(str);
|
|
if (subscription == null) {
|
|
if (MediaBrowserCompat.DEBUG) {
|
|
Log.d(MediaBrowserCompat.TAG, "onLoadChildren for id that isn't subscribed id=" + str);
|
|
return;
|
|
}
|
|
return;
|
|
}
|
|
SubscriptionCallback callback = subscription.getCallback(bundle);
|
|
if (callback != null) {
|
|
if (bundle == null) {
|
|
if (list == null) {
|
|
callback.onError(str);
|
|
return;
|
|
}
|
|
this.mNotifyChildrenChangedOptions = bundle2;
|
|
callback.onChildrenLoaded(str, list);
|
|
this.mNotifyChildrenChangedOptions = null;
|
|
return;
|
|
}
|
|
if (list == null) {
|
|
callback.onError(str, bundle);
|
|
return;
|
|
}
|
|
this.mNotifyChildrenChangedOptions = bundle2;
|
|
callback.onChildrenLoaded(str, list, bundle);
|
|
this.mNotifyChildrenChangedOptions = null;
|
|
}
|
|
}
|
|
}
|
|
|
|
@Override // android.support.v4.media.MediaBrowserCompat.MediaBrowserServiceCallbackImpl
|
|
public void onServiceConnected(Messenger messenger, String str, MediaSessionCompat.Token token, Bundle bundle) {
|
|
}
|
|
|
|
@Override // android.support.v4.media.MediaBrowserCompat.MediaBrowserImpl
|
|
public void search(@NonNull final String str, final Bundle bundle, @NonNull final SearchCallback searchCallback) {
|
|
if (isConnected()) {
|
|
if (this.mServiceBinderWrapper == null) {
|
|
Log.i(MediaBrowserCompat.TAG, "The connected service doesn't support search.");
|
|
this.mHandler.post(new Runnable() { // from class: android.support.v4.media.MediaBrowserCompat.MediaBrowserImplApi21.4
|
|
@Override // java.lang.Runnable
|
|
public void run() {
|
|
searchCallback.onError(str, bundle);
|
|
}
|
|
});
|
|
return;
|
|
}
|
|
try {
|
|
this.mServiceBinderWrapper.search(str, bundle, new SearchResultReceiver(str, bundle, searchCallback, this.mHandler), this.mCallbacksMessenger);
|
|
return;
|
|
} catch (RemoteException e) {
|
|
Log.i(MediaBrowserCompat.TAG, "Remote error searching items with query: " + str, e);
|
|
this.mHandler.post(new Runnable() { // from class: android.support.v4.media.MediaBrowserCompat.MediaBrowserImplApi21.5
|
|
@Override // java.lang.Runnable
|
|
public void run() {
|
|
searchCallback.onError(str, bundle);
|
|
}
|
|
});
|
|
return;
|
|
}
|
|
}
|
|
throw new IllegalStateException("search() called while not connected");
|
|
}
|
|
|
|
@Override // android.support.v4.media.MediaBrowserCompat.MediaBrowserImpl
|
|
public void sendCustomAction(@NonNull final String str, final Bundle bundle, @Nullable final CustomActionCallback customActionCallback) {
|
|
if (isConnected()) {
|
|
if (this.mServiceBinderWrapper == null) {
|
|
Log.i(MediaBrowserCompat.TAG, "The connected service doesn't support sendCustomAction.");
|
|
if (customActionCallback != null) {
|
|
this.mHandler.post(new Runnable() { // from class: android.support.v4.media.MediaBrowserCompat.MediaBrowserImplApi21.6
|
|
@Override // java.lang.Runnable
|
|
public void run() {
|
|
customActionCallback.onError(str, bundle, null);
|
|
}
|
|
});
|
|
}
|
|
}
|
|
try {
|
|
this.mServiceBinderWrapper.sendCustomAction(str, bundle, new CustomActionResultReceiver(str, bundle, customActionCallback, this.mHandler), this.mCallbacksMessenger);
|
|
return;
|
|
} catch (RemoteException e) {
|
|
Log.i(MediaBrowserCompat.TAG, "Remote error sending a custom action: action=" + str + ", extras=" + bundle, e);
|
|
if (customActionCallback != null) {
|
|
this.mHandler.post(new Runnable() { // from class: android.support.v4.media.MediaBrowserCompat.MediaBrowserImplApi21.7
|
|
@Override // java.lang.Runnable
|
|
public void run() {
|
|
customActionCallback.onError(str, bundle, null);
|
|
}
|
|
});
|
|
return;
|
|
}
|
|
return;
|
|
}
|
|
}
|
|
throw new IllegalStateException("Cannot send a custom action (" + str + ") with extras " + bundle + " because the browser is not connected to the service.");
|
|
}
|
|
|
|
@Override // android.support.v4.media.MediaBrowserCompat.MediaBrowserImpl
|
|
public void subscribe(@NonNull String str, Bundle bundle, @NonNull SubscriptionCallback subscriptionCallback) {
|
|
Bundle bundle2;
|
|
Subscription subscription = (Subscription) this.mSubscriptions.get(str);
|
|
if (subscription == null) {
|
|
subscription = new Subscription();
|
|
this.mSubscriptions.put(str, subscription);
|
|
}
|
|
subscriptionCallback.setSubscription(subscription);
|
|
if (bundle == null) {
|
|
bundle2 = null;
|
|
} else {
|
|
bundle2 = new Bundle(bundle);
|
|
}
|
|
subscription.putCallback(bundle2, subscriptionCallback);
|
|
ServiceBinderWrapper serviceBinderWrapper = this.mServiceBinderWrapper;
|
|
if (serviceBinderWrapper == null) {
|
|
this.mBrowserFwk.subscribe(str, subscriptionCallback.mSubscriptionCallbackFwk);
|
|
return;
|
|
}
|
|
try {
|
|
serviceBinderWrapper.addSubscription(str, subscriptionCallback.mToken, bundle2, this.mCallbacksMessenger);
|
|
} catch (RemoteException unused) {
|
|
Log.i(MediaBrowserCompat.TAG, "Remote error subscribing media item: " + str);
|
|
}
|
|
}
|
|
|
|
@Override // android.support.v4.media.MediaBrowserCompat.MediaBrowserImpl
|
|
public void unsubscribe(@NonNull String str, SubscriptionCallback subscriptionCallback) {
|
|
Subscription subscription = (Subscription) this.mSubscriptions.get(str);
|
|
if (subscription != null) {
|
|
ServiceBinderWrapper serviceBinderWrapper = this.mServiceBinderWrapper;
|
|
if (serviceBinderWrapper == null) {
|
|
if (subscriptionCallback == null) {
|
|
this.mBrowserFwk.unsubscribe(str);
|
|
} else {
|
|
List<SubscriptionCallback> callbacks = subscription.getCallbacks();
|
|
List<Bundle> optionsList = subscription.getOptionsList();
|
|
for (int size = callbacks.size() - 1; size >= 0; size--) {
|
|
if (callbacks.get(size) == subscriptionCallback) {
|
|
callbacks.remove(size);
|
|
optionsList.remove(size);
|
|
}
|
|
}
|
|
if (callbacks.size() == 0) {
|
|
this.mBrowserFwk.unsubscribe(str);
|
|
}
|
|
}
|
|
} else {
|
|
try {
|
|
if (subscriptionCallback == null) {
|
|
serviceBinderWrapper.removeSubscription(str, null, this.mCallbacksMessenger);
|
|
} else {
|
|
List<SubscriptionCallback> callbacks2 = subscription.getCallbacks();
|
|
List<Bundle> optionsList2 = subscription.getOptionsList();
|
|
for (int size2 = callbacks2.size() - 1; size2 >= 0; size2--) {
|
|
if (callbacks2.get(size2) == subscriptionCallback) {
|
|
this.mServiceBinderWrapper.removeSubscription(str, subscriptionCallback.mToken, this.mCallbacksMessenger);
|
|
callbacks2.remove(size2);
|
|
optionsList2.remove(size2);
|
|
}
|
|
}
|
|
}
|
|
} catch (RemoteException unused) {
|
|
Log.d(MediaBrowserCompat.TAG, "removeSubscription failed with RemoteException parentId=" + str);
|
|
}
|
|
}
|
|
if (subscription.isEmpty() || subscriptionCallback == null) {
|
|
this.mSubscriptions.remove(str);
|
|
}
|
|
}
|
|
}
|
|
|
|
@Override // android.support.v4.media.MediaBrowserCompat.MediaBrowserServiceCallbackImpl
|
|
public void onConnectionFailed(Messenger messenger) {
|
|
}
|
|
}
|
|
|
|
@RequiresApi
|
|
/* loaded from: classes.dex */
|
|
public static class MediaBrowserImplApi23 extends MediaBrowserImplApi21 {
|
|
public MediaBrowserImplApi23(Context context, ComponentName componentName, ConnectionCallback connectionCallback, Bundle bundle) {
|
|
super(context, componentName, connectionCallback, bundle);
|
|
}
|
|
|
|
@Override // android.support.v4.media.MediaBrowserCompat.MediaBrowserImplApi21, android.support.v4.media.MediaBrowserCompat.MediaBrowserImpl
|
|
public void getItem(@NonNull String str, @NonNull ItemCallback itemCallback) {
|
|
if (this.mServiceBinderWrapper == null) {
|
|
this.mBrowserFwk.getItem(str, itemCallback.mItemCallbackFwk);
|
|
} else {
|
|
super.getItem(str, itemCallback);
|
|
}
|
|
}
|
|
}
|
|
|
|
@RequiresApi
|
|
/* loaded from: classes.dex */
|
|
public static class MediaBrowserImplApi26 extends MediaBrowserImplApi23 {
|
|
public MediaBrowserImplApi26(Context context, ComponentName componentName, ConnectionCallback connectionCallback, Bundle bundle) {
|
|
super(context, componentName, connectionCallback, bundle);
|
|
}
|
|
|
|
@Override // android.support.v4.media.MediaBrowserCompat.MediaBrowserImplApi21, android.support.v4.media.MediaBrowserCompat.MediaBrowserImpl
|
|
public void subscribe(@NonNull String str, @Nullable Bundle bundle, @NonNull SubscriptionCallback subscriptionCallback) {
|
|
if (this.mServiceBinderWrapper != null && this.mServiceVersion >= 2) {
|
|
super.subscribe(str, bundle, subscriptionCallback);
|
|
} else if (bundle == null) {
|
|
this.mBrowserFwk.subscribe(str, subscriptionCallback.mSubscriptionCallbackFwk);
|
|
} else {
|
|
this.mBrowserFwk.subscribe(str, bundle, subscriptionCallback.mSubscriptionCallbackFwk);
|
|
}
|
|
}
|
|
|
|
@Override // android.support.v4.media.MediaBrowserCompat.MediaBrowserImplApi21, android.support.v4.media.MediaBrowserCompat.MediaBrowserImpl
|
|
public void unsubscribe(@NonNull String str, SubscriptionCallback subscriptionCallback) {
|
|
if (this.mServiceBinderWrapper != null && this.mServiceVersion >= 2) {
|
|
super.unsubscribe(str, subscriptionCallback);
|
|
} else if (subscriptionCallback == null) {
|
|
this.mBrowserFwk.unsubscribe(str);
|
|
} else {
|
|
this.mBrowserFwk.unsubscribe(str, subscriptionCallback.mSubscriptionCallbackFwk);
|
|
}
|
|
}
|
|
}
|
|
|
|
/* loaded from: classes.dex */
|
|
public static class MediaBrowserImplBase implements MediaBrowserImpl, MediaBrowserServiceCallbackImpl {
|
|
static final int CONNECT_STATE_CONNECTED = 3;
|
|
static final int CONNECT_STATE_CONNECTING = 2;
|
|
static final int CONNECT_STATE_DISCONNECTED = 1;
|
|
static final int CONNECT_STATE_DISCONNECTING = 0;
|
|
static final int CONNECT_STATE_SUSPENDED = 4;
|
|
final ConnectionCallback mCallback;
|
|
Messenger mCallbacksMessenger;
|
|
final Context mContext;
|
|
private Bundle mExtras;
|
|
private MediaSessionCompat.Token mMediaSessionToken;
|
|
private Bundle mNotifyChildrenChangedOptions;
|
|
final Bundle mRootHints;
|
|
private String mRootId;
|
|
ServiceBinderWrapper mServiceBinderWrapper;
|
|
final ComponentName mServiceComponent;
|
|
MediaServiceConnection mServiceConnection;
|
|
final CallbackHandler mHandler = new CallbackHandler(this);
|
|
private final ArrayMap<String, Subscription> mSubscriptions = new SimpleArrayMap(0);
|
|
int mState = 1;
|
|
|
|
/* loaded from: classes.dex */
|
|
public class MediaServiceConnection implements ServiceConnection {
|
|
public MediaServiceConnection() {
|
|
}
|
|
|
|
private void postOrRun(Runnable runnable) {
|
|
if (Thread.currentThread() == MediaBrowserImplBase.this.mHandler.getLooper().getThread()) {
|
|
runnable.run();
|
|
} else {
|
|
MediaBrowserImplBase.this.mHandler.post(runnable);
|
|
}
|
|
}
|
|
|
|
public boolean isCurrent(String str) {
|
|
int i;
|
|
MediaBrowserImplBase mediaBrowserImplBase = MediaBrowserImplBase.this;
|
|
if (mediaBrowserImplBase.mServiceConnection == this && (i = mediaBrowserImplBase.mState) != 0 && i != 1) {
|
|
return true;
|
|
}
|
|
int i2 = mediaBrowserImplBase.mState;
|
|
if (i2 != 0 && i2 != 1) {
|
|
StringBuilder v = a.v(str, " for ");
|
|
v.append(MediaBrowserImplBase.this.mServiceComponent);
|
|
v.append(" with mServiceConnection=");
|
|
v.append(MediaBrowserImplBase.this.mServiceConnection);
|
|
v.append(" this=");
|
|
v.append(this);
|
|
Log.i(MediaBrowserCompat.TAG, v.toString());
|
|
return MediaBrowserCompat.DEBUG;
|
|
}
|
|
return MediaBrowserCompat.DEBUG;
|
|
}
|
|
|
|
@Override // android.content.ServiceConnection
|
|
public void onServiceConnected(final ComponentName componentName, final IBinder iBinder) {
|
|
postOrRun(new Runnable() { // from class: android.support.v4.media.MediaBrowserCompat.MediaBrowserImplBase.MediaServiceConnection.1
|
|
@Override // java.lang.Runnable
|
|
public void run() {
|
|
boolean z = MediaBrowserCompat.DEBUG;
|
|
if (z) {
|
|
Log.d(MediaBrowserCompat.TAG, "MediaServiceConnection.onServiceConnected name=" + componentName + " binder=" + iBinder);
|
|
MediaBrowserImplBase.this.dump();
|
|
}
|
|
if (MediaServiceConnection.this.isCurrent("onServiceConnected")) {
|
|
MediaBrowserImplBase mediaBrowserImplBase = MediaBrowserImplBase.this;
|
|
mediaBrowserImplBase.mServiceBinderWrapper = new ServiceBinderWrapper(iBinder, mediaBrowserImplBase.mRootHints);
|
|
MediaBrowserImplBase.this.mCallbacksMessenger = new Messenger(MediaBrowserImplBase.this.mHandler);
|
|
MediaBrowserImplBase mediaBrowserImplBase2 = MediaBrowserImplBase.this;
|
|
mediaBrowserImplBase2.mHandler.setCallbacksMessenger(mediaBrowserImplBase2.mCallbacksMessenger);
|
|
MediaBrowserImplBase.this.mState = 2;
|
|
if (z) {
|
|
try {
|
|
Log.d(MediaBrowserCompat.TAG, "ServiceCallbacks.onConnect...");
|
|
MediaBrowserImplBase.this.dump();
|
|
} catch (RemoteException unused) {
|
|
Log.w(MediaBrowserCompat.TAG, "RemoteException during connect for " + MediaBrowserImplBase.this.mServiceComponent);
|
|
if (MediaBrowserCompat.DEBUG) {
|
|
Log.d(MediaBrowserCompat.TAG, "ServiceCallbacks.onConnect...");
|
|
MediaBrowserImplBase.this.dump();
|
|
return;
|
|
}
|
|
return;
|
|
}
|
|
}
|
|
MediaBrowserImplBase mediaBrowserImplBase3 = MediaBrowserImplBase.this;
|
|
mediaBrowserImplBase3.mServiceBinderWrapper.connect(mediaBrowserImplBase3.mContext, mediaBrowserImplBase3.mCallbacksMessenger);
|
|
}
|
|
}
|
|
});
|
|
}
|
|
|
|
@Override // android.content.ServiceConnection
|
|
public void onServiceDisconnected(final ComponentName componentName) {
|
|
postOrRun(new Runnable() { // from class: android.support.v4.media.MediaBrowserCompat.MediaBrowserImplBase.MediaServiceConnection.2
|
|
@Override // java.lang.Runnable
|
|
public void run() {
|
|
if (MediaBrowserCompat.DEBUG) {
|
|
Log.d(MediaBrowserCompat.TAG, "MediaServiceConnection.onServiceDisconnected name=" + componentName + " this=" + this + " mServiceConnection=" + MediaBrowserImplBase.this.mServiceConnection);
|
|
MediaBrowserImplBase.this.dump();
|
|
}
|
|
if (!MediaServiceConnection.this.isCurrent("onServiceDisconnected")) {
|
|
return;
|
|
}
|
|
MediaBrowserImplBase mediaBrowserImplBase = MediaBrowserImplBase.this;
|
|
mediaBrowserImplBase.mServiceBinderWrapper = null;
|
|
mediaBrowserImplBase.mCallbacksMessenger = null;
|
|
mediaBrowserImplBase.mHandler.setCallbacksMessenger(null);
|
|
MediaBrowserImplBase mediaBrowserImplBase2 = MediaBrowserImplBase.this;
|
|
mediaBrowserImplBase2.mState = 4;
|
|
mediaBrowserImplBase2.mCallback.onConnectionSuspended();
|
|
}
|
|
});
|
|
}
|
|
}
|
|
|
|
/* JADX WARN: Type inference failed for: r0v1, types: [androidx.collection.ArrayMap<java.lang.String, android.support.v4.media.MediaBrowserCompat$Subscription>, androidx.collection.SimpleArrayMap] */
|
|
public MediaBrowserImplBase(Context context, ComponentName componentName, ConnectionCallback connectionCallback, Bundle bundle) {
|
|
Bundle bundle2;
|
|
if (context != null) {
|
|
if (componentName != null) {
|
|
if (connectionCallback != null) {
|
|
this.mContext = context;
|
|
this.mServiceComponent = componentName;
|
|
this.mCallback = connectionCallback;
|
|
if (bundle == null) {
|
|
bundle2 = null;
|
|
} else {
|
|
bundle2 = new Bundle(bundle);
|
|
}
|
|
this.mRootHints = bundle2;
|
|
return;
|
|
}
|
|
throw new IllegalArgumentException("connection callback must not be null");
|
|
}
|
|
throw new IllegalArgumentException("service component must not be null");
|
|
}
|
|
throw new IllegalArgumentException("context must not be null");
|
|
}
|
|
|
|
private static String getStateLabel(int i) {
|
|
if (i != 0) {
|
|
if (i != 1) {
|
|
if (i != 2) {
|
|
if (i != 3) {
|
|
if (i != 4) {
|
|
return a.e(i, "UNKNOWN/");
|
|
}
|
|
return "CONNECT_STATE_SUSPENDED";
|
|
}
|
|
return "CONNECT_STATE_CONNECTED";
|
|
}
|
|
return "CONNECT_STATE_CONNECTING";
|
|
}
|
|
return "CONNECT_STATE_DISCONNECTED";
|
|
}
|
|
return "CONNECT_STATE_DISCONNECTING";
|
|
}
|
|
|
|
private boolean isCurrent(Messenger messenger, String str) {
|
|
int i;
|
|
if (this.mCallbacksMessenger == messenger && (i = this.mState) != 0 && i != 1) {
|
|
return true;
|
|
}
|
|
int i2 = this.mState;
|
|
if (i2 != 0 && i2 != 1) {
|
|
StringBuilder v = a.v(str, " for ");
|
|
v.append(this.mServiceComponent);
|
|
v.append(" with mCallbacksMessenger=");
|
|
v.append(this.mCallbacksMessenger);
|
|
v.append(" this=");
|
|
v.append(this);
|
|
Log.i(MediaBrowserCompat.TAG, v.toString());
|
|
return MediaBrowserCompat.DEBUG;
|
|
}
|
|
return MediaBrowserCompat.DEBUG;
|
|
}
|
|
|
|
@Override // android.support.v4.media.MediaBrowserCompat.MediaBrowserImpl
|
|
public void connect() {
|
|
int i = this.mState;
|
|
if (i != 0 && i != 1) {
|
|
throw new IllegalStateException(a.p(new StringBuilder("connect() called while neigther disconnecting nor disconnected (state="), getStateLabel(this.mState), ")"));
|
|
}
|
|
this.mState = 2;
|
|
this.mHandler.post(new Runnable() { // from class: android.support.v4.media.MediaBrowserCompat.MediaBrowserImplBase.1
|
|
@Override // java.lang.Runnable
|
|
public void run() {
|
|
boolean z;
|
|
MediaBrowserImplBase mediaBrowserImplBase = MediaBrowserImplBase.this;
|
|
if (mediaBrowserImplBase.mState != 0) {
|
|
mediaBrowserImplBase.mState = 2;
|
|
if (MediaBrowserCompat.DEBUG && mediaBrowserImplBase.mServiceConnection != null) {
|
|
throw new RuntimeException("mServiceConnection should be null. Instead it is " + MediaBrowserImplBase.this.mServiceConnection);
|
|
}
|
|
if (mediaBrowserImplBase.mServiceBinderWrapper == null) {
|
|
if (mediaBrowserImplBase.mCallbacksMessenger == null) {
|
|
Intent intent = new Intent("android.media.browse.MediaBrowserService");
|
|
intent.setComponent(MediaBrowserImplBase.this.mServiceComponent);
|
|
MediaBrowserImplBase mediaBrowserImplBase2 = MediaBrowserImplBase.this;
|
|
mediaBrowserImplBase2.mServiceConnection = new MediaServiceConnection();
|
|
try {
|
|
MediaBrowserImplBase mediaBrowserImplBase3 = MediaBrowserImplBase.this;
|
|
z = mediaBrowserImplBase3.mContext.bindService(intent, mediaBrowserImplBase3.mServiceConnection, 1);
|
|
} catch (Exception unused) {
|
|
Log.e(MediaBrowserCompat.TAG, "Failed binding to service " + MediaBrowserImplBase.this.mServiceComponent);
|
|
z = MediaBrowserCompat.DEBUG;
|
|
}
|
|
if (!z) {
|
|
MediaBrowserImplBase.this.forceCloseConnection();
|
|
MediaBrowserImplBase.this.mCallback.onConnectionFailed();
|
|
}
|
|
if (MediaBrowserCompat.DEBUG) {
|
|
Log.d(MediaBrowserCompat.TAG, "connect...");
|
|
MediaBrowserImplBase.this.dump();
|
|
return;
|
|
}
|
|
return;
|
|
}
|
|
throw new RuntimeException("mCallbacksMessenger should be null. Instead it is " + MediaBrowserImplBase.this.mCallbacksMessenger);
|
|
}
|
|
throw new RuntimeException("mServiceBinderWrapper should be null. Instead it is " + MediaBrowserImplBase.this.mServiceBinderWrapper);
|
|
}
|
|
}
|
|
});
|
|
}
|
|
|
|
@Override // android.support.v4.media.MediaBrowserCompat.MediaBrowserImpl
|
|
public void disconnect() {
|
|
this.mState = 0;
|
|
this.mHandler.post(new Runnable() { // from class: android.support.v4.media.MediaBrowserCompat.MediaBrowserImplBase.2
|
|
@Override // java.lang.Runnable
|
|
public void run() {
|
|
MediaBrowserImplBase mediaBrowserImplBase = MediaBrowserImplBase.this;
|
|
Messenger messenger = mediaBrowserImplBase.mCallbacksMessenger;
|
|
if (messenger != null) {
|
|
try {
|
|
mediaBrowserImplBase.mServiceBinderWrapper.disconnect(messenger);
|
|
} catch (RemoteException unused) {
|
|
Log.w(MediaBrowserCompat.TAG, "RemoteException during connect for " + MediaBrowserImplBase.this.mServiceComponent);
|
|
}
|
|
}
|
|
MediaBrowserImplBase mediaBrowserImplBase2 = MediaBrowserImplBase.this;
|
|
int i = mediaBrowserImplBase2.mState;
|
|
mediaBrowserImplBase2.forceCloseConnection();
|
|
if (i != 0) {
|
|
MediaBrowserImplBase.this.mState = i;
|
|
}
|
|
if (MediaBrowserCompat.DEBUG) {
|
|
Log.d(MediaBrowserCompat.TAG, "disconnect...");
|
|
MediaBrowserImplBase.this.dump();
|
|
}
|
|
}
|
|
});
|
|
}
|
|
|
|
public void dump() {
|
|
Log.d(MediaBrowserCompat.TAG, "MediaBrowserCompat...");
|
|
Log.d(MediaBrowserCompat.TAG, " mServiceComponent=" + this.mServiceComponent);
|
|
Log.d(MediaBrowserCompat.TAG, " mCallback=" + this.mCallback);
|
|
Log.d(MediaBrowserCompat.TAG, " mRootHints=" + this.mRootHints);
|
|
Log.d(MediaBrowserCompat.TAG, " mState=" + getStateLabel(this.mState));
|
|
Log.d(MediaBrowserCompat.TAG, " mServiceConnection=" + this.mServiceConnection);
|
|
Log.d(MediaBrowserCompat.TAG, " mServiceBinderWrapper=" + this.mServiceBinderWrapper);
|
|
Log.d(MediaBrowserCompat.TAG, " mCallbacksMessenger=" + this.mCallbacksMessenger);
|
|
Log.d(MediaBrowserCompat.TAG, " mRootId=" + this.mRootId);
|
|
Log.d(MediaBrowserCompat.TAG, " mMediaSessionToken=" + this.mMediaSessionToken);
|
|
}
|
|
|
|
public void forceCloseConnection() {
|
|
MediaServiceConnection mediaServiceConnection = this.mServiceConnection;
|
|
if (mediaServiceConnection != null) {
|
|
this.mContext.unbindService(mediaServiceConnection);
|
|
}
|
|
this.mState = 1;
|
|
this.mServiceConnection = null;
|
|
this.mServiceBinderWrapper = null;
|
|
this.mCallbacksMessenger = null;
|
|
this.mHandler.setCallbacksMessenger(null);
|
|
this.mRootId = null;
|
|
this.mMediaSessionToken = null;
|
|
}
|
|
|
|
@Override // android.support.v4.media.MediaBrowserCompat.MediaBrowserImpl
|
|
@Nullable
|
|
public Bundle getExtras() {
|
|
if (isConnected()) {
|
|
return this.mExtras;
|
|
}
|
|
throw new IllegalStateException(a.p(new StringBuilder("getExtras() called while not connected (state="), getStateLabel(this.mState), ")"));
|
|
}
|
|
|
|
@Override // android.support.v4.media.MediaBrowserCompat.MediaBrowserImpl
|
|
public void getItem(@NonNull final String str, @NonNull final ItemCallback itemCallback) {
|
|
if (!TextUtils.isEmpty(str)) {
|
|
if (itemCallback != null) {
|
|
if (!isConnected()) {
|
|
Log.i(MediaBrowserCompat.TAG, "Not connected, unable to retrieve the MediaItem.");
|
|
this.mHandler.post(new Runnable() { // from class: android.support.v4.media.MediaBrowserCompat.MediaBrowserImplBase.3
|
|
@Override // java.lang.Runnable
|
|
public void run() {
|
|
itemCallback.onError(str);
|
|
}
|
|
});
|
|
return;
|
|
}
|
|
try {
|
|
this.mServiceBinderWrapper.getMediaItem(str, new ItemReceiver(str, itemCallback, this.mHandler), this.mCallbacksMessenger);
|
|
return;
|
|
} catch (RemoteException unused) {
|
|
Log.i(MediaBrowserCompat.TAG, "Remote error getting media item: " + str);
|
|
this.mHandler.post(new Runnable() { // from class: android.support.v4.media.MediaBrowserCompat.MediaBrowserImplBase.4
|
|
@Override // java.lang.Runnable
|
|
public void run() {
|
|
itemCallback.onError(str);
|
|
}
|
|
});
|
|
return;
|
|
}
|
|
}
|
|
throw new IllegalArgumentException("cb is null");
|
|
}
|
|
throw new IllegalArgumentException("mediaId is empty");
|
|
}
|
|
|
|
@Override // android.support.v4.media.MediaBrowserCompat.MediaBrowserImpl
|
|
public Bundle getNotifyChildrenChangedOptions() {
|
|
return this.mNotifyChildrenChangedOptions;
|
|
}
|
|
|
|
@Override // android.support.v4.media.MediaBrowserCompat.MediaBrowserImpl
|
|
@NonNull
|
|
public String getRoot() {
|
|
if (isConnected()) {
|
|
return this.mRootId;
|
|
}
|
|
throw new IllegalStateException(a.p(new StringBuilder("getRoot() called while not connected(state="), getStateLabel(this.mState), ")"));
|
|
}
|
|
|
|
@Override // android.support.v4.media.MediaBrowserCompat.MediaBrowserImpl
|
|
@NonNull
|
|
public ComponentName getServiceComponent() {
|
|
if (isConnected()) {
|
|
return this.mServiceComponent;
|
|
}
|
|
throw new IllegalStateException(a.g(this.mState, ")", new StringBuilder("getServiceComponent() called while not connected (state=")));
|
|
}
|
|
|
|
@Override // android.support.v4.media.MediaBrowserCompat.MediaBrowserImpl
|
|
@NonNull
|
|
public MediaSessionCompat.Token getSessionToken() {
|
|
if (isConnected()) {
|
|
return this.mMediaSessionToken;
|
|
}
|
|
throw new IllegalStateException(a.g(this.mState, ")", new StringBuilder("getSessionToken() called while not connected(state=")));
|
|
}
|
|
|
|
@Override // android.support.v4.media.MediaBrowserCompat.MediaBrowserImpl
|
|
public boolean isConnected() {
|
|
if (this.mState == 3) {
|
|
return true;
|
|
}
|
|
return MediaBrowserCompat.DEBUG;
|
|
}
|
|
|
|
@Override // android.support.v4.media.MediaBrowserCompat.MediaBrowserServiceCallbackImpl
|
|
public void onConnectionFailed(Messenger messenger) {
|
|
Log.e(MediaBrowserCompat.TAG, "onConnectFailed for " + this.mServiceComponent);
|
|
if (!isCurrent(messenger, "onConnectFailed")) {
|
|
return;
|
|
}
|
|
if (this.mState != 2) {
|
|
Log.w(MediaBrowserCompat.TAG, "onConnect from service while mState=" + getStateLabel(this.mState) + "... ignoring");
|
|
return;
|
|
}
|
|
forceCloseConnection();
|
|
this.mCallback.onConnectionFailed();
|
|
}
|
|
|
|
@Override // android.support.v4.media.MediaBrowserCompat.MediaBrowserServiceCallbackImpl
|
|
public void onLoadChildren(Messenger messenger, String str, List<MediaItem> list, Bundle bundle, Bundle bundle2) {
|
|
if (isCurrent(messenger, "onLoadChildren")) {
|
|
boolean z = MediaBrowserCompat.DEBUG;
|
|
if (z) {
|
|
Log.d(MediaBrowserCompat.TAG, "onLoadChildren for " + this.mServiceComponent + " id=" + str);
|
|
}
|
|
Subscription subscription = (Subscription) this.mSubscriptions.get(str);
|
|
if (subscription == null) {
|
|
if (z) {
|
|
Log.d(MediaBrowserCompat.TAG, "onLoadChildren for id that isn't subscribed id=" + str);
|
|
return;
|
|
}
|
|
return;
|
|
}
|
|
SubscriptionCallback callback = subscription.getCallback(bundle);
|
|
if (callback != null) {
|
|
if (bundle == null) {
|
|
if (list == null) {
|
|
callback.onError(str);
|
|
return;
|
|
}
|
|
this.mNotifyChildrenChangedOptions = bundle2;
|
|
callback.onChildrenLoaded(str, list);
|
|
this.mNotifyChildrenChangedOptions = null;
|
|
return;
|
|
}
|
|
if (list == null) {
|
|
callback.onError(str, bundle);
|
|
return;
|
|
}
|
|
this.mNotifyChildrenChangedOptions = bundle2;
|
|
callback.onChildrenLoaded(str, list, bundle);
|
|
this.mNotifyChildrenChangedOptions = null;
|
|
}
|
|
}
|
|
}
|
|
|
|
@Override // android.support.v4.media.MediaBrowserCompat.MediaBrowserServiceCallbackImpl
|
|
public void onServiceConnected(Messenger messenger, String str, MediaSessionCompat.Token token, Bundle bundle) {
|
|
if (isCurrent(messenger, "onConnect")) {
|
|
if (this.mState != 2) {
|
|
Log.w(MediaBrowserCompat.TAG, "onConnect from service while mState=" + getStateLabel(this.mState) + "... ignoring");
|
|
return;
|
|
}
|
|
this.mRootId = str;
|
|
this.mMediaSessionToken = token;
|
|
this.mExtras = bundle;
|
|
this.mState = 3;
|
|
if (MediaBrowserCompat.DEBUG) {
|
|
Log.d(MediaBrowserCompat.TAG, "ServiceCallbacks.onConnect...");
|
|
dump();
|
|
}
|
|
this.mCallback.onConnected();
|
|
try {
|
|
for (Map.Entry entry : this.mSubscriptions.entrySet()) {
|
|
String str2 = (String) entry.getKey();
|
|
Subscription subscription = (Subscription) entry.getValue();
|
|
List<SubscriptionCallback> callbacks = subscription.getCallbacks();
|
|
List<Bundle> optionsList = subscription.getOptionsList();
|
|
for (int i = 0; i < callbacks.size(); i++) {
|
|
this.mServiceBinderWrapper.addSubscription(str2, callbacks.get(i).mToken, optionsList.get(i), this.mCallbacksMessenger);
|
|
}
|
|
}
|
|
} catch (RemoteException unused) {
|
|
Log.d(MediaBrowserCompat.TAG, "addSubscription failed with RemoteException.");
|
|
}
|
|
}
|
|
}
|
|
|
|
@Override // android.support.v4.media.MediaBrowserCompat.MediaBrowserImpl
|
|
public void search(@NonNull final String str, final Bundle bundle, @NonNull final SearchCallback searchCallback) {
|
|
if (isConnected()) {
|
|
try {
|
|
this.mServiceBinderWrapper.search(str, bundle, new SearchResultReceiver(str, bundle, searchCallback, this.mHandler), this.mCallbacksMessenger);
|
|
return;
|
|
} catch (RemoteException e) {
|
|
Log.i(MediaBrowserCompat.TAG, "Remote error searching items with query: " + str, e);
|
|
this.mHandler.post(new Runnable() { // from class: android.support.v4.media.MediaBrowserCompat.MediaBrowserImplBase.5
|
|
@Override // java.lang.Runnable
|
|
public void run() {
|
|
searchCallback.onError(str, bundle);
|
|
}
|
|
});
|
|
return;
|
|
}
|
|
}
|
|
throw new IllegalStateException(a.p(new StringBuilder("search() called while not connected (state="), getStateLabel(this.mState), ")"));
|
|
}
|
|
|
|
@Override // android.support.v4.media.MediaBrowserCompat.MediaBrowserImpl
|
|
public void sendCustomAction(@NonNull final String str, final Bundle bundle, @Nullable final CustomActionCallback customActionCallback) {
|
|
if (isConnected()) {
|
|
try {
|
|
this.mServiceBinderWrapper.sendCustomAction(str, bundle, new CustomActionResultReceiver(str, bundle, customActionCallback, this.mHandler), this.mCallbacksMessenger);
|
|
return;
|
|
} catch (RemoteException e) {
|
|
Log.i(MediaBrowserCompat.TAG, "Remote error sending a custom action: action=" + str + ", extras=" + bundle, e);
|
|
if (customActionCallback != null) {
|
|
this.mHandler.post(new Runnable() { // from class: android.support.v4.media.MediaBrowserCompat.MediaBrowserImplBase.6
|
|
@Override // java.lang.Runnable
|
|
public void run() {
|
|
customActionCallback.onError(str, bundle, null);
|
|
}
|
|
});
|
|
return;
|
|
}
|
|
return;
|
|
}
|
|
}
|
|
throw new IllegalStateException("Cannot send a custom action (" + str + ") with extras " + bundle + " because the browser is not connected to the service.");
|
|
}
|
|
|
|
@Override // android.support.v4.media.MediaBrowserCompat.MediaBrowserImpl
|
|
public void subscribe(@NonNull String str, Bundle bundle, @NonNull SubscriptionCallback subscriptionCallback) {
|
|
Bundle bundle2;
|
|
Subscription subscription = (Subscription) this.mSubscriptions.get(str);
|
|
if (subscription == null) {
|
|
subscription = new Subscription();
|
|
this.mSubscriptions.put(str, subscription);
|
|
}
|
|
if (bundle == null) {
|
|
bundle2 = null;
|
|
} else {
|
|
bundle2 = new Bundle(bundle);
|
|
}
|
|
subscription.putCallback(bundle2, subscriptionCallback);
|
|
if (isConnected()) {
|
|
try {
|
|
this.mServiceBinderWrapper.addSubscription(str, subscriptionCallback.mToken, bundle2, this.mCallbacksMessenger);
|
|
} catch (RemoteException unused) {
|
|
Log.d(MediaBrowserCompat.TAG, "addSubscription failed with RemoteException parentId=" + str);
|
|
}
|
|
}
|
|
}
|
|
|
|
@Override // android.support.v4.media.MediaBrowserCompat.MediaBrowserImpl
|
|
public void unsubscribe(@NonNull String str, SubscriptionCallback subscriptionCallback) {
|
|
Subscription subscription = (Subscription) this.mSubscriptions.get(str);
|
|
if (subscription != null) {
|
|
try {
|
|
if (subscriptionCallback == null) {
|
|
if (isConnected()) {
|
|
this.mServiceBinderWrapper.removeSubscription(str, null, this.mCallbacksMessenger);
|
|
}
|
|
} else {
|
|
List<SubscriptionCallback> callbacks = subscription.getCallbacks();
|
|
List<Bundle> optionsList = subscription.getOptionsList();
|
|
for (int size = callbacks.size() - 1; size >= 0; size--) {
|
|
if (callbacks.get(size) == subscriptionCallback) {
|
|
if (isConnected()) {
|
|
this.mServiceBinderWrapper.removeSubscription(str, subscriptionCallback.mToken, this.mCallbacksMessenger);
|
|
}
|
|
callbacks.remove(size);
|
|
optionsList.remove(size);
|
|
}
|
|
}
|
|
}
|
|
} catch (RemoteException unused) {
|
|
Log.d(MediaBrowserCompat.TAG, "removeSubscription failed with RemoteException parentId=" + str);
|
|
}
|
|
if (subscription.isEmpty() || subscriptionCallback == null) {
|
|
this.mSubscriptions.remove(str);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
/* loaded from: classes.dex */
|
|
public interface MediaBrowserServiceCallbackImpl {
|
|
void onConnectionFailed(Messenger messenger);
|
|
|
|
void onLoadChildren(Messenger messenger, String str, List<MediaItem> list, Bundle bundle, Bundle bundle2);
|
|
|
|
void onServiceConnected(Messenger messenger, String str, MediaSessionCompat.Token token, Bundle bundle);
|
|
}
|
|
|
|
/* loaded from: classes.dex */
|
|
public static abstract class SearchCallback {
|
|
public void onError(@NonNull String str, Bundle bundle) {
|
|
}
|
|
|
|
public void onSearchResult(@NonNull String str, Bundle bundle, @NonNull List<MediaItem> list) {
|
|
}
|
|
}
|
|
|
|
/* loaded from: classes.dex */
|
|
public static class SearchResultReceiver extends ResultReceiver {
|
|
private final SearchCallback mCallback;
|
|
private final Bundle mExtras;
|
|
private final String mQuery;
|
|
|
|
public SearchResultReceiver(String str, Bundle bundle, SearchCallback searchCallback, Handler handler) {
|
|
super(handler);
|
|
this.mQuery = str;
|
|
this.mExtras = bundle;
|
|
this.mCallback = searchCallback;
|
|
}
|
|
|
|
@Override // android.support.v4.os.ResultReceiver
|
|
public void onReceiveResult(int i, Bundle bundle) {
|
|
if (bundle != null) {
|
|
bundle = MediaSessionCompat.unparcelWithClassLoader(bundle);
|
|
}
|
|
if (i == 0 && bundle != null && bundle.containsKey("search_results")) {
|
|
Parcelable[] parcelableArray = bundle.getParcelableArray("search_results");
|
|
if (parcelableArray != null) {
|
|
ArrayList arrayList = new ArrayList(parcelableArray.length);
|
|
for (Parcelable parcelable : parcelableArray) {
|
|
arrayList.add((MediaItem) parcelable);
|
|
}
|
|
this.mCallback.onSearchResult(this.mQuery, this.mExtras, arrayList);
|
|
return;
|
|
}
|
|
this.mCallback.onError(this.mQuery, this.mExtras);
|
|
return;
|
|
}
|
|
this.mCallback.onError(this.mQuery, this.mExtras);
|
|
}
|
|
}
|
|
|
|
/* loaded from: classes.dex */
|
|
public static class ServiceBinderWrapper {
|
|
private Messenger mMessenger;
|
|
private Bundle mRootHints;
|
|
|
|
public ServiceBinderWrapper(IBinder iBinder, Bundle bundle) {
|
|
this.mMessenger = new Messenger(iBinder);
|
|
this.mRootHints = bundle;
|
|
}
|
|
|
|
private void sendRequest(int i, Bundle bundle, Messenger messenger) {
|
|
Message obtain = Message.obtain();
|
|
obtain.what = i;
|
|
obtain.arg1 = 1;
|
|
obtain.setData(bundle);
|
|
obtain.replyTo = messenger;
|
|
this.mMessenger.send(obtain);
|
|
}
|
|
|
|
public void addSubscription(String str, IBinder iBinder, Bundle bundle, Messenger messenger) {
|
|
Bundle bundle2 = new Bundle();
|
|
bundle2.putString("data_media_item_id", str);
|
|
bundle2.putBinder("data_callback_token", iBinder);
|
|
bundle2.putBundle("data_options", bundle);
|
|
sendRequest(3, bundle2, messenger);
|
|
}
|
|
|
|
public void connect(Context context, Messenger messenger) {
|
|
Bundle bundle = new Bundle();
|
|
bundle.putString("data_package_name", context.getPackageName());
|
|
bundle.putInt("data_calling_pid", Process.myPid());
|
|
bundle.putBundle("data_root_hints", this.mRootHints);
|
|
sendRequest(1, bundle, messenger);
|
|
}
|
|
|
|
public void disconnect(Messenger messenger) {
|
|
sendRequest(2, null, messenger);
|
|
}
|
|
|
|
public void getMediaItem(String str, ResultReceiver resultReceiver, Messenger messenger) {
|
|
Bundle bundle = new Bundle();
|
|
bundle.putString("data_media_item_id", str);
|
|
bundle.putParcelable("data_result_receiver", resultReceiver);
|
|
sendRequest(5, bundle, messenger);
|
|
}
|
|
|
|
public void registerCallbackMessenger(Context context, Messenger messenger) {
|
|
Bundle bundle = new Bundle();
|
|
bundle.putString("data_package_name", context.getPackageName());
|
|
bundle.putInt("data_calling_pid", Process.myPid());
|
|
bundle.putBundle("data_root_hints", this.mRootHints);
|
|
sendRequest(6, bundle, messenger);
|
|
}
|
|
|
|
public void removeSubscription(String str, IBinder iBinder, Messenger messenger) {
|
|
Bundle bundle = new Bundle();
|
|
bundle.putString("data_media_item_id", str);
|
|
bundle.putBinder("data_callback_token", iBinder);
|
|
sendRequest(4, bundle, messenger);
|
|
}
|
|
|
|
public void search(String str, Bundle bundle, ResultReceiver resultReceiver, Messenger messenger) {
|
|
Bundle bundle2 = new Bundle();
|
|
bundle2.putString("data_search_query", str);
|
|
bundle2.putBundle("data_search_extras", bundle);
|
|
bundle2.putParcelable("data_result_receiver", resultReceiver);
|
|
sendRequest(8, bundle2, messenger);
|
|
}
|
|
|
|
public void sendCustomAction(String str, Bundle bundle, ResultReceiver resultReceiver, Messenger messenger) {
|
|
Bundle bundle2 = new Bundle();
|
|
bundle2.putString("data_custom_action", str);
|
|
bundle2.putBundle("data_custom_action_extras", bundle);
|
|
bundle2.putParcelable("data_result_receiver", resultReceiver);
|
|
sendRequest(9, bundle2, messenger);
|
|
}
|
|
|
|
public void unregisterCallbackMessenger(Messenger messenger) {
|
|
sendRequest(7, null, messenger);
|
|
}
|
|
}
|
|
|
|
/* loaded from: classes.dex */
|
|
public static class Subscription {
|
|
private final List<SubscriptionCallback> mCallbacks = new ArrayList();
|
|
private final List<Bundle> mOptionsList = new ArrayList();
|
|
|
|
public SubscriptionCallback getCallback(Bundle bundle) {
|
|
for (int i = 0; i < this.mOptionsList.size(); i++) {
|
|
if (MediaBrowserCompatUtils.a(this.mOptionsList.get(i), bundle)) {
|
|
return this.mCallbacks.get(i);
|
|
}
|
|
}
|
|
return null;
|
|
}
|
|
|
|
public List<SubscriptionCallback> getCallbacks() {
|
|
return this.mCallbacks;
|
|
}
|
|
|
|
public List<Bundle> getOptionsList() {
|
|
return this.mOptionsList;
|
|
}
|
|
|
|
public boolean isEmpty() {
|
|
return this.mCallbacks.isEmpty();
|
|
}
|
|
|
|
public void putCallback(Bundle bundle, SubscriptionCallback subscriptionCallback) {
|
|
for (int i = 0; i < this.mOptionsList.size(); i++) {
|
|
if (MediaBrowserCompatUtils.a(this.mOptionsList.get(i), bundle)) {
|
|
this.mCallbacks.set(i, subscriptionCallback);
|
|
return;
|
|
}
|
|
}
|
|
this.mCallbacks.add(subscriptionCallback);
|
|
this.mOptionsList.add(bundle);
|
|
}
|
|
}
|
|
|
|
/* loaded from: classes.dex */
|
|
public static abstract class SubscriptionCallback {
|
|
final MediaBrowser.SubscriptionCallback mSubscriptionCallbackFwk;
|
|
WeakReference<Subscription> mSubscriptionRef;
|
|
final IBinder mToken = new Binder();
|
|
|
|
@RequiresApi
|
|
/* loaded from: classes.dex */
|
|
public class SubscriptionCallbackApi21 extends MediaBrowser.SubscriptionCallback {
|
|
public SubscriptionCallbackApi21() {
|
|
}
|
|
|
|
public List<MediaItem> applyOptions(List<MediaItem> list, Bundle bundle) {
|
|
if (list == null) {
|
|
return null;
|
|
}
|
|
int i = bundle.getInt(MediaBrowserCompat.EXTRA_PAGE, -1);
|
|
int i2 = bundle.getInt(MediaBrowserCompat.EXTRA_PAGE_SIZE, -1);
|
|
if (i == -1 && i2 == -1) {
|
|
return list;
|
|
}
|
|
int i3 = i2 * i;
|
|
int i4 = i3 + i2;
|
|
if (i >= 0 && i2 >= 1 && i3 < list.size()) {
|
|
if (i4 > list.size()) {
|
|
i4 = list.size();
|
|
}
|
|
return list.subList(i3, i4);
|
|
}
|
|
return Collections.EMPTY_LIST;
|
|
}
|
|
|
|
@Override // android.media.browse.MediaBrowser.SubscriptionCallback
|
|
public void onChildrenLoaded(@NonNull String str, List<MediaBrowser.MediaItem> list) {
|
|
Subscription subscription;
|
|
WeakReference<Subscription> weakReference = SubscriptionCallback.this.mSubscriptionRef;
|
|
if (weakReference == null) {
|
|
subscription = null;
|
|
} else {
|
|
subscription = weakReference.get();
|
|
}
|
|
if (subscription == null) {
|
|
SubscriptionCallback.this.onChildrenLoaded(str, MediaItem.fromMediaItemList(list));
|
|
return;
|
|
}
|
|
List<MediaItem> fromMediaItemList = MediaItem.fromMediaItemList(list);
|
|
List<SubscriptionCallback> callbacks = subscription.getCallbacks();
|
|
List<Bundle> optionsList = subscription.getOptionsList();
|
|
for (int i = 0; i < callbacks.size(); i++) {
|
|
Bundle bundle = optionsList.get(i);
|
|
if (bundle == null) {
|
|
SubscriptionCallback.this.onChildrenLoaded(str, fromMediaItemList);
|
|
} else {
|
|
SubscriptionCallback.this.onChildrenLoaded(str, applyOptions(fromMediaItemList, bundle), bundle);
|
|
}
|
|
}
|
|
}
|
|
|
|
@Override // android.media.browse.MediaBrowser.SubscriptionCallback
|
|
public void onError(@NonNull String str) {
|
|
SubscriptionCallback.this.onError(str);
|
|
}
|
|
}
|
|
|
|
@RequiresApi
|
|
/* loaded from: classes.dex */
|
|
public class SubscriptionCallbackApi26 extends SubscriptionCallbackApi21 {
|
|
public SubscriptionCallbackApi26() {
|
|
super();
|
|
}
|
|
|
|
@Override // android.media.browse.MediaBrowser.SubscriptionCallback
|
|
public void onChildrenLoaded(@NonNull String str, @NonNull List<MediaBrowser.MediaItem> list, @NonNull Bundle bundle) {
|
|
MediaSessionCompat.ensureClassLoader(bundle);
|
|
SubscriptionCallback.this.onChildrenLoaded(str, MediaItem.fromMediaItemList(list), bundle);
|
|
}
|
|
|
|
@Override // android.media.browse.MediaBrowser.SubscriptionCallback
|
|
public void onError(@NonNull String str, @NonNull Bundle bundle) {
|
|
MediaSessionCompat.ensureClassLoader(bundle);
|
|
SubscriptionCallback.this.onError(str, bundle);
|
|
}
|
|
}
|
|
|
|
public SubscriptionCallback() {
|
|
if (Build.VERSION.SDK_INT >= 26) {
|
|
this.mSubscriptionCallbackFwk = new SubscriptionCallbackApi26();
|
|
} else {
|
|
this.mSubscriptionCallbackFwk = new SubscriptionCallbackApi21();
|
|
}
|
|
}
|
|
|
|
public void onChildrenLoaded(@NonNull String str, @NonNull List<MediaItem> list) {
|
|
}
|
|
|
|
public void onError(@NonNull String str) {
|
|
}
|
|
|
|
public void setSubscription(Subscription subscription) {
|
|
this.mSubscriptionRef = new WeakReference<>(subscription);
|
|
}
|
|
|
|
public void onChildrenLoaded(@NonNull String str, @NonNull List<MediaItem> list, @NonNull Bundle bundle) {
|
|
}
|
|
|
|
public void onError(@NonNull String str, @NonNull Bundle bundle) {
|
|
}
|
|
}
|
|
|
|
public MediaBrowserCompat(Context context, ComponentName componentName, ConnectionCallback connectionCallback, Bundle bundle) {
|
|
if (Build.VERSION.SDK_INT >= 26) {
|
|
this.mImpl = new MediaBrowserImplApi26(context, componentName, connectionCallback, bundle);
|
|
} else {
|
|
this.mImpl = new MediaBrowserImplApi23(context, componentName, connectionCallback, bundle);
|
|
}
|
|
}
|
|
|
|
public void connect() {
|
|
Log.d(TAG, "Connecting to a MediaBrowserService.");
|
|
this.mImpl.connect();
|
|
}
|
|
|
|
public void disconnect() {
|
|
this.mImpl.disconnect();
|
|
}
|
|
|
|
@Nullable
|
|
public Bundle getExtras() {
|
|
return this.mImpl.getExtras();
|
|
}
|
|
|
|
public void getItem(@NonNull String str, @NonNull ItemCallback itemCallback) {
|
|
this.mImpl.getItem(str, itemCallback);
|
|
}
|
|
|
|
@Nullable
|
|
@RestrictTo
|
|
public Bundle getNotifyChildrenChangedOptions() {
|
|
return this.mImpl.getNotifyChildrenChangedOptions();
|
|
}
|
|
|
|
@NonNull
|
|
public String getRoot() {
|
|
return this.mImpl.getRoot();
|
|
}
|
|
|
|
@NonNull
|
|
public ComponentName getServiceComponent() {
|
|
return this.mImpl.getServiceComponent();
|
|
}
|
|
|
|
@NonNull
|
|
public MediaSessionCompat.Token getSessionToken() {
|
|
return this.mImpl.getSessionToken();
|
|
}
|
|
|
|
public boolean isConnected() {
|
|
return this.mImpl.isConnected();
|
|
}
|
|
|
|
public void search(@NonNull String str, Bundle bundle, @NonNull SearchCallback searchCallback) {
|
|
if (!TextUtils.isEmpty(str)) {
|
|
if (searchCallback != null) {
|
|
this.mImpl.search(str, bundle, searchCallback);
|
|
return;
|
|
}
|
|
throw new IllegalArgumentException("callback cannot be null");
|
|
}
|
|
throw new IllegalArgumentException("query cannot be empty");
|
|
}
|
|
|
|
public void sendCustomAction(@NonNull String str, Bundle bundle, @Nullable CustomActionCallback customActionCallback) {
|
|
if (!TextUtils.isEmpty(str)) {
|
|
this.mImpl.sendCustomAction(str, bundle, customActionCallback);
|
|
return;
|
|
}
|
|
throw new IllegalArgumentException("action cannot be empty");
|
|
}
|
|
|
|
public void subscribe(@NonNull String str, @NonNull SubscriptionCallback subscriptionCallback) {
|
|
if (TextUtils.isEmpty(str)) {
|
|
throw new IllegalArgumentException("parentId is empty");
|
|
}
|
|
if (subscriptionCallback != null) {
|
|
this.mImpl.subscribe(str, null, subscriptionCallback);
|
|
return;
|
|
}
|
|
throw new IllegalArgumentException("callback is null");
|
|
}
|
|
|
|
public void unsubscribe(@NonNull String str) {
|
|
if (!TextUtils.isEmpty(str)) {
|
|
this.mImpl.unsubscribe(str, null);
|
|
return;
|
|
}
|
|
throw new IllegalArgumentException("parentId is empty");
|
|
}
|
|
|
|
public void unsubscribe(@NonNull String str, @NonNull SubscriptionCallback subscriptionCallback) {
|
|
if (TextUtils.isEmpty(str)) {
|
|
throw new IllegalArgumentException("parentId is empty");
|
|
}
|
|
if (subscriptionCallback != null) {
|
|
this.mImpl.unsubscribe(str, subscriptionCallback);
|
|
return;
|
|
}
|
|
throw new IllegalArgumentException("callback is null");
|
|
}
|
|
|
|
public void subscribe(@NonNull String str, @NonNull Bundle bundle, @NonNull SubscriptionCallback subscriptionCallback) {
|
|
if (TextUtils.isEmpty(str)) {
|
|
throw new IllegalArgumentException("parentId is empty");
|
|
}
|
|
if (subscriptionCallback == null) {
|
|
throw new IllegalArgumentException("callback is null");
|
|
}
|
|
if (bundle != null) {
|
|
this.mImpl.subscribe(str, bundle, subscriptionCallback);
|
|
return;
|
|
}
|
|
throw new IllegalArgumentException("options are null");
|
|
}
|
|
|
|
@SuppressLint({"BanParcelableUsage"})
|
|
/* loaded from: classes.dex */
|
|
public static class MediaItem implements Parcelable {
|
|
public static final Parcelable.Creator<MediaItem> CREATOR = new Parcelable.Creator<MediaItem>() { // from class: android.support.v4.media.MediaBrowserCompat.MediaItem.1
|
|
/* JADX WARN: Can't rename method to resolve collision */
|
|
@Override // android.os.Parcelable.Creator
|
|
public MediaItem createFromParcel(Parcel parcel) {
|
|
return new MediaItem(parcel);
|
|
}
|
|
|
|
/* JADX WARN: Can't rename method to resolve collision */
|
|
@Override // android.os.Parcelable.Creator
|
|
public MediaItem[] newArray(int i) {
|
|
return new MediaItem[i];
|
|
}
|
|
};
|
|
public static final int FLAG_BROWSABLE = 1;
|
|
public static final int FLAG_PLAYABLE = 2;
|
|
private final MediaDescriptionCompat mDescription;
|
|
private final int mFlags;
|
|
|
|
public MediaItem(@NonNull MediaDescriptionCompat mediaDescriptionCompat, int i) {
|
|
if (mediaDescriptionCompat != null) {
|
|
if (!TextUtils.isEmpty(mediaDescriptionCompat.getMediaId())) {
|
|
this.mFlags = i;
|
|
this.mDescription = mediaDescriptionCompat;
|
|
return;
|
|
}
|
|
throw new IllegalArgumentException("description must have a non-empty media id");
|
|
}
|
|
throw new IllegalArgumentException("description cannot be null");
|
|
}
|
|
|
|
public static MediaItem fromMediaItem(Object obj) {
|
|
if (obj != null) {
|
|
MediaBrowser.MediaItem mediaItem = (MediaBrowser.MediaItem) obj;
|
|
return new MediaItem(MediaDescriptionCompat.fromMediaDescription(Api21Impl.getDescription(mediaItem)), Api21Impl.getFlags(mediaItem));
|
|
}
|
|
return null;
|
|
}
|
|
|
|
public static List<MediaItem> fromMediaItemList(List<?> list) {
|
|
if (list != null) {
|
|
ArrayList arrayList = new ArrayList(list.size());
|
|
Iterator<?> it = list.iterator();
|
|
while (it.hasNext()) {
|
|
arrayList.add(fromMediaItem(it.next()));
|
|
}
|
|
return arrayList;
|
|
}
|
|
return null;
|
|
}
|
|
|
|
@Override // android.os.Parcelable
|
|
public int describeContents() {
|
|
return 0;
|
|
}
|
|
|
|
@NonNull
|
|
public MediaDescriptionCompat getDescription() {
|
|
return this.mDescription;
|
|
}
|
|
|
|
public int getFlags() {
|
|
return this.mFlags;
|
|
}
|
|
|
|
@Nullable
|
|
public String getMediaId() {
|
|
return this.mDescription.getMediaId();
|
|
}
|
|
|
|
public boolean isBrowsable() {
|
|
if ((this.mFlags & 1) != 0) {
|
|
return true;
|
|
}
|
|
return MediaBrowserCompat.DEBUG;
|
|
}
|
|
|
|
public boolean isPlayable() {
|
|
if ((this.mFlags & 2) != 0) {
|
|
return true;
|
|
}
|
|
return MediaBrowserCompat.DEBUG;
|
|
}
|
|
|
|
@NonNull
|
|
public String toString() {
|
|
return "MediaItem{mFlags=" + this.mFlags + ", mDescription=" + this.mDescription + '}';
|
|
}
|
|
|
|
@Override // android.os.Parcelable
|
|
public void writeToParcel(Parcel parcel, int i) {
|
|
parcel.writeInt(this.mFlags);
|
|
this.mDescription.writeToParcel(parcel, i);
|
|
}
|
|
|
|
public MediaItem(Parcel parcel) {
|
|
this.mFlags = parcel.readInt();
|
|
this.mDescription = MediaDescriptionCompat.CREATOR.createFromParcel(parcel);
|
|
}
|
|
}
|
|
}
|