package p138.p139.p140.p141;

import android.os.Bundle;
import android.text.TextUtils;
import java.util.ArrayList;
import java.util.concurrent.Callable;
import org.json.JSONException;
import p000.p001.p002.p003.p004.C0567;
import p138.p139.p140.p141.C2766;
import p138.p139.p140.p142.C2802;

/* JADX INFO: renamed from: ދ.֏.֏.֏.ޏ, reason: contains not printable characters */
/* JADX INFO: loaded from: classes.dex */
public final class CallableC2779 implements Callable<C2766.C2767> {

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

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

    public CallableC2779(C2759 c2759, String str) {
        this.f8573 = c2759;
        this.f8572 = str;
    }

    @Override // java.util.concurrent.Callable
    public final /* synthetic */ C2766.C2767 call() {
        C2759 c2759 = this.f8573;
        String str = this.f8572;
        if (c2759 == null) {
            throw null;
        }
        String strValueOf = String.valueOf(str);
        C2802.m4857("BillingClient", strValueOf.length() != 0 ? "Querying owned items, item type: ".concat(strValueOf) : new String("Querying owned items, item type: "));
        ArrayList arrayList = new ArrayList();
        boolean z = c2759.f8520;
        boolean z2 = c2759.f8524;
        String str2 = c2759.f8508;
        Bundle bundle = new Bundle();
        bundle.putString("playBillingLibraryVersion", str2);
        if (z && z2) {
            bundle.putBoolean("enablePendingPurchases", true);
        }
        String string = null;
        do {
            try {
                Bundle bundleMo7905 = c2759.f8520 ? c2759.f8514.mo7905(9, c2759.f8511.getPackageName(), str, string, bundle) : c2759.f8514.mo7904(3, c2759.f8511.getPackageName(), str, string);
                C2764 c2764M1868 = C0567.m1868(bundleMo7905, "BillingClient", "getPurchase()");
                if (c2764M1868 != C2785.f8594) {
                    return new C2766.C2767(c2764M1868, null);
                }
                ArrayList<String> stringArrayList = bundleMo7905.getStringArrayList("INAPP_PURCHASE_ITEM_LIST");
                ArrayList<String> stringArrayList2 = bundleMo7905.getStringArrayList("INAPP_PURCHASE_DATA_LIST");
                ArrayList<String> stringArrayList3 = bundleMo7905.getStringArrayList("INAPP_DATA_SIGNATURE_LIST");
                for (int i = 0; i < stringArrayList2.size(); i++) {
                    String str3 = stringArrayList2.get(i);
                    String str4 = stringArrayList3.get(i);
                    String strValueOf2 = String.valueOf(stringArrayList.get(i));
                    C2802.m4857("BillingClient", strValueOf2.length() != 0 ? "Sku is owned: ".concat(strValueOf2) : new String("Sku is owned: "));
                    try {
                        C2766 c2766 = new C2766(str3, str4);
                        if (TextUtils.isEmpty(c2766.m4843())) {
                            C2802.m4859("BillingClient", "BUG: empty/null token!");
                        }
                        arrayList.add(c2766);
                    } catch (JSONException e) {
                        String strValueOf3 = String.valueOf(e);
                        StringBuilder sb = new StringBuilder(strValueOf3.length() + 48);
                        sb.append("Got an exception trying to decode the purchase: ");
                        sb.append(strValueOf3);
                        C2802.m4859("BillingClient", sb.toString());
                        return new C2766.C2767(C2785.f8591, null);
                    }
                }
                string = bundleMo7905.getString("INAPP_CONTINUATION_TOKEN");
                String strValueOf4 = String.valueOf(string);
                C2802.m4857("BillingClient", strValueOf4.length() != 0 ? "Continuation token: ".concat(strValueOf4) : new String("Continuation token: "));
            } catch (Exception e2) {
                String strValueOf5 = String.valueOf(e2);
                StringBuilder sb2 = new StringBuilder(strValueOf5.length() + 57);
                sb2.append("Got exception trying to get purchases: ");
                sb2.append(strValueOf5);
                sb2.append("; try to reconnect");
                C2802.m4859("BillingClient", sb2.toString());
                return new C2766.C2767(C2785.f8595, null);
            }
        } while (!TextUtils.isEmpty(string));
        return new C2766.C2767(C2785.f8594, arrayList);
    }
}
