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;

/* JADX INFO: renamed from: ᵔٴᵚ, reason: contains not printable characters */
/* JADX INFO: loaded from: classes3.dex */
public abstract class AbstractC2252 {

    /* JADX INFO: renamed from: ᵲᵶᵳˈ, reason: contains not printable characters */
    public static final int f8911 = Runtime.getRuntime().availableProcessors();

    /* JADX INFO: renamed from: ʽˈˋ, reason: contains not printable characters */
    public static void m5865(Bundle bundle, String str, long j) {
        bundle.putString("playBillingLibraryVersion", "9.1.0");
        if (str != null) {
            bundle.putString("playBillingLibraryWrapperVersion", str);
        }
        bundle.putLong("billingClientSessionId", j);
    }

    /* JADX INFO: renamed from: ˊᵫᵗ, reason: contains not printable characters */
    public static void m5866(String str) {
        try {
            Log.isLoggable(str, 5);
        } catch (Throwable unused) {
        }
    }

    /* JADX INFO: renamed from: ːˏᵟᵯ, reason: contains not printable characters */
    public static Bundle m5867(C1591 c1591, int i) {
        Bundle bundle = new Bundle();
        bundle.putInt("RESPONSE_CODE", c1591.f6394);
        bundle.putString("DEBUG_MESSAGE", c1591.f6393);
        bundle.putInt("LOG_REASON", AbstractC0659.m2421(i));
        return bundle;
    }

    /* JADX INFO: renamed from: ᵨᵣ, reason: contains not printable characters */
    public static C1591 m5868(Intent intent, String str) {
        if (intent != null) {
            C1260 c1260M4435 = C1591.m4435();
            c1260M4435.f5308 = m5869(str, intent.getExtras());
            c1260M4435.f5307 = m5873(str, intent.getExtras());
            return c1260M4435.m3754();
        }
        Log.isLoggable("BillingHelper", 5);
        C1260 c1260M44352 = C1591.m4435();
        c1260M44352.f5308 = 6;
        c1260M44352.f5307 = "An internal error occurred.";
        return c1260M44352.m3754();
    }

    /* JADX INFO: renamed from: ᵲᵶᵳˈ, reason: contains not printable characters */
    public static int m5869(String str, Bundle bundle) {
        if (bundle == null) {
            Log.isLoggable(str, 5);
            return 6;
        }
        Object obj = bundle.get("RESPONSE_CODE");
        if (obj == null) {
            m5870(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;
    }

    /* JADX INFO: renamed from: ᵵᵽ, reason: contains not printable characters */
    public static void m5870(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;
        }
    }

    /* JADX INFO: renamed from: ᵷᵺʾᵖ, reason: contains not printable characters */
    public static Bundle m5871(String str, ArrayList arrayList, ᵨᵡᵱ r10, long j) {
        Bundle bundle = new Bundle();
        m5865(bundle, str, j);
        bundle.putBoolean("enablePendingPurchases", true);
        bundle.putString("SKU_DETAILS_RESPONSE_FORMAT", "PRODUCT_DETAILS");
        C0092 c0092 = AbstractC1707.f6825;
        Object[] objArr = {"subs", "inapp"};
        for (int i = 0; i < 2; i++) {
            if (objArr[i] == null) {
                C4935.m10233(AbstractC2704.m6517(i, "at index "));
                return null;
            }
        }
        bundle.putStringArrayList("PRODUCT_TYPES_TO_RETURN_MULTIPLE_OFFERS", new ArrayList<>(AbstractC1707.m4721(2, objArr)));
        Object[] objArr2 = {"inapp"};
        for (int i2 = 0; i2 < 1; i2++) {
            if (objArr2[i2] == null) {
                C4935.m10233(AbstractC2704.m6517(i2, "at index "));
                return null;
            }
        }
        bundle.putStringArrayList("PRODUCT_TYPES_TO_RETURN_PREORDER_OFFERS", new ArrayList<>(AbstractC1707.m4721(1, objArr2)));
        Object[] objArr3 = {"inapp"};
        for (int i3 = 0; i3 < 1; i3++) {
            if (objArr3[i3] == null) {
                C4935.m10233(AbstractC2704.m6517(i3, "at index "));
                return null;
            }
        }
        bundle.putStringArrayList("PRODUCT_TYPES_TO_RETURN_RENT_OFFERS", new ArrayList<>(AbstractC1707.m4721(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++) {
            C5050 c5050 = (C5050) arrayList.get(i4);
            arrayList2.add(null);
            z |= !TextUtils.isEmpty(null);
            c5050.getClass();
            arrayList4.add(null);
            z2 |= !TextUtils.isEmpty(null);
            if (c5050.f19091.equals("first_party")) {
                C4935.m10233("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;
    }

    /* JADX INFO: renamed from: ᵻʽᵯ, reason: contains not printable characters */
    public static C5526 m5872(String str, String str2, Set set) {
        C5526 c5526;
        C5526 c55262 = null;
        if (str == null || str2 == null) {
            m5870("BillingHelper", "Received a null purchase data.");
            return null;
        }
        try {
            c5526 = new C5526(str, str2);
        } catch (JSONException e) {
            e = e;
        }
        try {
            set.isEmpty();
            return c5526;
        } catch (JSONException e2) {
            e = e2;
            c55262 = c5526;
            "Got JSONException while parsing purchase data: ".concat(e.toString());
            Log.isLoggable("BillingHelper", 5);
            return c55262;
        }
    }

    /* JADX INFO: renamed from: ᵻˈᵦʼ, reason: contains not printable characters */
    public static String m5873(String str, Bundle bundle) {
        if (bundle == null) {
            Log.isLoggable(str, 5);
            return "";
        }
        Object obj = bundle.get("DEBUG_MESSAGE");
        if (obj == null) {
            m5870(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 "";
    }
}
