package defpackage;

import android.content.ComponentName;
import android.content.Context;
import android.content.ServiceConnection;
import android.os.DeadObjectException;
import android.os.IBinder;
import android.os.IInterface;
import android.os.Looper;
import android.os.RemoteException;

/* renamed from: ːᵪʡʥ, reason: contains not printable characters */
/* loaded from: classes3.dex */
public final class ServiceConnectionC1979 implements ServiceConnection, InterfaceC1929, InterfaceC1300 {

    /* renamed from: ᵢˇᵭ, reason: contains not printable characters */
    public volatile C1074 f7957;

    /* renamed from: ᵧᵾˀˈ, reason: contains not printable characters */
    public volatile boolean f7958;

    /* renamed from: ᵿʗᵝʽ, reason: contains not printable characters */
    public final /* synthetic */ C0323 f7959;

    public ServiceConnectionC1979(C0323 c0323) {
        this.f7959 = c0323;
    }

    @Override // android.content.ServiceConnection
    public final void onServiceConnected(ComponentName componentName, IBinder iBinder) {
        C1325 c1325 = ((C4205) ((ᵢˇᵭ) this.f7959).ᵧᵾˀˈ).f15698;
        C4205.m9132(c1325);
        c1325.m4049();
        synchronized (this) {
            if (iBinder == null) {
                this.f7958 = false;
                C1736 c1736 = ((C4205) ((ᵢˇᵭ) this.f7959).ᵧᵾˀˈ).f15715;
                C4205.m9132(c1736);
                c1736.f6937.m6038("Service connected with null binder");
                return;
            }
            Object c0506 = null;
            try {
                String interfaceDescriptor = iBinder.getInterfaceDescriptor();
                if ("com.google.android.gms.measurement.internal.IMeasurementService".equals(interfaceDescriptor)) {
                    IInterface iInterfaceQueryLocalInterface = iBinder.queryLocalInterface("com.google.android.gms.measurement.internal.IMeasurementService");
                    c0506 = iInterfaceQueryLocalInterface instanceof InterfaceC3519 ? (InterfaceC3519) iInterfaceQueryLocalInterface : new C0506(iBinder);
                    C1736 c17362 = ((C4205) ((ᵢˇᵭ) this.f7959).ᵧᵾˀˈ).f15715;
                    C4205.m9132(c17362);
                    c17362.f6935.m6038("Bound to IMeasurementService interface");
                } else {
                    C1736 c17363 = ((C4205) ((ᵢˇᵭ) this.f7959).ᵧᵾˀˈ).f15715;
                    C4205.m9132(c17363);
                    c17363.f6937.m6039(interfaceDescriptor, "Got binder with a wrong descriptor");
                }
            } catch (RemoteException unused) {
                C1736 c17364 = ((C4205) ((ᵢˇᵭ) this.f7959).ᵧᵾˀˈ).f15715;
                C4205.m9132(c17364);
                c17364.f6937.m6038("Service connect failed to get IMeasurementService");
            }
            if (c0506 == null) {
                this.f7958 = false;
                try {
                    C3580 c3580M8186 = C3580.m8186();
                    C0323 c0323 = this.f7959;
                    c3580M8186.m8188(((C4205) ((ᵢˇᵭ) c0323).ᵧᵾˀˈ).f15719, c0323.f2003);
                } catch (IllegalArgumentException unused2) {
                }
            } else {
                C1325 c13252 = ((C4205) ((ᵢˇᵭ) this.f7959).ᵧᵾˀˈ).f15698;
                C4205.m9132(c13252);
                c13252.m4043(new ﹶᴵ(12, this, c0506, false));
            }
        }
    }

    @Override // android.content.ServiceConnection
    public final void onServiceDisconnected(ComponentName componentName) {
        C4205 c4205 = (C4205) ((ᵢˇᵭ) this.f7959).ᵧᵾˀˈ;
        C1325 c1325 = c4205.f15698;
        C4205.m9132(c1325);
        c1325.m4049();
        C1736 c1736 = c4205.f15715;
        C4205.m9132(c1736);
        c1736.f6941.m6038("Service disconnected");
        C1325 c13252 = c4205.f15698;
        C4205.m9132(c13252);
        c13252.m4043(new RunnableC1011(this, 20, componentName));
    }

