package android.support.v4.media.session;

import Mqv2r_3.KQgRr5e_0.KQgRr5e_0.QxJ9d_1.IFxWkV_5.KQgRr5e_0;
import Mqv2r_3.KQgRr5e_0.KQgRr5e_0.QxJ9d_1.IFxWkV_5.PGPF6hQ_2;
import Mqv2r_3.KQgRr5e_0.KQgRr5e_0.QxJ9d_1.IFxWkV_5.QxJ9d_1;
import android.content.Context;
import android.os.Build;
import android.os.Bundle;
import android.os.Handler;
import android.os.IBinder;
import android.os.Message;
import android.os.RemoteException;
import android.os.ResultReceiver;
import android.support.v4.media.MediaMetadataCompat;
import android.support.v4.media.session.MediaSessionCompat;
import android.util.Log;
import android.view.KeyEvent;
import java.lang.ref.WeakReference;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
/* loaded from: classes.dex */
public final class MediaControllerCompat {
    public final QxJ9d_1 KQgRr5e_0;

    /* loaded from: classes.dex */
    public static final class IFxWkV_5 {
        public IFxWkV_5(int i, int i2, int i3, int i4, int i5) {
        }
    }

    /* loaded from: classes.dex */
    public static abstract class KQgRr5e_0 implements IBinder.DeathRecipient {
        public Mqv2r_3.KQgRr5e_0.KQgRr5e_0.QxJ9d_1.IFxWkV_5.KQgRr5e_0 KQgRr5e_0;

        /* renamed from: KQgRr5e_0  reason: collision with other field name */
        public HandlerC0085KQgRr5e_0 f1808KQgRr5e_0;

        /* renamed from: android.support.v4.media.session.MediaControllerCompat$KQgRr5e_0$KQgRr5e_0  reason: collision with other inner class name */
        /* loaded from: classes.dex */
        public class HandlerC0085KQgRr5e_0 extends Handler {
        }

        public KQgRr5e_0() {
            if (Build.VERSION.SDK_INT >= 21) {
                Mqv2r_3.KQgRr5e_0.KQgRr5e_0.QxJ9d_1.IFxWkV_5.PGPF6hQ_2.KQgRr5e_0(new QxJ9d_1(this));
            } else {
                this.KQgRr5e_0 = new PGPF6hQ_2(this);
            }
        }

        public void KQgRr5e_0() {
        }

        public void KQgRr5e_0(int i, Object obj, Bundle bundle) {
            HandlerC0085KQgRr5e_0 handlerC0085KQgRr5e_0 = this.f1808KQgRr5e_0;
            if (handlerC0085KQgRr5e_0 != null) {
                Message obtainMessage = handlerC0085KQgRr5e_0.obtainMessage(i, obj);
                obtainMessage.setData(bundle);
                obtainMessage.sendToTarget();
            }
        }

        public void KQgRr5e_0(Bundle bundle) {
        }

        public void KQgRr5e_0(MediaMetadataCompat mediaMetadataCompat) {
        }

        public void KQgRr5e_0(IFxWkV_5 iFxWkV_5) {
        }

        public void KQgRr5e_0(PlaybackStateCompat playbackStateCompat) {
        }

        public void KQgRr5e_0(CharSequence charSequence) {
        }

        public void KQgRr5e_0(String str, Bundle bundle) {
        }

        public void KQgRr5e_0(List<MediaSessionCompat.QueueItem> list) {
        }

        @Override // android.os.IBinder.DeathRecipient
        public void binderDied() {
            KQgRr5e_0(8, null, null);
        }

        /* loaded from: classes.dex */
        public static class PGPF6hQ_2 extends KQgRr5e_0.AbstractBinderC0027KQgRr5e_0 {
            public final WeakReference<KQgRr5e_0> KQgRr5e_0;

            public PGPF6hQ_2(KQgRr5e_0 kQgRr5e_0) {
                this.KQgRr5e_0 = new WeakReference<>(kQgRr5e_0);
            }

