discord-jadx/app/src/main/java/c/i/a/f/h/n/a.java

122 lines
4.1 KiB
Java

package c.i.a.f.h.n;
import android.content.Intent;
import android.os.Bundle;
import android.text.TextUtils;
import android.util.Log;
import androidx.annotation.Nullable;
import c.d.a.a.q;
import com.android.billingclient.api.BillingResult;
import com.android.billingclient.api.Purchase;
import java.util.ArrayList;
import org.json.JSONException;
/* compiled from: com.android.billingclient:billing@@4.0.0 */
public final class a {
public static final int a = Runtime.getRuntime().availableProcessors();
public static int a(Bundle bundle, String str) {
if (bundle == null) {
f(str, "Unexpected null bundle received!");
return 6;
}
Object obj = bundle.get("RESPONSE_CODE");
if (obj == null) {
e(str, "getResponseCodeFromBundle() got null response code, assuming OK");
return 0;
} else if (obj instanceof Integer) {
return ((Integer) obj).intValue();
} else {
String name = obj.getClass().getName();
f(str, name.length() != 0 ? "Unexpected type for bundle response code: ".concat(name) : new String("Unexpected type for bundle response code: "));
return 6;
}
}
public static Bundle b(int i, boolean z2, String str, @Nullable String str2, ArrayList<q> arrayList) {
Bundle bundle = new Bundle();
if (i >= 9) {
bundle.putString("playBillingLibraryVersion", str);
}
if (i >= 9 && z2) {
bundle.putBoolean("enablePendingPurchases", true);
}
if (i >= 14) {
ArrayList<String> arrayList2 = new ArrayList<>();
int size = arrayList.size();
boolean z3 = false;
for (int i2 = 0; i2 < size; i2++) {
arrayList.get(i2);
arrayList2.add(null);
z3 |= !TextUtils.isEmpty(null);
}
if (z3) {
bundle.putStringArrayList("SKU_OFFER_ID_TOKEN_LIST", arrayList2);
}
}
return bundle;
}
public static BillingResult c(Intent intent, String str) {
if (intent == null) {
f("BillingHelper", "Got null intent!");
BillingResult billingResult = new BillingResult();
billingResult.a = 6;
billingResult.b = "An internal error occurred.";
return billingResult;
}
int a2 = a(intent.getExtras(), str);
String d = d(intent.getExtras(), str);
BillingResult billingResult2 = new BillingResult();
billingResult2.a = a2;
billingResult2.b = d;
return billingResult2;
}
public static String d(Bundle bundle, String str) {
if (bundle == null) {
f(str, "Unexpected null bundle received!");
return "";
}
Object obj = bundle.get("DEBUG_MESSAGE");
if (obj == null) {
e(str, "getDebugMessageFromBundle() got null response code, assuming OK");
return "";
} else if (obj instanceof String) {
return (String) obj;
} else {
String name = obj.getClass().getName();
f(str, name.length() != 0 ? "Unexpected type for debug message: ".concat(name) : new String("Unexpected type for debug message: "));
return "";
}
}
public static void e(String str, String str2) {
if (Log.isLoggable(str, 2)) {
Log.v(str, str2);
}
}
public static void f(String str, String str2) {
if (Log.isLoggable(str, 5)) {
Log.w(str, str2);
}
}
public static Purchase g(String str, String str2) {
if (str == null || str2 == null) {
f("BillingHelper", "Received a bad purchase data.");
return null;
}
try {
return new Purchase(str, str2);
} catch (JSONException e) {
String valueOf = String.valueOf(e);
StringBuilder sb = new StringBuilder(valueOf.length() + 47);
sb.append("Got JSONException while parsing purchase data: ");
sb.append(valueOf);
f("BillingHelper", sb.toString());
return null;
}
}
}