101 lines
3.2 KiB
Java
101 lines
3.2 KiB
Java
package androidx.media;
|
|
|
|
import android.content.Context;
|
|
import android.content.Intent;
|
|
import android.media.browse.MediaBrowser;
|
|
import android.os.Bundle;
|
|
import android.os.IBinder;
|
|
import android.os.Parcel;
|
|
import android.service.media.MediaBrowserService;
|
|
import android.support.v4.media.session.MediaSessionCompat;
|
|
import java.util.ArrayList;
|
|
import java.util.List;
|
|
|
|
/* loaded from: classes.dex */
|
|
class MediaBrowserServiceCompatApi21 {
|
|
|
|
static class BrowserRoot {
|
|
final String a;
|
|
final Bundle b;
|
|
}
|
|
|
|
static class MediaBrowserServiceAdaptor extends MediaBrowserService {
|
|
final ServiceCompatProxy a;
|
|
|
|
MediaBrowserServiceAdaptor(Context context, ServiceCompatProxy serviceCompatProxy) {
|
|
attachBaseContext(context);
|
|
this.a = serviceCompatProxy;
|
|
}
|
|
|
|
@Override // android.service.media.MediaBrowserService
|
|
public MediaBrowserService.BrowserRoot onGetRoot(String str, int i, Bundle bundle) {
|
|
MediaSessionCompat.a(bundle);
|
|
BrowserRoot a = this.a.a(str, i, bundle == null ? null : new Bundle(bundle));
|
|
if (a == null) {
|
|
return null;
|
|
}
|
|
return new MediaBrowserService.BrowserRoot(a.a, a.b);
|
|
}
|
|
|
|
@Override // android.service.media.MediaBrowserService
|
|
public void onLoadChildren(String str, MediaBrowserService.Result<List<MediaBrowser.MediaItem>> result) {
|
|
this.a.b(str, new ResultWrapper<>(result));
|
|
}
|
|
}
|
|
|
|
public interface ServiceCompatProxy {
|
|
BrowserRoot a(String str, int i, Bundle bundle);
|
|
|
|
void b(String str, ResultWrapper<List<Parcel>> resultWrapper);
|
|
}
|
|
|
|
public static Object a(Context context, ServiceCompatProxy serviceCompatProxy) {
|
|
return new MediaBrowserServiceAdaptor(context, serviceCompatProxy);
|
|
}
|
|
|
|
public static void a(Object obj) {
|
|
((MediaBrowserService) obj).onCreate();
|
|
}
|
|
|
|
public static IBinder a(Object obj, Intent intent) {
|
|
return ((MediaBrowserService) obj).onBind(intent);
|
|
}
|
|
|
|
static class ResultWrapper<T> {
|
|
MediaBrowserService.Result a;
|
|
|
|
ResultWrapper(MediaBrowserService.Result result) {
|
|
this.a = result;
|
|
}
|
|
|
|
/* JADX WARN: Multi-variable type inference failed */
|
|
public void a(T t) {
|
|
if (t instanceof List) {
|
|
this.a.sendResult(a((List<Parcel>) t));
|
|
return;
|
|
}
|
|
if (!(t instanceof Parcel)) {
|
|
this.a.sendResult(null);
|
|
return;
|
|
}
|
|
Parcel parcel = (Parcel) t;
|
|
parcel.setDataPosition(0);
|
|
this.a.sendResult(MediaBrowser.MediaItem.CREATOR.createFromParcel(parcel));
|
|
parcel.recycle();
|
|
}
|
|
|
|
List<MediaBrowser.MediaItem> a(List<Parcel> list) {
|
|
if (list == null) {
|
|
return null;
|
|
}
|
|
ArrayList arrayList = new ArrayList();
|
|
for (Parcel parcel : list) {
|
|
parcel.setDataPosition(0);
|
|
arrayList.add(MediaBrowser.MediaItem.CREATOR.createFromParcel(parcel));
|
|
parcel.recycle();
|
|
}
|
|
return arrayList;
|
|
}
|
|
}
|
|
}
|