package defpackage;

import android.content.Intent;
import android.os.Bundle;
import android.text.TextUtils;
import android.util.Log;
import java.util.ArrayList;
import java.util.Set;
import org.json.JSONException;

/* renamed from: ˏˎᵱ, reason: contains not printable characters */
/* loaded from: classes3.dex */
public abstract class AbstractC1845 {

    /* renamed from: ᵥᵯˎ, reason: contains not printable characters */
    public static final int f7462 = Runtime.getRuntime().availableProcessors();

    /* renamed from: ˇʼʤˎ, reason: contains not printable characters */
    public static C3297 m5206(Intent intent, String str) {
        if (intent != null) {
            C5092 c5092M7684 = C3297.m7684();
            c5092M7684.f19027 = m5211(str, intent.getExtras());
            c5092M7684.f19026 = m5208(str, intent.getExtras());
            return c5092M7684.m10560();
        }
        Log.isLoggable("BillingHelper", 5);
        C5092 c5092M76842 = C3297.m7684();
        c5092M76842.f19027 = 6;
        c5092M76842.f19026 = "An internal error occurred.";
        return c5092M76842.m10560();
    }

    /* renamed from: ˎˏʜʾ, reason: contains not printable characters */
    public static void m5207(String str, String str2) {
        if (!Log.isLoggable(str, 2) || str2.isEmpty()) {
            return;
        }
        int i = 40000;
        while (!str2.isEmpty() && i > 0) {
            int iMin = Math.min(str2.length(), Math.min(4000, i));
            str2.substring(0, iMin);
            str2 = str2.substring(iMin);
            i -= iMin;
        }
    }

    /* renamed from: ˏˋٴ, reason: contains not printable characters */
    public static String m5208(String str, Bundle bundle) {
        if (bundle == null) {
            Log.isLoggable(str, 5);
            return "";
        }
        Object obj = bundle.get("DEBUG_MESSAGE");
        if (obj == null) {
            m5207(str, "getDebugMessageFromBundle() got null response code, assuming OK");
            return "";
        }
        if (obj instanceof String) {
            return (String) obj;
        }
        "Unexpected type for debug message: ".concat(obj.getClass().getName());
        Log.isLoggable(str, 5);
        return "";
    }

    /* renamed from: ˏᵙ, reason: contains not printable characters */
    public static Bundle m5209(C3297 c3297, int i) {
        Bundle bundle = new Bundle();
        bundle.putInt("RESPONSE_CODE", c3297.f12347);
        bundle.putString("DEBUG_MESSAGE", c3297.f12346);
        bundle.putInt("LOG_REASON", AbstractC4737.m10018(i));
        return bundle;
    }

    /* renamed from: ᵝᵵᵺ, reason: contains not printable characters */
    public static C0122 m5210(String str, String str2, Set set) {
        C0122 c0122;
        C0122 c01222 = null;
        if (str == null || str2 == null) {
            m5207("BillingHelper", "Received a null purchase data.");
            return null;
        }
        try {
            c0122 = new C0122(str, str2);
        } catch (JSONException e) {
            e = e;
        }
        try {
            set.isEmpty();
            return c0122;
        } catch (JSONException e2) {
            e = e2;
            c01222 = c0122;
            "Got JSONException while parsing purchase data: ".concat(e.toString());
            Log.isLoggable("BillingHelper", 5);
            return c01222;
        }
    }

    /* renamed from: ᵥᵯˎ, reason: contains not printable characters */
    public static int m5211(String str, Bundle bundle) {
        if (bundle == null) {
            Log.isLoggable(str, 5);
            return 6;
        }
        Object obj = bundle.get("RESPONSE_CODE");
        if (obj == null) {
            m5207(str, "getResponseCodeFromBundle() got null response code, assuming OK");
            return 0;
        }
        if (obj instanceof Integer) {
            return ((Integer) obj).intValue();
        }
        "Unexpected type for bundle response code: ".concat(obj.getClass().getName());
        Log.isLoggable(str, 5);
        return 6;
    }

