package defpackage;

import android.content.ComponentName;
import android.content.ServiceConnection;
import android.os.DeadObjectException;
import android.os.IBinder;
import android.os.IInterface;
import android.os.RemoteException;
import android.util.Log;

/* renamed from: ᵖˈᵡ, reason: contains not printable characters */
/* loaded from: classes3.dex */
public final class ServiceConnectionC2349 implements ServiceConnection {

    /* renamed from: ᵢˇᵭ, reason: contains not printable characters */
    public final C0352 f9192;

    /* renamed from: ᵤᵙᵷ, reason: contains not printable characters */
    public final /* synthetic */ C3768 f9193;

    /* renamed from: ᵧᵾˀˈ, reason: contains not printable characters */
    public final InterfaceC4273 f9194;

    /* renamed from: ᵾᵬ, reason: contains not printable characters */
    public final int f9195;

    /* renamed from: ᵿʗᵝʽ, reason: contains not printable characters */
    public final C0352 f9196;

    public ServiceConnectionC2349(C3768 c3768, InterfaceC4273 interfaceC4273, int i) {
        this.f9193 = c3768;
        ᵩʛʽ r2 = c3768.f14061;
        this.f9192 = new C0352(r2);
        this.f9196 = new C0352(r2);
        this.f9194 = interfaceC4273;
        this.f9195 = i;
    }

    @Override // android.content.ServiceConnection
    public final void onBindingDied(ComponentName componentName) {
        int i = AbstractC1845.f7462;
        Log.isLoggable("BillingClient", 5);
        try {
            C3768 c3768 = this.f9193;
            boolean zM8394 = C3768.m8394(c3768);
            C0553 c0553 = c3768.f14075;
            if (zM8394) {
                C3826 c3826M1077 = C0044.m1077();
                c3826M1077.m10377();
                C0044.m1082((C0044) c3826M1077.f18337, 6);
                C3225 c3225M5935 = C2256.m5935();
                c3225M5935.m10377();
                C2256.m5936((C2256) c3225M5935.f18337, 110);
                c3826M1077.m8469(c3225M5935);
                C1702 c1702M5683 = C2093.m5683();
                int i2 = this.f9195;
                c1702M5683.m4891(i2 > 0);
                c1702M5683.m4892(i2);
                c3826M1077.m8470(c1702M5683);
                c0553.m2368((C0044) c3826M1077.m10376());
            } else {
                C4611 c4611M9777 = C4611.m9777();
                c0553.getClass();
                try {
                    C1769 c1769M7130 = C2930.m7130();
                    c1769M7130.m5045((C4559) c0553.f2892);
                    c1769M7130.m10377();
                    C2930.m7124((C2930) c1769M7130.f18337, c4611M9777);
                    ((C4164) c0553.f2894).m9076((C2930) c1769M7130.m10376());
                } catch (Throwable unused) {
                    AbstractC1845.m5213("BillingLogger");
                }
            }
        } catch (Throwable unused2) {
            AbstractC1845.m5213("BillingClient");
        }
        C3768 c37682 = this.f9193;
        synchronized (c37682.f14080) {
            if (c37682.f14062 != 3 && c37682.f14062 != 0) {
                c37682.m8414(0);
                c37682.m8399();
                try {
                    this.f9194.mo4523();
                } catch (Throwable unused3) {
                    AbstractC1845.m5213("BillingClient");
                }
            }
        }
    }

    @Override // android.content.ServiceConnection
    public final void onServiceConnected(ComponentName componentName, IBinder iBinder) {
        InterfaceC0233 c0157;
        AbstractC1845.m5207("BillingClient", "Billing service connected.");
        C3768 c3768 = this.f9193;
        synchronized (c3768.f14080) {
            try {
                if (c3768.f14062 == 3) {
                    return;
                }
                int i = AbstractBinderC2920.f11349;
                if (iBinder == null) {
                    c0157 = null;
                } else {
                    IInterface iInterfaceQueryLocalInterface = iBinder.queryLocalInterface("com.android.vending.billing.IInAppBillingService");
                    c0157 = iInterfaceQueryLocalInterface instanceof InterfaceC0233 ? (InterfaceC0233) iInterfaceQueryLocalInterface : new C0157(iBinder, "com.android.vending.billing.IInAppBillingService", 2);
                }
                c3768.f14055 = c0157;
                if (C3768.m8397(new CallableC3631(1, this), 30000L, new RunnableC5339(4, this), c3768.m8415(), c3768.m8407()) == null) {
                    int i2 = this.f9195;
                    C3297 c3297M8408 = c3768.m8408();
                    c3768.m8405(25, i2, c3297M8408);
                    m6096(c3297M8408);
                }
            } catch (Throwable th) {
                throw th;
            }
        }
    }

