discord-jadx/app/src/main/java/com/android/billingclient/api/ProxyBillingActivity.java

133 lines
5.2 KiB
Java

package com.android.billingclient.api;
import android.app.Activity;
import android.app.PendingIntent;
import android.content.Intent;
import android.content.IntentSender;
import android.os.Bundle;
import android.os.ResultReceiver;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import c.i.a.f.h.n.a;
/* compiled from: com.android.billingclient:billing@@3.0.3 */
public class ProxyBillingActivity extends Activity {
@Nullable
public ResultReceiver i;
public boolean j;
public final Intent a() {
Intent intent = new Intent("com.android.vending.billing.PURCHASES_UPDATED");
intent.setPackage(getApplicationContext().getPackageName());
return intent;
}
/* JADX WARNING: Removed duplicated region for block: B:10:0x003b */
/* JADX WARNING: Removed duplicated region for block: B:14:0x0047 */
@Override // android.app.Activity
public void onActivityResult(int i, int i2, @Nullable Intent intent) {
ResultReceiver resultReceiver;
super.onActivityResult(i, i2, intent);
if (i == 100) {
int i3 = a.c(intent, "ProxyBillingActivity").a;
if (i2 == -1) {
if (i3 != 0) {
i2 = -1;
} else {
i3 = 0;
resultReceiver = this.i;
if (resultReceiver == null) {
resultReceiver.send(i3, intent == null ? null : intent.getExtras());
} else {
Intent a = a();
if (intent != null) {
a.putExtras(intent.getExtras());
}
sendBroadcast(a);
}
}
}
StringBuilder sb = new StringBuilder(85);
sb.append("Activity finished with resultCode ");
sb.append(i2);
sb.append(" and billing's responseCode: ");
sb.append(i3);
a.b("ProxyBillingActivity", sb.toString());
resultReceiver = this.i;
if (resultReceiver == null) {
}
} else {
StringBuilder sb2 = new StringBuilder(69);
sb2.append("Got onActivityResult with wrong requestCode: ");
sb2.append(i);
sb2.append("; skipping...");
a.b("ProxyBillingActivity", sb2.toString());
}
this.j = false;
finish();
}
@Override // android.app.Activity
public void onCreate(@Nullable Bundle bundle) {
PendingIntent pendingIntent;
super.onCreate(bundle);
if (bundle == null) {
a.a("ProxyBillingActivity", "Launching Play Store billing flow");
if (getIntent().hasExtra("BUY_INTENT")) {
pendingIntent = (PendingIntent) getIntent().getParcelableExtra("BUY_INTENT");
} else if (getIntent().hasExtra("SUBS_MANAGEMENT_INTENT")) {
pendingIntent = (PendingIntent) getIntent().getParcelableExtra("SUBS_MANAGEMENT_INTENT");
this.i = (ResultReceiver) getIntent().getParcelableExtra("result_receiver");
} else {
pendingIntent = null;
}
try {
this.j = true;
startIntentSenderForResult(pendingIntent.getIntentSender(), 100, new Intent(), 0, 0, 0);
} catch (IntentSender.SendIntentException e) {
String valueOf = String.valueOf(e);
StringBuilder sb = new StringBuilder(valueOf.length() + 53);
sb.append("Got exception while trying to start a purchase flow: ");
sb.append(valueOf);
a.b("ProxyBillingActivity", sb.toString());
ResultReceiver resultReceiver = this.i;
if (resultReceiver != null) {
resultReceiver.send(6, null);
} else {
Intent a = a();
a.putExtra("RESPONSE_CODE", 6);
a.putExtra("DEBUG_MESSAGE", "An internal error occurred.");
sendBroadcast(a);
}
this.j = false;
finish();
}
} else {
a.a("ProxyBillingActivity", "Launching Play Store billing flow from savedInstanceState");
this.j = bundle.getBoolean("send_cancelled_broadcast_if_finished", false);
if (bundle.containsKey("result_receiver")) {
this.i = (ResultReceiver) bundle.getParcelable("result_receiver");
}
}
}
@Override // android.app.Activity
public void onDestroy() {
super.onDestroy();
if (isFinishing() && this.j) {
Intent a = a();
a.putExtra("RESPONSE_CODE", 1);
a.putExtra("DEBUG_MESSAGE", "Billing dialog closed.");
sendBroadcast(a);
}
}
@Override // android.app.Activity
public void onSaveInstanceState(@NonNull Bundle bundle) {
ResultReceiver resultReceiver = this.i;
if (resultReceiver != null) {
bundle.putParcelable("result_receiver", resultReceiver);
}
bundle.putBoolean("send_cancelled_broadcast_if_finished", this.j);
}
}