package d3;

import android.content.ComponentName;
import android.content.ServiceConnection;
import android.os.IBinder;
import android.os.IInterface;
import com.google.android.gms.internal.measurement.C0730z;

/* JADX INFO: renamed from: d3.h0, reason: case insensitive filesystem */
/* JADX INFO: loaded from: classes.dex */
public final class ServiceConnectionC0788h0 implements ServiceConnection {

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

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

    public ServiceConnectionC0788h0(C0791i0 c0791i0, String str) {
        this.f11997r = c0791i0;
        this.f11996q = str;
    }

    @Override // android.content.ServiceConnection
    public final void onServiceConnected(ComponentName componentName, IBinder iBinder) {
        C0791i0 c0791i0 = this.f11997r;
        if (iBinder == null) {
            Z z8 = c0791i0.f12005r.f12150y;
            C0817r0.k(z8);
            z8.f11878y.b("Install Referrer connection returned with null binder");
            return;
        }
        try {
            int i = com.google.android.gms.internal.measurement.A.f9554e;
            IInterface iInterfaceQueryLocalInterface = iBinder.queryLocalInterface("com.google.android.finsky.externalreferrer.IGetInstallReferrerService");
            com.google.android.gms.internal.measurement.B c0730z = iInterfaceQueryLocalInterface instanceof com.google.android.gms.internal.measurement.B ? (com.google.android.gms.internal.measurement.B) iInterfaceQueryLocalInterface : new C0730z(iBinder, "com.google.android.finsky.externalreferrer.IGetInstallReferrerService", 1);
            if (c0730z == null) {
                Z z9 = c0791i0.f12005r.f12150y;
                C0817r0.k(z9);
                z9.f11878y.b("Install Referrer Service implementation was not found");
                return;
            }
            C0817r0 c0817r0 = c0791i0.f12005r;
            Z z10 = c0817r0.f12150y;
            C0817r0.k(z10);
            z10.D.b("Install Referrer Service connected");
            C0815q0 c0815q0 = c0817r0.f12151z;
            C0817r0.k(c0815q0);
            c0815q0.O(new G3.b(this, c0730z, this));
        } catch (RuntimeException e8) {
            Z z11 = c0791i0.f12005r.f12150y;
            C0817r0.k(z11);
            z11.f11878y.c(e8, "Exception occurred while calling Install Referrer API");
        }
    }

    @Override // android.content.ServiceConnection
    public final void onServiceDisconnected(ComponentName componentName) {
        Z z8 = this.f11997r.f12005r.f12150y;
        C0817r0.k(z8);
        z8.D.b("Install Referrer Service disconnected");
    }
}