            @Override // Mqv2r_3.KQgRr5e_0.KQgRr5e_0.QxJ9d_1.IFxWkV_5.KQgRr5e_0
            public void KQgRr5e_0(String str, Bundle bundle) throws RemoteException {
                KQgRr5e_0 kQgRr5e_0 = this.KQgRr5e_0.get();
                if (kQgRr5e_0 != null) {
                    kQgRr5e_0.KQgRr5e_0(1, str, bundle);
                }
            }

            @Override // Mqv2r_3.KQgRr5e_0.KQgRr5e_0.QxJ9d_1.IFxWkV_5.KQgRr5e_0
            public void KQgRr5e_0(boolean z) throws RemoteException {
            }

            @Override // Mqv2r_3.KQgRr5e_0.KQgRr5e_0.QxJ9d_1.IFxWkV_5.KQgRr5e_0
            public void QxJ9d_1(boolean z) throws RemoteException {
                KQgRr5e_0 kQgRr5e_0 = this.KQgRr5e_0.get();
                if (kQgRr5e_0 != null) {
                    kQgRr5e_0.KQgRr5e_0(11, Boolean.valueOf(z), null);
                }
            }

            @Override // Mqv2r_3.KQgRr5e_0.KQgRr5e_0.QxJ9d_1.IFxWkV_5.KQgRr5e_0
            public void KQgRr5e_0() throws RemoteException {
                KQgRr5e_0 kQgRr5e_0 = this.KQgRr5e_0.get();
                if (kQgRr5e_0 != null) {
                    kQgRr5e_0.KQgRr5e_0(8, null, null);
                }
            }

            @Override // Mqv2r_3.KQgRr5e_0.KQgRr5e_0.QxJ9d_1.IFxWkV_5.KQgRr5e_0
            public void QxJ9d_1(int i) throws RemoteException {
                KQgRr5e_0 kQgRr5e_0 = this.KQgRr5e_0.get();
                if (kQgRr5e_0 != null) {
                    kQgRr5e_0.KQgRr5e_0(12, Integer.valueOf(i), null);
                }
            }

            @Override // Mqv2r_3.KQgRr5e_0.KQgRr5e_0.QxJ9d_1.IFxWkV_5.KQgRr5e_0
            public void KQgRr5e_0(PlaybackStateCompat playbackStateCompat) throws RemoteException {
                KQgRr5e_0 kQgRr5e_0 = this.KQgRr5e_0.get();
                if (kQgRr5e_0 != null) {
                    kQgRr5e_0.KQgRr5e_0(2, playbackStateCompat, null);
                }
            }

            @Override // Mqv2r_3.KQgRr5e_0.KQgRr5e_0.QxJ9d_1.IFxWkV_5.KQgRr5e_0
            public void KQgRr5e_0(MediaMetadataCompat mediaMetadataCompat) throws RemoteException {
                KQgRr5e_0 kQgRr5e_0 = this.KQgRr5e_0.get();
                if (kQgRr5e_0 != null) {
                    kQgRr5e_0.KQgRr5e_0(3, mediaMetadataCompat, null);
                }
            }

            @Override // Mqv2r_3.KQgRr5e_0.KQgRr5e_0.QxJ9d_1.IFxWkV_5.KQgRr5e_0
            public void QxJ9d_1() throws RemoteException {
                KQgRr5e_0 kQgRr5e_0 = this.KQgRr5e_0.get();
                if (kQgRr5e_0 != null) {
                    kQgRr5e_0.KQgRr5e_0(13, null, null);
                }
            }

            @Override // Mqv2r_3.KQgRr5e_0.KQgRr5e_0.QxJ9d_1.IFxWkV_5.KQgRr5e_0
            public void KQgRr5e_0(List<MediaSessionCompat.QueueItem> list) throws RemoteException {
                KQgRr5e_0 kQgRr5e_0 = this.KQgRr5e_0.get();
                if (kQgRr5e_0 != null) {
                    kQgRr5e_0.KQgRr5e_0(5, list, null);
                }
            }

            @Override // Mqv2r_3.KQgRr5e_0.KQgRr5e_0.QxJ9d_1.IFxWkV_5.KQgRr5e_0
            public void KQgRr5e_0(CharSequence charSequence) throws RemoteException {
                KQgRr5e_0 kQgRr5e_0 = this.KQgRr5e_0.get();
                if (kQgRr5e_0 != null) {
                    kQgRr5e_0.KQgRr5e_0(6, charSequence, null);
                }
            }