    /* renamed from: ᵴᵳ, reason: contains not printable characters */
    public static void m5212(Bundle bundle, String str, long j) {
        bundle.putString("playBillingLibraryVersion", "9.0.0");
        if (str != null) {
            bundle.putString("playBillingLibraryWrapperVersion", str);
        }
        bundle.putLong("billingClientSessionId", j);
    }

    /* renamed from: ᵹᵝᵶ, reason: contains not printable characters */
    public static void m5213(String str) {
        try {
            Log.isLoggable(str, 5);
        } catch (Throwable unused) {
        }
    }

    /* renamed from: ᵻᵢﹳᵰ, reason: contains not printable characters */
    public static Bundle m5214(String str, ArrayList arrayList, ˊᵿʗ r10, long j) {
        Bundle bundle = new Bundle();
        m5212(bundle, str, j);
        bundle.putBoolean("enablePendingPurchases", true);
        bundle.putString("SKU_DETAILS_RESPONSE_FORMAT", "PRODUCT_DETAILS");
        C4741 c4741 = AbstractC5058.f18890;
        Object[] objArr = {"subs", "inapp"};
        for (int i = 0; i < 2; i++) {
            if (objArr[i] == null) {
                C1260.m3813(AbstractC2990.m7313(i, "at index "));
                return null;
            }
        }
        bundle.putStringArrayList("PRODUCT_TYPES_TO_RETURN_MULTIPLE_OFFERS", new ArrayList<>(AbstractC5058.m10523(2, objArr)));
        Object[] objArr2 = {"inapp"};
        for (int i2 = 0; i2 < 1; i2++) {
            if (objArr2[i2] == null) {
                C1260.m3813(AbstractC2990.m7313(i2, "at index "));
                return null;
            }
        }
        bundle.putStringArrayList("PRODUCT_TYPES_TO_RETURN_PREORDER_OFFERS", new ArrayList<>(AbstractC5058.m10523(1, objArr2)));
        Object[] objArr3 = {"inapp"};
        for (int i3 = 0; i3 < 1; i3++) {
            if (objArr3[i3] == null) {
                C1260.m3813(AbstractC2990.m7313(i3, "at index "));
                return null;
            }
        }
        bundle.putStringArrayList("PRODUCT_TYPES_TO_RETURN_RENT_OFFERS", new ArrayList<>(AbstractC5058.m10523(1, objArr3)));
        bundle.putBoolean("SHOULD_RETURN_UNFETCHED_PRODUCTS", true);
        ArrayList<String> arrayList2 = new ArrayList<>();
        ArrayList<String> arrayList3 = new ArrayList<>();
        ArrayList<String> arrayList4 = new ArrayList<>();
        int size = arrayList.size();
        boolean z = false;
        boolean z2 = false;
        for (int i4 = 0; i4 < size; i4++) {
            C2946 c2946 = (C2946) arrayList.get(i4);
            arrayList2.add(null);
            z |= !TextUtils.isEmpty(null);
            c2946.getClass();
            arrayList4.add(null);
            z2 |= !TextUtils.isEmpty(null);
            if (c2946.f11411.equals("first_party")) {
                C1260.m3813("Serialized DocId is required for constructing ExtraParams to query ProductDetails for all first party products.");
                return null;
            }
        }
        if (z) {
            bundle.putStringArrayList("SKU_OFFER_ID_TOKEN_LIST", arrayList2);
        }
        if (!arrayList3.isEmpty()) {
            bundle.putStringArrayList("SKU_SERIALIZED_DOCID_LIST", arrayList3);
        }
        if (!TextUtils.isEmpty(null)) {
            bundle.putString("accountName", null);
        }
        if (z2) {
            bundle.putStringArrayList("SKU_DYNAMIC_PRODUCT_TOKEN_LIST", arrayList4);
        }
        return bundle;
    }
}