    @Override // defpackage.InterfaceC1929
    /* renamed from: ˎˏʜʾ */
    public final void mo5403() {
        C1325 c1325 = ((C4205) ((ᵢˇᵭ) this.f7959).ᵧᵾˀˈ).f15698;
        C4205.m9132(c1325);
        c1325.m4049();
        synchronized (this) {
            try {
                ᵩʛʽ.ᵝᵵᵺ(this.f7957);
                InterfaceC3519 interfaceC3519 = (InterfaceC3519) this.f7957.m3715();
                C1325 c13252 = ((C4205) ((ᵢˇᵭ) this.f7959).ᵧᵾˀˈ).f15698;
                C4205.m9132(c13252);
                c13252.m4043(new RunnableC1011(this, 21, interfaceC3519));
            } catch (DeadObjectException | IllegalStateException unused) {
                this.f7957 = null;
                this.f7958 = false;
            }
        }
    }

    @Override // defpackage.InterfaceC1929
    /* renamed from: ˏˋٴ */
    public final void mo5404(int i) {
        C4205 c4205 = (C4205) ((ᵢˇᵭ) this.f7959).ᵧᵾˀˈ;
        C1325 c1325 = c4205.f15698;
        C4205.m9132(c1325);
        c1325.m4049();
        C1736 c1736 = c4205.f15715;
        C4205.m9132(c1736);
        c1736.f6941.m6038("Service connection suspended");
        C1325 c13252 = c4205.f15698;
        C4205.m9132(c13252);
        c13252.m4043(new RunnableC5339(8, this));
    }

    @Override // defpackage.InterfaceC1300
    /* renamed from: ᵥᵯˎ */
    public final void mo4020(C0548 c0548) {
        C0323 c0323 = this.f7959;
        C1325 c1325 = ((C4205) ((ᵢˇᵭ) c0323).ᵧᵾˀˈ).f15698;
        C4205.m9132(c1325);
        c1325.m4049();
        C1736 c1736 = ((C4205) ((ᵢˇᵭ) c0323).ᵧᵾˀˈ).f15715;
        if (c1736 == null || !c1736.f20501) {
            c1736 = null;
        }
        if (c1736 != null) {
            c1736.f6935.m6039(c0548, "Service connection failed");
        }
        synchronized (this) {
            this.f7958 = false;
            this.f7957 = null;
        }
        C1325 c13252 = ((C4205) ((ᵢˇᵭ) this.f7959).ᵧᵾˀˈ).f15698;
        C4205.m9132(c13252);
        c13252.m4043(new ﹶᴵ(13, this, c0548, false));
    }

    /* renamed from: ᵴᵳ, reason: contains not printable characters */
    public final void m5482() {
        ServiceConnectionC1979 serviceConnectionC1979;
        C0323 c0323 = this.f7959;
        c0323.m6590();
        Context context = ((C4205) ((ᵢˇᵭ) c0323).ᵧᵾˀˈ).f15719;
        synchronized (this) {
            try {
                try {
                    if (this.f7958) {
                        C1736 c1736 = ((C4205) ((ᵢˇᵭ) this.f7959).ᵧᵾˀˈ).f15715;
                        C4205.m9132(c1736);
                        c1736.f6935.m6038("Connection attempt already in progress");
                        return;
                    }
                    if (this.f7957 != null && (this.f7957.m3721() || this.f7957.m3709())) {
                        C1736 c17362 = ((C4205) ((ᵢˇᵭ) this.f7959).ᵧᵾˀˈ).f15715;
                        C4205.m9132(c17362);
                        c17362.f6935.m6038("Already awaiting connection attempt");
                        return;
                    }
                    try {
                        try {
                            serviceConnectionC1979 = this;
                            try {
                                serviceConnectionC1979.f7957 = new C1074(context, Looper.getMainLooper(), C2782.m6867(context), C1029.f4496, 93, serviceConnectionC1979, this, null);
                                try {
                                    C1736 c17363 = ((C4205) ((ᵢˇᵭ) serviceConnectionC1979.f7959).ᵧᵾˀˈ).f15715;
                                    C4205.m9132(c17363);
                                    c17363.f6935.m6038("Connecting to remote service");
                                    serviceConnectionC1979.f7958 = true;
                                    ᵩʛʽ.ᵝᵵᵺ(serviceConnectionC1979.f7957);
                                    serviceConnectionC1979.f7957.m3716();
                                } catch (Throwable th) {
                                    th = th;
                                    throw th;
                                }
                            } catch (Throwable th2) {
                                th = th2;
                                th = th;
                                throw th;
                            }
                        } catch (Throwable th3) {
                            th = th3;
                            serviceConnectionC1979 = this;
                        }
                    } catch (Throwable th4) {
                        th = th4;
                        serviceConnectionC1979 = this;
                    }
                } catch (Throwable th5) {
                    th = th5;
                    serviceConnectionC1979 = this;
                }
            } catch (Throwable th6) {
                th = th6;
            }
        }
    }
}