            @Override // Mqv2r_3.KQgRr5e_0.KQgRr5e_0.QxJ9d_1.IFxWkV_5.KQgRr5e_0
            public void KQgRr5e_0(int i) throws RemoteException {
                KQgRr5e_0 kQgRr5e_0 = this.KQgRr5e_0.get();
                if (kQgRr5e_0 != null) {
                    kQgRr5e_0.KQgRr5e_0(9, Integer.valueOf(i), null);
                }
            }

            @Override // Mqv2r_3.KQgRr5e_0.KQgRr5e_0.QxJ9d_1.IFxWkV_5.KQgRr5e_0
            public void KQgRr5e_0(Bundle bundle) throws RemoteException {
                KQgRr5e_0 kQgRr5e_0 = this.KQgRr5e_0.get();
                if (kQgRr5e_0 != null) {
                    kQgRr5e_0.KQgRr5e_0(7, bundle, null);
                }
            }

            @Override // Mqv2r_3.KQgRr5e_0.KQgRr5e_0.QxJ9d_1.IFxWkV_5.KQgRr5e_0
            public void KQgRr5e_0(ParcelableVolumeInfo parcelableVolumeInfo) throws RemoteException {
                KQgRr5e_0 kQgRr5e_0 = this.KQgRr5e_0.get();
                if (kQgRr5e_0 != null) {
                    kQgRr5e_0.KQgRr5e_0(4, parcelableVolumeInfo != null ? new IFxWkV_5(parcelableVolumeInfo.KQgRr5e_0, parcelableVolumeInfo.QxJ9d_1, parcelableVolumeInfo.PGPF6hQ_2, parcelableVolumeInfo.f3420Mqv2r_3, parcelableVolumeInfo.f3421X6FRs_4) : null, null);
                }
            }
        }

        /* loaded from: classes.dex */
        public static class QxJ9d_1 implements PGPF6hQ_2.KQgRr5e_0 {
            public final WeakReference<KQgRr5e_0> KQgRr5e_0;

            public QxJ9d_1(KQgRr5e_0 kQgRr5e_0) {
                this.KQgRr5e_0 = new WeakReference<>(kQgRr5e_0);
            }

            @Override // Mqv2r_3.KQgRr5e_0.KQgRr5e_0.QxJ9d_1.IFxWkV_5.PGPF6hQ_2.KQgRr5e_0
            public void KQgRr5e_0() {
                KQgRr5e_0 kQgRr5e_0 = this.KQgRr5e_0.get();
                if (kQgRr5e_0 != null) {
                    kQgRr5e_0.KQgRr5e_0();
                }
            }

            @Override // Mqv2r_3.KQgRr5e_0.KQgRr5e_0.QxJ9d_1.IFxWkV_5.PGPF6hQ_2.KQgRr5e_0
            public void QxJ9d_1(Object obj) {
                KQgRr5e_0 kQgRr5e_0 = this.KQgRr5e_0.get();
                if (kQgRr5e_0 != null) {
                    kQgRr5e_0.KQgRr5e_0(MediaMetadataCompat.KQgRr5e_0(obj));
                }
            }

            @Override // Mqv2r_3.KQgRr5e_0.KQgRr5e_0.QxJ9d_1.IFxWkV_5.PGPF6hQ_2.KQgRr5e_0
            public void KQgRr5e_0(String str, Bundle bundle) {
                KQgRr5e_0 kQgRr5e_0 = this.KQgRr5e_0.get();
                if (kQgRr5e_0 != null) {
                    if (kQgRr5e_0.KQgRr5e_0 == null || Build.VERSION.SDK_INT >= 23) {
                        kQgRr5e_0.KQgRr5e_0(str, bundle);
                    }
                }
            }

