package com.android.billingclient.api;

import android.app.PendingIntent;
import android.content.Intent;
import android.content.IntentSender;
import android.os.Bundle;
import android.os.ResultReceiver;
import androidx.fragment.app.C1042c0;
import com.android.billingclient.api.ProxyBillingActivityV2;
import com.google.android.apps.common.proguard.UsedByReflection;
import com.google.android.gms.internal.play_billing.zzc;
import com.google.android.gms.internal.play_billing.zzie;
import d.AbstractActivityC1833l;
import g.AbstractC2050d;
import g.C2047a;
import g.C2057k;
import g.InterfaceC2048b;
import kotlin.jvm.internal.o;

/* JADX INFO: loaded from: classes.dex */
@UsedByReflection("PlatformActivityProxy")
public class ProxyBillingActivityV2 extends AbstractActivityC1833l {

    /* JADX INFO: renamed from: a, reason: collision with root package name */
    public AbstractC2050d f13556a;

    /* JADX INFO: renamed from: b, reason: collision with root package name */
    public AbstractC2050d f13557b;

    /* JADX INFO: renamed from: c, reason: collision with root package name */
    public AbstractC2050d f13558c;

    /* JADX INFO: renamed from: d, reason: collision with root package name */
    public ResultReceiver f13559d;

    /* JADX INFO: renamed from: e, reason: collision with root package name */
    public ResultReceiver f13560e;

    /* JADX INFO: renamed from: f, reason: collision with root package name */
    public ResultReceiver f13561f;

