package androidx.activity;

import android.content.Intent;
import android.content.IntentSender;
import android.os.Bundle;
import android.os.Handler;
import android.os.Looper;

/* JADX INFO: loaded from: classes.dex */
public final class o extends androidx.activity.result.i {

    /* JADX INFO: renamed from: h, reason: collision with root package name */
    public final /* synthetic */ ComponentActivity f495h;

    public o(ComponentActivity componentActivity) {
        this.f495h = componentActivity;
    }

    @Override // androidx.activity.result.i
    public final void b(int i10, b.a aVar, Object obj, androidx.core.app.h hVar) {
        Bundle bundle;
        nb.g.i(aVar, "contract");
        ComponentActivity componentActivity = this.f495h;
        xyz.stream.utils.a0 a0VarB = aVar.b(componentActivity, obj);
        int i11 = 0;
        if (a0VarB != null) {
            new Handler(Looper.getMainLooper()).post(new n(this, i10, a0VarB, i11));
            return;
        }
        Intent intentA = aVar.a(componentActivity, obj);
        if (intentA.getExtras() != null) {
            Bundle extras = intentA.getExtras();
            nb.g.f(extras);
            if (extras.getClassLoader() == null) {
                intentA.setExtrasClassLoader(componentActivity.getClassLoader());
            }
        }
        if (intentA.hasExtra("androidx.activity.result.contract.extra.ACTIVITY_OPTIONS_BUNDLE")) {
            Bundle bundleExtra = intentA.getBundleExtra("androidx.activity.result.contract.extra.ACTIVITY_OPTIONS_BUNDLE");
            intentA.removeExtra("androidx.activity.result.contract.extra.ACTIVITY_OPTIONS_BUNDLE");
            bundle = bundleExtra;
        } else {
            bundle = hVar != null ? hVar.toBundle() : null;
        }
        if (nb.g.c("androidx.activity.result.contract.action.REQUEST_PERMISSIONS", intentA.getAction())) {
            String[] stringArrayExtra = intentA.getStringArrayExtra("androidx.activity.result.contract.extra.PERMISSIONS");
            if (stringArrayExtra == null) {
                stringArrayExtra = new String[0];
            }
            androidx.core.app.f.c(componentActivity, stringArrayExtra, i10);
            return;
        }
        if (!nb.g.c("androidx.activity.result.contract.action.INTENT_SENDER_REQUEST", intentA.getAction())) {
            androidx.core.app.f.startActivityForResult(componentActivity, intentA, i10, bundle);
            return;
        }
        androidx.activity.result.l lVar = (androidx.activity.result.l) intentA.getParcelableExtra("androidx.activity.result.contract.extra.INTENT_SENDER_REQUEST");
        try {
            nb.g.f(lVar);
            androidx.core.app.f.startIntentSenderForResult(componentActivity, lVar.f530a, i10, lVar.f531b, lVar.f532c, lVar.f533d, 0, bundle);
        } catch (IntentSender.SendIntentException e10) {
            new Handler(Looper.getMainLooper()).post(new n(this, i10, e10, 1));
        }
    }
}
