78 lines
2.6 KiB
Java
78 lines
2.6 KiB
Java
package androidx.media;
|
|
|
|
import android.content.Context;
|
|
import android.media.browse.MediaBrowser;
|
|
import android.os.Bundle;
|
|
import android.os.Parcel;
|
|
import android.service.media.MediaBrowserService;
|
|
import android.support.v4.media.session.MediaSessionCompat;
|
|
import android.util.Log;
|
|
import androidx.media.MediaBrowserServiceCompatApi23;
|
|
import java.lang.reflect.Field;
|
|
import java.util.ArrayList;
|
|
import java.util.List;
|
|
|
|
/* loaded from: classes.dex */
|
|
class MediaBrowserServiceCompatApi26 {
|
|
static Field a;
|
|
|
|
static class MediaBrowserServiceAdaptor extends MediaBrowserServiceCompatApi23.MediaBrowserServiceAdaptor {
|
|
MediaBrowserServiceAdaptor(Context context, ServiceCompatProxy serviceCompatProxy) {
|
|
super(context, serviceCompatProxy);
|
|
}
|
|
|
|
@Override // android.service.media.MediaBrowserService
|
|
public void onLoadChildren(String str, MediaBrowserService.Result<List<MediaBrowser.MediaItem>> result, Bundle bundle) {
|
|
MediaSessionCompat.a(bundle);
|
|
((ServiceCompatProxy) this.a).a(str, new ResultWrapper(result), bundle);
|
|
}
|
|
}
|
|
|
|
public interface ServiceCompatProxy extends MediaBrowserServiceCompatApi23.ServiceCompatProxy {
|
|
void a(String str, ResultWrapper resultWrapper, Bundle bundle);
|
|
}
|
|
|
|
static {
|
|
try {
|
|
a = MediaBrowserService.Result.class.getDeclaredField("mFlags");
|
|
a.setAccessible(true);
|
|
} catch (NoSuchFieldException e) {
|
|
Log.w("MBSCompatApi26", e);
|
|
}
|
|
}
|
|
|
|
public static Object a(Context context, ServiceCompatProxy serviceCompatProxy) {
|
|
return new MediaBrowserServiceAdaptor(context, serviceCompatProxy);
|
|
}
|
|
|
|
static class ResultWrapper {
|
|
MediaBrowserService.Result a;
|
|
|
|
ResultWrapper(MediaBrowserService.Result result) {
|
|
this.a = result;
|
|
}
|
|
|
|
public void a(List<Parcel> list, int i) {
|
|
try {
|
|
MediaBrowserServiceCompatApi26.a.setInt(this.a, i);
|
|
} catch (IllegalAccessException e) {
|
|
Log.w("MBSCompatApi26", e);
|
|
}
|
|
this.a.sendResult(a(list));
|
|
}
|
|
|
|
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;
|
|
}
|
|
}
|
|
}
|