    @Override // android.content.ServiceConnection
    public final void onServiceDisconnected(ComponentName componentName) {
        int i = AbstractC1845.f7462;
        Log.isLoggable("BillingClient", 5);
        try {
            C3768 c3768 = this.f9193;
            boolean zM8394 = C3768.m8394(c3768);
            C0553 c0553 = c3768.f14075;
            if (zM8394) {
                C3826 c3826M1077 = C0044.m1077();
                c3826M1077.m10377();
                C0044.m1082((C0044) c3826M1077.f18337, 6);
                C3225 c3225M5935 = C2256.m5935();
                c3225M5935.m10377();
                C2256.m5936((C2256) c3225M5935.f18337, 109);
                c3826M1077.m8469(c3225M5935);
                C1702 c1702M5683 = C2093.m5683();
                int i2 = this.f9195;
                c1702M5683.m4891(i2 > 0);
                c1702M5683.m4892(i2);
                c3826M1077.m8470(c1702M5683);
                c0553.m2368((C0044) c3826M1077.m10376());
            } else {
                C3130 c3130M7482 = C3130.m7482();
                c0553.getClass();
                if (c3130M7482 != null) {
                    try {
                        C1769 c1769M7130 = C2930.m7130();
                        c1769M7130.m5045((C4559) c0553.f2892);
                        c1769M7130.m10377();
                        C2930.m7126((C2930) c1769M7130.f18337, c3130M7482);
                        ((C4164) c0553.f2894).m9076((C2930) c1769M7130.m10376());
                    } catch (Throwable unused) {
                        AbstractC1845.m5213("BillingLogger");
                    }
                }
            }
        } catch (Throwable unused2) {
            AbstractC1845.m5213("BillingClient");
        }
        C3768 c37682 = this.f9193;
        synchronized (c37682.f14080) {
            try {
                C0352 c0352 = this.f9196;
                c0352.f2093 = 0L;
                c0352.f2095 = false;
                c0352.m1776();
                if (c37682.f14062 == 3) {
                    return;
                }
                c37682.m8414(0);
                try {
                    this.f9194.mo4523();
                } catch (Throwable unused3) {
                    AbstractC1845.m5213("BillingClient");
                }
            } finally {
            }
        }
    }

    /* renamed from: ˇʼʤˎ, reason: contains not printable characters */
    public final void m6096(C3297 c3297) {
        C3768 c3768 = this.f9193;
        synchronized (c3768.f14080) {
            try {
                if (c3768.f14062 == 3) {
                    return;
                }
                try {
                    this.f9194.mo4522(c3297);
                } catch (Throwable unused) {
                    AbstractC1845.m5213("BillingClient");
                }
            } catch (Throwable th) {
                throw th;
            }
        }
    }

