package p138.p139.p140.p142;

import android.content.Intent;
import android.os.Bundle;
import android.text.TextUtils;
import android.util.Log;
import java.util.ArrayList;
import java.util.List;
import org.json.JSONException;
import p138.p139.p140.p141.C2756;
import p138.p139.p140.p141.C2764;
import p138.p139.p140.p141.C2766;

/* JADX INFO: renamed from: ދ.֏.֏.ؠ.֏, reason: contains not printable characters */
/* JADX INFO: loaded from: classes.dex */
public final class C2802 {

    /* JADX INFO: renamed from: ֏, reason: contains not printable characters */
    public static int f8630 = Runtime.getRuntime().availableProcessors();

    /* JADX INFO: renamed from: ֏, reason: contains not printable characters */
    public static Bundle m4852(C2756 c2756, String str) {
        Bundle bundle = new Bundle();
        bundle.putString("playBillingLibraryVersion", str);
        String str2 = c2756.f8505;
        if (!TextUtils.isEmpty(str2)) {
            bundle.putString("developerPayload", str2);
        }
        return bundle;
    }

    /* JADX INFO: renamed from: ֏, reason: contains not printable characters */
    public static Bundle m4853(boolean z, boolean z2, boolean z3, String str, String str2) {
        Bundle bundle = new Bundle();
        if (z) {
            bundle.putString("playBillingLibraryVersion", str);
        }
        if (z && z3) {
            bundle.putBoolean("enablePendingPurchases", true);
        }
        if (z2 && str2 != null) {
            bundle.putString("SKU_PACKAGE_NAME", str2);
        }
        return bundle;
    }

    /* JADX INFO: renamed from: ֏, reason: contains not printable characters */
    public static String m4854(Bundle bundle, String str) {
        if (bundle == null) {
            m4859(str, "Unexpected null bundle received!");
            return "";
        }
        Object obj = bundle.get("DEBUG_MESSAGE");
        if (obj == null) {
            m4857(str, "getDebugMessageFromBundle() got null response code, assuming OK");
            return "";
        }
        if (obj instanceof String) {
            return (String) obj;
        }
        String name = obj.getClass().getName();
        m4859(str, name.length() != 0 ? "Unexpected type for debug message: ".concat(name) : new String("Unexpected type for debug message: "));
        return "";
    }

    /* JADX INFO: renamed from: ֏, reason: contains not printable characters */
    public static List<C2766> m4855(Bundle bundle) {
        if (bundle == null) {
            return null;
        }
        ArrayList<String> stringArrayList = bundle.getStringArrayList("INAPP_PURCHASE_DATA_LIST");
        ArrayList<String> stringArrayList2 = bundle.getStringArrayList("INAPP_DATA_SIGNATURE_LIST");
        ArrayList arrayList = new ArrayList();
        if (stringArrayList == null || stringArrayList2 == null) {
            m4859("BillingHelper", "Couldn't find purchase lists, trying to find single data.");
            C2766 c2766M4860 = m4860(bundle.getString("INAPP_PURCHASE_DATA"), bundle.getString("INAPP_DATA_SIGNATURE"));
            if (c2766M4860 == null) {
                m4859("BillingHelper", "Couldn't find single purchase data as well.");
                return null;
            }
            arrayList.add(c2766M4860);
        } else {
            for (int i = 0; i < stringArrayList.size() && i < stringArrayList2.size(); i++) {
                C2766 c2766M48602 = m4860(stringArrayList.get(i), stringArrayList2.get(i));
                if (c2766M48602 != null) {
                    arrayList.add(c2766M48602);
                }
            }
        }
        return arrayList;
    }

    /* JADX INFO: renamed from: ֏, reason: contains not printable characters */
    public static C2764 m4856(Intent intent, String str) {
        if (intent != null) {
            C2764.C2765 c2765M4840 = C2764.m4840();
            c2765M4840.f8544 = m4858(intent.getExtras(), str);
            c2765M4840.f8545 = m4854(intent.getExtras(), str);
            return c2765M4840.m4841();
        }
        m4859("BillingHelper", "Got null intent!");
        C2764.C2765 c2765M48402 = C2764.m4840();
        c2765M48402.f8544 = 6;
        c2765M48402.f8545 = "An internal error occurred.";
        return c2765M48402.m4841();
    }

    /* JADX INFO: renamed from: ֏, reason: contains not printable characters */
    public static void m4857(String str, String str2) {
        if (Log.isLoggable(str, 2)) {
            Log.v(str, str2);
        }
    }

    /* JADX INFO: renamed from: ؠ, reason: contains not printable characters */
    public static int m4858(Bundle bundle, String str) {
        if (bundle == null) {
            m4859(str, "Unexpected null bundle received!");
            return 6;
        }
        Object obj = bundle.get("RESPONSE_CODE");
        if (obj == null) {
            m4857(str, "getResponseCodeFromBundle() got null response code, assuming OK");
            return 0;
        }
        if (obj instanceof Integer) {
            return ((Integer) obj).intValue();
        }
        String name = obj.getClass().getName();
        m4859(str, name.length() != 0 ? "Unexpected type for bundle response code: ".concat(name) : new String("Unexpected type for bundle response code: "));
        return 6;
    }

    /* JADX INFO: renamed from: ؠ, reason: contains not printable characters */
    public static void m4859(String str, String str2) {
        if (Log.isLoggable(str, 5)) {
            Log.w(str, str2);
        }
    }

    /* JADX INFO: renamed from: ހ, reason: contains not printable characters */
    public static C2766 m4860(String str, String str2) {
        if (str == null || str2 == null) {
            m4859("BillingHelper", "Received a bad purchase data.");
            return null;
        }
        try {
            return new C2766(str, str2);
        } catch (JSONException e) {
            String strValueOf = String.valueOf(e);
            StringBuilder sb = new StringBuilder(strValueOf.length() + 47);
            sb.append("Got JSONException while parsing purchase data: ");
            sb.append(strValueOf);
            m4859("BillingHelper", sb.toString());
            return null;
        }
    }
}
