package p138.p139.p140.p141;

import android.content.ComponentName;
import android.content.Context;
import android.content.ServiceConnection;
import android.os.Handler;
import android.os.IBinder;
import android.os.Looper;
import android.os.ResultReceiver;
import android.text.TextUtils;
import java.util.List;
import java.util.concurrent.Callable;
import java.util.concurrent.CancellationException;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.Future;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;
import p138.p139.p140.p141.C2766;
import p138.p139.p140.p142.C2802;
import p138.p176.p177.p242.p258.p264.AbstractBinderC4748;
import p138.p176.p177.p242.p258.p264.InterfaceC4746;

/* JADX INFO: renamed from: ދ.֏.֏.֏.ށ, reason: contains not printable characters */
/* JADX INFO: loaded from: classes.dex */
public class C2759 extends AbstractC2758 {

    /* JADX INFO: renamed from: ֏, reason: contains not printable characters */
    public int f8507;

    /* JADX INFO: renamed from: ؠ, reason: contains not printable characters */
    public final String f8508;

    /* JADX INFO: renamed from: ހ, reason: contains not printable characters */
    public final Handler f8509;

    /* JADX INFO: renamed from: ށ, reason: contains not printable characters */
    public C2788 f8510;

    /* JADX INFO: renamed from: ނ, reason: contains not printable characters */
    public Context f8511;

    /* JADX INFO: renamed from: ރ, reason: contains not printable characters */
    public final int f8512;

    /* JADX INFO: renamed from: ބ, reason: contains not printable characters */
    public final int f8513;

    /* JADX INFO: renamed from: ޅ, reason: contains not printable characters */
    public InterfaceC4746 f8514;

    /* JADX INFO: renamed from: ކ, reason: contains not printable characters */
    public ServiceConnectionC2760 f8515;

    /* JADX INFO: renamed from: އ, reason: contains not printable characters */
    public boolean f8516;

    /* JADX INFO: renamed from: ވ, reason: contains not printable characters */
    public boolean f8517;

    /* JADX INFO: renamed from: މ, reason: contains not printable characters */
    public boolean f8518;

    /* JADX INFO: renamed from: ފ, reason: contains not printable characters */
    public boolean f8519;

    /* JADX INFO: renamed from: ދ, reason: contains not printable characters */
    public boolean f8520;

    /* JADX INFO: renamed from: ތ, reason: contains not printable characters */
    public boolean f8521;

    /* JADX INFO: renamed from: ލ, reason: contains not printable characters */
    public boolean f8522;

    /* JADX INFO: renamed from: ގ, reason: contains not printable characters */
    public boolean f8523;

    /* JADX INFO: renamed from: ޏ, reason: contains not printable characters */
    public boolean f8524;

    /* JADX INFO: renamed from: ސ, reason: contains not printable characters */
    public ExecutorService f8525;

    /* JADX INFO: renamed from: ޑ, reason: contains not printable characters */
    public String f8526;

    /* JADX INFO: renamed from: ޒ, reason: contains not printable characters */
    public final ResultReceiver f8527;

    /* JADX INFO: renamed from: ދ.֏.֏.֏.ށ$֏, reason: contains not printable characters */
    public final class ServiceConnectionC2760 implements ServiceConnection {

        /* JADX INFO: renamed from: ֏, reason: contains not printable characters */
        public final Object f8528 = new Object();

        /* JADX INFO: renamed from: ؠ, reason: contains not printable characters */
        public boolean f8529 = false;

        /* JADX INFO: renamed from: ހ, reason: contains not printable characters */
        public InterfaceC2762 f8530;

        @Override // android.content.ServiceConnection
        public final void onServiceConnected(ComponentName componentName, IBinder iBinder) {
            C2802.m4857("BillingClient", "Billing service connected.");
            C2759.this.f8514 = AbstractBinderC4748.m7911(iBinder);
            if (C2759.this.m4834(new CallableC2783(this), 30000L, new RunnableC2782(this)) == null) {
                C2759.m4833(C2759.this, new RunnableC2781(this, C2759.this.m4836()));
            }
        }

        @Override // android.content.ServiceConnection
        public final void onServiceDisconnected(ComponentName componentName) {
            C2802.m4859("BillingClient", "Billing service disconnected.");
            C2759 c2759 = C2759.this;
            c2759.f8514 = null;
            c2759.f8507 = 0;
            synchronized (this.f8528) {
                if (this.f8530 != null) {
                    this.f8530.m4838();
                }
            }
        }
    }

    /* JADX INFO: renamed from: ދ.֏.֏.֏.ށ$ؠ, reason: contains not printable characters */
    public static class C2761 {

        /* JADX INFO: renamed from: ֏, reason: contains not printable characters */
        public final List<C2768> f8532;

        /* JADX INFO: renamed from: ؠ, reason: contains not printable characters */
        public final C2764 f8533;

