package defpackage;

import android.content.Context;
import android.os.Bundle;
import android.text.TextUtils;
import android.util.Log;
import java.util.concurrent.Callable;

/* JADX INFO: renamed from: ᵙʙʠ, reason: contains not printable characters */
/* JADX INFO: loaded from: classes3.dex */
public final class CallableC2619 implements Callable {

    /* JADX INFO: renamed from: ʽˈˋ, reason: contains not printable characters */
    public final /* synthetic */ Object f10138;

    /* JADX INFO: renamed from: ᵲᵶᵳˈ, reason: contains not printable characters */
    public final /* synthetic */ int f10139;

    public /* synthetic */ CallableC2619(int i, Object obj) {
        this.f10139 = i;
        this.f10138 = obj;
    }

    public CallableC2619(BinderC3227 binderC3227, C0357 c0357, String str) {
        this.f10139 = 3;
        this.f10138 = binderC3227;
    }

    /* JADX WARN: Multi-variable type inference failed */
    /* JADX INFO: renamed from: ʽˈˋ, reason: contains not printable characters */
    private final Object m6344() {
        int i;
        Bundle bundle;
        InterfaceC1506 interfaceC1506;
        ServiceConnectionC4611 serviceConnectionC4611 = (ServiceConnectionC4611) this.f10138;
        C2780 c2780 = serviceConnectionC4611.f17532;
        synchronized (c2780.f10680) {
            try {
                if (c2780.f10688 == 3) {
                    return null;
                }
                int i2 = 1;
                boolean z = false;
                if (c2780.f10688 == 1) {
                    i = 0;
                    z = true;
                } else {
                    i = 0;
                }
                if (TextUtils.isEmpty(null)) {
                    bundle = null;
                } else {
                    bundle = new Bundle();
                    bundle.putString("accountName", null);
                    AbstractC2252.m5865(bundle, c2780.f10686, c2780.f10674.longValue());
                }
                synchronized (c2780.f10680) {
                    interfaceC1506 = c2780.f10701;
                }
                C2780 c27802 = serviceConnectionC4611.f17532;
                if (interfaceC1506 == null) {
                    c27802.m6736(i);
                    int i3 = serviceConnectionC4611.f17531;
                    C1591 c1591 = AbstractC4228.f16126;
                    c27802.m6729(107, i3, c1591);
                    serviceConnectionC4611.m9723(c1591);
                    return null;
                }
                String packageName = c27802.f10698.getPackageName();
                try {
                    C4987 c4987 = (C4987) interfaceC1506;
                    if (c4987.m10303(25, packageName, "inapp") != 0) {
                        int i4 = 29;
                        int iM10303 = 3;
                        int i5 = 29;
                        while (true) {
                            if (i5 < 3) {
                                i5 = i;
                                break;
                            }
                            try {
                                AbstractC2252.m5870("BillingClient", ᵱˉˈ.ˁʢᵛ(i5, "trying subs apiVersion: "));
                                iM10303 = bundle == null ? c4987.m10303(i5, packageName, "subs") : c4987.m10306(i5, packageName, "subs", bundle);
                                if (iM10303 == 0) {
                                    AbstractC2252.m5870("BillingClient", ᵱˉˈ.ˁʢᵛ(i5, "highestLevelSupportedForSubs: "));
                                    break;
                                }
                                i5--;
                            } catch (Exception e) {
                                serviceConnectionC4611.m9725(e, z);
                            }
                        }
                        C2780 c27803 = serviceConnectionC4611.f17532;
                        c27803.getClass();
                        c27803.f10687 = i5 >= 3 ? 1 : i;
                        if (i5 < 3) {
                            AbstractC2252.m5870("BillingClient", "In-app billing API does not support subscription on this device.");
                            i2 = 9;
                        }
                        while (true) {
                            if (i4 < 3) {
                                break;
                            }
                            AbstractC2252.m5870("BillingClient", ᵱˉˈ.ˁʢᵛ(i4, "trying inapp apiVersion: "));
                            iM10303 = bundle == null ? c4987.m10303(i4, packageName, "inapp") : c4987.m10306(i4, packageName, "inapp", bundle);
                            if (iM10303 == 0) {
                                c27803.f10702 = i4;
                                AbstractC2252.m5870("BillingClient", "mHighestLevelSupportedForInApp: " + i4);
                                break;
                            }
                            i4--;
                        }
                        C2780.m6708(c27803, c27803.f10702);
                        if (c27803.f10702 < 3) {
                            int i6 = AbstractC2252.f8911;
                            Log.isLoggable("BillingClient", 5);
                            i2 = 36;
                        }
                        int i7 = i2;
                        C2780.m6710(c27803, iM10303);
                        if (iM10303 == 0) {
                            serviceConnectionC4611.m9726(i, z);
                            serviceConnectionC4611.m9723(AbstractC4228.f16131);
                            return null;
                        }
                        C1591 c15912 = AbstractC4228.f16114;
                        serviceConnectionC4611.m9722(c15912, i7, null, z, 0);
                        serviceConnectionC4611.m9723(c15912);
                        return null;
                    }
                    C2780 c27804 = serviceConnectionC4611.f17532;
                    Context context = c27804.f10698;
                    ᵺᵘ.ˑʢ();
                    ᵺᵘ.ˈⁱᵡ();
                    ᵺᵘ.ᵛˑﹳ();
                    ᵺᵘ.ᵨˈʼﹶ();
                    long jMin = 100;
                    int i8 = i;
                    Exception e2 = null;
                    while (true) {
                        long j = i8;
                        if (j > 3) {
                            break;
                        }
                        try {
                            Boolean boolValueOf = Boolean.valueOf(z);
                            Bundle bundle2 = new Bundle();
                            bundle2.putString("callingPackage", c27804.f10698.getPackageName());
                            AbstractC2252.m5865(bundle2, c27804.f10686, c27804.f10674.longValue());
                            if (c27804.f10679 != null) {
                                bundle2.putBoolean("enablePendingPurchases", true);
                            }
                            c4987.m10299(c27804.f10698.getPackageName(), bundle2, new BinderC2615(c27804, serviceConnectionC4611, boolValueOf, i8));
                            break;
                        } catch (SecurityException e3) {
                            serviceConnectionC4611.m9727(e3, z, i8);
                        } catch (Exception e4) {
                            e2 = e4;
                            if (j != 3) {
                                AbstractC2252.m5866("BillingClient");
                                try {
                                    Thread.sleep(jMin);
                                    jMin = (long) Math.min(jMin * 2.0d, 60000.0d);
                                    i8++;
                                } catch (InterruptedException e5) {
                                    Thread.currentThread().interrupt();
                                    serviceConnectionC4611.m9727(e5, z, i8);
                                }
                            } else {
                                serviceConnectionC4611.m9727(e2, z, i8);
                            }
                        }
                    }
                    serviceConnectionC4611.m9727(e2, z, i8);
                } catch (Exception e6) {
                    serviceConnectionC4611.m9725(e6, z);
                }
                return null;
            } finally {
            }
        }
    }

