2021-07-24 02:37:17 +00:00
package androidx.media ;
import android.annotation.SuppressLint ;
import android.app.Service ;
import android.content.Context ;
import android.content.Intent ;
import android.media.browse.MediaBrowser ;
import android.media.session.MediaSession ;
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.RemoteException ;
import android.service.media.MediaBrowserService ;
import android.support.v4.media.MediaBrowserCompat ;
import android.support.v4.media.session.MediaSessionCompat ;
import android.support.v4.os.ResultReceiver ;
import android.text.TextUtils ;
import android.util.Log ;
import androidx.annotation.NonNull ;
import androidx.annotation.Nullable ;
import androidx.annotation.RequiresApi ;
import androidx.annotation.RestrictTo ;
import androidx.collection.ArrayMap ;
import androidx.core.app.BundleCompat ;
import androidx.core.util.Pair ;
import androidx.media.MediaSessionManager ;
2021-12-17 22:01:24 +00:00
import b.d.b.a.a ;
2021-07-24 02:37:17 +00:00
import java.io.FileDescriptor ;
import java.io.PrintWriter ;
import java.util.ArrayList ;
import java.util.Collections ;
import java.util.HashMap ;
import java.util.Iterator ;
import java.util.List ;
2021-11-01 07:19:03 +00:00
import x.a.b.b.a.b ;
2021-07-24 02:37:17 +00:00
public abstract class MediaBrowserServiceCompat extends Service {
2021-08-09 22:50:52 +00:00
public static final boolean DEBUG = Log . isLoggable ( TAG , 3 ) ;
2021-07-24 02:37:17 +00:00
private static final float EPSILON = 1 . 0E - 5f ;
@RestrictTo ( { RestrictTo . Scope . LIBRARY } )
public static final String KEY_MEDIA_ITEM = " media_item " ;
@RestrictTo ( { RestrictTo . Scope . LIBRARY } )
public static final String KEY_SEARCH_RESULTS = " search_results " ;
@RestrictTo ( { RestrictTo . Scope . LIBRARY } )
public static final int RESULT_ERROR = - 1 ;
public static final int RESULT_FLAG_ON_LOAD_ITEM_NOT_IMPLEMENTED = 2 ;
public static final int RESULT_FLAG_ON_SEARCH_NOT_IMPLEMENTED = 4 ;
public static final int RESULT_FLAG_OPTION_NOT_HANDLED = 1 ;
@RestrictTo ( { RestrictTo . Scope . LIBRARY } )
public static final int RESULT_OK = 0 ;
@RestrictTo ( { RestrictTo . Scope . LIBRARY } )
public static final int RESULT_PROGRESS_UPDATE = 1 ;
public static final String SERVICE_INTERFACE = " android.media.browse.MediaBrowserService " ;
public static final String TAG = " MBServiceCompat " ;
2021-08-09 22:50:52 +00:00
public final ConnectionRecord mConnectionFromFwk = new ConnectionRecord ( MediaSessionManager . RemoteUserInfo . LEGACY_CONTROLLER , - 1 , - 1 , null , null ) ;
2021-07-24 02:37:17 +00:00
public final ArrayMap < IBinder , ConnectionRecord > mConnections = new ArrayMap < > ( ) ;
public ConnectionRecord mCurConnection ;
public final ServiceHandler mHandler = new ServiceHandler ( ) ;
private MediaBrowserServiceImpl mImpl ;
public final ArrayList < ConnectionRecord > mPendingConnections = new ArrayList < > ( ) ;
public MediaSessionCompat . Token mSession ;
/* renamed from: androidx.media.MediaBrowserServiceCompat$1 reason: invalid class name */
public class AnonymousClass1 extends Result < List < MediaBrowserCompat . MediaItem > > {
public final /* synthetic */ ConnectionRecord val$connection ;
public final /* synthetic */ Bundle val$notifyChildrenChangedOptions ;
public final /* synthetic */ String val$parentId ;
public final /* synthetic */ Bundle val$subscribeOptions ;
/* JADX INFO: super call moved to the top of the method (can break code semantics) */
public AnonymousClass1 ( Object obj , ConnectionRecord connectionRecord , String str , Bundle bundle , Bundle bundle2 ) {
super ( obj ) ;
this . val$connection = connectionRecord ;
this . val$parentId = str ;
this . val$subscribeOptions = bundle ;
this . val$notifyChildrenChangedOptions = bundle2 ;
}
2021-11-05 21:05:33 +00:00
public void onResultSent ( @Nullable List < MediaBrowserCompat . MediaItem > list ) {
2021-07-24 02:37:17 +00:00
if ( MediaBrowserServiceCompat . this . mConnections . get ( this . val$connection . callbacks . asBinder ( ) ) = = this . val$connection ) {
if ( ( getFlags ( ) & 1 ) ! = 0 ) {
list = MediaBrowserServiceCompat . this . applyOptions ( list , this . val$subscribeOptions ) ;
}
try {
this . val$connection . callbacks . onLoadChildren ( this . val$parentId , list , this . val$subscribeOptions , this . val$notifyChildrenChangedOptions ) ;
} catch ( RemoteException unused ) {
2021-11-05 21:05:33 +00:00
StringBuilder R = a . R ( " Calling onLoadChildren() failed for id= " ) ;
R . append ( this . val$parentId ) ;
R . append ( " package= " ) ;
2021-12-17 22:01:24 +00:00
a . o0 ( R , this . val$connection . pkg , MediaBrowserServiceCompat . TAG ) ;
2021-07-24 02:37:17 +00:00
}
} else if ( MediaBrowserServiceCompat . DEBUG ) {
2021-11-05 21:05:33 +00:00
StringBuilder R2 = a . R ( " Not sending onLoadChildren result for connection that has been disconnected. pkg= " ) ;
R2 . append ( this . val$connection . pkg ) ;
R2 . append ( " id= " ) ;
R2 . append ( this . val$parentId ) ;
Log . d ( MediaBrowserServiceCompat . TAG , R2 . toString ( ) ) ;
2021-07-24 02:37:17 +00:00
}
}
}
/* renamed from: androidx.media.MediaBrowserServiceCompat$2 reason: invalid class name */
public class AnonymousClass2 extends Result < MediaBrowserCompat . MediaItem > {
public final /* synthetic */ ResultReceiver val$receiver ;
/* JADX INFO: super call moved to the top of the method (can break code semantics) */
public AnonymousClass2 ( Object obj , ResultReceiver resultReceiver ) {
super ( obj ) ;
this . val$receiver = resultReceiver ;
}
2021-11-05 21:05:33 +00:00
public void onResultSent ( @Nullable MediaBrowserCompat . MediaItem mediaItem ) {
2021-07-24 02:37:17 +00:00
if ( ( getFlags ( ) & 2 ) ! = 0 ) {
this . val$receiver . b ( - 1 , null ) ;
return ;
}
Bundle bundle = new Bundle ( ) ;
2021-08-09 22:50:52 +00:00
bundle . putParcelable ( MediaBrowserServiceCompat . KEY_MEDIA_ITEM , mediaItem ) ;
2021-07-24 02:37:17 +00:00
this . val$receiver . b ( 0 , bundle ) ;
}
}
/* renamed from: androidx.media.MediaBrowserServiceCompat$3 reason: invalid class name */
public class AnonymousClass3 extends Result < List < MediaBrowserCompat . MediaItem > > {
public final /* synthetic */ ResultReceiver val$receiver ;
/* JADX INFO: super call moved to the top of the method (can break code semantics) */
public AnonymousClass3 ( Object obj , ResultReceiver resultReceiver ) {
super ( obj ) ;
this . val$receiver = resultReceiver ;
}
2021-11-05 21:05:33 +00:00
public void onResultSent ( @Nullable List < MediaBrowserCompat . MediaItem > list ) {
2021-07-24 02:37:17 +00:00
if ( ( getFlags ( ) & 4 ) ! = 0 | | list = = null ) {
this . val$receiver . b ( - 1 , null ) ;
return ;
}
Bundle bundle = new Bundle ( ) ;
2021-08-09 22:50:52 +00:00
bundle . putParcelableArray ( MediaBrowserServiceCompat . KEY_SEARCH_RESULTS , ( Parcelable [ ] ) list . toArray ( new MediaBrowserCompat . MediaItem [ 0 ] ) ) ;
2021-07-24 02:37:17 +00:00
this . val$receiver . b ( 0 , bundle ) ;
}
}
/* renamed from: androidx.media.MediaBrowserServiceCompat$4 reason: invalid class name */
public class AnonymousClass4 extends Result < Bundle > {
public final /* synthetic */ ResultReceiver val$receiver ;
/* JADX INFO: super call moved to the top of the method (can break code semantics) */
public AnonymousClass4 ( Object obj , ResultReceiver resultReceiver ) {
super ( obj ) ;
this . val$receiver = resultReceiver ;
}
@Override // androidx.media.MediaBrowserServiceCompat.Result
2021-11-05 21:05:33 +00:00
public void onErrorSent ( @Nullable Bundle bundle ) {
2021-07-24 02:37:17 +00:00
this . val$receiver . b ( - 1 , bundle ) ;
}
@Override // androidx.media.MediaBrowserServiceCompat.Result
2021-11-05 21:05:33 +00:00
public void onProgressUpdateSent ( @Nullable Bundle bundle ) {
2021-07-24 02:37:17 +00:00
this . val$receiver . b ( 1 , bundle ) ;
}
2021-11-05 21:05:33 +00:00
public void onResultSent ( @Nullable Bundle bundle ) {
2021-07-24 02:37:17 +00:00
this . val$receiver . b ( 0 , bundle ) ;
}
}
public static final class BrowserRoot {
public static final String EXTRA_OFFLINE = " android.service.media.extra.OFFLINE " ;
public static final String EXTRA_RECENT = " android.service.media.extra.RECENT " ;
public static final String EXTRA_SUGGESTED = " android.service.media.extra.SUGGESTED " ;
@Deprecated
public static final String EXTRA_SUGGESTION_KEYWORDS = " android.service.media.extra.SUGGESTION_KEYWORDS " ;
private final Bundle mExtras ;
private final String mRootId ;
public BrowserRoot ( @NonNull String str , @Nullable Bundle bundle ) {
if ( str ! = null ) {
this . mRootId = str ;
this . mExtras = bundle ;
return ;
}
throw new IllegalArgumentException ( " The root id in BrowserRoot cannot be null. Use null for BrowserRoot instead " ) ;
}
public static /* synthetic */ String access$000 ( BrowserRoot browserRoot ) {
return browserRoot . mRootId ;
}
public static /* synthetic */ Bundle access$100 ( BrowserRoot browserRoot ) {
return browserRoot . mExtras ;
}
public Bundle getExtras ( ) {
return this . mExtras ;
}
public String getRootId ( ) {
return this . mRootId ;
}
}
public class ConnectionRecord implements IBinder . DeathRecipient {
public final MediaSessionManager . RemoteUserInfo browserInfo ;
public final ServiceCallbacks callbacks ;
public final int pid ;
public final String pkg ;
public BrowserRoot root ;
public final Bundle rootHints ;
public final HashMap < String , List < Pair < IBinder , Bundle > > > subscriptions = new HashMap < > ( ) ;
public final int uid ;
/* renamed from: androidx.media.MediaBrowserServiceCompat$ConnectionRecord$1 reason: invalid class name */
public class AnonymousClass1 implements Runnable {
public AnonymousClass1 ( ) {
}
@Override // java.lang.Runnable
public void run ( ) {
ConnectionRecord connectionRecord = ConnectionRecord . this ;
MediaBrowserServiceCompat . this . mConnections . remove ( connectionRecord . callbacks . asBinder ( ) ) ;
}
}
public ConnectionRecord ( String str , int i , int i2 , Bundle bundle , ServiceCallbacks serviceCallbacks ) {
this . pkg = str ;
this . pid = i ;
this . uid = i2 ;
this . browserInfo = new MediaSessionManager . RemoteUserInfo ( str , i , i2 ) ;
this . rootHints = bundle ;
this . callbacks = serviceCallbacks ;
}
@Override // android.os.IBinder.DeathRecipient
public void binderDied ( ) {
MediaBrowserServiceCompat . this . mHandler . post ( new AnonymousClass1 ( ) ) ;
}
}
public interface MediaBrowserServiceImpl {
Bundle getBrowserRootHints ( ) ;
MediaSessionManager . RemoteUserInfo getCurrentBrowserInfo ( ) ;
void notifyChildrenChanged ( MediaSessionManager . RemoteUserInfo remoteUserInfo , String str , Bundle bundle ) ;
void notifyChildrenChanged ( String str , Bundle bundle ) ;
IBinder onBind ( Intent intent ) ;
void onCreate ( ) ;
void setSessionToken ( MediaSessionCompat . Token token ) ;
}
@RequiresApi ( 21 )
public class MediaBrowserServiceImplApi21 implements MediaBrowserServiceImpl {
public Messenger mMessenger ;
public final List < Bundle > mRootExtrasList = new ArrayList ( ) ;
public MediaBrowserService mServiceFwk ;
/* renamed from: androidx.media.MediaBrowserServiceCompat$MediaBrowserServiceImplApi21$1 reason: invalid class name */
public class AnonymousClass1 implements Runnable {
public final /* synthetic */ MediaSessionCompat . Token val$token ;
public AnonymousClass1 ( MediaSessionCompat . Token token ) {
this . val$token = token ;
}
@Override // java.lang.Runnable
public void run ( ) {
2021-11-05 21:05:33 +00:00
MediaBrowserServiceImplApi21 . this . setSessionTokenOnHandler ( this . val$token ) ;
2021-07-24 02:37:17 +00:00
}
}
/* renamed from: androidx.media.MediaBrowserServiceCompat$MediaBrowserServiceImplApi21$2 reason: invalid class name */
public class AnonymousClass2 extends Result < List < MediaBrowserCompat . MediaItem > > {
public final /* synthetic */ ResultWrapper val$resultWrapper ;
/* JADX INFO: super call moved to the top of the method (can break code semantics) */
public AnonymousClass2 ( Object obj , ResultWrapper resultWrapper ) {
super ( obj ) ;
this . val$resultWrapper = resultWrapper ;
}
@Override // androidx.media.MediaBrowserServiceCompat.Result
public void detach ( ) {
this . val$resultWrapper . detach ( ) ;
}
2021-11-05 21:05:33 +00:00
public void onResultSent ( @Nullable List < MediaBrowserCompat . MediaItem > list ) {
2021-07-24 02:37:17 +00:00
ArrayList arrayList ;
if ( list ! = null ) {
arrayList = new ArrayList ( ) ;
for ( MediaBrowserCompat . MediaItem mediaItem : list ) {
Parcel obtain = Parcel . obtain ( ) ;
mediaItem . writeToParcel ( obtain , 0 ) ;
arrayList . add ( obtain ) ;
}
} else {
arrayList = null ;
}
this . val$resultWrapper . sendResult ( arrayList ) ;
}
}
/* renamed from: androidx.media.MediaBrowserServiceCompat$MediaBrowserServiceImplApi21$3 reason: invalid class name */
public class AnonymousClass3 implements Runnable {
public final /* synthetic */ Bundle val$options ;
public final /* synthetic */ String val$parentId ;
public AnonymousClass3 ( String str , Bundle bundle ) {
this . val$parentId = str ;
this . val$options = bundle ;
}
@Override // java.lang.Runnable
public void run ( ) {
for ( IBinder iBinder : MediaBrowserServiceCompat . this . mConnections . keySet ( ) ) {
ArrayMap < IBinder , ConnectionRecord > arrayMap = MediaBrowserServiceCompat . this . mConnections ;
MediaBrowserServiceImplApi21 . this . notifyChildrenChangedForCompatOnHandler ( arrayMap . get ( iBinder ) , this . val$parentId , this . val$options ) ;
}
}
}
/* renamed from: androidx.media.MediaBrowserServiceCompat$MediaBrowserServiceImplApi21$4 reason: invalid class name */
public class AnonymousClass4 implements Runnable {
public final /* synthetic */ Bundle val$options ;
public final /* synthetic */ String val$parentId ;
public final /* synthetic */ MediaSessionManager . RemoteUserInfo val$remoteUserInfo ;
public AnonymousClass4 ( MediaSessionManager . RemoteUserInfo remoteUserInfo , String str , Bundle bundle ) {
this . val$remoteUserInfo = remoteUserInfo ;
this . val$parentId = str ;
this . val$options = bundle ;
}
@Override // java.lang.Runnable
public void run ( ) {
for ( int i = 0 ; i < MediaBrowserServiceCompat . this . mConnections . size ( ) ; i + + ) {
ConnectionRecord valueAt = MediaBrowserServiceCompat . this . mConnections . valueAt ( i ) ;
if ( valueAt . browserInfo . equals ( this . val$remoteUserInfo ) ) {
MediaBrowserServiceImplApi21 . this . notifyChildrenChangedForCompatOnHandler ( valueAt , this . val$parentId , this . val$options ) ;
}
}
}
}
2021-11-05 21:05:33 +00:00
@RequiresApi ( 21 )
2021-07-24 02:37:17 +00:00
public class MediaBrowserServiceApi21 extends MediaBrowserService {
public MediaBrowserServiceApi21 ( Context context ) {
attachBaseContext ( context ) ;
}
@Override // android.service.media.MediaBrowserService
@SuppressLint ( { " SyntheticAccessor " } )
public MediaBrowserService . BrowserRoot onGetRoot ( String str , int i , Bundle bundle ) {
MediaSessionCompat . a ( bundle ) ;
BrowserRoot onGetRoot = MediaBrowserServiceImplApi21 . this . onGetRoot ( str , i , bundle = = null ? null : new Bundle ( bundle ) ) ;
if ( onGetRoot = = null ) {
return null ;
}
return new MediaBrowserService . BrowserRoot ( BrowserRoot . access$000 ( onGetRoot ) , BrowserRoot . access$100 ( onGetRoot ) ) ;
}
@Override // android.service.media.MediaBrowserService
public void onLoadChildren ( String str , MediaBrowserService . Result < List < MediaBrowser . MediaItem > > result ) {
MediaBrowserServiceImplApi21 . this . onLoadChildren ( str , new ResultWrapper < > ( result ) ) ;
}
}
public MediaBrowserServiceImplApi21 ( ) {
}
@Override // androidx.media.MediaBrowserServiceCompat.MediaBrowserServiceImpl
public Bundle getBrowserRootHints ( ) {
if ( this . mMessenger = = null ) {
return null ;
}
ConnectionRecord connectionRecord = MediaBrowserServiceCompat . this . mCurConnection ;
if ( connectionRecord = = null ) {
throw new IllegalStateException ( " This should be called inside of onGetRoot, onLoadChildren, onLoadItem, onSearch, or onCustomAction methods " ) ;
} else if ( connectionRecord . rootHints = = null ) {
return null ;
} else {
return new Bundle ( MediaBrowserServiceCompat . this . mCurConnection . rootHints ) ;
}
}
@Override // androidx.media.MediaBrowserServiceCompat.MediaBrowserServiceImpl
public MediaSessionManager . RemoteUserInfo getCurrentBrowserInfo ( ) {
ConnectionRecord connectionRecord = MediaBrowserServiceCompat . this . mCurConnection ;
if ( connectionRecord ! = null ) {
return connectionRecord . browserInfo ;
}
throw new IllegalStateException ( " This should be called inside of onGetRoot, onLoadChildren, onLoadItem, onSearch, or onCustomAction methods " ) ;
}
@Override // androidx.media.MediaBrowserServiceCompat.MediaBrowserServiceImpl
public void notifyChildrenChanged ( MediaSessionManager . RemoteUserInfo remoteUserInfo , String str , Bundle bundle ) {
notifyChildrenChangedForCompat ( remoteUserInfo , str , bundle ) ;
}
@Override // androidx.media.MediaBrowserServiceCompat.MediaBrowserServiceImpl
public void notifyChildrenChanged ( String str , Bundle bundle ) {
notifyChildrenChangedForFramework ( str , bundle ) ;
notifyChildrenChangedForCompat ( str , bundle ) ;
}
public void notifyChildrenChangedForCompat ( MediaSessionManager . RemoteUserInfo remoteUserInfo , String str , Bundle bundle ) {
MediaBrowserServiceCompat . this . mHandler . post ( new AnonymousClass4 ( remoteUserInfo , str , bundle ) ) ;
}
public void notifyChildrenChangedForCompat ( String str , Bundle bundle ) {
MediaBrowserServiceCompat . this . mHandler . post ( new AnonymousClass3 ( str , bundle ) ) ;
}
public void notifyChildrenChangedForCompatOnHandler ( ConnectionRecord connectionRecord , String str , Bundle bundle ) {
List < Pair < IBinder , Bundle > > list = connectionRecord . subscriptions . get ( str ) ;
if ( list ! = null ) {
for ( Pair < IBinder , Bundle > pair : list ) {
if ( MediaBrowserCompatUtils . hasDuplicatedItems ( bundle , pair . second ) ) {
MediaBrowserServiceCompat . this . performLoadChildren ( str , connectionRecord , pair . second , bundle ) ;
}
}
}
}
public void notifyChildrenChangedForFramework ( String str , Bundle bundle ) {
this . mServiceFwk . notifyChildrenChanged ( str ) ;
}
@Override // androidx.media.MediaBrowserServiceCompat.MediaBrowserServiceImpl
public IBinder onBind ( Intent intent ) {
return this . mServiceFwk . onBind ( intent ) ;
}
@Override // androidx.media.MediaBrowserServiceCompat.MediaBrowserServiceImpl
public void onCreate ( ) {
MediaBrowserServiceApi21 mediaBrowserServiceApi21 = new MediaBrowserServiceApi21 ( MediaBrowserServiceCompat . this ) ;
this . mServiceFwk = mediaBrowserServiceApi21 ;
mediaBrowserServiceApi21 . onCreate ( ) ;
}
public BrowserRoot onGetRoot ( String str , int i , Bundle bundle ) {
int i2 ;
Bundle bundle2 ;
2021-08-09 22:50:52 +00:00
if ( bundle = = null | | bundle . getInt ( MediaBrowserProtocol . EXTRA_CLIENT_VERSION , 0 ) = = 0 ) {
2021-07-24 02:37:17 +00:00
bundle2 = null ;
i2 = - 1 ;
} else {
2021-08-09 22:50:52 +00:00
bundle . remove ( MediaBrowserProtocol . EXTRA_CLIENT_VERSION ) ;
2021-07-24 02:37:17 +00:00
this . mMessenger = new Messenger ( MediaBrowserServiceCompat . this . mHandler ) ;
bundle2 = new Bundle ( ) ;
2021-08-09 22:50:52 +00:00
bundle2 . putInt ( MediaBrowserProtocol . EXTRA_SERVICE_VERSION , 2 ) ;
BundleCompat . putBinder ( bundle2 , MediaBrowserProtocol . EXTRA_MESSENGER_BINDER , this . mMessenger . getBinder ( ) ) ;
2021-07-24 02:37:17 +00:00
MediaSessionCompat . Token token = MediaBrowserServiceCompat . this . mSession ;
if ( token ! = null ) {
2021-12-17 22:01:24 +00:00
b b2 = token . b ( ) ;
BundleCompat . putBinder ( bundle2 , MediaBrowserProtocol . EXTRA_SESSION_BINDER , b2 = = null ? null : b2 . asBinder ( ) ) ;
2021-07-24 02:37:17 +00:00
} else {
this . mRootExtrasList . add ( bundle2 ) ;
}
2021-08-09 22:50:52 +00:00
int i3 = bundle . getInt ( MediaBrowserProtocol . EXTRA_CALLING_PID , - 1 ) ;
bundle . remove ( MediaBrowserProtocol . EXTRA_CALLING_PID ) ;
2021-07-24 02:37:17 +00:00
i2 = i3 ;
}
ConnectionRecord connectionRecord = new ConnectionRecord ( str , i2 , i , bundle , null ) ;
MediaBrowserServiceCompat mediaBrowserServiceCompat = MediaBrowserServiceCompat . this ;
mediaBrowserServiceCompat . mCurConnection = connectionRecord ;
BrowserRoot onGetRoot = mediaBrowserServiceCompat . onGetRoot ( str , i , bundle ) ;
MediaBrowserServiceCompat mediaBrowserServiceCompat2 = MediaBrowserServiceCompat . this ;
mediaBrowserServiceCompat2 . mCurConnection = null ;
if ( onGetRoot = = null ) {
return null ;
}
if ( this . mMessenger ! = null ) {
mediaBrowserServiceCompat2 . mPendingConnections . add ( connectionRecord ) ;
}
if ( bundle2 = = null ) {
bundle2 = onGetRoot . getExtras ( ) ;
} else if ( onGetRoot . getExtras ( ) ! = null ) {
bundle2 . putAll ( onGetRoot . getExtras ( ) ) ;
}
return new BrowserRoot ( onGetRoot . getRootId ( ) , bundle2 ) ;
}
public void onLoadChildren ( String str , ResultWrapper < List < Parcel > > resultWrapper ) {
AnonymousClass2 r0 = new AnonymousClass2 ( str , resultWrapper ) ;
MediaBrowserServiceCompat mediaBrowserServiceCompat = MediaBrowserServiceCompat . this ;
mediaBrowserServiceCompat . mCurConnection = mediaBrowserServiceCompat . mConnectionFromFwk ;
mediaBrowserServiceCompat . onLoadChildren ( str , r0 ) ;
MediaBrowserServiceCompat . this . mCurConnection = null ;
}
@Override // androidx.media.MediaBrowserServiceCompat.MediaBrowserServiceImpl
public void setSessionToken ( MediaSessionCompat . Token token ) {
MediaBrowserServiceCompat . this . mHandler . postOrRun ( new AnonymousClass1 ( token ) ) ;
}
2021-11-05 21:05:33 +00:00
public void setSessionTokenOnHandler ( MediaSessionCompat . Token token ) {
if ( ! this . mRootExtrasList . isEmpty ( ) ) {
2021-12-17 22:01:24 +00:00
b b2 = token . b ( ) ;
if ( b2 ! = null ) {
2021-11-05 21:05:33 +00:00
for ( Bundle bundle : this . mRootExtrasList ) {
2021-12-17 22:01:24 +00:00
BundleCompat . putBinder ( bundle , MediaBrowserProtocol . EXTRA_SESSION_BINDER , b2 . asBinder ( ) ) ;
2021-11-05 21:05:33 +00:00
}
}
this . mRootExtrasList . clear ( ) ;
}
2021-12-17 22:01:24 +00:00
this . mServiceFwk . setSessionToken ( ( MediaSession . Token ) token . k ) ;
2021-11-05 21:05:33 +00:00
}
2021-07-24 02:37:17 +00:00
}
@RequiresApi ( 23 )
public class MediaBrowserServiceImplApi23 extends MediaBrowserServiceImplApi21 {
/* renamed from: androidx.media.MediaBrowserServiceCompat$MediaBrowserServiceImplApi23$1 reason: invalid class name */
public class AnonymousClass1 extends Result < MediaBrowserCompat . MediaItem > {
public final /* synthetic */ ResultWrapper val$resultWrapper ;
/* JADX INFO: super call moved to the top of the method (can break code semantics) */
public AnonymousClass1 ( Object obj , ResultWrapper resultWrapper ) {
super ( obj ) ;
this . val$resultWrapper = resultWrapper ;
}
@Override // androidx.media.MediaBrowserServiceCompat.Result
public void detach ( ) {
this . val$resultWrapper . detach ( ) ;
}
2021-11-05 21:05:33 +00:00
public void onResultSent ( @Nullable MediaBrowserCompat . MediaItem mediaItem ) {
2021-07-24 02:37:17 +00:00
if ( mediaItem = = null ) {
this . val$resultWrapper . sendResult ( null ) ;
return ;
}
Parcel obtain = Parcel . obtain ( ) ;
mediaItem . writeToParcel ( obtain , 0 ) ;
this . val$resultWrapper . sendResult ( obtain ) ;
}
}
public class MediaBrowserServiceApi23 extends MediaBrowserServiceImplApi21 . MediaBrowserServiceApi21 {
public MediaBrowserServiceApi23 ( Context context ) {
super ( context ) ;
}
@Override // android.service.media.MediaBrowserService
public void onLoadItem ( String str , MediaBrowserService . Result < MediaBrowser . MediaItem > result ) {
MediaBrowserServiceImplApi23 . this . onLoadItem ( str , new ResultWrapper < > ( result ) ) ;
}
}
public MediaBrowserServiceImplApi23 ( ) {
super ( ) ;
}
@Override // androidx.media.MediaBrowserServiceCompat.MediaBrowserServiceImplApi21, androidx.media.MediaBrowserServiceCompat.MediaBrowserServiceImpl
public void onCreate ( ) {
MediaBrowserServiceApi23 mediaBrowserServiceApi23 = new MediaBrowserServiceApi23 ( MediaBrowserServiceCompat . this ) ;
this . mServiceFwk = mediaBrowserServiceApi23 ;
mediaBrowserServiceApi23 . onCreate ( ) ;
}
public void onLoadItem ( String str , ResultWrapper < Parcel > resultWrapper ) {
AnonymousClass1 r0 = new AnonymousClass1 ( str , resultWrapper ) ;
MediaBrowserServiceCompat mediaBrowserServiceCompat = MediaBrowserServiceCompat . this ;
mediaBrowserServiceCompat . mCurConnection = mediaBrowserServiceCompat . mConnectionFromFwk ;
mediaBrowserServiceCompat . onLoadItem ( str , r0 ) ;
MediaBrowserServiceCompat . this . mCurConnection = null ;
}
}
@RequiresApi ( 26 )
public class MediaBrowserServiceImplApi26 extends MediaBrowserServiceImplApi23 {
/* renamed from: androidx.media.MediaBrowserServiceCompat$MediaBrowserServiceImplApi26$1 reason: invalid class name */
public class AnonymousClass1 extends Result < List < MediaBrowserCompat . MediaItem > > {
public final /* synthetic */ Bundle val$options ;
public final /* synthetic */ ResultWrapper val$resultWrapper ;
/* JADX INFO: super call moved to the top of the method (can break code semantics) */
public AnonymousClass1 ( Object obj , ResultWrapper resultWrapper , Bundle bundle ) {
super ( obj ) ;
this . val$resultWrapper = resultWrapper ;
this . val$options = bundle ;
}
@Override // androidx.media.MediaBrowserServiceCompat.Result
public void detach ( ) {
this . val$resultWrapper . detach ( ) ;
}
2021-11-05 21:05:33 +00:00
public void onResultSent ( @Nullable List < MediaBrowserCompat . MediaItem > list ) {
2021-07-24 02:37:17 +00:00
if ( list = = null ) {
this . val$resultWrapper . sendResult ( null ) ;
return ;
}
if ( ( getFlags ( ) & 1 ) ! = 0 ) {
list = MediaBrowserServiceCompat . this . applyOptions ( list , this . val$options ) ;
}
ArrayList arrayList = new ArrayList ( ) ;
for ( MediaBrowserCompat . MediaItem mediaItem : list ) {
Parcel obtain = Parcel . obtain ( ) ;
mediaItem . writeToParcel ( obtain , 0 ) ;
arrayList . add ( obtain ) ;
}
this . val$resultWrapper . sendResult ( arrayList ) ;
}
}
public class MediaBrowserServiceApi26 extends MediaBrowserServiceImplApi23 . MediaBrowserServiceApi23 {
public MediaBrowserServiceApi26 ( Context context ) {
super ( context ) ;
}
@Override // android.service.media.MediaBrowserService
public void onLoadChildren ( String str , MediaBrowserService . Result < List < MediaBrowser . MediaItem > > result , Bundle bundle ) {
MediaSessionCompat . a ( bundle ) ;
MediaBrowserServiceImplApi26 mediaBrowserServiceImplApi26 = MediaBrowserServiceImplApi26 . this ;
MediaBrowserServiceCompat mediaBrowserServiceCompat = MediaBrowserServiceCompat . this ;
mediaBrowserServiceCompat . mCurConnection = mediaBrowserServiceCompat . mConnectionFromFwk ;
mediaBrowserServiceImplApi26 . onLoadChildren ( str , new ResultWrapper < > ( result ) , bundle ) ;
MediaBrowserServiceCompat . this . mCurConnection = null ;
}
}
public MediaBrowserServiceImplApi26 ( ) {
super ( ) ;
}
@Override // androidx.media.MediaBrowserServiceCompat.MediaBrowserServiceImplApi21, androidx.media.MediaBrowserServiceCompat.MediaBrowserServiceImpl
public Bundle getBrowserRootHints ( ) {
MediaBrowserServiceCompat mediaBrowserServiceCompat = MediaBrowserServiceCompat . this ;
ConnectionRecord connectionRecord = mediaBrowserServiceCompat . mCurConnection ;
if ( connectionRecord = = null ) {
throw new IllegalStateException ( " This should be called inside of onGetRoot, onLoadChildren, onLoadItem, onSearch, or onCustomAction methods " ) ;
} else if ( connectionRecord = = mediaBrowserServiceCompat . mConnectionFromFwk ) {
return this . mServiceFwk . getBrowserRootHints ( ) ;
} else {
if ( connectionRecord . rootHints = = null ) {
return null ;
}
return new Bundle ( MediaBrowserServiceCompat . this . mCurConnection . rootHints ) ;
}
}
@Override // androidx.media.MediaBrowserServiceCompat.MediaBrowserServiceImplApi21
public void notifyChildrenChangedForFramework ( String str , Bundle bundle ) {
if ( bundle ! = null ) {
this . mServiceFwk . notifyChildrenChanged ( str , bundle ) ;
} else {
super . notifyChildrenChangedForFramework ( str , bundle ) ;
}
}
@Override // androidx.media.MediaBrowserServiceCompat.MediaBrowserServiceImplApi23, androidx.media.MediaBrowserServiceCompat.MediaBrowserServiceImplApi21, androidx.media.MediaBrowserServiceCompat.MediaBrowserServiceImpl
public void onCreate ( ) {
MediaBrowserServiceApi26 mediaBrowserServiceApi26 = new MediaBrowserServiceApi26 ( MediaBrowserServiceCompat . this ) ;
this . mServiceFwk = mediaBrowserServiceApi26 ;
mediaBrowserServiceApi26 . onCreate ( ) ;
}
public void onLoadChildren ( String str , ResultWrapper < List < Parcel > > resultWrapper , Bundle bundle ) {
AnonymousClass1 r0 = new AnonymousClass1 ( str , resultWrapper , bundle ) ;
MediaBrowserServiceCompat mediaBrowserServiceCompat = MediaBrowserServiceCompat . this ;
mediaBrowserServiceCompat . mCurConnection = mediaBrowserServiceCompat . mConnectionFromFwk ;
mediaBrowserServiceCompat . onLoadChildren ( str , r0 , bundle ) ;
MediaBrowserServiceCompat . this . mCurConnection = null ;
}
}
@RequiresApi ( 28 )
public class MediaBrowserServiceImplApi28 extends MediaBrowserServiceImplApi26 {
public MediaBrowserServiceImplApi28 ( ) {
super ( ) ;
}
@Override // androidx.media.MediaBrowserServiceCompat.MediaBrowserServiceImplApi21, androidx.media.MediaBrowserServiceCompat.MediaBrowserServiceImpl
public MediaSessionManager . RemoteUserInfo getCurrentBrowserInfo ( ) {
MediaBrowserServiceCompat mediaBrowserServiceCompat = MediaBrowserServiceCompat . this ;
ConnectionRecord connectionRecord = mediaBrowserServiceCompat . mCurConnection ;
if ( connectionRecord ! = null ) {
return connectionRecord = = mediaBrowserServiceCompat . mConnectionFromFwk ? new MediaSessionManager . RemoteUserInfo ( this . mServiceFwk . getCurrentBrowserInfo ( ) ) : connectionRecord . browserInfo ;
}
throw new IllegalStateException ( " This should be called inside of onGetRoot, onLoadChildren, onLoadItem, onSearch, or onCustomAction methods " ) ;
}
}
public class MediaBrowserServiceImplBase implements MediaBrowserServiceImpl {
private Messenger mMessenger ;
/* renamed from: androidx.media.MediaBrowserServiceCompat$MediaBrowserServiceImplBase$1 reason: invalid class name */
public class AnonymousClass1 implements Runnable {
public final /* synthetic */ MediaSessionCompat . Token val$token ;
public AnonymousClass1 ( MediaSessionCompat . Token token ) {
this . val$token = token ;
}
@Override // java.lang.Runnable
public void run ( ) {
Iterator < ConnectionRecord > it = MediaBrowserServiceCompat . this . mConnections . values ( ) . iterator ( ) ;
while ( it . hasNext ( ) ) {
ConnectionRecord next = it . next ( ) ;
try {
next . callbacks . onConnect ( next . root . getRootId ( ) , this . val$token , next . root . getExtras ( ) ) ;
} catch ( RemoteException unused ) {
2021-11-05 21:05:33 +00:00
StringBuilder R = a . R ( " Connection for " ) ;
R . append ( next . pkg ) ;
R . append ( " is no longer valid. " ) ;
Log . w ( MediaBrowserServiceCompat . TAG , R . toString ( ) ) ;
2021-07-24 02:37:17 +00:00
it . remove ( ) ;
}
}
}
}
/* renamed from: androidx.media.MediaBrowserServiceCompat$MediaBrowserServiceImplBase$2 reason: invalid class name */
public class AnonymousClass2 implements Runnable {
public final /* synthetic */ Bundle val$options ;
public final /* synthetic */ String val$parentId ;
public AnonymousClass2 ( String str , Bundle bundle ) {
this . val$parentId = str ;
this . val$options = bundle ;
}
@Override // java.lang.Runnable
public void run ( ) {
for ( IBinder iBinder : MediaBrowserServiceCompat . this . mConnections . keySet ( ) ) {
ArrayMap < IBinder , ConnectionRecord > arrayMap = MediaBrowserServiceCompat . this . mConnections ;
MediaBrowserServiceImplBase . this . notifyChildrenChangedOnHandler ( arrayMap . get ( iBinder ) , this . val$parentId , this . val$options ) ;
}
}
}
/* renamed from: androidx.media.MediaBrowserServiceCompat$MediaBrowserServiceImplBase$3 reason: invalid class name */
public class AnonymousClass3 implements Runnable {
public final /* synthetic */ Bundle val$options ;
public final /* synthetic */ String val$parentId ;
public final /* synthetic */ MediaSessionManager . RemoteUserInfo val$remoteUserInfo ;
public AnonymousClass3 ( MediaSessionManager . RemoteUserInfo remoteUserInfo , String str , Bundle bundle ) {
this . val$remoteUserInfo = remoteUserInfo ;
this . val$parentId = str ;
this . val$options = bundle ;
}
@Override // java.lang.Runnable
public void run ( ) {
for ( int i = 0 ; i < MediaBrowserServiceCompat . this . mConnections . size ( ) ; i + + ) {
ConnectionRecord valueAt = MediaBrowserServiceCompat . this . mConnections . valueAt ( i ) ;
if ( valueAt . browserInfo . equals ( this . val$remoteUserInfo ) ) {
MediaBrowserServiceImplBase . this . notifyChildrenChangedOnHandler ( valueAt , this . val$parentId , this . val$options ) ;
return ;
}
}
}
}
public MediaBrowserServiceImplBase ( ) {
}
@Override // androidx.media.MediaBrowserServiceCompat.MediaBrowserServiceImpl
public Bundle getBrowserRootHints ( ) {
ConnectionRecord connectionRecord = MediaBrowserServiceCompat . this . mCurConnection ;
if ( connectionRecord = = null ) {
throw new IllegalStateException ( " This should be called inside of onLoadChildren, onLoadItem, onSearch, or onCustomAction methods " ) ;
} else if ( connectionRecord . rootHints = = null ) {
return null ;
} else {
return new Bundle ( MediaBrowserServiceCompat . this . mCurConnection . rootHints ) ;
}
}
@Override // androidx.media.MediaBrowserServiceCompat.MediaBrowserServiceImpl
public MediaSessionManager . RemoteUserInfo getCurrentBrowserInfo ( ) {
ConnectionRecord connectionRecord = MediaBrowserServiceCompat . this . mCurConnection ;
if ( connectionRecord ! = null ) {
return connectionRecord . browserInfo ;
}
throw new IllegalStateException ( " This should be called inside of onLoadChildren, onLoadItem, onSearch, or onCustomAction methods " ) ;
}
@Override // androidx.media.MediaBrowserServiceCompat.MediaBrowserServiceImpl
public void notifyChildrenChanged ( @NonNull MediaSessionManager . RemoteUserInfo remoteUserInfo , @NonNull String str , Bundle bundle ) {
MediaBrowserServiceCompat . this . mHandler . post ( new AnonymousClass3 ( remoteUserInfo , str , bundle ) ) ;
}
@Override // androidx.media.MediaBrowserServiceCompat.MediaBrowserServiceImpl
public void notifyChildrenChanged ( @NonNull String str , Bundle bundle ) {
MediaBrowserServiceCompat . this . mHandler . post ( new AnonymousClass2 ( str , bundle ) ) ;
}
public void notifyChildrenChangedOnHandler ( ConnectionRecord connectionRecord , String str , Bundle bundle ) {
List < Pair < IBinder , Bundle > > list = connectionRecord . subscriptions . get ( str ) ;
if ( list ! = null ) {
for ( Pair < IBinder , Bundle > pair : list ) {
if ( MediaBrowserCompatUtils . hasDuplicatedItems ( bundle , pair . second ) ) {
MediaBrowserServiceCompat . this . performLoadChildren ( str , connectionRecord , pair . second , bundle ) ;
}
}
}
}
@Override // androidx.media.MediaBrowserServiceCompat.MediaBrowserServiceImpl
public IBinder onBind ( Intent intent ) {
2021-08-09 22:50:52 +00:00
if ( MediaBrowserServiceCompat . SERVICE_INTERFACE . equals ( intent . getAction ( ) ) ) {
2021-07-24 02:37:17 +00:00
return this . mMessenger . getBinder ( ) ;
}
return null ;
}
@Override // androidx.media.MediaBrowserServiceCompat.MediaBrowserServiceImpl
public void onCreate ( ) {
this . mMessenger = new Messenger ( MediaBrowserServiceCompat . this . mHandler ) ;
}
@Override // androidx.media.MediaBrowserServiceCompat.MediaBrowserServiceImpl
public void setSessionToken ( MediaSessionCompat . Token token ) {
MediaBrowserServiceCompat . this . mHandler . post ( new AnonymousClass1 ( token ) ) ;
}
}
public static class Result < T > {
private final Object mDebug ;
private boolean mDetachCalled ;
private int mFlags ;
private boolean mSendErrorCalled ;
private boolean mSendResultCalled ;
public Result ( Object obj ) {
this . mDebug = obj ;
}
2021-11-05 21:05:33 +00:00
private void checkExtraFields ( @Nullable Bundle bundle ) {
2021-07-24 02:37:17 +00:00
if ( bundle ! = null & & bundle . containsKey ( " android.media.browse.extra.DOWNLOAD_PROGRESS " ) ) {
float f = bundle . getFloat ( " android.media.browse.extra.DOWNLOAD_PROGRESS " ) ;
if ( f < - 1 . 0E - 5f | | f > 1 . 00001f ) {
throw new IllegalArgumentException ( " The value of the EXTRA_DOWNLOAD_PROGRESS field must be a float number within [0.0, 1.0] " ) ;
}
}
}
public void detach ( ) {
if ( this . mDetachCalled ) {
2021-11-05 21:05:33 +00:00
StringBuilder R = a . R ( " detach() called when detach() had already been called for: " ) ;
R . append ( this . mDebug ) ;
throw new IllegalStateException ( R . toString ( ) ) ;
2021-07-24 02:37:17 +00:00
} else if ( this . mSendResultCalled ) {
2021-11-05 21:05:33 +00:00
StringBuilder R2 = a . R ( " detach() called when sendResult() had already been called for: " ) ;
R2 . append ( this . mDebug ) ;
throw new IllegalStateException ( R2 . toString ( ) ) ;
2021-07-24 02:37:17 +00:00
} else if ( ! this . mSendErrorCalled ) {
this . mDetachCalled = true ;
} else {
2021-11-05 21:05:33 +00:00
StringBuilder R3 = a . R ( " detach() called when sendError() had already been called for: " ) ;
R3 . append ( this . mDebug ) ;
throw new IllegalStateException ( R3 . toString ( ) ) ;
2021-07-24 02:37:17 +00:00
}
}
public int getFlags ( ) {
return this . mFlags ;
}
public boolean isDone ( ) {
return this . mDetachCalled | | this . mSendResultCalled | | this . mSendErrorCalled ;
}
2021-11-05 21:05:33 +00:00
public void onErrorSent ( @Nullable Bundle bundle ) {
StringBuilder R = a . R ( " It is not supported to send an error for " ) ;
R . append ( this . mDebug ) ;
throw new UnsupportedOperationException ( R . toString ( ) ) ;
2021-07-24 02:37:17 +00:00
}
2021-11-05 21:05:33 +00:00
public void onProgressUpdateSent ( @Nullable Bundle bundle ) {
StringBuilder R = a . R ( " It is not supported to send an interim update for " ) ;
R . append ( this . mDebug ) ;
throw new UnsupportedOperationException ( R . toString ( ) ) ;
2021-07-24 02:37:17 +00:00
}
2021-11-05 21:05:33 +00:00
public void onResultSent ( @Nullable T t ) {
2021-07-24 02:37:17 +00:00
}
2021-11-05 21:05:33 +00:00
public void sendError ( @Nullable Bundle bundle ) {
2021-07-24 02:37:17 +00:00
if ( this . mSendResultCalled | | this . mSendErrorCalled ) {
2021-11-05 21:05:33 +00:00
StringBuilder R = a . R ( " sendError() called when either sendResult() or sendError() had already been called for: " ) ;
R . append ( this . mDebug ) ;
throw new IllegalStateException ( R . toString ( ) ) ;
2021-07-24 02:37:17 +00:00
}
this . mSendErrorCalled = true ;
onErrorSent ( bundle ) ;
}
2021-11-05 21:05:33 +00:00
public void sendProgressUpdate ( @Nullable Bundle bundle ) {
2021-07-24 02:37:17 +00:00
if ( this . mSendResultCalled | | this . mSendErrorCalled ) {
2021-11-05 21:05:33 +00:00
StringBuilder R = a . R ( " sendProgressUpdate() called when either sendResult() or sendError() had already been called for: " ) ;
R . append ( this . mDebug ) ;
throw new IllegalStateException ( R . toString ( ) ) ;
2021-07-24 02:37:17 +00:00
}
checkExtraFields ( bundle ) ;
onProgressUpdateSent ( bundle ) ;
}
2021-11-05 21:05:33 +00:00
public void sendResult ( @Nullable T t ) {
2021-07-24 02:37:17 +00:00
if ( this . mSendResultCalled | | this . mSendErrorCalled ) {
2021-11-05 21:05:33 +00:00
StringBuilder R = a . R ( " sendResult() called when either sendResult() or sendError() had already been called for: " ) ;
R . append ( this . mDebug ) ;
throw new IllegalStateException ( R . toString ( ) ) ;
2021-07-24 02:37:17 +00:00
}
this . mSendResultCalled = true ;
onResultSent ( t ) ;
}
public void setFlags ( int i ) {
this . mFlags = i ;
}
}
@RequiresApi ( 21 )
public static class ResultWrapper < T > {
public MediaBrowserService . Result mResultFwk ;
public ResultWrapper ( MediaBrowserService . Result result ) {
this . mResultFwk = result ;
}
public void detach ( ) {
this . mResultFwk . detach ( ) ;
}
public List < MediaBrowser . MediaItem > parcelListToItemList ( List < Parcel > list ) {
if ( list = = null ) {
return null ;
}
ArrayList arrayList = new ArrayList ( ) ;
for ( Parcel parcel : list ) {
parcel . setDataPosition ( 0 ) ;
arrayList . add ( ( MediaBrowser . MediaItem ) MediaBrowser . MediaItem . CREATOR . createFromParcel ( parcel ) ) ;
parcel . recycle ( ) ;
}
return arrayList ;
}
/* JADX DEBUG: Multi-variable search result rejected for r0v4, resolved type: android.service.media.MediaBrowserService$Result */
/* JADX DEBUG: Multi-variable search result rejected for r0v5, resolved type: android.service.media.MediaBrowserService$Result */
/* JADX WARN: Multi-variable type inference failed */
public void sendResult ( T t ) {
if ( t instanceof List ) {
this . mResultFwk . sendResult ( parcelListToItemList ( t ) ) ;
} else if ( t instanceof Parcel ) {
T t2 = t ;
t2 . setDataPosition ( 0 ) ;
this . mResultFwk . sendResult ( MediaBrowser . MediaItem . CREATOR . createFromParcel ( t2 ) ) ;
t2 . recycle ( ) ;
} else {
this . mResultFwk . sendResult ( null ) ;
}
}
}
public class ServiceBinderImpl {
/* renamed from: androidx.media.MediaBrowserServiceCompat$ServiceBinderImpl$1 reason: invalid class name */
public class AnonymousClass1 implements Runnable {
public final /* synthetic */ ServiceCallbacks val$callbacks ;
public final /* synthetic */ int val$pid ;
public final /* synthetic */ String val$pkg ;
public final /* synthetic */ Bundle val$rootHints ;
public final /* synthetic */ int val$uid ;
public AnonymousClass1 ( ServiceCallbacks serviceCallbacks , String str , int i , int i2 , Bundle bundle ) {
this . val$callbacks = serviceCallbacks ;
this . val$pkg = str ;
this . val$pid = i ;
this . val$uid = i2 ;
this . val$rootHints = bundle ;
}
@Override // java.lang.Runnable
public void run ( ) {
IBinder asBinder = this . val$callbacks . asBinder ( ) ;
MediaBrowserServiceCompat . this . mConnections . remove ( asBinder ) ;
ConnectionRecord connectionRecord = new ConnectionRecord ( this . val$pkg , this . val$pid , this . val$uid , this . val$rootHints , this . val$callbacks ) ;
MediaBrowserServiceCompat mediaBrowserServiceCompat = MediaBrowserServiceCompat . this ;
mediaBrowserServiceCompat . mCurConnection = connectionRecord ;
BrowserRoot onGetRoot = mediaBrowserServiceCompat . onGetRoot ( this . val$pkg , this . val$uid , this . val$rootHints ) ;
connectionRecord . root = onGetRoot ;
MediaBrowserServiceCompat mediaBrowserServiceCompat2 = MediaBrowserServiceCompat . this ;
mediaBrowserServiceCompat2 . mCurConnection = null ;
if ( onGetRoot = = null ) {
2021-11-05 21:05:33 +00:00
StringBuilder R = a . R ( " No root for client " ) ;
R . append ( this . val$pkg ) ;
R . append ( " from service " ) ;
R . append ( getClass ( ) . getName ( ) ) ;
Log . i ( MediaBrowserServiceCompat . TAG , R . toString ( ) ) ;
2021-07-24 02:37:17 +00:00
try {
this . val$callbacks . onConnectFailed ( ) ;
} catch ( RemoteException unused ) {
2021-12-17 22:01:24 +00:00
a . o0 ( a . R ( " Calling onConnectFailed() failed. Ignoring. pkg= " ) , this . val$pkg , MediaBrowserServiceCompat . TAG ) ;
2021-07-24 02:37:17 +00:00
}
} else {
try {
mediaBrowserServiceCompat2 . mConnections . put ( asBinder , connectionRecord ) ;
asBinder . linkToDeath ( connectionRecord , 0 ) ;
if ( MediaBrowserServiceCompat . this . mSession ! = null ) {
this . val$callbacks . onConnect ( connectionRecord . root . getRootId ( ) , MediaBrowserServiceCompat . this . mSession , connectionRecord . root . getExtras ( ) ) ;
}
} catch ( RemoteException unused2 ) {
2021-12-17 22:01:24 +00:00
a . o0 ( a . R ( " Calling onConnect() failed. Dropping client. pkg= " ) , this . val$pkg , MediaBrowserServiceCompat . TAG ) ;
2021-07-24 02:37:17 +00:00
MediaBrowserServiceCompat . this . mConnections . remove ( asBinder ) ;
}
}
}
}
/* renamed from: androidx.media.MediaBrowserServiceCompat$ServiceBinderImpl$2 reason: invalid class name */
public class AnonymousClass2 implements Runnable {
public final /* synthetic */ ServiceCallbacks val$callbacks ;
public AnonymousClass2 ( ServiceCallbacks serviceCallbacks ) {
this . val$callbacks = serviceCallbacks ;
}
@Override // java.lang.Runnable
public void run ( ) {
ConnectionRecord remove = MediaBrowserServiceCompat . this . mConnections . remove ( this . val$callbacks . asBinder ( ) ) ;
if ( remove ! = null ) {
remove . callbacks . asBinder ( ) . unlinkToDeath ( remove , 0 ) ;
}
}
}
/* renamed from: androidx.media.MediaBrowserServiceCompat$ServiceBinderImpl$3 reason: invalid class name */
public class AnonymousClass3 implements Runnable {
public final /* synthetic */ ServiceCallbacks val$callbacks ;
public final /* synthetic */ String val$id ;
public final /* synthetic */ Bundle val$options ;
public final /* synthetic */ IBinder val$token ;
public AnonymousClass3 ( ServiceCallbacks serviceCallbacks , String str , IBinder iBinder , Bundle bundle ) {
this . val$callbacks = serviceCallbacks ;
this . val$id = str ;
this . val$token = iBinder ;
this . val$options = bundle ;
}
@Override // java.lang.Runnable
public void run ( ) {
ConnectionRecord connectionRecord = MediaBrowserServiceCompat . this . mConnections . get ( this . val$callbacks . asBinder ( ) ) ;
if ( connectionRecord = = null ) {
2021-12-17 22:01:24 +00:00
a . o0 ( a . R ( " addSubscription for callback that isn't registered id= " ) , this . val$id , MediaBrowserServiceCompat . TAG ) ;
2021-07-24 02:37:17 +00:00
} else {
MediaBrowserServiceCompat . this . addSubscription ( this . val$id , connectionRecord , this . val$token , this . val$options ) ;
}
}
}
/* renamed from: androidx.media.MediaBrowserServiceCompat$ServiceBinderImpl$4 reason: invalid class name */
public class AnonymousClass4 implements Runnable {
public final /* synthetic */ ServiceCallbacks val$callbacks ;
public final /* synthetic */ String val$id ;
public final /* synthetic */ IBinder val$token ;
public AnonymousClass4 ( ServiceCallbacks serviceCallbacks , String str , IBinder iBinder ) {
this . val$callbacks = serviceCallbacks ;
this . val$id = str ;
this . val$token = iBinder ;
}
@Override // java.lang.Runnable
public void run ( ) {
ConnectionRecord connectionRecord = MediaBrowserServiceCompat . this . mConnections . get ( this . val$callbacks . asBinder ( ) ) ;
if ( connectionRecord = = null ) {
2021-12-17 22:01:24 +00:00
a . o0 ( a . R ( " removeSubscription for callback that isn't registered id= " ) , this . val$id , MediaBrowserServiceCompat . TAG ) ;
2021-07-24 02:37:17 +00:00
} else if ( ! MediaBrowserServiceCompat . this . removeSubscription ( this . val$id , connectionRecord , this . val$token ) ) {
2021-11-05 21:05:33 +00:00
StringBuilder R = a . R ( " removeSubscription called for " ) ;
R . append ( this . val$id ) ;
R . append ( " which is not subscribed " ) ;
Log . w ( MediaBrowserServiceCompat . TAG , R . toString ( ) ) ;
2021-07-24 02:37:17 +00:00
}
}
}
/* renamed from: androidx.media.MediaBrowserServiceCompat$ServiceBinderImpl$5 reason: invalid class name */
public class AnonymousClass5 implements Runnable {
public final /* synthetic */ ServiceCallbacks val$callbacks ;
public final /* synthetic */ String val$mediaId ;
public final /* synthetic */ ResultReceiver val$receiver ;
public AnonymousClass5 ( ServiceCallbacks serviceCallbacks , String str , ResultReceiver resultReceiver ) {
this . val$callbacks = serviceCallbacks ;
this . val$mediaId = str ;
this . val$receiver = resultReceiver ;
}
@Override // java.lang.Runnable
public void run ( ) {
ConnectionRecord connectionRecord = MediaBrowserServiceCompat . this . mConnections . get ( this . val$callbacks . asBinder ( ) ) ;
if ( connectionRecord = = null ) {
2021-12-17 22:01:24 +00:00
a . o0 ( a . R ( " getMediaItem for callback that isn't registered id= " ) , this . val$mediaId , MediaBrowserServiceCompat . TAG ) ;
2021-07-24 02:37:17 +00:00
} else {
MediaBrowserServiceCompat . this . performLoadItem ( this . val$mediaId , connectionRecord , this . val$receiver ) ;
}
}
}
/* renamed from: androidx.media.MediaBrowserServiceCompat$ServiceBinderImpl$6 reason: invalid class name */
public class AnonymousClass6 implements Runnable {
public final /* synthetic */ ServiceCallbacks val$callbacks ;
public final /* synthetic */ int val$pid ;
public final /* synthetic */ String val$pkg ;
public final /* synthetic */ Bundle val$rootHints ;
public final /* synthetic */ int val$uid ;
public AnonymousClass6 ( ServiceCallbacks serviceCallbacks , int i , String str , int i2 , Bundle bundle ) {
this . val$callbacks = serviceCallbacks ;
this . val$uid = i ;
this . val$pkg = str ;
this . val$pid = i2 ;
this . val$rootHints = bundle ;
}
@Override // java.lang.Runnable
public void run ( ) {
2021-11-05 21:05:33 +00:00
ConnectionRecord connectionRecord ;
2021-07-24 02:37:17 +00:00
IBinder asBinder = this . val$callbacks . asBinder ( ) ;
MediaBrowserServiceCompat . this . mConnections . remove ( asBinder ) ;
Iterator < ConnectionRecord > it = MediaBrowserServiceCompat . this . mPendingConnections . iterator ( ) ;
2021-11-05 21:05:33 +00:00
while ( true ) {
connectionRecord = null ;
if ( ! it . hasNext ( ) ) {
break ;
}
2021-07-24 02:37:17 +00:00
ConnectionRecord next = it . next ( ) ;
if ( next . uid = = this . val$uid ) {
if ( TextUtils . isEmpty ( this . val$pkg ) | | this . val$pid < = 0 ) {
connectionRecord = new ConnectionRecord ( next . pkg , next . pid , next . uid , this . val$rootHints , this . val$callbacks ) ;
}
it . remove ( ) ;
}
}
if ( connectionRecord = = null ) {
connectionRecord = new ConnectionRecord ( this . val$pkg , this . val$pid , this . val$uid , this . val$rootHints , this . val$callbacks ) ;
}
MediaBrowserServiceCompat . this . mConnections . put ( asBinder , connectionRecord ) ;
try {
asBinder . linkToDeath ( connectionRecord , 0 ) ;
} catch ( RemoteException unused ) {
2021-08-09 22:50:52 +00:00
Log . w ( MediaBrowserServiceCompat . TAG , " IBinder is already dead. " ) ;
2021-07-24 02:37:17 +00:00
}
}
}
/* renamed from: androidx.media.MediaBrowserServiceCompat$ServiceBinderImpl$7 reason: invalid class name */
public class AnonymousClass7 implements Runnable {
public final /* synthetic */ ServiceCallbacks val$callbacks ;
public AnonymousClass7 ( ServiceCallbacks serviceCallbacks ) {
this . val$callbacks = serviceCallbacks ;
}
@Override // java.lang.Runnable
public void run ( ) {
IBinder asBinder = this . val$callbacks . asBinder ( ) ;
ConnectionRecord remove = MediaBrowserServiceCompat . this . mConnections . remove ( asBinder ) ;
if ( remove ! = null ) {
asBinder . unlinkToDeath ( remove , 0 ) ;
}
}
}
/* renamed from: androidx.media.MediaBrowserServiceCompat$ServiceBinderImpl$8 reason: invalid class name */
public class AnonymousClass8 implements Runnable {
public final /* synthetic */ ServiceCallbacks val$callbacks ;
public final /* synthetic */ Bundle val$extras ;
public final /* synthetic */ String val$query ;
public final /* synthetic */ ResultReceiver val$receiver ;
public AnonymousClass8 ( ServiceCallbacks serviceCallbacks , String str , Bundle bundle , ResultReceiver resultReceiver ) {
this . val$callbacks = serviceCallbacks ;
this . val$query = str ;
this . val$extras = bundle ;
this . val$receiver = resultReceiver ;
}
@Override // java.lang.Runnable
public void run ( ) {
ConnectionRecord connectionRecord = MediaBrowserServiceCompat . this . mConnections . get ( this . val$callbacks . asBinder ( ) ) ;
if ( connectionRecord = = null ) {
2021-12-17 22:01:24 +00:00
a . o0 ( a . R ( " search for callback that isn't registered query= " ) , this . val$query , MediaBrowserServiceCompat . TAG ) ;
2021-07-24 02:37:17 +00:00
} else {
MediaBrowserServiceCompat . this . performSearch ( this . val$query , this . val$extras , connectionRecord , this . val$receiver ) ;
}
}
}
/* renamed from: androidx.media.MediaBrowserServiceCompat$ServiceBinderImpl$9 reason: invalid class name */
public class AnonymousClass9 implements Runnable {
public final /* synthetic */ String val$action ;
public final /* synthetic */ ServiceCallbacks val$callbacks ;
public final /* synthetic */ Bundle val$extras ;
public final /* synthetic */ ResultReceiver val$receiver ;
public AnonymousClass9 ( ServiceCallbacks serviceCallbacks , String str , Bundle bundle , ResultReceiver resultReceiver ) {
this . val$callbacks = serviceCallbacks ;
this . val$action = str ;
this . val$extras = bundle ;
this . val$receiver = resultReceiver ;
}
@Override // java.lang.Runnable
public void run ( ) {
ConnectionRecord connectionRecord = MediaBrowserServiceCompat . this . mConnections . get ( this . val$callbacks . asBinder ( ) ) ;
if ( connectionRecord = = null ) {
2021-11-05 21:05:33 +00:00
StringBuilder R = a . R ( " sendCustomAction for callback that isn't registered action= " ) ;
R . append ( this . val$action ) ;
R . append ( " , extras= " ) ;
R . append ( this . val$extras ) ;
Log . w ( MediaBrowserServiceCompat . TAG , R . toString ( ) ) ;
2021-07-24 02:37:17 +00:00
return ;
}
MediaBrowserServiceCompat . this . performCustomAction ( this . val$action , this . val$extras , connectionRecord , this . val$receiver ) ;
}
}
public ServiceBinderImpl ( ) {
}
public void addSubscription ( String str , IBinder iBinder , Bundle bundle , ServiceCallbacks serviceCallbacks ) {
MediaBrowserServiceCompat . this . mHandler . postOrRun ( new AnonymousClass3 ( serviceCallbacks , str , iBinder , bundle ) ) ;
}
public void connect ( String str , int i , int i2 , Bundle bundle , ServiceCallbacks serviceCallbacks ) {
if ( MediaBrowserServiceCompat . this . isValidPackage ( str , i2 ) ) {
MediaBrowserServiceCompat . this . mHandler . postOrRun ( new AnonymousClass1 ( serviceCallbacks , str , i , i2 , bundle ) ) ;
return ;
}
throw new IllegalArgumentException ( " Package/uid mismatch: uid= " + i2 + " package= " + str ) ;
}
public void disconnect ( ServiceCallbacks serviceCallbacks ) {
MediaBrowserServiceCompat . this . mHandler . postOrRun ( new AnonymousClass2 ( serviceCallbacks ) ) ;
}
public void getMediaItem ( String str , ResultReceiver resultReceiver , ServiceCallbacks serviceCallbacks ) {
if ( ! TextUtils . isEmpty ( str ) & & resultReceiver ! = null ) {
MediaBrowserServiceCompat . this . mHandler . postOrRun ( new AnonymousClass5 ( serviceCallbacks , str , resultReceiver ) ) ;
}
}
public void registerCallbacks ( ServiceCallbacks serviceCallbacks , String str , int i , int i2 , Bundle bundle ) {
MediaBrowserServiceCompat . this . mHandler . postOrRun ( new AnonymousClass6 ( serviceCallbacks , i2 , str , i , bundle ) ) ;
}
public void removeSubscription ( String str , IBinder iBinder , ServiceCallbacks serviceCallbacks ) {
MediaBrowserServiceCompat . this . mHandler . postOrRun ( new AnonymousClass4 ( serviceCallbacks , str , iBinder ) ) ;
}
public void search ( String str , Bundle bundle , ResultReceiver resultReceiver , ServiceCallbacks serviceCallbacks ) {
if ( ! TextUtils . isEmpty ( str ) & & resultReceiver ! = null ) {
MediaBrowserServiceCompat . this . mHandler . postOrRun ( new AnonymousClass8 ( serviceCallbacks , str , bundle , resultReceiver ) ) ;
}
}
public void sendCustomAction ( String str , Bundle bundle , ResultReceiver resultReceiver , ServiceCallbacks serviceCallbacks ) {
if ( ! TextUtils . isEmpty ( str ) & & resultReceiver ! = null ) {
MediaBrowserServiceCompat . this . mHandler . postOrRun ( new AnonymousClass9 ( serviceCallbacks , str , bundle , resultReceiver ) ) ;
}
}
public void unregisterCallbacks ( ServiceCallbacks serviceCallbacks ) {
MediaBrowserServiceCompat . this . mHandler . postOrRun ( new AnonymousClass7 ( serviceCallbacks ) ) ;
}
}
public interface ServiceCallbacks {
IBinder asBinder ( ) ;
void onConnect ( String str , MediaSessionCompat . Token token , Bundle bundle ) throws RemoteException ;
void onConnectFailed ( ) throws RemoteException ;
void onLoadChildren ( String str , List < MediaBrowserCompat . MediaItem > list , Bundle bundle , Bundle bundle2 ) throws RemoteException ;
}
public static class ServiceCallbacksCompat implements ServiceCallbacks {
public final Messenger mCallbacks ;
public ServiceCallbacksCompat ( Messenger messenger ) {
this . mCallbacks = messenger ;
}
private void sendRequest ( int i , Bundle bundle ) throws RemoteException {
Message obtain = Message . obtain ( ) ;
obtain . what = i ;
obtain . arg1 = 2 ;
obtain . setData ( bundle ) ;
this . mCallbacks . send ( obtain ) ;
}
@Override // androidx.media.MediaBrowserServiceCompat.ServiceCallbacks
public IBinder asBinder ( ) {
return this . mCallbacks . getBinder ( ) ;
}
@Override // androidx.media.MediaBrowserServiceCompat.ServiceCallbacks
public void onConnect ( String str , MediaSessionCompat . Token token , Bundle bundle ) throws RemoteException {
if ( bundle = = null ) {
bundle = new Bundle ( ) ;
}
2021-08-09 22:50:52 +00:00
bundle . putInt ( MediaBrowserProtocol . EXTRA_SERVICE_VERSION , 2 ) ;
2021-07-24 02:37:17 +00:00
Bundle bundle2 = new Bundle ( ) ;
2021-08-09 22:50:52 +00:00
bundle2 . putString ( MediaBrowserProtocol . DATA_MEDIA_ITEM_ID , str ) ;
bundle2 . putParcelable ( MediaBrowserProtocol . DATA_MEDIA_SESSION_TOKEN , token ) ;
bundle2 . putBundle ( MediaBrowserProtocol . DATA_ROOT_HINTS , bundle ) ;
2021-07-24 02:37:17 +00:00
sendRequest ( 1 , bundle2 ) ;
}
@Override // androidx.media.MediaBrowserServiceCompat.ServiceCallbacks
public void onConnectFailed ( ) throws RemoteException {
sendRequest ( 2 , null ) ;
}
@Override // androidx.media.MediaBrowserServiceCompat.ServiceCallbacks
public void onLoadChildren ( String str , List < MediaBrowserCompat . MediaItem > list , Bundle bundle , Bundle bundle2 ) throws RemoteException {
Bundle bundle3 = new Bundle ( ) ;
2021-08-09 22:50:52 +00:00
bundle3 . putString ( MediaBrowserProtocol . DATA_MEDIA_ITEM_ID , str ) ;
bundle3 . putBundle ( MediaBrowserProtocol . DATA_OPTIONS , bundle ) ;
bundle3 . putBundle ( MediaBrowserProtocol . DATA_NOTIFY_CHILDREN_CHANGED_OPTIONS , bundle2 ) ;
2021-07-24 02:37:17 +00:00
if ( list ! = null ) {
2021-08-09 22:50:52 +00:00
bundle3 . putParcelableArrayList ( MediaBrowserProtocol . DATA_MEDIA_ITEM_LIST , list instanceof ArrayList ? ( ArrayList ) list : new ArrayList < > ( list ) ) ;
2021-07-24 02:37:17 +00:00
}
sendRequest ( 3 , bundle3 ) ;
}
}
public final class ServiceHandler extends Handler {
private final ServiceBinderImpl mServiceBinderImpl ;
public ServiceHandler ( ) {
this . mServiceBinderImpl = new ServiceBinderImpl ( ) ;
}
@Override // android.os.Handler
public void handleMessage ( Message message ) {
Bundle data = message . getData ( ) ;
switch ( message . what ) {
case 1 :
2021-08-09 22:50:52 +00:00
Bundle bundle = data . getBundle ( MediaBrowserProtocol . DATA_ROOT_HINTS ) ;
2021-07-24 02:37:17 +00:00
MediaSessionCompat . a ( bundle ) ;
2021-08-09 22:50:52 +00:00
this . mServiceBinderImpl . connect ( data . getString ( MediaBrowserProtocol . DATA_PACKAGE_NAME ) , data . getInt ( MediaBrowserProtocol . DATA_CALLING_PID ) , data . getInt ( MediaBrowserProtocol . DATA_CALLING_UID ) , bundle , new ServiceCallbacksCompat ( message . replyTo ) ) ;
2021-07-24 02:37:17 +00:00
return ;
case 2 :
this . mServiceBinderImpl . disconnect ( new ServiceCallbacksCompat ( message . replyTo ) ) ;
return ;
case 3 :
2021-08-09 22:50:52 +00:00
Bundle bundle2 = data . getBundle ( MediaBrowserProtocol . DATA_OPTIONS ) ;
2021-07-24 02:37:17 +00:00
MediaSessionCompat . a ( bundle2 ) ;
2021-08-09 22:50:52 +00:00
this . mServiceBinderImpl . addSubscription ( data . getString ( MediaBrowserProtocol . DATA_MEDIA_ITEM_ID ) , BundleCompat . getBinder ( data , MediaBrowserProtocol . DATA_CALLBACK_TOKEN ) , bundle2 , new ServiceCallbacksCompat ( message . replyTo ) ) ;
2021-07-24 02:37:17 +00:00
return ;
case 4 :
2021-08-09 22:50:52 +00:00
this . mServiceBinderImpl . removeSubscription ( data . getString ( MediaBrowserProtocol . DATA_MEDIA_ITEM_ID ) , BundleCompat . getBinder ( data , MediaBrowserProtocol . DATA_CALLBACK_TOKEN ) , new ServiceCallbacksCompat ( message . replyTo ) ) ;
2021-07-24 02:37:17 +00:00
return ;
case 5 :
2021-08-09 22:50:52 +00:00
this . mServiceBinderImpl . getMediaItem ( data . getString ( MediaBrowserProtocol . DATA_MEDIA_ITEM_ID ) , ( ResultReceiver ) data . getParcelable ( MediaBrowserProtocol . DATA_RESULT_RECEIVER ) , new ServiceCallbacksCompat ( message . replyTo ) ) ;
2021-07-24 02:37:17 +00:00
return ;
case 6 :
2021-08-09 22:50:52 +00:00
Bundle bundle3 = data . getBundle ( MediaBrowserProtocol . DATA_ROOT_HINTS ) ;
2021-07-24 02:37:17 +00:00
MediaSessionCompat . a ( bundle3 ) ;
2021-08-09 22:50:52 +00:00
this . mServiceBinderImpl . registerCallbacks ( new ServiceCallbacksCompat ( message . replyTo ) , data . getString ( MediaBrowserProtocol . DATA_PACKAGE_NAME ) , data . getInt ( MediaBrowserProtocol . DATA_CALLING_PID ) , data . getInt ( MediaBrowserProtocol . DATA_CALLING_UID ) , bundle3 ) ;
2021-07-24 02:37:17 +00:00
return ;
case 7 :
this . mServiceBinderImpl . unregisterCallbacks ( new ServiceCallbacksCompat ( message . replyTo ) ) ;
return ;
case 8 :
2021-08-09 22:50:52 +00:00
Bundle bundle4 = data . getBundle ( MediaBrowserProtocol . DATA_SEARCH_EXTRAS ) ;
2021-07-24 02:37:17 +00:00
MediaSessionCompat . a ( bundle4 ) ;
2021-08-09 22:50:52 +00:00
this . mServiceBinderImpl . search ( data . getString ( MediaBrowserProtocol . DATA_SEARCH_QUERY ) , bundle4 , ( ResultReceiver ) data . getParcelable ( MediaBrowserProtocol . DATA_RESULT_RECEIVER ) , new ServiceCallbacksCompat ( message . replyTo ) ) ;
2021-07-24 02:37:17 +00:00
return ;
case 9 :
2021-08-09 22:50:52 +00:00
Bundle bundle5 = data . getBundle ( MediaBrowserProtocol . DATA_CUSTOM_ACTION_EXTRAS ) ;
2021-07-24 02:37:17 +00:00
MediaSessionCompat . a ( bundle5 ) ;
2021-08-09 22:50:52 +00:00
this . mServiceBinderImpl . sendCustomAction ( data . getString ( MediaBrowserProtocol . DATA_CUSTOM_ACTION ) , bundle5 , ( ResultReceiver ) data . getParcelable ( MediaBrowserProtocol . DATA_RESULT_RECEIVER ) , new ServiceCallbacksCompat ( message . replyTo ) ) ;
2021-07-24 02:37:17 +00:00
return ;
default :
2021-08-09 22:50:52 +00:00
Log . w ( MediaBrowserServiceCompat . TAG , " Unhandled message: " + message + " \ n Service version: 2 \ n Client version: " + message . arg1 ) ;
2021-07-24 02:37:17 +00:00
return ;
}
}
public void postOrRun ( Runnable runnable ) {
if ( Thread . currentThread ( ) = = getLooper ( ) . getThread ( ) ) {
runnable . run ( ) ;
} else {
post ( runnable ) ;
}
}
@Override // android.os.Handler
public boolean sendMessageAtTime ( Message message , long j ) {
Bundle data = message . getData ( ) ;
data . setClassLoader ( MediaBrowserCompat . class . getClassLoader ( ) ) ;
2021-08-09 22:50:52 +00:00
data . putInt ( MediaBrowserProtocol . DATA_CALLING_UID , Binder . getCallingUid ( ) ) ;
2021-07-24 02:37:17 +00:00
int callingPid = Binder . getCallingPid ( ) ;
if ( callingPid > 0 ) {
2021-08-09 22:50:52 +00:00
data . putInt ( MediaBrowserProtocol . DATA_CALLING_PID , callingPid ) ;
} else if ( ! data . containsKey ( MediaBrowserProtocol . DATA_CALLING_PID ) ) {
data . putInt ( MediaBrowserProtocol . DATA_CALLING_PID , - 1 ) ;
2021-07-24 02:37:17 +00:00
}
return super . sendMessageAtTime ( message , j ) ;
}
}
public void addSubscription ( String str , ConnectionRecord connectionRecord , IBinder iBinder , Bundle bundle ) {
List < Pair < IBinder , Bundle > > list = connectionRecord . subscriptions . get ( str ) ;
if ( list = = null ) {
list = new ArrayList < > ( ) ;
}
for ( Pair < IBinder , Bundle > pair : list ) {
if ( iBinder = = pair . first & & MediaBrowserCompatUtils . areSameOptions ( bundle , pair . second ) ) {
return ;
}
}
list . add ( new Pair < > ( iBinder , bundle ) ) ;
connectionRecord . subscriptions . put ( str , list ) ;
performLoadChildren ( str , connectionRecord , bundle , null ) ;
this . mCurConnection = connectionRecord ;
onSubscribe ( str , bundle ) ;
this . mCurConnection = null ;
}
public List < MediaBrowserCompat . MediaItem > applyOptions ( List < MediaBrowserCompat . MediaItem > list , Bundle bundle ) {
if ( list = = null ) {
return null ;
}
int i = bundle . getInt ( " android.media.browse.extra.PAGE " , - 1 ) ;
int i2 = bundle . getInt ( " android.media.browse.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 ( ) ) {
return Collections . emptyList ( ) ;
}
if ( i4 > list . size ( ) ) {
i4 = list . size ( ) ;
}
return list . subList ( i3 , i4 ) ;
}
@RestrictTo ( { RestrictTo . Scope . LIBRARY_GROUP_PREFIX } )
public void attachToBaseContext ( Context context ) {
attachBaseContext ( context ) ;
}
@Override // android.app.Service
public void dump ( FileDescriptor fileDescriptor , PrintWriter printWriter , String [ ] strArr ) {
}
public final Bundle getBrowserRootHints ( ) {
return this . mImpl . getBrowserRootHints ( ) ;
}
@NonNull
public final MediaSessionManager . RemoteUserInfo getCurrentBrowserInfo ( ) {
return this . mImpl . getCurrentBrowserInfo ( ) ;
}
@Nullable
public MediaSessionCompat . Token getSessionToken ( ) {
return this . mSession ;
}
public boolean isValidPackage ( String str , int i ) {
if ( str = = null ) {
return false ;
}
for ( String str2 : getPackageManager ( ) . getPackagesForUid ( i ) ) {
if ( str2 . equals ( str ) ) {
return true ;
}
}
return false ;
}
@RestrictTo ( { RestrictTo . Scope . LIBRARY_GROUP_PREFIX } )
public void notifyChildrenChanged ( @NonNull MediaSessionManager . RemoteUserInfo remoteUserInfo , @NonNull String str , @NonNull Bundle bundle ) {
if ( remoteUserInfo = = null ) {
throw new IllegalArgumentException ( " remoteUserInfo cannot be null in notifyChildrenChanged " ) ;
} else if ( str = = null ) {
throw new IllegalArgumentException ( " parentId cannot be null in notifyChildrenChanged " ) ;
} else if ( bundle ! = null ) {
this . mImpl . notifyChildrenChanged ( remoteUserInfo , str , bundle ) ;
} else {
throw new IllegalArgumentException ( " options cannot be null in notifyChildrenChanged " ) ;
}
}
public void notifyChildrenChanged ( @NonNull String str ) {
if ( str ! = null ) {
this . mImpl . notifyChildrenChanged ( str , null ) ;
return ;
}
throw new IllegalArgumentException ( " parentId cannot be null in notifyChildrenChanged " ) ;
}
public void notifyChildrenChanged ( @NonNull String str , @NonNull Bundle bundle ) {
if ( str = = null ) {
throw new IllegalArgumentException ( " parentId cannot be null in notifyChildrenChanged " ) ;
} else if ( bundle ! = null ) {
this . mImpl . notifyChildrenChanged ( str , bundle ) ;
} else {
throw new IllegalArgumentException ( " options cannot be null in notifyChildrenChanged " ) ;
}
}
@Override // android.app.Service
public IBinder onBind ( Intent intent ) {
return this . mImpl . onBind ( intent ) ;
}
@Override // android.app.Service
public void onCreate ( ) {
super . onCreate ( ) ;
int i = Build . VERSION . SDK_INT ;
if ( i > = 28 ) {
this . mImpl = new MediaBrowserServiceImplApi28 ( ) ;
} else if ( i > = 26 ) {
this . mImpl = new MediaBrowserServiceImplApi26 ( ) ;
} else if ( i > = 23 ) {
this . mImpl = new MediaBrowserServiceImplApi23 ( ) ;
} else {
this . mImpl = new MediaBrowserServiceImplApi21 ( ) ;
}
this . mImpl . onCreate ( ) ;
}
public void onCustomAction ( @NonNull String str , Bundle bundle , @NonNull Result < Bundle > result ) {
result . sendError ( null ) ;
}
@Nullable
public abstract BrowserRoot onGetRoot ( @NonNull String str , int i , @Nullable Bundle bundle ) ;
public abstract void onLoadChildren ( @NonNull String str , @NonNull Result < List < MediaBrowserCompat . MediaItem > > result ) ;
public void onLoadChildren ( @NonNull String str , @NonNull Result < List < MediaBrowserCompat . MediaItem > > result , @NonNull Bundle bundle ) {
result . setFlags ( 1 ) ;
onLoadChildren ( str , result ) ;
}
public void onLoadItem ( String str , @NonNull Result < MediaBrowserCompat . MediaItem > result ) {
result . setFlags ( 2 ) ;
result . sendResult ( null ) ;
}
public void onSearch ( @NonNull String str , Bundle bundle , @NonNull Result < List < MediaBrowserCompat . MediaItem > > result ) {
result . setFlags ( 4 ) ;
result . sendResult ( null ) ;
}
@RestrictTo ( { RestrictTo . Scope . LIBRARY } )
public void onSubscribe ( String str , Bundle bundle ) {
}
@RestrictTo ( { RestrictTo . Scope . LIBRARY } )
public void onUnsubscribe ( String str ) {
}
public void performCustomAction ( String str , Bundle bundle , ConnectionRecord connectionRecord , ResultReceiver resultReceiver ) {
AnonymousClass4 r0 = new AnonymousClass4 ( str , resultReceiver ) ;
this . mCurConnection = connectionRecord ;
onCustomAction ( str , bundle , r0 ) ;
this . mCurConnection = null ;
if ( ! r0 . isDone ( ) ) {
throw new IllegalStateException ( " onCustomAction must call detach() or sendResult() or sendError() before returning for action= " + str + " extras= " + bundle ) ;
}
}
public void performLoadChildren ( String str , ConnectionRecord connectionRecord , Bundle bundle , Bundle bundle2 ) {
AnonymousClass1 r7 = new AnonymousClass1 ( str , connectionRecord , str , bundle , bundle2 ) ;
this . mCurConnection = connectionRecord ;
if ( bundle = = null ) {
onLoadChildren ( str , r7 ) ;
} else {
onLoadChildren ( str , r7 , bundle ) ;
}
this . mCurConnection = null ;
if ( ! r7 . isDone ( ) ) {
2022-01-17 16:29:36 +00:00
throw new IllegalStateException ( a . J ( a . R ( " onLoadChildren must call detach() or sendResult() before returning for package= " ) , connectionRecord . pkg , " id= " , str ) ) ;
2021-07-24 02:37:17 +00:00
}
}
public void performLoadItem ( String str , ConnectionRecord connectionRecord , ResultReceiver resultReceiver ) {
AnonymousClass2 r0 = new AnonymousClass2 ( str , resultReceiver ) ;
this . mCurConnection = connectionRecord ;
onLoadItem ( str , r0 ) ;
this . mCurConnection = null ;
if ( ! r0 . isDone ( ) ) {
2021-11-05 21:05:33 +00:00
throw new IllegalStateException ( a . v ( " onLoadItem must call detach() or sendResult() before returning for id= " , str ) ) ;
2021-07-24 02:37:17 +00:00
}
}
public void performSearch ( String str , Bundle bundle , ConnectionRecord connectionRecord , ResultReceiver resultReceiver ) {
AnonymousClass3 r0 = new AnonymousClass3 ( str , resultReceiver ) ;
this . mCurConnection = connectionRecord ;
onSearch ( str , bundle , r0 ) ;
this . mCurConnection = null ;
if ( ! r0 . isDone ( ) ) {
2021-11-05 21:05:33 +00:00
throw new IllegalStateException ( a . v ( " onSearch must call detach() or sendResult() before returning for query= " , str ) ) ;
2021-07-24 02:37:17 +00:00
}
}
public boolean removeSubscription ( String str , ConnectionRecord connectionRecord , IBinder iBinder ) {
boolean z2 = true ;
boolean z3 = false ;
ConnectionRecord connectionRecord2 = null ;
if ( iBinder = = null ) {
try {
if ( connectionRecord . subscriptions . remove ( str ) = = null ) {
z2 = false ;
}
return z2 ;
} finally {
this . mCurConnection = connectionRecord ;
onUnsubscribe ( str ) ;
this . mCurConnection = connectionRecord2 ;
}
} else {
List < Pair < IBinder , Bundle > > list = connectionRecord . subscriptions . get ( str ) ;
if ( list ! = null ) {
Iterator < Pair < IBinder , Bundle > > it = list . iterator ( ) ;
while ( it . hasNext ( ) ) {
if ( iBinder = = it . next ( ) . first ) {
it . remove ( ) ;
z3 = true ;
}
}
if ( list . size ( ) = = 0 ) {
connectionRecord . subscriptions . remove ( str ) ;
}
}
this . mCurConnection = connectionRecord ;
onUnsubscribe ( str ) ;
this . mCurConnection = null ;
return z3 ;
}
}
public void setSessionToken ( MediaSessionCompat . Token token ) {
if ( token = = null ) {
throw new IllegalArgumentException ( " Session token may not be null " ) ;
} else if ( this . mSession = = null ) {
this . mSession = token ;
this . mImpl . setSessionToken ( token ) ;
} else {
throw new IllegalStateException ( " The session token has already been set " ) ;
}
}
}