        public C2761(C2764 c2764, List<C2768> list) {
            this.f8532 = list;
            this.f8533 = c2764;
        }
    }

    public C2759(String str, boolean z, int i, Context context, InterfaceC2770 interfaceC2770, int i2) {
        String str2;
        try {
            str2 = (String) Class.forName("com.android.billingclient.ktx.BuildConfig").getField("VERSION_NAME").get(null);
        } catch (Exception unused) {
            str2 = "2.2.1";
        }
        this.f8507 = 0;
        this.f8509 = new Handler(Looper.getMainLooper());
        this.f8527 = new ResultReceiverC2791(this, this.f8509);
        this.f8526 = str;
        this.f8512 = i;
        this.f8513 = i2;
        this.f8508 = str2;
        Context applicationContext = context.getApplicationContext();
        this.f8511 = applicationContext;
        this.f8510 = new C2788(applicationContext, interfaceC2770);
        this.f8524 = z;
    }

    /* JADX INFO: renamed from: ֏, reason: contains not printable characters */
    public static /* synthetic */ void m4833(C2759 c2759, Runnable runnable) {
        if (c2759 == null) {
            throw null;
        }
        if (Thread.interrupted()) {
            return;
        }
        c2759.f8509.post(runnable);
    }

    /* JADX INFO: renamed from: ֏, reason: contains not printable characters */
    public final <T> Future<T> m4834(Callable<T> callable, long j, Runnable runnable) {
        long j2 = (long) (j * 0.95d);
        if (this.f8525 == null) {
            this.f8525 = Executors.newFixedThreadPool(C2802.f8630);
        }
        try {
            Future<T> futureSubmit = this.f8525.submit(callable);
            this.f8509.postDelayed(new RunnableC2801(futureSubmit, runnable), j2);
            return futureSubmit;
        } catch (Exception e) {
            String strValueOf = String.valueOf(e);
            StringBuilder sb = new StringBuilder(strValueOf.length() + 28);
            sb.append("Async task throws exception ");
            sb.append(strValueOf);
            C2802.m4859("BillingClient", sb.toString());
            return null;
        }
    }

    /* JADX INFO: renamed from: ֏, reason: contains not printable characters */
    public final C2764 m4835(C2764 c2764) {
        this.f8510.f8600.f8601.m4845(c2764, null);
        return c2764;
    }

    @Override // p138.p139.p140.p141.AbstractC2758
    /* JADX INFO: renamed from: ֏ */
    public C2766.C2767 mo4830(String str) {
        if (!mo4832()) {
            return new C2766.C2767(C2785.f8595, null);
        }
        if (TextUtils.isEmpty(str)) {
            C2802.m4859("BillingClient", "Please provide a valid SKU type.");
            return new C2766.C2767(C2785.f8587, null);
        }
        try {
            return (C2766.C2767) m4834(new CallableC2779(this, str), 5000L, null).get(5000L, TimeUnit.MILLISECONDS);
        } catch (CancellationException | TimeoutException unused) {
            return new C2766.C2767(C2785.f8596, null);
        } catch (Exception unused2) {
            return new C2766.C2767(C2785.f8591, null);
        }
    }

    @Override // p138.p139.p140.p141.AbstractC2758
    /* JADX INFO: renamed from: ֏ */
    public void mo4831(C2773 c2773, InterfaceC2775 interfaceC2775) {
        if (!mo4832()) {
            interfaceC2775.m4850(C2785.f8595, null);
            return;
        }
        String str = c2773.f8559;
        List<String> list = c2773.f8561;
        String str2 = c2773.f8560;
        if (TextUtils.isEmpty(str)) {
            C2802.m4859("BillingClient", "Please fix the input params. SKU type can't be empty.");
            interfaceC2775.m4850(C2785.f8587, null);
            return;
        }
        if (list == null) {
            C2802.m4859("BillingClient", "Please fix the input params. The list of SKUs can't be empty.");
            interfaceC2775.m4850(C2785.f8586, null);
        } else if (!this.f8523 && str2 != null) {
            C2802.m4859("BillingClient", "The user's client is too old to handle skuPackageName from SkuDetails.");
            interfaceC2775.m4850(C2785.f8585, null);
        } else if (m4834(new CallableC2790(this, str, list, str2, interfaceC2775), 30000L, new RunnableC2792(interfaceC2775)) == null) {
            interfaceC2775.m4850(m4836(), null);
        }
    }

    @Override // p138.p139.p140.p141.AbstractC2758
    /* JADX INFO: renamed from: ֏ */
    public boolean mo4832() {
        return (this.f8507 != 2 || this.f8514 == null || this.f8515 == null) ? false : true;
    }

    /* JADX INFO: renamed from: ؠ, reason: contains not printable characters */
    public final C2764 m4836() {
        int i = this.f8507;
        return (i == 0 || i == 3) ? C2785.f8595 : C2785.f8591;
    }
}