    /* JADX INFO: renamed from: ᵲᵶᵳˈ, reason: contains not printable characters */
    private final Object m6345() {
        synchronized (((C2899) this.f10138)) {
            try {
                C2899 c2899 = (C2899) this.f10138;
                if (c2899.f11147 == null) {
                    return null;
                }
                c2899.m6957();
                if (((C2899) this.f10138).m6952()) {
                    ((C2899) this.f10138).m6954();
                    ((C2899) this.f10138).f11134 = 0;
                }
                return null;
            } finally {
            }
        }
    }

    @Override // java.util.concurrent.Callable
    public final Object call() {
        switch (this.f10139) {
            case 0:
                return m6345();
            case 1:
                return m6344();
            case 2:
                return new C3058(((C1811) this.f10138).f7227);
            case 3:
                BinderC3227 binderC3227 = (BinderC3227) this.f10138;
                binderC3227.f12288.m6913();
                C5004 c5004 = binderC3227.f12288.f11105;
                C2894.m6882(c5004);
                c5004.ˈᵲᵢ();
                throw new IllegalStateException("Unexpected call on client side");
            default:
                C2991 c2991 = (C2991) this.f10138;
                synchronized (((C0516) c2991.f11521).f2678) {
                    c2991.f11520 = null;
                    break;
                }
                return null;
        }
    }
}
