discord-jadx/app/src/main/java/c/d/a/a/j.java

142 lines
6.9 KiB
Java

package c.d.a.a;
import android.os.Bundle;
import android.text.TextUtils;
import c.i.a.f.h.n.a;
import c.i.a.f.h.n.k;
import c.i.a.f.h.n.l;
import c.i.a.f.h.n.m;
import com.android.billingclient.api.BillingResult;
import com.android.billingclient.api.Purchase;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.Callable;
import org.json.JSONException;
/* compiled from: com.android.billingclient:billing@@4.0.0 */
public final class j implements Callable<Void> {
public final /* synthetic */ String i;
public final /* synthetic */ f j;
public final /* synthetic */ a k;
public j(a aVar, String str, f fVar) {
this.k = aVar;
this.i = str;
this.j = fVar;
}
/* Return type fixed from 'java.lang.Object' to match base method */
@Override // java.util.concurrent.Callable
public final Void call() throws Exception {
Purchase.a aVar;
a aVar2 = this.k;
String str = this.i;
String valueOf = String.valueOf(str);
a.e("BillingClient", valueOf.length() != 0 ? "Querying owned items, item type: ".concat(valueOf) : new String("Querying owned items, item type: "));
ArrayList arrayList = new ArrayList();
boolean z2 = aVar2.k;
boolean z3 = aVar2.p;
String str2 = aVar2.b;
Bundle bundle = new Bundle();
bundle.putString("playBillingLibraryVersion", str2);
int i = 1;
if (z2 && z3) {
bundle.putBoolean("enablePendingPurchases", true);
}
String str3 = null;
while (true) {
try {
Bundle s0 = aVar2.k ? aVar2.f.s0(9, aVar2.e.getPackageName(), str, str3, bundle) : aVar2.f.F(3, aVar2.e.getPackageName(), str, str3);
BillingResult billingResult = p.h;
if (s0 == null) {
Object[] objArr = new Object[i];
objArr[0] = "getPurchase()";
a.f("BillingClient", String.format("%s got null owned items list", objArr));
} else {
int a = a.a(s0, "BillingClient");
String d = a.d(s0, "BillingClient");
BillingResult billingResult2 = new BillingResult();
billingResult2.a = a;
billingResult2.b = d;
if (a != 0) {
a.f("BillingClient", String.format("%s failed. Response code: %s", "getPurchase()", Integer.valueOf(a)));
billingResult = billingResult2;
i = 1;
} else if (!s0.containsKey("INAPP_PURCHASE_ITEM_LIST") || !s0.containsKey("INAPP_PURCHASE_DATA_LIST") || !s0.containsKey("INAPP_DATA_SIGNATURE_LIST")) {
i = 1;
a.f("BillingClient", String.format("Bundle returned from %s doesn't contain required fields.", "getPurchase()"));
} else {
ArrayList<String> stringArrayList = s0.getStringArrayList("INAPP_PURCHASE_ITEM_LIST");
ArrayList<String> stringArrayList2 = s0.getStringArrayList("INAPP_PURCHASE_DATA_LIST");
ArrayList<String> stringArrayList3 = s0.getStringArrayList("INAPP_DATA_SIGNATURE_LIST");
if (stringArrayList == null) {
i = 1;
a.f("BillingClient", String.format("Bundle returned from %s contains null SKUs list.", "getPurchase()"));
} else {
i = 1;
if (stringArrayList2 == null) {
a.f("BillingClient", String.format("Bundle returned from %s contains null purchases list.", "getPurchase()"));
} else if (stringArrayList3 == null) {
a.f("BillingClient", String.format("Bundle returned from %s contains null signatures list.", "getPurchase()"));
} else {
billingResult = p.i;
}
}
}
}
if (billingResult != p.i) {
aVar = new Purchase.a(billingResult, null);
break;
}
ArrayList<String> stringArrayList4 = s0.getStringArrayList("INAPP_PURCHASE_ITEM_LIST");
ArrayList<String> stringArrayList5 = s0.getStringArrayList("INAPP_PURCHASE_DATA_LIST");
ArrayList<String> stringArrayList6 = s0.getStringArrayList("INAPP_DATA_SIGNATURE_LIST");
for (int i2 = 0; i2 < stringArrayList5.size(); i2++) {
String str4 = stringArrayList5.get(i2);
String str5 = stringArrayList6.get(i2);
String valueOf2 = String.valueOf(stringArrayList4.get(i2));
a.e("BillingClient", valueOf2.length() != 0 ? "Sku is owned: ".concat(valueOf2) : new String("Sku is owned: "));
try {
Purchase purchase = new Purchase(str4, str5);
if (TextUtils.isEmpty(purchase.a())) {
a.f("BillingClient", "BUG: empty/null token!");
}
arrayList.add(purchase);
} catch (JSONException e) {
String valueOf3 = String.valueOf(e);
StringBuilder sb = new StringBuilder(valueOf3.length() + 48);
sb.append("Got an exception trying to decode the purchase: ");
sb.append(valueOf3);
a.f("BillingClient", sb.toString());
aVar = new Purchase.a(p.h, null);
}
}
str3 = s0.getString("INAPP_CONTINUATION_TOKEN");
String valueOf4 = String.valueOf(str3);
a.e("BillingClient", valueOf4.length() != 0 ? "Continuation token: ".concat(valueOf4) : new String("Continuation token: "));
if (TextUtils.isEmpty(str3)) {
aVar = new Purchase.a(p.i, arrayList);
break;
}
} catch (Exception e2) {
String valueOf5 = String.valueOf(e2);
StringBuilder sb2 = new StringBuilder(valueOf5.length() + 57);
sb2.append("Got exception trying to get purchases: ");
sb2.append(valueOf5);
sb2.append("; try to reconnect");
a.f("BillingClient", sb2.toString());
aVar = new Purchase.a(p.j, null);
}
}
List<Purchase> list = aVar.a;
if (list != null) {
this.j.onQueryPurchasesResponse(aVar.b, list);
return null;
}
f fVar = this.j;
BillingResult billingResult3 = aVar.b;
m<Object> mVar = k.j;
fVar.onQueryPurchasesResponse(billingResult3, l.k);
return null;
}
}