package defpackage;

import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.content.pm.ResolveInfo;
import android.content.pm.ServiceInfo;
import android.util.Log;
import ar.tvplayer.core.data.network.parse.ʽˈˋ;
import ar.tvplayer.core.domain.ˉᵲ;
import ar.tvplayer.core.domain.ˏːˆ;
import j$.util.Objects;
import java.util.List;
import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;

/* JADX INFO: renamed from: ᵪᵾᵪ, reason: contains not printable characters */
/* JADX INFO: loaded from: classes3.dex */
public final class C3939 extends C2780 {

    /* JADX INFO: renamed from: ʿᵿʽᵞ, reason: contains not printable characters */
    public volatile int f15056;

    /* JADX INFO: renamed from: ˋʿᐧ, reason: contains not printable characters */
    public volatile ScheduledExecutorService f15057;

    /* JADX INFO: renamed from: ᵛˀˊ, reason: contains not printable characters */
    public final Context f15058;

    /* JADX INFO: renamed from: ᵡᵶ, reason: contains not printable characters */
    public volatile InterfaceC2805 f15059;

    /* JADX INFO: renamed from: ᵡᵶᵬʤ, reason: contains not printable characters */
    public volatile ServiceConnectionC5183 f15060;

    public C3939(C5314 c5314, Context context, ˏːˆ r3, C0306 c0306) {
        super(c5314, context, r3, c0306);
        this.f15056 = 0;
        this.f15058 = context;
    }

    public C3939(C5314 c5314, Context context, C0306 c0306) {
        super(c5314, context, c0306);
        this.f15056 = 0;
        this.f15058 = context;
    }

    @Override // defpackage.C2780
    /* JADX INFO: renamed from: ˀᵭ */
    public final void mo6714(ᵢʒʡᵟ r4, InterfaceC1621 interfaceC1621) {
        m8677(7, new C3370(2, interfaceC1621), new ᵶᵮˋᵬ(this, r4, interfaceC1621, 7));
    }

    @Override // defpackage.C2780
    /* JADX INFO: renamed from: ˁˌᵩ */
    public final C1591 mo6716(AbstractActivityC2057 abstractActivityC2057, C0764 c0764) {
        int iIntValue = 0;
        try {
            iIntValue = ((Integer) m8680(2).get(28500L, TimeUnit.MILLISECONDS)).intValue();
        } catch (TimeoutException unused) {
            m8679(102, 28, AbstractC4228.f16115);
            AbstractC2252.m5866("BillingClientTesting");
        } catch (Exception e) {
            if (e instanceof InterruptedException) {
                Thread.currentThread().interrupt();
            }
            m8679(95, 28, AbstractC4228.f16115);
            AbstractC2252.m5866("BillingClientTesting");
        }
        if (iIntValue > 0) {
            C1591 c1591M9200 = AbstractC4228.m9200(iIntValue, "Billing override value was set by a license tester.");
            m8679(93, 2, c1591M9200);
            m6718(c1591M9200);
            return c1591M9200;
        }
        try {
            return super.mo6716(abstractActivityC2057, c0764);
        } catch (Exception unused2) {
            C1591 c1591 = AbstractC4228.f16117;
            m8679(103, 2, c1591);
            AbstractC2252.m5866("BillingClientTesting");
            return c1591;
        }
    }

    /* JADX INFO: renamed from: ˆˀᵯ, reason: contains not printable characters */
    public final void m8677(int i, InterfaceC1298 interfaceC1298, Runnable runnable) {
        ScheduledExecutorService scheduledExecutorService;
        InterfaceFutureC1876 interfaceFutureC1876M8680 = m8680(i);
        TimeUnit timeUnit = TimeUnit.MILLISECONDS;
        synchronized (this) {
            try {
                if (this.f15057 == null) {
                    this.f15057 = Executors.newSingleThreadScheduledExecutor();
                }
                scheduledExecutorService = this.f15057;
            } catch (Throwable th) {
                throw th;
            }
        }
        if (!interfaceFutureC1876M8680.isDone()) {
            C2609 c2609 = new C2609();
            c2609.f10120 = interfaceFutureC1876M8680;
            RunnableC1726 runnableC1726 = new RunnableC1726();
            runnableC1726.f6921 = c2609;
            c2609.f10121 = scheduledExecutorService.schedule(runnableC1726, 28500L, timeUnit);
            interfaceFutureC1876M8680.mo3844(runnableC1726, EnumC0494.f2605);
            interfaceFutureC1876M8680 = c2609;
        }
        ˆᴵᵶ r1 = new ˆᴵᵶ(this, i, interfaceC1298, runnable);
        interfaceFutureC1876M8680.mo3844(new ᵙᵘ(interfaceFutureC1876M8680, 0, r1), m6722());
    }

    @Override // defpackage.C2780
    /* JADX INFO: renamed from: ˉᵵᵜ */
    public final void mo6721(C2571 c2571, ʽˈˋ r5) {
        m8677(3, new C5013(), new ᵶᵮˋᵬ(this, c2571, r5, 8));
    }