            @Override // Mqv2r_3.KQgRr5e_0.KQgRr5e_0.QxJ9d_1.IFxWkV_5.PGPF6hQ_2.KQgRr5e_0
            public void KQgRr5e_0(Object obj) {
                KQgRr5e_0 kQgRr5e_0 = this.KQgRr5e_0.get();
                if (kQgRr5e_0 == null || kQgRr5e_0.KQgRr5e_0 != null) {
                    return;
                }
                kQgRr5e_0.KQgRr5e_0(PlaybackStateCompat.KQgRr5e_0(obj));
            }

            @Override // Mqv2r_3.KQgRr5e_0.KQgRr5e_0.QxJ9d_1.IFxWkV_5.PGPF6hQ_2.KQgRr5e_0
            public void KQgRr5e_0(List<?> list) {
                KQgRr5e_0 kQgRr5e_0 = this.KQgRr5e_0.get();
                if (kQgRr5e_0 != null) {
                    kQgRr5e_0.KQgRr5e_0(MediaSessionCompat.QueueItem.KQgRr5e_0(list));
                }
            }

            @Override // Mqv2r_3.KQgRr5e_0.KQgRr5e_0.QxJ9d_1.IFxWkV_5.PGPF6hQ_2.KQgRr5e_0
            public void KQgRr5e_0(CharSequence charSequence) {
                KQgRr5e_0 kQgRr5e_0 = this.KQgRr5e_0.get();
                if (kQgRr5e_0 != null) {
                    kQgRr5e_0.KQgRr5e_0(charSequence);
                }
            }

            @Override // Mqv2r_3.KQgRr5e_0.KQgRr5e_0.QxJ9d_1.IFxWkV_5.PGPF6hQ_2.KQgRr5e_0
            public void KQgRr5e_0(Bundle bundle) {
                KQgRr5e_0 kQgRr5e_0 = this.KQgRr5e_0.get();
                if (kQgRr5e_0 != null) {
                    kQgRr5e_0.KQgRr5e_0(bundle);
                }
            }

            @Override // Mqv2r_3.KQgRr5e_0.KQgRr5e_0.QxJ9d_1.IFxWkV_5.PGPF6hQ_2.KQgRr5e_0
            public void KQgRr5e_0(int i, int i2, int i3, int i4, int i5) {
                KQgRr5e_0 kQgRr5e_0 = this.KQgRr5e_0.get();
                if (kQgRr5e_0 != null) {
                    kQgRr5e_0.KQgRr5e_0(new IFxWkV_5(i, i2, i3, i4, i5));
                }
            }
        }
    }

    /* loaded from: classes.dex */
    public static class MediaControllerImplApi21 implements QxJ9d_1 {
        public final MediaSessionCompat.Token KQgRr5e_0;

        /* renamed from: KQgRr5e_0  reason: collision with other field name */
        public final Object f1809KQgRr5e_0;
        public final Object QxJ9d_1 = new Object();

        /* renamed from: KQgRr5e_0  reason: collision with other field name */
        public final List<KQgRr5e_0> f1811KQgRr5e_0 = new ArrayList();

        /* renamed from: KQgRr5e_0  reason: collision with other field name */
        public HashMap<KQgRr5e_0, KQgRr5e_0> f1810KQgRr5e_0 = new HashMap<>();

        /* loaded from: classes.dex */
        public static class ExtraBinderRequestResultReceiver extends ResultReceiver {
            public WeakReference<MediaControllerImplApi21> KQgRr5e_0;

            public ExtraBinderRequestResultReceiver(MediaControllerImplApi21 mediaControllerImplApi21) {
                super(null);
                this.KQgRr5e_0 = new WeakReference<>(mediaControllerImplApi21);
            }

            @Override // android.os.ResultReceiver
            public void onReceiveResult(int i, Bundle bundle) {
                MediaControllerImplApi21 mediaControllerImplApi21 = this.KQgRr5e_0.get();
                if (mediaControllerImplApi21 == null || bundle == null) {
                    return;
                }
                synchronized (mediaControllerImplApi21.QxJ9d_1) {
                    mediaControllerImplApi21.KQgRr5e_0.KQgRr5e_0(QxJ9d_1.KQgRr5e_0.KQgRr5e_0(X6FRs_4.IMuAHx_6.Mqv2r_3.PGPF6hQ_2.KQgRr5e_0(bundle, "android.support.v4.media.session.EXTRA_BINDER")));
                    mediaControllerImplApi21.KQgRr5e_0.KQgRr5e_0(bundle.getBundle("android.support.v4.media.session.SESSION_TOKEN2_BUNDLE"));
                    mediaControllerImplApi21.KQgRr5e_0();
                }
            }
        }

