package P2;

import android.content.ComponentName;
import android.content.ServiceConnection;
import android.os.IBinder;
import android.os.IInterface;

/* JADX INFO: loaded from: classes.dex */
public final class A implements ServiceConnection {

    /* JADX INFO: renamed from: q, reason: collision with root package name */
    public final int f5328q;

    /* JADX INFO: renamed from: r, reason: collision with root package name */
    public final /* synthetic */ AbstractC0248e f5329r;

    public A(AbstractC0248e abstractC0248e, int i) {
        this.f5329r = abstractC0248e;
        this.f5328q = i;
    }

    @Override // android.content.ServiceConnection
    public final void onServiceConnected(ComponentName componentName, IBinder iBinder) {
        AbstractC0248e abstractC0248e = this.f5329r;
        if (iBinder == null) {
            AbstractC0248e.y(abstractC0248e);
            return;
        }
        synchronized (abstractC0248e.f5368h) {
            try {
                AbstractC0248e abstractC0248e2 = this.f5329r;
                IInterface iInterfaceQueryLocalInterface = iBinder.queryLocalInterface("com.google.android.gms.common.internal.IGmsServiceBroker");
                abstractC0248e2.i = (iInterfaceQueryLocalInterface == null || !(iInterfaceQueryLocalInterface instanceof s)) ? new s(iBinder) : (s) iInterfaceQueryLocalInterface;
            } catch (Throwable th) {
                throw th;
            }
        }
        AbstractC0248e abstractC0248e3 = this.f5329r;
        int i = this.f5328q;
        abstractC0248e3.getClass();
        C c3 = new C(abstractC0248e3, 0, null);
        y yVar = abstractC0248e3.f5366f;
        yVar.sendMessage(yVar.obtainMessage(7, i, -1, c3));
    }

    @Override // android.content.ServiceConnection
    public final void onServiceDisconnected(ComponentName componentName) {
        AbstractC0248e abstractC0248e;
        synchronized (this.f5329r.f5368h) {
            abstractC0248e = this.f5329r;
            abstractC0248e.i = null;
        }
        int i = this.f5328q;
        y yVar = abstractC0248e.f5366f;
        yVar.sendMessage(yVar.obtainMessage(6, i, 1));
    }
}
