526 lines
22 KiB
Java
526 lines
22 KiB
Java
package c.d.a.a;
|
|
|
|
import android.app.Activity;
|
|
import android.app.PendingIntent;
|
|
import android.content.ComponentName;
|
|
import android.content.Context;
|
|
import android.content.Intent;
|
|
import android.content.IntentFilter;
|
|
import android.content.pm.PackageManager;
|
|
import android.content.pm.ResolveInfo;
|
|
import android.content.pm.ServiceInfo;
|
|
import android.os.Bundle;
|
|
import android.os.Handler;
|
|
import android.os.Looper;
|
|
import android.text.TextUtils;
|
|
import androidx.annotation.AnyThread;
|
|
import androidx.annotation.Nullable;
|
|
import c.i.a.f.h.n.d;
|
|
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.BillingClient;
|
|
import com.android.billingclient.api.BillingFlowParams;
|
|
import com.android.billingclient.api.BillingResult;
|
|
import com.android.billingclient.api.ProxyBillingActivity;
|
|
import com.android.billingclient.api.SkuDetails;
|
|
import java.util.ArrayList;
|
|
import java.util.Arrays;
|
|
import java.util.List;
|
|
import java.util.Objects;
|
|
import java.util.concurrent.Callable;
|
|
import java.util.concurrent.CancellationException;
|
|
import java.util.concurrent.ExecutorService;
|
|
import java.util.concurrent.Executors;
|
|
import java.util.concurrent.Future;
|
|
import java.util.concurrent.TimeUnit;
|
|
import java.util.concurrent.TimeoutException;
|
|
import org.json.JSONException;
|
|
import org.json.JSONObject;
|
|
/* compiled from: com.android.billingclient:billing@@4.0.0 */
|
|
public class a extends BillingClient {
|
|
public volatile int a;
|
|
public final String b;
|
|
|
|
/* renamed from: c reason: collision with root package name */
|
|
public final Handler f350c;
|
|
public volatile s d;
|
|
public Context e;
|
|
public volatile d f;
|
|
public volatile n g;
|
|
public boolean h;
|
|
public int i;
|
|
public boolean j;
|
|
public boolean k;
|
|
public boolean l;
|
|
public boolean m;
|
|
public boolean n;
|
|
public boolean o;
|
|
public boolean p;
|
|
public ExecutorService q;
|
|
|
|
@AnyThread
|
|
public a(@Nullable String str, boolean z2, Context context, g gVar) {
|
|
String str2;
|
|
try {
|
|
str2 = (String) Class.forName("c.d.a.b.a").getField("VERSION_NAME").get(null);
|
|
} catch (Exception unused) {
|
|
str2 = "4.0.0";
|
|
}
|
|
this.a = 0;
|
|
this.f350c = new Handler(Looper.getMainLooper());
|
|
this.i = 0;
|
|
this.b = str2;
|
|
Context applicationContext = context.getApplicationContext();
|
|
this.e = applicationContext;
|
|
this.d = new s(applicationContext, gVar);
|
|
this.p = z2;
|
|
}
|
|
|
|
@Override // com.android.billingclient.api.BillingClient
|
|
public final void a(d dVar, e eVar) {
|
|
if (!d()) {
|
|
eVar.onConsumeResponse(p.j, dVar.a);
|
|
} else if (l(new t(this, dVar, eVar), 30000, new x(eVar, dVar), i()) == null) {
|
|
eVar.onConsumeResponse(k(), dVar.a);
|
|
}
|
|
}
|
|
|
|
@Override // com.android.billingclient.api.BillingClient
|
|
public final void b() {
|
|
int i = 3;
|
|
try {
|
|
this.d.a();
|
|
if (this.g != null) {
|
|
n nVar = this.g;
|
|
synchronized (nVar.i) {
|
|
nVar.k = null;
|
|
nVar.j = true;
|
|
}
|
|
}
|
|
if (!(this.g == null || this.f == null)) {
|
|
c.i.a.f.h.n.a.e("BillingClient", "Unbinding from service.");
|
|
this.e.unbindService(this.g);
|
|
this.g = null;
|
|
}
|
|
this.f = null;
|
|
ExecutorService executorService = this.q;
|
|
if (executorService != null) {
|
|
executorService.shutdownNow();
|
|
this.q = null;
|
|
}
|
|
} catch (Exception e) {
|
|
String valueOf = String.valueOf(e);
|
|
StringBuilder sb = new StringBuilder(valueOf.length() + 48);
|
|
sb.append("There was an exception while ending connection: ");
|
|
sb.append(valueOf);
|
|
c.i.a.f.h.n.a.f("BillingClient", sb.toString());
|
|
} finally {
|
|
this.a = i;
|
|
}
|
|
}
|
|
|
|
@Override // com.android.billingclient.api.BillingClient
|
|
public final int c() {
|
|
return this.a;
|
|
}
|
|
|
|
@Override // com.android.billingclient.api.BillingClient
|
|
public final boolean d() {
|
|
return (this.a != 2 || this.f == null || this.g == null) ? false : true;
|
|
}
|
|
|
|
/* JADX WARNING: Code restructure failed: missing block: B:147:0x03d8, code lost:
|
|
r1 = r19;
|
|
*/
|
|
/* JADX WARNING: Code restructure failed: missing block: B:151:0x03df, code lost:
|
|
r1 = r19;
|
|
*/
|
|
/* JADX WARNING: Failed to process nested try/catch */
|
|
/* JADX WARNING: Removed duplicated region for block: B:152:? A[ExcHandler: Exception (unused java.lang.Exception), SYNTHETIC, Splitter:B:134:0x0387] */
|
|
@Override // com.android.billingclient.api.BillingClient
|
|
public final BillingResult e(Activity activity, BillingFlowParams billingFlowParams) {
|
|
String str;
|
|
String str2;
|
|
String str3;
|
|
String str4;
|
|
Future future;
|
|
String str5;
|
|
String str6;
|
|
String str7;
|
|
boolean z2;
|
|
String str8;
|
|
String str9;
|
|
if (!d()) {
|
|
BillingResult billingResult = p.j;
|
|
j(billingResult);
|
|
return billingResult;
|
|
}
|
|
Objects.requireNonNull(billingFlowParams);
|
|
ArrayList arrayList = new ArrayList();
|
|
arrayList.addAll(billingFlowParams.f);
|
|
SkuDetails skuDetails = (SkuDetails) arrayList.get(0);
|
|
String e = skuDetails.e();
|
|
String str10 = "BillingClient";
|
|
if (e.equals("subs") && !this.h) {
|
|
c.i.a.f.h.n.a.f(str10, "Current client doesn't support subscriptions.");
|
|
BillingResult billingResult2 = p.l;
|
|
j(billingResult2);
|
|
return billingResult2;
|
|
} else if (((!billingFlowParams.g && billingFlowParams.b == null && billingFlowParams.d == null && billingFlowParams.e == 0 && !billingFlowParams.a) ? false : true) && !this.j) {
|
|
c.i.a.f.h.n.a.f(str10, "Current client doesn't support extra params for buy intent.");
|
|
BillingResult billingResult3 = p.f;
|
|
j(billingResult3);
|
|
return billingResult3;
|
|
} else if (arrayList.size() <= 1 || this.o) {
|
|
String str11 = "";
|
|
int i = 0;
|
|
String str12 = str11;
|
|
while (i < arrayList.size()) {
|
|
String valueOf = String.valueOf(str12);
|
|
String valueOf2 = String.valueOf(arrayList.get(i));
|
|
String H = c.d.b.a.a.H(new StringBuilder(valueOf.length() + valueOf2.length()), valueOf, valueOf2);
|
|
if (i < arrayList.size() - 1) {
|
|
H = String.valueOf(H).concat(", ");
|
|
}
|
|
str12 = H;
|
|
i++;
|
|
str11 = str11;
|
|
}
|
|
StringBuilder sb = new StringBuilder(String.valueOf(str12).length() + 41 + e.length());
|
|
sb.append("Constructing buy intent for ");
|
|
sb.append(str12);
|
|
sb.append(", item type: ");
|
|
sb.append(e);
|
|
c.i.a.f.h.n.a.e(str10, sb.toString());
|
|
if (this.j) {
|
|
boolean z3 = this.k;
|
|
boolean z4 = this.p;
|
|
String str13 = this.b;
|
|
Bundle bundle = new Bundle();
|
|
bundle.putString("playBillingLibraryVersion", str13);
|
|
int i2 = billingFlowParams.e;
|
|
if (i2 != 0) {
|
|
bundle.putInt("prorationMode", i2);
|
|
}
|
|
if (!TextUtils.isEmpty(billingFlowParams.b)) {
|
|
bundle.putString("accountId", billingFlowParams.b);
|
|
}
|
|
if (!TextUtils.isEmpty(billingFlowParams.d)) {
|
|
bundle.putString("obfuscatedProfileId", billingFlowParams.d);
|
|
}
|
|
if (billingFlowParams.g) {
|
|
bundle.putBoolean("vr", true);
|
|
}
|
|
if (!TextUtils.isEmpty(null)) {
|
|
bundle.putStringArrayList("skusToReplace", new ArrayList<>(Arrays.asList(null)));
|
|
}
|
|
if (!TextUtils.isEmpty(billingFlowParams.f1579c)) {
|
|
bundle.putString("oldSkuPurchaseToken", billingFlowParams.f1579c);
|
|
}
|
|
if (!TextUtils.isEmpty(null)) {
|
|
bundle.putString("oldSkuPurchaseId", null);
|
|
}
|
|
if (!TextUtils.isEmpty(null)) {
|
|
bundle.putString("paymentsPurchaseParams", null);
|
|
}
|
|
if (z3 && z4) {
|
|
bundle.putBoolean("enablePendingPurchases", true);
|
|
}
|
|
ArrayList<String> arrayList2 = new ArrayList<>();
|
|
ArrayList<String> arrayList3 = new ArrayList<>();
|
|
ArrayList<String> arrayList4 = new ArrayList<>();
|
|
ArrayList<Integer> arrayList5 = new ArrayList<>();
|
|
str4 = "; try to reconnect";
|
|
ArrayList<String> arrayList6 = new ArrayList<>();
|
|
str3 = str12;
|
|
int size = arrayList.size();
|
|
boolean z5 = false;
|
|
boolean z6 = false;
|
|
boolean z7 = false;
|
|
boolean z8 = false;
|
|
str = "BUY_INTENT";
|
|
int i3 = 0;
|
|
while (i3 < size) {
|
|
SkuDetails skuDetails2 = (SkuDetails) arrayList.get(i3);
|
|
if (!skuDetails2.b.optString("skuDetailsToken").isEmpty()) {
|
|
arrayList2.add(skuDetails2.b.optString("skuDetailsToken"));
|
|
}
|
|
try {
|
|
str9 = new JSONObject(skuDetails2.a).optString("offer_id_token");
|
|
} catch (JSONException unused) {
|
|
str9 = str11;
|
|
}
|
|
String optString = skuDetails2.b.optString("offer_id");
|
|
int optInt = skuDetails2.b.optInt("offer_type");
|
|
String optString2 = skuDetails2.b.optString("serializedDocid");
|
|
arrayList3.add(str9);
|
|
z5 |= !TextUtils.isEmpty(str9);
|
|
arrayList4.add(optString);
|
|
z6 |= !TextUtils.isEmpty(optString);
|
|
arrayList5.add(Integer.valueOf(optInt));
|
|
z7 |= optInt != 0;
|
|
z8 |= !TextUtils.isEmpty(optString2);
|
|
arrayList6.add(optString2);
|
|
i3++;
|
|
str10 = str10;
|
|
size = size;
|
|
e = e;
|
|
}
|
|
str2 = str10;
|
|
if (!arrayList2.isEmpty()) {
|
|
bundle.putStringArrayList("skuDetailsTokens", arrayList2);
|
|
}
|
|
if (z5) {
|
|
if (!this.m) {
|
|
BillingResult billingResult4 = p.g;
|
|
j(billingResult4);
|
|
return billingResult4;
|
|
}
|
|
bundle.putStringArrayList("SKU_OFFER_ID_TOKEN_LIST", arrayList3);
|
|
}
|
|
if (z6) {
|
|
bundle.putStringArrayList("SKU_OFFER_ID_LIST", arrayList4);
|
|
}
|
|
if (z7) {
|
|
bundle.putIntegerArrayList("SKU_OFFER_TYPE_LIST", arrayList5);
|
|
}
|
|
if (z8) {
|
|
bundle.putStringArrayList("SKU_SERIALIZED_DOCID_LIST", arrayList6);
|
|
}
|
|
if (!TextUtils.isEmpty(skuDetails.f())) {
|
|
bundle.putString("skuPackageName", skuDetails.f());
|
|
str8 = null;
|
|
z2 = true;
|
|
} else {
|
|
str8 = null;
|
|
z2 = false;
|
|
}
|
|
if (!TextUtils.isEmpty(str8)) {
|
|
bundle.putString("accountName", str8);
|
|
}
|
|
if (arrayList.size() > 1) {
|
|
ArrayList<String> arrayList7 = new ArrayList<>(arrayList.size() - 1);
|
|
ArrayList<String> arrayList8 = new ArrayList<>(arrayList.size() - 1);
|
|
for (int i4 = 1; i4 < arrayList.size(); i4++) {
|
|
arrayList7.add(((SkuDetails) arrayList.get(i4)).d());
|
|
arrayList8.add(((SkuDetails) arrayList.get(i4)).e());
|
|
}
|
|
bundle.putStringArrayList("additionalSkus", arrayList7);
|
|
bundle.putStringArrayList("additionalSkuTypes", arrayList8);
|
|
}
|
|
if (!TextUtils.isEmpty(activity.getIntent().getStringExtra("PROXY_PACKAGE"))) {
|
|
String stringExtra = activity.getIntent().getStringExtra("PROXY_PACKAGE");
|
|
bundle.putString("proxyPackage", stringExtra);
|
|
try {
|
|
bundle.putString("proxyPackageVersion", this.e.getPackageManager().getPackageInfo(stringExtra, 0).versionName);
|
|
} catch (PackageManager.NameNotFoundException unused2) {
|
|
bundle.putString("proxyPackageVersion", "package not found");
|
|
}
|
|
}
|
|
future = l(new b0(this, (!this.n || !z2) ? this.k ? 9 : billingFlowParams.g ? 7 : 6 : 15, skuDetails, e, billingFlowParams, bundle), 5000, null, this.f350c);
|
|
} else {
|
|
str = "BUY_INTENT";
|
|
str4 = "; try to reconnect";
|
|
str2 = str10;
|
|
str3 = str12;
|
|
future = l(new u(this, skuDetails, e), 5000, null, this.f350c);
|
|
}
|
|
try {
|
|
Bundle bundle2 = (Bundle) future.get(5000, TimeUnit.MILLISECONDS);
|
|
str6 = str2;
|
|
try {
|
|
int a = c.i.a.f.h.n.a.a(bundle2, str6);
|
|
String d = c.i.a.f.h.n.a.d(bundle2, str6);
|
|
if (a != 0) {
|
|
StringBuilder sb2 = new StringBuilder(52);
|
|
sb2.append("Unable to buy item, Error response code: ");
|
|
sb2.append(a);
|
|
c.i.a.f.h.n.a.f(str6, sb2.toString());
|
|
BillingResult billingResult5 = new BillingResult();
|
|
billingResult5.a = a;
|
|
billingResult5.b = d;
|
|
j(billingResult5);
|
|
return billingResult5;
|
|
}
|
|
Intent intent = new Intent(activity, ProxyBillingActivity.class);
|
|
intent.putExtra(str, (PendingIntent) bundle2.getParcelable(str));
|
|
activity.startActivity(intent);
|
|
return p.i;
|
|
} catch (CancellationException | TimeoutException unused3) {
|
|
str7 = str4;
|
|
str5 = str3;
|
|
StringBuilder sb3 = new StringBuilder(String.valueOf(str5).length() + 68);
|
|
sb3.append("Time out while launching billing flow: ; for sku: ");
|
|
sb3.append(str5);
|
|
sb3.append(str7);
|
|
c.i.a.f.h.n.a.f(str6, sb3.toString());
|
|
BillingResult billingResult6 = p.k;
|
|
j(billingResult6);
|
|
return billingResult6;
|
|
} catch (Exception unused4) {
|
|
StringBuilder sb4 = new StringBuilder(String.valueOf(str3).length() + 69);
|
|
sb4.append("Exception while launching billing flow: ; for sku: ");
|
|
sb4.append(str3);
|
|
sb4.append(str4);
|
|
c.i.a.f.h.n.a.f(str6, sb4.toString());
|
|
BillingResult billingResult7 = p.j;
|
|
j(billingResult7);
|
|
return billingResult7;
|
|
}
|
|
} catch (CancellationException | TimeoutException unused5) {
|
|
str7 = str4;
|
|
str5 = str3;
|
|
str6 = str2;
|
|
StringBuilder sb3 = new StringBuilder(String.valueOf(str5).length() + 68);
|
|
sb3.append("Time out while launching billing flow: ; for sku: ");
|
|
sb3.append(str5);
|
|
sb3.append(str7);
|
|
c.i.a.f.h.n.a.f(str6, sb3.toString());
|
|
BillingResult billingResult6 = p.k;
|
|
j(billingResult6);
|
|
return billingResult6;
|
|
} catch (Exception unused6) {
|
|
}
|
|
} else {
|
|
c.i.a.f.h.n.a.f(str10, "Current client doesn't support multi-item purchases.");
|
|
BillingResult billingResult8 = p.m;
|
|
j(billingResult8);
|
|
return billingResult8;
|
|
}
|
|
}
|
|
|
|
@Override // com.android.billingclient.api.BillingClient
|
|
public void f(String str, f fVar) {
|
|
if (!d()) {
|
|
BillingResult billingResult = p.j;
|
|
m<Object> mVar = k.j;
|
|
fVar.onQueryPurchasesResponse(billingResult, l.k);
|
|
} else if (TextUtils.isEmpty(str)) {
|
|
c.i.a.f.h.n.a.f("BillingClient", "Please provide a valid SKU type.");
|
|
BillingResult billingResult2 = p.e;
|
|
m<Object> mVar2 = k.j;
|
|
fVar.onQueryPurchasesResponse(billingResult2, l.k);
|
|
} else if (l(new j(this, str, fVar), 30000, new y(fVar), i()) == null) {
|
|
BillingResult k = k();
|
|
m<Object> mVar3 = k.j;
|
|
fVar.onQueryPurchasesResponse(k, l.k);
|
|
}
|
|
}
|
|
|
|
@Override // com.android.billingclient.api.BillingClient
|
|
public final void g(h hVar, i iVar) {
|
|
if (!d()) {
|
|
iVar.onSkuDetailsResponse(p.j, null);
|
|
return;
|
|
}
|
|
String str = hVar.a;
|
|
List<String> list = hVar.b;
|
|
if (TextUtils.isEmpty(str)) {
|
|
c.i.a.f.h.n.a.f("BillingClient", "Please fix the input params. SKU type can't be empty.");
|
|
iVar.onSkuDetailsResponse(p.e, null);
|
|
} else if (list != null) {
|
|
ArrayList arrayList = new ArrayList();
|
|
for (String str2 : list) {
|
|
if (!TextUtils.isEmpty(str2)) {
|
|
arrayList.add(new q(str2));
|
|
} else {
|
|
throw new IllegalArgumentException("SKU must be set.");
|
|
}
|
|
}
|
|
if (l(new v(this, str, arrayList, iVar), 30000, new z(iVar), i()) == null) {
|
|
iVar.onSkuDetailsResponse(k(), null);
|
|
}
|
|
} else {
|
|
c.i.a.f.h.n.a.f("BillingClient", "Please fix the input params. The list of SKUs can't be empty - set SKU list or SkuWithOffer list.");
|
|
iVar.onSkuDetailsResponse(p.d, null);
|
|
}
|
|
}
|
|
|
|
@Override // com.android.billingclient.api.BillingClient
|
|
public final void h(b bVar) {
|
|
ServiceInfo serviceInfo;
|
|
if (d()) {
|
|
c.i.a.f.h.n.a.e("BillingClient", "Service connection is valid. No need to re-initialize.");
|
|
bVar.onBillingSetupFinished(p.i);
|
|
} else if (this.a == 1) {
|
|
c.i.a.f.h.n.a.f("BillingClient", "Client is already in the process of connecting to billing service.");
|
|
bVar.onBillingSetupFinished(p.f351c);
|
|
} else if (this.a == 3) {
|
|
c.i.a.f.h.n.a.f("BillingClient", "Client was already closed and can't be reused. Please create another instance.");
|
|
bVar.onBillingSetupFinished(p.j);
|
|
} else {
|
|
this.a = 1;
|
|
s sVar = this.d;
|
|
r rVar = sVar.b;
|
|
Context context = sVar.a;
|
|
IntentFilter intentFilter = new IntentFilter("com.android.vending.billing.PURCHASES_UPDATED");
|
|
if (!rVar.b) {
|
|
context.registerReceiver(rVar.f352c.b, intentFilter);
|
|
rVar.b = true;
|
|
}
|
|
c.i.a.f.h.n.a.e("BillingClient", "Starting in-app billing setup.");
|
|
this.g = new n(this, bVar);
|
|
Intent intent = new Intent("com.android.vending.billing.InAppBillingService.BIND");
|
|
intent.setPackage("com.android.vending");
|
|
List<ResolveInfo> queryIntentServices = this.e.getPackageManager().queryIntentServices(intent, 0);
|
|
if (!(queryIntentServices == null || queryIntentServices.isEmpty() || (serviceInfo = queryIntentServices.get(0).serviceInfo) == null)) {
|
|
String str = serviceInfo.packageName;
|
|
String str2 = serviceInfo.name;
|
|
if (!"com.android.vending".equals(str) || str2 == null) {
|
|
c.i.a.f.h.n.a.f("BillingClient", "The device doesn't have valid Play Store.");
|
|
} else {
|
|
ComponentName componentName = new ComponentName(str, str2);
|
|
Intent intent2 = new Intent(intent);
|
|
intent2.setComponent(componentName);
|
|
intent2.putExtra("playBillingLibraryVersion", this.b);
|
|
if (this.e.bindService(intent2, this.g, 1)) {
|
|
c.i.a.f.h.n.a.e("BillingClient", "Service was bonded successfully.");
|
|
return;
|
|
}
|
|
c.i.a.f.h.n.a.f("BillingClient", "Connection to Billing service is blocked.");
|
|
}
|
|
}
|
|
this.a = 0;
|
|
c.i.a.f.h.n.a.e("BillingClient", "Billing service unavailable on device.");
|
|
bVar.onBillingSetupFinished(p.b);
|
|
}
|
|
}
|
|
|
|
public final Handler i() {
|
|
return Looper.myLooper() == null ? this.f350c : new Handler(Looper.myLooper());
|
|
}
|
|
|
|
public final BillingResult j(BillingResult billingResult) {
|
|
if (Thread.interrupted()) {
|
|
return billingResult;
|
|
}
|
|
this.f350c.post(new w(this, billingResult));
|
|
return billingResult;
|
|
}
|
|
|
|
public final BillingResult k() {
|
|
return (this.a == 0 || this.a == 3) ? p.j : p.h;
|
|
}
|
|
|
|
@Nullable
|
|
public final <T> Future<T> l(Callable<T> callable, long j, @Nullable Runnable runnable, Handler handler) {
|
|
long j2 = (long) (((double) j) * 0.95d);
|
|
if (this.q == null) {
|
|
this.q = Executors.newFixedThreadPool(c.i.a.f.h.n.a.a, new k(this));
|
|
}
|
|
try {
|
|
Future<T> submit = this.q.submit(callable);
|
|
handler.postDelayed(new a0(submit, runnable), j2);
|
|
return submit;
|
|
} catch (Exception e) {
|
|
String valueOf = String.valueOf(e);
|
|
StringBuilder sb = new StringBuilder(valueOf.length() + 28);
|
|
sb.append("Async task throws exception ");
|
|
sb.append(valueOf);
|
|
c.i.a.f.h.n.a.f("BillingClient", sb.toString());
|
|
return null;
|
|
}
|
|
}
|
|
}
|