        /* loaded from: classes.dex */
        public static class KQgRr5e_0 extends KQgRr5e_0.PGPF6hQ_2 {
            public KQgRr5e_0(KQgRr5e_0 kQgRr5e_0) {
                super(kQgRr5e_0);
            }

            @Override // android.support.v4.media.session.MediaControllerCompat.KQgRr5e_0.PGPF6hQ_2, Mqv2r_3.KQgRr5e_0.KQgRr5e_0.QxJ9d_1.IFxWkV_5.KQgRr5e_0
            public void KQgRr5e_0() throws RemoteException {
                throw new AssertionError();
            }

            @Override // android.support.v4.media.session.MediaControllerCompat.KQgRr5e_0.PGPF6hQ_2, Mqv2r_3.KQgRr5e_0.KQgRr5e_0.QxJ9d_1.IFxWkV_5.KQgRr5e_0
            public void KQgRr5e_0(MediaMetadataCompat mediaMetadataCompat) throws RemoteException {
                throw new AssertionError();
            }

            @Override // android.support.v4.media.session.MediaControllerCompat.KQgRr5e_0.PGPF6hQ_2, Mqv2r_3.KQgRr5e_0.KQgRr5e_0.QxJ9d_1.IFxWkV_5.KQgRr5e_0
            public void KQgRr5e_0(List<MediaSessionCompat.QueueItem> list) throws RemoteException {
                throw new AssertionError();
            }

            @Override // android.support.v4.media.session.MediaControllerCompat.KQgRr5e_0.PGPF6hQ_2, Mqv2r_3.KQgRr5e_0.KQgRr5e_0.QxJ9d_1.IFxWkV_5.KQgRr5e_0
            public void KQgRr5e_0(CharSequence charSequence) throws RemoteException {
                throw new AssertionError();
            }

            @Override // android.support.v4.media.session.MediaControllerCompat.KQgRr5e_0.PGPF6hQ_2, Mqv2r_3.KQgRr5e_0.KQgRr5e_0.QxJ9d_1.IFxWkV_5.KQgRr5e_0
            public void KQgRr5e_0(Bundle bundle) throws RemoteException {
                throw new AssertionError();
            }

            @Override // android.support.v4.media.session.MediaControllerCompat.KQgRr5e_0.PGPF6hQ_2, Mqv2r_3.KQgRr5e_0.KQgRr5e_0.QxJ9d_1.IFxWkV_5.KQgRr5e_0
            public void KQgRr5e_0(ParcelableVolumeInfo parcelableVolumeInfo) throws RemoteException {
                throw new AssertionError();
            }
        }

        public MediaControllerImplApi21(Context context, MediaSessionCompat.Token token) throws RemoteException {
            this.KQgRr5e_0 = token;
            Object KQgRr5e_02 = Mqv2r_3.KQgRr5e_0.KQgRr5e_0.QxJ9d_1.IFxWkV_5.PGPF6hQ_2.KQgRr5e_0(context, token.m819KQgRr5e_0());
            this.f1809KQgRr5e_0 = KQgRr5e_02;
            if (KQgRr5e_02 != null) {
                if (this.KQgRr5e_0.KQgRr5e_0() == null) {
                    QxJ9d_1();
                    return;
                }
                return;
            }
            throw new RemoteException();
        }

        @Override // android.support.v4.media.session.MediaControllerCompat.QxJ9d_1
        public boolean KQgRr5e_0(KeyEvent keyEvent) {
            return Mqv2r_3.KQgRr5e_0.KQgRr5e_0.QxJ9d_1.IFxWkV_5.PGPF6hQ_2.KQgRr5e_0(this.f1809KQgRr5e_0, keyEvent);
        }

