package p138.p139.p140.p141;

import android.os.Bundle;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.Callable;
import org.json.JSONException;
import p138.p139.p140.p141.C2771;
import p138.p139.p140.p142.C2802;

/* JADX INFO: renamed from: ދ.֏.֏.֏.ޚ, reason: contains not printable characters */
/* JADX INFO: loaded from: classes.dex */
public final class CallableC2790 implements Callable<Void> {

    /* JADX INFO: renamed from: ֏, reason: contains not printable characters */
    public final /* synthetic */ String f8604;

    /* JADX INFO: renamed from: ؠ, reason: contains not printable characters */
    public final /* synthetic */ List f8605;

    /* JADX INFO: renamed from: ހ, reason: contains not printable characters */
    public final /* synthetic */ String f8606;

    /* JADX INFO: renamed from: ށ, reason: contains not printable characters */
    public final /* synthetic */ InterfaceC2775 f8607;

    /* JADX INFO: renamed from: ނ, reason: contains not printable characters */
    public final /* synthetic */ C2759 f8608;

    public CallableC2790(C2759 c2759, String str, List list, String str2, InterfaceC2775 interfaceC2775) {
        this.f8608 = c2759;
        this.f8604 = str;
        this.f8605 = list;
        this.f8606 = str2;
        this.f8607 = interfaceC2775;
    }

    @Override // java.util.concurrent.Callable
    public final /* synthetic */ Void call() {
        C2771.C2772 c2772;
        int i;
        Bundle bundleMo7902;
        C2759 c2759 = this.f8608;
        String str = this.f8604;
        List list = this.f8605;
        String str2 = this.f8606;
        if (c2759 == null) {
            throw null;
        }
        ArrayList arrayList = new ArrayList();
        int size = list.size();
        int i2 = 0;
        while (true) {
            if (i2 >= size) {
                c2772 = new C2771.C2772(0, "", arrayList);
                break;
            }
            int i3 = i2 + 20;
            ArrayList<String> arrayList2 = new ArrayList<>(list.subList(i2, i3 > size ? size : i3));
            Bundle bundle = new Bundle();
            bundle.putStringArrayList("ITEM_ID_LIST", arrayList2);
            bundle.putString("playBillingLibraryVersion", c2759.f8508);
            try {
                if (c2759.f8521) {
                    i = i3;
                    bundleMo7902 = c2759.f8514.mo7903(10, c2759.f8511.getPackageName(), str, bundle, C2802.m4853(c2759.f8520, c2759.f8523, c2759.f8524, c2759.f8508, str2));
                } else {
                    i = i3;
                    bundleMo7902 = c2759.f8514.mo7902(3, c2759.f8511.getPackageName(), str, bundle);
                }
                if (bundleMo7902 == null) {
                    C2802.m4859("BillingClient", "querySkuDetailsAsync got null sku details list");
                    c2772 = new C2771.C2772(4, "Null sku details list", null);
                    break;
                }
                if (bundleMo7902.containsKey("DETAILS_LIST")) {
                    ArrayList<String> stringArrayList = bundleMo7902.getStringArrayList("DETAILS_LIST");
                    if (stringArrayList == null) {
                        C2802.m4859("BillingClient", "querySkuDetailsAsync got null response list");
                        c2772 = new C2771.C2772(4, "querySkuDetailsAsync got null response list", null);
                        break;
                    }
                    for (int i4 = 0; i4 < stringArrayList.size(); i4++) {
                        try {
                            C2771 c2771 = new C2771(stringArrayList.get(i4));
                            String strValueOf = String.valueOf(c2771);
                            StringBuilder sb = new StringBuilder(strValueOf.length() + 17);
                            sb.append("Got sku details: ");
                            sb.append(strValueOf);
                            C2802.m4857("BillingClient", sb.toString());
                            arrayList.add(c2771);
                        } catch (JSONException unused) {
                            C2802.m4859("BillingClient", "Got a JSON exception trying to decode SkuDetails.");
                            c2772 = new C2771.C2772(6, "Error trying to decode SkuDetails.", null);
                        }
                    }
                    i2 = i;
                } else {
                    int iM4858 = C2802.m4858(bundleMo7902, "BillingClient");
                    String strM4854 = C2802.m4854(bundleMo7902, "BillingClient");
                    if (iM4858 != 0) {
                        StringBuilder sb2 = new StringBuilder(50);
                        sb2.append("getSkuDetails() failed. Response code: ");
                        sb2.append(iM4858);
                        C2802.m4859("BillingClient", sb2.toString());
                        c2772 = new C2771.C2772(iM4858, strM4854, arrayList);
                    } else {
                        C2802.m4859("BillingClient", "getSkuDetails() returned a bundle with neither an error nor a detail list.");
                        c2772 = new C2771.C2772(6, strM4854, arrayList);
                    }
                }
            } catch (Exception e) {
                String strValueOf2 = String.valueOf(e);
                StringBuilder sb3 = new StringBuilder(strValueOf2.length() + 63);
                sb3.append("querySkuDetailsAsync got a remote exception (try to reconnect).");
                sb3.append(strValueOf2);
                C2802.m4859("BillingClient", sb3.toString());
                c2772 = new C2771.C2772(-1, "Service connection is disconnected.", null);
            }
        }
        C2759.m4833(this.f8608, new RunnableC2793(this, c2772));
        return null;
    }
}
