package defpackage;

import android.content.Intent;
import android.content.IntentSender;
import android.os.Build;
import android.os.Bundle;
import android.os.Handler;
import android.os.Looper;
import android.text.TextUtils;
import j$.util.Objects;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.HashSet;

/* renamed from: ᵽᵭᵤ, reason: contains not printable characters */
/* loaded from: classes3.dex */
public final class C5371 {

    /* renamed from: ᵹᵝᵶ, reason: contains not printable characters */
    public final /* synthetic */ AbstractActivityC5046 f20145;

    /* renamed from: ᵥᵯˎ, reason: contains not printable characters */
    public final HashMap f20143 = new HashMap();

    /* renamed from: ᵴᵳ, reason: contains not printable characters */
    public final HashMap f20144 = new HashMap();

    /* renamed from: ˏᵙ, reason: contains not printable characters */
    public final HashMap f20142 = new HashMap();

    /* renamed from: ᵻᵢﹳᵰ, reason: contains not printable characters */
    public ArrayList f20146 = new ArrayList();

    /* renamed from: ˇʼʤˎ, reason: contains not printable characters */
    public final transient HashMap f20139 = new HashMap();

    /* renamed from: ˏˋٴ, reason: contains not printable characters */
    public final HashMap f20141 = new HashMap();

    /* renamed from: ˎˏʜʾ, reason: contains not printable characters */
    public final Bundle f20140 = new Bundle();

    public C5371(AbstractActivityC5046 abstractActivityC5046) {
        this.f20145 = abstractActivityC5046;
    }

    /* renamed from: ˇʼʤˎ, reason: contains not printable characters */
    public final void m11025(String str) {
        HashMap map = this.f20144;
        if (((Integer) map.get(str)) != null) {
            return;
        }
        AbstractC4597 abstractC4597 = AbstractC3560.f13336;
        int iNextInt = AbstractC3560.f13336.mo3011().nextInt(2147418112);
        while (true) {
            int i = iNextInt + 65536;
            Integer numValueOf = Integer.valueOf(i);
            HashMap map2 = this.f20143;
            if (!map2.containsKey(numValueOf)) {
                map2.put(Integer.valueOf(i), str);
                map.put(str, Integer.valueOf(i));
                return;
            } else {
                AbstractC4597 abstractC45972 = AbstractC3560.f13336;
                iNextInt = AbstractC3560.f13336.mo3011().nextInt(2147418112);
            }
        }
    }

    /* renamed from: ˏˋٴ, reason: contains not printable characters */
    public final void m11026(String str) {
        Integer num;
        if (!this.f20146.contains(str) && (num = (Integer) this.f20144.remove(str)) != null) {
            this.f20143.remove(num);
        }
        this.f20139.remove(str);
        HashMap map = this.f20141;
        if (map.containsKey(str)) {
            Objects.toString(map.get(str));
            map.remove(str);
        }
        Bundle bundle = this.f20140;
        if (bundle.containsKey(str)) {
            Objects.toString(bundle.getParcelable(str));
            bundle.remove(str);
        }
        HashMap map2 = this.f20142;
        C3287 c3287 = (C3287) map2.get(str);
        if (c3287 != null) {
            ArrayList arrayList = c3287.f12326;
            int size = arrayList.size();
            int i = 0;
            while (i < size) {
                Object obj = arrayList.get(i);
                i++;
                c3287.f12325.m9080((InterfaceC2287) obj);
            }
            arrayList.clear();
            map2.remove(str);
        }
    }

    /* renamed from: ˏᵙ, reason: contains not printable characters */
    public final C3339 m11027(String str, InterfaceC3985 interfaceC3985, ˁˈᵸ r11, InterfaceC1758 interfaceC1758) {
        C4171 c4171Mo2484 = interfaceC3985.mo2484();
        if (c4171Mo2484.f15587.m10953(EnumC5294.f19812)) {
            StringBuilder sb = new StringBuilder("LifecycleOwner ");
            sb.append(interfaceC3985);
            EnumC5294 enumC5294 = c4171Mo2484.f15587;
            sb.append(" is attempting to register while current state is ");
            sb.append(enumC5294);
            sb.append(". LifecycleOwners must call register before they are STARTED.");
            throw new IllegalStateException(sb.toString());
        }
        m11025(str);
        HashMap map = this.f20142;
        C3287 c3287 = (C3287) map.get(str);
        if (c3287 == null) {
            c3287 = new C3287(c4171Mo2484);
        }
        C3178 c3178 = new C3178(this, str, interfaceC1758, r11, 0);
        c3287.f12325.m9082(c3178);
        c3287.f12326.add(c3178);
        map.put(str, c3287);
        return new C3339(this, str, r11, 0);
    }