        public final void QxJ9d_1() {
            KQgRr5e_0("android.support.v4.media.session.command.GET_EXTRA_BINDER", null, new ExtraBinderRequestResultReceiver(this));
        }

        public void KQgRr5e_0(String str, Bundle bundle, ResultReceiver resultReceiver) {
            Mqv2r_3.KQgRr5e_0.KQgRr5e_0.QxJ9d_1.IFxWkV_5.PGPF6hQ_2.KQgRr5e_0(this.f1809KQgRr5e_0, str, bundle, resultReceiver);
        }

        public void KQgRr5e_0() {
            if (this.KQgRr5e_0.KQgRr5e_0() == null) {
                return;
            }
            for (KQgRr5e_0 kQgRr5e_0 : this.f1811KQgRr5e_0) {
                KQgRr5e_0 kQgRr5e_02 = new KQgRr5e_0(kQgRr5e_0);
                this.f1810KQgRr5e_0.put(kQgRr5e_0, kQgRr5e_02);
                kQgRr5e_0.KQgRr5e_0 = kQgRr5e_02;
                try {
                    this.KQgRr5e_0.KQgRr5e_0().KQgRr5e_0(kQgRr5e_02);
                    kQgRr5e_0.KQgRr5e_0(13, null, null);
                } catch (RemoteException e) {
                    Log.e("MediaControllerCompat", "Dead object in registerCallback.", e);
                }
            }
            this.f1811KQgRr5e_0.clear();
        }
    }

    /* loaded from: classes.dex */
    public static class Mqv2r_3 extends PGPF6hQ_2 {
        public Mqv2r_3(Context context, MediaSessionCompat.Token token) throws RemoteException {
            super(context, token);
        }
    }

    /* loaded from: classes.dex */
    public static class PGPF6hQ_2 extends MediaControllerImplApi21 {
        public PGPF6hQ_2(Context context, MediaSessionCompat.Token token) throws RemoteException {
            super(context, token);
        }
    }

    /* loaded from: classes.dex */
    public interface QxJ9d_1 {
        boolean KQgRr5e_0(KeyEvent keyEvent);
    }

    /* loaded from: classes.dex */
    public static class X6FRs_4 implements QxJ9d_1 {
        public Mqv2r_3.KQgRr5e_0.KQgRr5e_0.QxJ9d_1.IFxWkV_5.QxJ9d_1 KQgRr5e_0;

        public X6FRs_4(MediaSessionCompat.Token token) {
            this.KQgRr5e_0 = QxJ9d_1.KQgRr5e_0.KQgRr5e_0((IBinder) token.m819KQgRr5e_0());
        }

        @Override // android.support.v4.media.session.MediaControllerCompat.QxJ9d_1
        public boolean KQgRr5e_0(KeyEvent keyEvent) {
            if (keyEvent != null) {
                try {
                    this.KQgRr5e_0.KQgRr5e_0(keyEvent);
                    return false;
                } catch (RemoteException e) {
                    Log.e("MediaControllerCompat", "Dead object in dispatchMediaButtonEvent.", e);
                    return false;
                }
            }
            throw new IllegalArgumentException("event may not be null.");
        }
    }

    public MediaControllerCompat(Context context, MediaSessionCompat.Token token) throws RemoteException {
        new HashSet();
        if (token != null) {
            int i = Build.VERSION.SDK_INT;
            if (i >= 24) {
                this.KQgRr5e_0 = new Mqv2r_3(context, token);
                return;
            } else if (i >= 23) {
                this.KQgRr5e_0 = new PGPF6hQ_2(context, token);
                return;
            } else if (i >= 21) {
                this.KQgRr5e_0 = new MediaControllerImplApi21(context, token);
                return;
            } else {
                this.KQgRr5e_0 = new X6FRs_4(token);
                return;
            }
        }
        throw new IllegalArgumentException("sessionToken must not be null");
    }

    public boolean KQgRr5e_0(KeyEvent keyEvent) {
        if (keyEvent != null) {
            return this.KQgRr5e_0.KQgRr5e_0(keyEvent);
        }
        throw new IllegalArgumentException("KeyEvent may not be null");
    }
}