    /* JADX WARN: Removed duplicated region for block: B:15:0x0024  */
    /* JADX WARN: Removed duplicated region for block: B:17:0x002a  */
    /* JADX WARN: Removed duplicated region for block: B:20:0x0034  */
    /* JADX WARN: Removed duplicated region for block: B:22:0x0038  */
    /* JADX WARN: Removed duplicated region for block: B:25:0x0043  */
    /* JADX WARN: Removed duplicated region for block: B:26:0x0046  */
    /* renamed from: ˎˏʜʾ, reason: contains not printable characters */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
        To view partially-correct add '--show-bad-code' argument
    */
    public final void m6097(java.lang.Exception r10, boolean r11) {
        /*
            r9 = this;
            java.lang.String r0 = "BillingClient"
            defpackage.AbstractC1845.m5213(r0)
            boolean r0 = r10 instanceof android.os.DeadObjectException
            r1 = 42
            if (r0 == 0) goto Lf
            r2 = 91
        Ld:
            r5 = r2
            goto L1e
        Lf:
            boolean r2 = r10 instanceof android.os.RemoteException
            if (r2 == 0) goto L16
            r2 = 90
            goto Ld
        L16:
            boolean r2 = r10 instanceof java.lang.SecurityException
            if (r2 == 0) goto L1d
            r2 = 92
            goto Ld
        L1d:
            r5 = r1
        L1e:
            boolean r1 = defpackage.AbstractC1327.m4108(r5, r1)
            if (r1 == 0) goto L2a
            java.lang.String r10 = defpackage.AbstractC4993.m10445(r10)
        L28:
            r6 = r10
            goto L2c
        L2a:
            r10 = 0
            goto L28
        L2c:
            ᵨᵹ r10 = r9.f9193
            r1 = 0
            r10.m8414(r1)
            if (r0 == 0) goto L38
            ᵢᵲ r10 = defpackage.AbstractC5497.f20622
        L36:
            r4 = r10
            goto L3b
        L38:
            ᵢᵲ r10 = defpackage.AbstractC5497.f20625
            goto L36
        L3b:
            r8 = 0
            r3 = r9
            r7 = r11
            r3.m6099(r4, r5, r6, r7, r8)
            if (r0 == 0) goto L46
            ᵢᵲ r9 = defpackage.AbstractC5497.f20622
            goto L48
        L46:
            ᵢᵲ r9 = defpackage.AbstractC5497.f20625
        L48:
            r3.m6096(r9)
            return
        */
        throw new UnsupportedOperationException("Method not decompiled: defpackage.ServiceConnectionC2349.m6097(java.lang.Exception, boolean):void");
    }

    /* renamed from: ˏˋٴ, reason: contains not printable characters */
    public final void m6098(Exception exc, boolean z, int i) {
        AbstractC1845.m5213("BillingClient");
        boolean z2 = exc instanceof DeadObjectException;
        int i2 = z2 ? 132 : exc instanceof RemoteException ? 134 : exc instanceof SecurityException ? 133 : 131;
        String strM10445 = AbstractC4993.m10445(exc);
        this.f9193.m8414(0);
        m6099(z2 ? AbstractC5497.f20622 : AbstractC5497.f20625, i2, strM10445, z, i);
        m6096(z2 ? AbstractC5497.f20622 : AbstractC5497.f20625);
    }

    /* renamed from: ˏᵙ, reason: contains not printable characters */
    public final void m6099(C3297 c3297, int i, String str, boolean z, int i2) {
        try {
            C3225 c3225M5935 = C2256.m5935();
            int i3 = c3297.f12347;
            c3225M5935.m10377();
            C2256.m5932((C2256) c3225M5935.f18337, i3);
            String str2 = c3297.f12346;
            c3225M5935.m10377();
            C2256.m5934((C2256) c3225M5935.f18337, str2);
            c3225M5935.m10377();
            C2256.m5936((C2256) c3225M5935.f18337, i);
            c3225M5935.m10377();
            C2256.m5937((C2256) c3225M5935.f18337, i2);
            if (str != null) {
                c3225M5935.m10377();
                C2256.m5938((C2256) c3225M5935.f18337, str);
            }
            Long lM6101 = m6101(z);
            C3768 c3768 = this.f9193;
            if (!z) {
                C0187 c0187M5853 = C2190.m5853();
                c0187M5853.m10377();
                C2190.m5854((C2190) c0187M5853.f18337, (C2256) c3225M5935.m10376());
                if (lM6101 != null) {
                    long jLongValue = lM6101.longValue();
                    c0187M5853.m10377();
                    C2190.m5855((C2190) c0187M5853.f18337, jLongValue);
                }
                c3768.f14075.m2361((C2190) c0187M5853.m10376());
                return;
            }
            C1702 c1702M5683 = C2093.m5683();
            int i4 = this.f9195;
            c1702M5683.m4891(i4 > 0);
            c1702M5683.m4892(i4);
            c1702M5683.m10377();
            C2093.m5687((C2093) c1702M5683.f18337, i2);
            if (lM6101 != null) {
                long jLongValue2 = lM6101.longValue();
                c1702M5683.m10377();
                C2093.m5685((C2093) c1702M5683.f18337, jLongValue2);
            }
            C3826 c3826M1077 = C0044.m1077();
            c3826M1077.m8469(c3225M5935);
            c3826M1077.m10377();
            C0044.m1082((C0044) c3826M1077.f18337, 6);
            c3826M1077.m8470(c1702M5683);
            c3768.m8411((C0044) c3826M1077.m10376());
        } catch (Throwable unused) {
            AbstractC1845.m5213("BillingClient");
        }
    }