    /* renamed from: ᵥᵯˎ, reason: contains not printable characters */
    public final boolean m11028(int i, int i2, Intent intent) {
        String str = (String) this.f20143.get(Integer.valueOf(i));
        if (str == null) {
            return false;
        }
        C1551 c1551 = (C1551) this.f20139.get(str);
        if (c1551 != null) {
            InterfaceC1758 interfaceC1758 = c1551.f6187;
            if (this.f20146.contains(str)) {
                interfaceC1758.mo3768(c1551.f6188.ˑᵥˁ(intent, i2));
                this.f20146.remove(str);
                return true;
            }
        }
        this.f20141.remove(str);
        this.f20140.putParcelable(str, new C0098(intent, i2));
        return true;
    }

    /* renamed from: ᵴᵳ, reason: contains not printable characters */
    public final void m11029(int i, ˁˈᵸ r10, Object obj, ᵱᵞᵪ r12) {
        Bundle bundle;
        int i2;
        AbstractActivityC5046 abstractActivityC5046 = this.f20145;
        C2931 c2931 = r10.ᵾᵬ(abstractActivityC5046, obj);
        if (c2931 != null) {
            new Handler(Looper.getMainLooper()).post(new ᵦᵦᵰᵳ(this, i, c2931, 1));
            return;
        }
        Intent intent = r10.ˌᵜᵹᵩ(obj);
        if (intent.getExtras() != null && intent.getExtras().getClassLoader() == null) {
            intent.setExtrasClassLoader(abstractActivityC5046.getClassLoader());
        }
        if (intent.hasExtra("androidx.activity.result.contract.extra.ACTIVITY_OPTIONS_BUNDLE")) {
            bundle = intent.getBundleExtra("androidx.activity.result.contract.extra.ACTIVITY_OPTIONS_BUNDLE");
            intent.removeExtra("androidx.activity.result.contract.extra.ACTIVITY_OPTIONS_BUNDLE");
        } else {
            bundle = r12 != null ? ((C0781) r12).f3684.toBundle() : null;
        }
        Bundle bundle2 = bundle;
        if (!"androidx.activity.result.contract.action.REQUEST_PERMISSIONS".equals(intent.getAction())) {
            if (!"androidx.activity.result.contract.action.INTENT_SENDER_REQUEST".equals(intent.getAction())) {
                abstractActivityC5046.startActivityForResult(intent, i, bundle2);
                return;
            }
            C0230 c0230 = (C0230) intent.getParcelableExtra("androidx.activity.result.contract.extra.INTENT_SENDER_REQUEST");
            try {
                i2 = i;
            } catch (IntentSender.SendIntentException e) {
                e = e;
                i2 = i;
            }
            try {
                abstractActivityC5046.startIntentSenderForResult(c0230.f1760, i2, c0230.f1759, c0230.f1762, c0230.f1761, 0, bundle2);
                return;
            } catch (IntentSender.SendIntentException e2) {
                e = e2;
                new Handler(Looper.getMainLooper()).post(new ᵦᵦᵰᵳ(this, i2, e, 2));
                return;
            }
        }
        String[] stringArrayExtra = intent.getStringArrayExtra("androidx.activity.result.contract.extra.PERMISSIONS");
        if (stringArrayExtra == null) {
            stringArrayExtra = new String[0];
        }
        HashSet hashSet = new HashSet();
        for (int i3 = 0; i3 < stringArrayExtra.length; i3++) {
            if (TextUtils.isEmpty(stringArrayExtra[i3])) {
                ᵹˉᵞ.ˌᵜᵹᵩ(AbstractC1327.m4107(new StringBuilder("Permission request for permissions "), Arrays.toString(stringArrayExtra), " must not contain null or empty values"));
                return;
            }
            if (Build.VERSION.SDK_INT < 33 && TextUtils.equals(stringArrayExtra[i3], "android.permission.POST_NOTIFICATIONS")) {
                hashSet.add(Integer.valueOf(i3));
            }
        }
        int size = hashSet.size();
        String[] strArr = size > 0 ? new String[stringArrayExtra.length - size] : stringArrayExtra;
        if (size > 0) {
            if (size == stringArrayExtra.length) {
                return;
            }
            int i4 = 0;
            for (int i5 = 0; i5 < stringArrayExtra.length; i5++) {
                if (!hashSet.contains(Integer.valueOf(i5))) {
                    strArr[i4] = stringArrayExtra[i5];
                    i4++;
                }
            }
        }
        abstractActivityC5046.requestPermissions(stringArrayExtra, i);
    }

    /* renamed from: ᵻᵢﹳᵰ, reason: contains not printable characters */
    public final C3339 m11030(String str, ˁˈᵸ r4, InterfaceC1758 interfaceC1758) {
        m11025(str);
        this.f20139.put(str, new C1551(interfaceC1758, r4));
        HashMap map = this.f20141;
        if (map.containsKey(str)) {
            Object obj = map.get(str);
            map.remove(str);
            interfaceC1758.mo3768(obj);
        }
        Bundle bundle = this.f20140;
        C0098 c0098 = (C0098) bundle.getParcelable(str);
        if (c0098 != null) {
            bundle.remove(str);
            interfaceC1758.mo3768(r4.ˑᵥˁ(c0098.f1363, c0098.f1364));
        }
        return new C3339(this, str, r4, 1);
    }
}