    @Override // defpackage.C2780
    /* JADX INFO: renamed from: ˊᵾʽʼ */
    public final void mo6723(ˉᵲ r11) {
        synchronized (this) {
            if (m8678()) {
                AbstractC2252.m5870("BillingClientTesting", "Billing Override Service connection is valid. No need to re-initialize.");
                int i = AbstractC3817.f14473;
                C4112 c4112M8521 = AbstractC3817.m8521(26, EnumC4161.f15879);
                Objects.requireNonNull(c4112M8521, "ApiSuccess should not be null");
                ʽᵺᴵ r2 = this.f10699;
                r2.getClass();
                try {
                    r2.ˌᵨʠᵫ(c4112M8521, (C4745) r2.ᵜᵪʾ);
                } catch (Throwable unused) {
                    AbstractC2252.m5866("BillingLogger");
                }
            } else {
                int i2 = 1;
                if (this.f15056 == 1) {
                    int i3 = AbstractC2252.f8911;
                    Log.isLoggable("BillingClientTesting", 5);
                } else if (this.f15056 == 3) {
                    int i4 = AbstractC2252.f8911;
                    Log.isLoggable("BillingClientTesting", 5);
                    m8679(38, 26, AbstractC4228.m9200(-1, "Billing Override Service connection is disconnected."));
                } else {
                    this.f15056 = 1;
                    AbstractC2252.m5870("BillingClientTesting", "Starting Billing Override Service setup.");
                    this.f15060 = new ServiceConnectionC5183(1, this);
                    Intent intent = new Intent("com.google.android.apps.play.billingtestcompanion.BillingOverrideService.BIND");
                    intent.setPackage("com.google.android.apps.play.billingtestcompanion");
                    Context context = this.f15058;
                    List<ResolveInfo> listQueryIntentServices = context.getPackageManager().queryIntentServices(intent, 0);
                    if (listQueryIntentServices == null || listQueryIntentServices.isEmpty()) {
                        i2 = 41;
                    } else {
                        ServiceInfo serviceInfo = listQueryIntentServices.get(0).serviceInfo;
                        if (serviceInfo != null) {
                            String str = serviceInfo.packageName;
                            String str2 = serviceInfo.name;
                            if (!Objects.equals(str, "com.google.android.apps.play.billingtestcompanion") || str2 == null) {
                                Log.isLoggable("BillingClientTesting", 5);
                            } else {
                                ComponentName componentName = new ComponentName(str, str2);
                                Intent intent2 = new Intent(intent);
                                intent2.setComponent(componentName);
                                if (context.bindService(intent2, this.f15060, 1)) {
                                    AbstractC2252.m5870("BillingClientTesting", "Billing Override Service was bonded successfully.");
                                } else {
                                    Log.isLoggable("BillingClientTesting", 5);
                                }
                            }
                            i2 = 39;
                        }
                    }
                    this.f15056 = 0;
                    AbstractC2252.m5870("BillingClientTesting", "Billing Override Service unavailable on device.");
                    m8679(i2, 26, AbstractC4228.m9200(2, "Billing Override Service unavailable on device."));
                }
            }
        }
        m6739(r11, 0);
    }

    /* JADX INFO: renamed from: ˏʽˊᵰ, reason: contains not printable characters */
    public final synchronized boolean m8678() {
        if (this.f15056 == 2 && this.f15059 != null) {
            if (this.f15060 != null) {
                return true;
            }
        }
        return false;
    }

    /* JADX INFO: renamed from: ᵧᵢᵴᵸ, reason: contains not printable characters */
    public final void m8679(int i, int i2, C1591 c1591) {
        int i3 = AbstractC3817.f14473;
        C1887 c1887M8520 = AbstractC3817.m8520(i, i2, c1591, null, EnumC4161.f15879);
        Objects.requireNonNull(c1887M8520, "ApiFailure should not be null");
        this.f10699.ˏːˆ(c1887M8520);
    }

    /* JADX INFO: renamed from: ᵯˇ, reason: contains not printable characters */
    public final InterfaceFutureC1876 m8680(int i) {
        if (!m8678()) {
            int i2 = AbstractC2252.f8911;
            Log.isLoggable("BillingClientTesting", 5);
            m8679(94, 28, AbstractC4228.m9200(-1, "Billing Override Service connection is disconnected."));
            return new C1880(0);
        }
        C1785 c1785 = new C1785(i, 0, this);
        C1131 c1131 = new C1131();
        c1131.f4833 = new C2125();
        C1326 c1326 = new C1326(c1131);
        c1131.f4832 = c1326;
        c1131.f4834 = C1785.class;
        try {
            c1785.m4930(c1131);
            c1131.f4834 = "billingOverrideService.getBillingOverride";
            return c1326;
        } catch (Exception e) {
            c1326.m3845(e);
            return c1326;
        }
    }
}