    /* renamed from: ᵥᵯˎ, reason: contains not printable characters */
    public final void m6100() {
        synchronized (this.f9193.f14080) {
            C0352 c0352 = this.f9192;
            c0352.f2093 = 0L;
            c0352.f2095 = false;
            c0352.m1776();
        }
    }

    /* renamed from: ᵴᵳ, reason: contains not printable characters */
    public final Long m6101(boolean z) {
        C3768 c3768 = this.f9193;
        try {
            if (z) {
                synchronized (c3768.f14080) {
                    try {
                        C0352 c0352 = this.f9192;
                        if (!c0352.f2095) {
                            return null;
                        }
                        long j = c0352.f2094.ˎˑː();
                        if (!c0352.f2095) {
                            throw new IllegalStateException("This stopwatch is already stopped.");
                        }
                        c0352.f2095 = false;
                        long j2 = (j - c0352.f2096) + c0352.f2093;
                        c0352.f2093 = j2;
                        return Long.valueOf(j2 / 1000000);
                    } finally {
                    }
                }
            }
            synchronized (c3768.f14080) {
                try {
                    C0352 c03522 = this.f9196;
                    if (!c03522.f2095) {
                        return null;
                    }
                    long j3 = c03522.f2094.ˎˑː();
                    if (!c03522.f2095) {
                        throw new IllegalStateException("This stopwatch is already stopped.");
                    }
                    c03522.f2095 = false;
                    long j4 = (j3 - c03522.f2096) + c03522.f2093;
                    c03522.f2093 = j4;
                    return Long.valueOf(j4 / 1000000);
                } finally {
                }
            }
        } catch (Throwable unused) {
            AbstractC1845.m5213("BillingClient");
            return null;
        }
        AbstractC1845.m5213("BillingClient");
        return null;
    }

    /* renamed from: ᵻᵢﹳᵰ, reason: contains not printable characters */
    public final void m6102(int i, boolean z) {
        try {
            Long lM6101 = m6101(z);
            C3768 c3768 = this.f9193;
            if (!z) {
                C0187 c0187M5853 = C2190.m5853();
                C3225 c3225M5935 = C2256.m5935();
                c3225M5935.m10377();
                C2256.m5932((C2256) c3225M5935.f18337, 0);
                c3225M5935.m10377();
                C2256.m5937((C2256) c3225M5935.f18337, i);
                c0187M5853.m10377();
                C2190.m5854((C2190) c0187M5853.f18337, (C2256) c3225M5935.m10376());
                if (lM6101 != null) {
                    long jLongValue = lM6101.longValue();
                    c0187M5853.m10377();
                    C2190.m5855((C2190) c0187M5853.f18337, jLongValue);
                }
                c3768.f14075.m2361((C2190) c0187M5853.m10376());
                return;
            }
            C4951 c4951M8252 = C3659.m8252();
            c4951M8252.m10377();
            C3659.m8249((C3659) c4951M8252.f18337, 6);
            C1702 c1702M5683 = C2093.m5683();
            int i2 = this.f9195;
            c1702M5683.m4891(i2 > 0);
            c1702M5683.m4892(i2);
            c1702M5683.m10377();
            C2093.m5687((C2093) c1702M5683.f18337, i);
            if (lM6101 != null) {
                long jLongValue2 = lM6101.longValue();
                c1702M5683.m10377();
                C2093.m5685((C2093) c1702M5683.f18337, jLongValue2);
            }
            c4951M8252.m10377();
            C3659.m8250((C3659) c4951M8252.f18337, (C2093) c1702M5683.m10376());
            c3768.m8403((C3659) c4951M8252.m10376());
        } catch (Throwable unused) {
            AbstractC1845.m5213("BillingClient");
        }
    }
}
