package o;

import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.LinkedHashMap;

/* compiled from: r8-map-id-3b7cc9102578c509342fa2f0fabed2bfc72239cd258d579fc679bfcbc198b048 */
/* renamed from: o.x1, reason: case insensitive filesystem */
/* loaded from: classes.dex */
public final class C2867x1 extends AbstractC2772w1 {
    public final /* synthetic */ int a;

    public /* synthetic */ C2867x1(int i) {
        this.a = i;
    }

    @Override // o.AbstractC2772w1
    public final Intent a(Object obj) {
        Bundle bundleExtra;
        switch (this.a) {
            case 0:
                return new Intent("android.intent.action.GET_CONTENT").addCategory("android.intent.category.OPENABLE").setType((String) obj);
            case 1:
                return new Intent("androidx.activity.result.contract.action.REQUEST_PERMISSIONS").putExtra("androidx.activity.result.contract.extra.PERMISSIONS", (String[]) obj);
            case 2:
                return new Intent("androidx.activity.result.contract.action.REQUEST_PERMISSIONS").putExtra("androidx.activity.result.contract.extra.PERMISSIONS", new String[]{(String) obj});
            case 3:
                return (Intent) obj;
            default:
                C1659kI c1659kI = (C1659kI) obj;
                Intent intent = new Intent("androidx.activity.result.contract.action.INTENT_SENDER_REQUEST");
                Intent intent2 = c1659kI.m;
                if (intent2 != null && (bundleExtra = intent2.getBundleExtra("androidx.activity.result.contract.extra.ACTIVITY_OPTIONS_BUNDLE")) != null) {
                    intent.putExtra("androidx.activity.result.contract.extra.ACTIVITY_OPTIONS_BUNDLE", bundleExtra);
                    intent2.removeExtra("androidx.activity.result.contract.extra.ACTIVITY_OPTIONS_BUNDLE");
                    if (intent2.getBooleanExtra("androidx.fragment.extra.ACTIVITY_OPTIONS_BUNDLE", false)) {
                        c1659kI = new C1659kI(c1659kI.l, null, c1659kI.n, c1659kI.f612o);
                    }
                }
                intent.putExtra("androidx.activity.result.contract.extra.INTENT_SENDER_REQUEST", c1659kI);
                if (androidx.fragment.app.s.F(2)) {
                    intent.toString();
                }
                return intent;
        }
    }

    @Override // o.AbstractC2772w1
    public OD b(Context context, Object obj) {
        switch (this.a) {
            case 0:
                return null;
            case 1:
                String[] strArr = (String[]) obj;
                if (strArr.length == 0) {
                    return new OD(7, C0358Nv.l);
                }
                for (String str : strArr) {
                    if (Co0.l(context, str) != 0) {
                        return null;
                    }
                }
                int iZ = GN.Z(strArr.length);
                if (iZ < 16) {
                    iZ = 16;
                }
                LinkedHashMap linkedHashMap = new LinkedHashMap(iZ);
                for (String str2 : strArr) {
                    linkedHashMap.put(str2, Boolean.TRUE);
                }
                return new OD(7, linkedHashMap);
            case 2:
                if (Co0.l(context, (String) obj) != 0) {
                    return null;
                }
                return new OD(7, Boolean.TRUE);
            default:
                return super.b(context, obj);
        }
    }

    @Override // o.AbstractC2772w1
    public final Object c(Intent intent, int i) {
        switch (this.a) {
            case 0:
                if (i != -1) {
                    intent = null;
                }
                if (intent != null) {
                    break;
                }
                break;
            case 1:
                if (i == -1 && intent != null) {
                    String[] stringArrayExtra = intent.getStringArrayExtra("androidx.activity.result.contract.extra.PERMISSIONS");
                    int[] intArrayExtra = intent.getIntArrayExtra("androidx.activity.result.contract.extra.PERMISSION_GRANT_RESULTS");
                    if (intArrayExtra != null && stringArrayExtra != null) {
                        ArrayList arrayList = new ArrayList(intArrayExtra.length);
                        for (int i2 : intArrayExtra) {
                            arrayList.add(Boolean.valueOf(i2 == 0));
                        }
                        ArrayList arrayListQ = AbstractC2219q9.Q(stringArrayExtra);
                        Iterator it = arrayListQ.iterator();
                        Iterator it2 = arrayList.iterator();
                        ArrayList arrayList2 = new ArrayList(Math.min(AbstractC0034Bi.W(arrayListQ, 10), AbstractC0034Bi.W(arrayList, 10)));
                        while (it.hasNext() && it2.hasNext()) {
                            arrayList2.add(new C3001yV(it.next(), it2.next()));
                        }
                        break;
                    }
                }
                break;
            case 2:
                if (intent == null || i != -1) {
                    break;
                } else {
                    int[] intArrayExtra2 = intent.getIntArrayExtra("androidx.activity.result.contract.extra.PERMISSION_GRANT_RESULTS");
                    boolean z = false;
                    if (intArrayExtra2 != null) {
                        int length = intArrayExtra2.length;
                        int i3 = 0;
                        while (true) {
                            if (i3 < length) {
                                if (intArrayExtra2[i3] == 0) {
                                    z = true;
                                } else {
                                    i3++;
                                }
                            }
                        }
                    }
                    break;
                }
                break;
        }
        return new C2582u1(intent, i);
    }
}