    @Override // d.AbstractActivityC1833l, androidx.core.app.AbstractActivityC0998e, android.app.Activity
    public final void onCreate(Bundle bundle) {
        super.onCreate(bundle);
        final int i6 = 0;
        this.f13556a = registerForActivityResult(new C1042c0(4), new InterfaceC2048b(this) { // from class: I2.X

            /* JADX INFO: renamed from: b, reason: collision with root package name */
            public final /* synthetic */ ProxyBillingActivityV2 f2570b;

            {
                this.f2570b = this;
            }

            @Override // g.InterfaceC2048b
            public final void onActivityResult(Object obj) {
                C2047a c2047a = (C2047a) obj;
                switch (i6) {
                    case 0:
                        ProxyBillingActivityV2 proxyBillingActivityV2 = this.f2570b;
                        proxyBillingActivityV2.getClass();
                        Intent intent = c2047a.f16436b;
                        int i7 = zzc.zzh(intent, "ProxyBillingActivityV2").f2636a;
                        ResultReceiver resultReceiver = proxyBillingActivityV2.f13559d;
                        if (resultReceiver != null) {
                            resultReceiver.send(i7, intent == null ? null : intent.getExtras());
                        }
                        int i8 = c2047a.f16435a;
                        if (i8 != -1 || i7 != 0) {
                            zzc.zzn("ProxyBillingActivityV2", "Alternative billing only dialog finished with resultCode " + i8 + " and billing's responseCode: " + i7);
                        }
                        proxyBillingActivityV2.finish();
                        break;
                    case 1:
                        ProxyBillingActivityV2 proxyBillingActivityV22 = this.f2570b;
                        proxyBillingActivityV22.getClass();
                        Intent intent2 = c2047a.f16436b;
                        int i9 = zzc.zzh(intent2, "ProxyBillingActivityV2").f2636a;
                        ResultReceiver resultReceiver2 = proxyBillingActivityV22.f13560e;
                        if (resultReceiver2 != null) {
                            resultReceiver2.send(i9, intent2 == null ? null : intent2.getExtras());
                        }
                        int i10 = c2047a.f16435a;
                        if (i10 != -1 || i9 != 0) {
                            zzc.zzn("ProxyBillingActivityV2", "External offer dialog finished with resultCode: " + i10 + " and billing's responseCode: " + i9);
                        }
                        proxyBillingActivityV22.finish();
                        break;
                    default:
                        ProxyBillingActivityV2 proxyBillingActivityV23 = this.f2570b;
                        proxyBillingActivityV23.getClass();
                        Intent intent3 = c2047a.f16436b;
                        Bundle extras = intent3 == null ? null : intent3.getExtras();
                        int i11 = c2047a.f16435a;
                        if (i11 != -1) {
                            if (extras == null) {
                                extras = new Bundle();
                            }
                            zzc.zzn("ProxyBillingActivityV2", "External offer flow finished with resultCode: " + i11);
                            extras.putInt("INTERNAL_LOG_ERROR_REASON", zzie.ERROR_IN_ACTIVITY_RESULT.zza());
                            extras.putString("INTERNAL_LOG_ERROR_ADDITIONAL_DETAILS", "External offer flow finished with error resultCode: " + i11);
                        }
                        int i12 = zzc.zzh(intent3, "ProxyBillingActivityV2").f2636a;
                        ResultReceiver resultReceiver3 = proxyBillingActivityV23.f13561f;
                        if (resultReceiver3 != null) {
                            resultReceiver3.send(i12, extras);
                        } else {
                            zzc.zzn("ProxyBillingActivityV2", "External offer flow result receiver is null");
                        }
                        if (i12 != 0) {
                            zzc.zzn("ProxyBillingActivityV2", "External offer flow finished with billing responseCode: " + i12);
                        }
                        proxyBillingActivityV23.finish();
                        break;
                }
            }
        });
        final int i7 = 1;
        this.f13557b = registerForActivityResult(new C1042c0(4), new InterfaceC2048b(this) { // from class: I2.X

            /* JADX INFO: renamed from: b, reason: collision with root package name */
            public final /* synthetic */ ProxyBillingActivityV2 f2570b;

            {
                this.f2570b = this;
            }

            @Override // g.InterfaceC2048b
            public final void onActivityResult(Object obj) {
                C2047a c2047a = (C2047a) obj;
                switch (i7) {
                    case 0:
                        ProxyBillingActivityV2 proxyBillingActivityV2 = this.f2570b;
                        proxyBillingActivityV2.getClass();
                        Intent intent = c2047a.f16436b;
                        int i72 = zzc.zzh(intent, "ProxyBillingActivityV2").f2636a;
                        ResultReceiver resultReceiver = proxyBillingActivityV2.f13559d;
                        if (resultReceiver != null) {
                            resultReceiver.send(i72, intent == null ? null : intent.getExtras());
                        }
                        int i8 = c2047a.f16435a;
                        if (i8 != -1 || i72 != 0) {
                            zzc.zzn("ProxyBillingActivityV2", "Alternative billing only dialog finished with resultCode " + i8 + " and billing's responseCode: " + i72);
                        }
                        proxyBillingActivityV2.finish();
                        break;
                    case 1:
                        ProxyBillingActivityV2 proxyBillingActivityV22 = this.f2570b;
                        proxyBillingActivityV22.getClass();
                        Intent intent2 = c2047a.f16436b;
                        int i9 = zzc.zzh(intent2, "ProxyBillingActivityV2").f2636a;
                        ResultReceiver resultReceiver2 = proxyBillingActivityV22.f13560e;
                        if (resultReceiver2 != null) {
                            resultReceiver2.send(i9, intent2 == null ? null : intent2.getExtras());
                        }
                        int i10 = c2047a.f16435a;
                        if (i10 != -1 || i9 != 0) {
                            zzc.zzn("ProxyBillingActivityV2", "External offer dialog finished with resultCode: " + i10 + " and billing's responseCode: " + i9);
                        }
                        proxyBillingActivityV22.finish();
                        break;
                    default:
                        ProxyBillingActivityV2 proxyBillingActivityV23 = this.f2570b;
                        proxyBillingActivityV23.getClass();
                        Intent intent3 = c2047a.f16436b;
                        Bundle extras = intent3 == null ? null : intent3.getExtras();
                        int i11 = c2047a.f16435a;
                        if (i11 != -1) {
                            if (extras == null) {
                                extras = new Bundle();
                            }
                            zzc.zzn("ProxyBillingActivityV2", "External offer flow finished with resultCode: " + i11);
                            extras.putInt("INTERNAL_LOG_ERROR_REASON", zzie.ERROR_IN_ACTIVITY_RESULT.zza());
                            extras.putString("INTERNAL_LOG_ERROR_ADDITIONAL_DETAILS", "External offer flow finished with error resultCode: " + i11);
                        }
                        int i12 = zzc.zzh(intent3, "ProxyBillingActivityV2").f2636a;
                        ResultReceiver resultReceiver3 = proxyBillingActivityV23.f13561f;
                        if (resultReceiver3 != null) {
                            resultReceiver3.send(i12, extras);
                        } else {
                            zzc.zzn("ProxyBillingActivityV2", "External offer flow result receiver is null");
                        }
                        if (i12 != 0) {
                            zzc.zzn("ProxyBillingActivityV2", "External offer flow finished with billing responseCode: " + i12);
                        }
                        proxyBillingActivityV23.finish();
                        break;
                }
            }
        });
        final int i8 = 2;
        this.f13558c = registerForActivityResult(new C1042c0(4), new InterfaceC2048b(this) { // from class: I2.X

            /* JADX INFO: renamed from: b, reason: collision with root package name */
            public final /* synthetic */ ProxyBillingActivityV2 f2570b;

            {
                this.f2570b = this;
            }

            @Override // g.InterfaceC2048b
            public final void onActivityResult(Object obj) {
                C2047a c2047a = (C2047a) obj;
                switch (i8) {
                    case 0:
                        ProxyBillingActivityV2 proxyBillingActivityV2 = this.f2570b;
                        proxyBillingActivityV2.getClass();
                        Intent intent = c2047a.f16436b;
                        int i72 = zzc.zzh(intent, "ProxyBillingActivityV2").f2636a;
                        ResultReceiver resultReceiver = proxyBillingActivityV2.f13559d;
                        if (resultReceiver != null) {
                            resultReceiver.send(i72, intent == null ? null : intent.getExtras());
                        }
                        int i82 = c2047a.f16435a;
                        if (i82 != -1 || i72 != 0) {
                            zzc.zzn("ProxyBillingActivityV2", "Alternative billing only dialog finished with resultCode " + i82 + " and billing's responseCode: " + i72);
                        }
                        proxyBillingActivityV2.finish();
                        break;
                    case 1:
                        ProxyBillingActivityV2 proxyBillingActivityV22 = this.f2570b;
                        proxyBillingActivityV22.getClass();
                        Intent intent2 = c2047a.f16436b;
                        int i9 = zzc.zzh(intent2, "ProxyBillingActivityV2").f2636a;
                        ResultReceiver resultReceiver2 = proxyBillingActivityV22.f13560e;
                        if (resultReceiver2 != null) {
                            resultReceiver2.send(i9, intent2 == null ? null : intent2.getExtras());
                        }
                        int i10 = c2047a.f16435a;
                        if (i10 != -1 || i9 != 0) {
                            zzc.zzn("ProxyBillingActivityV2", "External offer dialog finished with resultCode: " + i10 + " and billing's responseCode: " + i9);
                        }
                        proxyBillingActivityV22.finish();
                        break;
                    default:
                        ProxyBillingActivityV2 proxyBillingActivityV23 = this.f2570b;
                        proxyBillingActivityV23.getClass();
                        Intent intent3 = c2047a.f16436b;
                        Bundle extras = intent3 == null ? null : intent3.getExtras();
                        int i11 = c2047a.f16435a;
                        if (i11 != -1) {
                            if (extras == null) {
                                extras = new Bundle();
                            }
                            zzc.zzn("ProxyBillingActivityV2", "External offer flow finished with resultCode: " + i11);
                            extras.putInt("INTERNAL_LOG_ERROR_REASON", zzie.ERROR_IN_ACTIVITY_RESULT.zza());
                            extras.putString("INTERNAL_LOG_ERROR_ADDITIONAL_DETAILS", "External offer flow finished with error resultCode: " + i11);
                        }
                        int i12 = zzc.zzh(intent3, "ProxyBillingActivityV2").f2636a;
                        ResultReceiver resultReceiver3 = proxyBillingActivityV23.f13561f;
                        if (resultReceiver3 != null) {
                            resultReceiver3.send(i12, extras);
                        } else {
                            zzc.zzn("ProxyBillingActivityV2", "External offer flow result receiver is null");
                        }
                        if (i12 != 0) {
                            zzc.zzn("ProxyBillingActivityV2", "External offer flow finished with billing responseCode: " + i12);
                        }
                        proxyBillingActivityV23.finish();
                        break;
                }
            }
        });
        if (bundle != null) {
            if (bundle.containsKey("alternative_billing_only_dialog_result_receiver")) {
                this.f13559d = (ResultReceiver) bundle.getParcelable("alternative_billing_only_dialog_result_receiver");
            }
            if (bundle.containsKey("external_payment_dialog_result_receiver")) {
                this.f13560e = (ResultReceiver) bundle.getParcelable("external_payment_dialog_result_receiver");
            }
            if (bundle.containsKey("external_offer_flow_result_receiver")) {
                this.f13561f = (ResultReceiver) bundle.getParcelable("external_offer_flow_result_receiver");
                return;
            }
            return;
        }
        zzc.zzm("ProxyBillingActivityV2", "Launching Play Store billing dialog");
        if (getIntent().hasExtra("ALTERNATIVE_BILLING_ONLY_DIALOG_INTENT")) {
            PendingIntent pendingIntent = (PendingIntent) getIntent().getParcelableExtra("ALTERNATIVE_BILLING_ONLY_DIALOG_INTENT");
            this.f13559d = (ResultReceiver) getIntent().getParcelableExtra("alternative_billing_only_dialog_result_receiver");
            AbstractC2050d abstractC2050d = this.f13556a;
            o.h(pendingIntent, "pendingIntent");
            IntentSender intentSender = pendingIntent.getIntentSender();
            o.g(intentSender, "pendingIntent.intentSender");
            abstractC2050d.a(new C2057k(intentSender, null, 0, 0));
            return;
        }
        if (getIntent().hasExtra("external_payment_dialog_pending_intent")) {
            PendingIntent pendingIntent2 = (PendingIntent) getIntent().getParcelableExtra("external_payment_dialog_pending_intent");
            this.f13560e = (ResultReceiver) getIntent().getParcelableExtra("external_payment_dialog_result_receiver");
            AbstractC2050d abstractC2050d2 = this.f13557b;
            o.h(pendingIntent2, "pendingIntent");
            IntentSender intentSender2 = pendingIntent2.getIntentSender();
            o.g(intentSender2, "pendingIntent.intentSender");
            abstractC2050d2.a(new C2057k(intentSender2, null, 0, 0));
            return;
        }
        if (getIntent().hasExtra("external_offer_flow_pending_intent")) {
            PendingIntent pendingIntent3 = (PendingIntent) getIntent().getParcelableExtra("external_offer_flow_pending_intent");
            this.f13561f = (ResultReceiver) getIntent().getParcelableExtra("external_offer_flow_result_receiver");
            AbstractC2050d abstractC2050d3 = this.f13558c;
            o.h(pendingIntent3, "pendingIntent");
            IntentSender intentSender3 = pendingIntent3.getIntentSender();
            o.g(intentSender3, "pendingIntent.intentSender");
            abstractC2050d3.a(new C2057k(intentSender3, null, 0, 0));
        }
    }

    @Override // d.AbstractActivityC1833l, androidx.core.app.AbstractActivityC0998e, android.app.Activity
    public final void onSaveInstanceState(Bundle bundle) {
        super.onSaveInstanceState(bundle);
        ResultReceiver resultReceiver = this.f13559d;
        if (resultReceiver != null) {
            bundle.putParcelable("alternative_billing_only_dialog_result_receiver", resultReceiver);
        }
        ResultReceiver resultReceiver2 = this.f13560e;
        if (resultReceiver2 != null) {
            bundle.putParcelable("external_payment_dialog_result_receiver", resultReceiver2);
        }
        ResultReceiver resultReceiver3 = this.f13561f;
        if (resultReceiver3 != null) {
            bundle.putParcelable("external_offer_flow_result_receiver", resultReceiver3);
        }
    }
}
