package com.google.android.gms.internal.play_billing; import android.content.Intent; import android.os.Bundle; import android.util.Log; import com.android.billingclient.api.Purchase; import com.android.billingclient.api.d; import com.google.android.gms.ads.RequestConfiguration; import java.util.ArrayList; import java.util.List; import n1.f; import org.json.JSONException; /* loaded from: classes.dex */ public final class zzb { public static final int zza = Runtime.getRuntime().availableProcessors(); public static int zza(Intent intent, String str) { if (intent != null) { return zzm(intent.getExtras(), "ProxyBillingActivity"); } zzk("ProxyBillingActivity", "Got null intent!"); return 0; } public static int zzb(Bundle bundle, String str) { if (bundle == null) { zzk(str, "Unexpected null bundle received!"); return 6; } Object obj = bundle.get("RESPONSE_CODE"); if (obj == null) { zzj(str, "getResponseCodeFromBundle() got null response code, assuming OK"); return 0; } if (obj instanceof Integer) { return ((Integer) obj).intValue(); } zzk(str, "Unexpected type for bundle response code: ".concat(obj.getClass().getName())); return 6; } public static Bundle zzc(boolean z10, boolean z11, boolean z12, boolean z13, String str) { Bundle bundle = new Bundle(); bundle.putString("playBillingLibraryVersion", str); if (z10 && z12) { bundle.putBoolean("enablePendingPurchases", true); } if (z11 && z13) { bundle.putBoolean("enablePendingPurchaseForSubscriptions", true); } return bundle; } public static Bundle zzd(String str) { Bundle bundle = new Bundle(); bundle.putString("playBillingLibraryVersion", str); return bundle; } public static d zze(Intent intent, String str) { if (intent != null) { d.a c10 = d.c(); c10.c(zzb(intent.getExtras(), str)); c10.b(zzg(intent.getExtras(), str)); return c10.a(); } zzk("BillingHelper", "Got null intent!"); d.a c11 = d.c(); c11.c(6); c11.b("An internal error occurred."); return c11.a(); } public static f zzf(Bundle bundle, String str) { return bundle == null ? new f(0, null) : new f(zzm(bundle, "BillingClient"), bundle.getString("IN_APP_MESSAGE_PURCHASE_TOKEN")); } public static String zzg(Bundle bundle, String str) { if (bundle == null) { zzk(str, "Unexpected null bundle received!"); return RequestConfiguration.MAX_AD_CONTENT_RATING_UNSPECIFIED; } Object obj = bundle.get("DEBUG_MESSAGE"); if (obj == null) { zzj(str, "getDebugMessageFromBundle() got null response code, assuming OK"); return RequestConfiguration.MAX_AD_CONTENT_RATING_UNSPECIFIED; } if (obj instanceof String) { return (String) obj; } zzk(str, "Unexpected type for debug message: ".concat(obj.getClass().getName())); return RequestConfiguration.MAX_AD_CONTENT_RATING_UNSPECIFIED; } public static String zzh(int i10) { return zza.zza(i10).toString(); } public static List zzi(Bundle bundle) { ArrayList stringArrayList = bundle.getStringArrayList("INAPP_PURCHASE_DATA_LIST"); ArrayList stringArrayList2 = bundle.getStringArrayList("INAPP_DATA_SIGNATURE_LIST"); ArrayList arrayList = new ArrayList(); if (stringArrayList == null || stringArrayList2 == null) { Purchase zzn = zzn(bundle.getString("INAPP_PURCHASE_DATA"), bundle.getString("INAPP_DATA_SIGNATURE")); if (zzn == null) { zzj("BillingHelper", "Couldn't find single purchase data as well."); return null; } arrayList.add(zzn); } else { zzj("BillingHelper", "Found purchase list of " + stringArrayList.size() + " items"); for (int i10 = 0; i10 < stringArrayList.size() && i10 < stringArrayList2.size(); i10++) { Purchase zzn2 = zzn(stringArrayList.get(i10), stringArrayList2.get(i10)); if (zzn2 != null) { arrayList.add(zzn2); } } } return arrayList; } public static void zzj(String str, String str2) { if (Log.isLoggable(str, 2)) { if (str2.isEmpty()) { Log.v(str, str2); return; } int i10 = 40000; while (!str2.isEmpty() && i10 > 0) { int min = Math.min(str2.length(), Math.min(4000, i10)); Log.v(str, str2.substring(0, min)); str2 = str2.substring(min); i10 -= min; } } } public static void zzk(String str, String str2) { if (Log.isLoggable(str, 5)) { Log.w(str, str2); } } public static void zzl(String str, String str2, Throwable th) { if (Log.isLoggable(str, 5)) { Log.w(str, str2, th); } } private static int zzm(Bundle bundle, String str) { if (bundle != null) { return bundle.getInt("IN_APP_MESSAGE_RESPONSE_CODE", 0); } zzk(str, "Unexpected null bundle received!"); return 0; } private static Purchase zzn(String str, String str2) { if (str == null || str2 == null) { zzj("BillingHelper", "Received a null purchase data."); return null; } try { return new Purchase(str, str2); } catch (JSONException e10) { zzk("BillingHelper", "Got JSONException while parsing purchase data: ".concat(e10.toString())); return null; } } }