package o;

import android.app.job.JobInfo;
import android.app.job.JobScheduler;
import android.content.ClipDescription;
import android.content.ComponentName;
import android.content.Context;
import android.database.Cursor;
import android.net.ConnectivityManager;
import android.net.Network;
import android.net.NetworkCapabilities;
import android.net.NetworkRequest;
import android.net.Uri;
import android.os.Bundle;
import android.os.Handler;
import android.os.LocaleList;
import android.os.PersistableBundle;
import android.os.Trace;
import android.text.Editable;
import android.text.Selection;
import android.text.TextPaint;
import android.util.Base64;
import android.util.Log;
import android.util.SparseArray;
import android.view.KeyEvent;
import android.view.View;
import android.view.ViewGroup;
import androidx.lifecycle.LifecycleService;
import androidx.recyclerview.widget.RecyclerView;
import androidx.work.impl.WorkDatabase_Impl;
import com.google.android.datatransport.runtime.scheduling.jobscheduling.JobInfoSchedulerService;
import com.google.android.gms.common.ConnectionResult;
import com.google.android.gms.common.R;
import com.google.firebase.messaging.FirebaseMessagingService;
import java.io.ByteArrayOutputStream;
import java.net.URLEncoder;
import java.nio.ByteBuffer;
import java.nio.charset.Charset;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.Set;
import java.util.UUID;
import java.util.WeakHashMap;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.TimeUnit;
import java.util.zip.Adler32;

/* compiled from: r8-map-id-3b7cc9102578c509342fa2f0fabed2bfc72239cd258d579fc679bfcbc198b048 */
/* renamed from: o.zm0, reason: case insensitive filesystem */
/* loaded from: classes.dex */
public final class C3126zm0 implements F2, E2, InterfaceC2956xx, AH, InterfaceC0810bS, Y30, InterfaceC3051yx {
    public static volatile C3126zm0 p;
    public static final Object q = new Object();
    public static final C0195Hn r = new C0195Hn(0);
    public static final C0347Nk s = new C0347Nk(1);
    public final /* synthetic */ int l;
    public Object m;
    public Object n;

    /* renamed from: o, reason: collision with root package name */
    public Object f831o;

    public /* synthetic */ C3126zm0(int i, boolean z) {
        this.l = i;
    }

    public static C3126zm0 B(Context context) {
        if (p == null) {
            synchronized (q) {
                try {
                    if (p == null) {
                        p = new C3126zm0(context, 1);
                    }
                } finally {
                }
            }
        }
        return p;
    }

    public static final void g(C3126zm0 c3126zm0, Network network, boolean z) {
        Oh0 oh0;
        boolean z2;
        Network[] allNetworks = ((ConnectivityManager) c3126zm0.m).getAllNetworks();
        int length = allNetworks.length;
        boolean z3 = false;
        int i = 0;
        while (true) {
            if (i >= length) {
                break;
            }
            Network network2 = allNetworks[i];
            if (F3.c(network2, network)) {
                z2 = z;
            } else {
                NetworkCapabilities networkCapabilities = ((ConnectivityManager) c3126zm0.m).getNetworkCapabilities(network2);
                z2 = networkCapabilities != null && networkCapabilities.hasCapability(12);
            }
            if (z2) {
                z3 = true;
                break;
            }
            i++;
        }
        ComponentCallbacks2C1301gc0 componentCallbacks2C1301gc0 = (ComponentCallbacks2C1301gc0) c3126zm0.n;
        if (((C2961y00) componentCallbacks2C1301gc0.m.get()) != null) {
            componentCallbacks2C1301gc0.f541o = z3;
            oh0 = Oh0.a;
        } else {
            oh0 = null;
        }
        if (oh0 == null) {
            componentCallbacks2C1301gc0.a();
        }
    }

    public static final void n() {
        if (Za0.P(Thread.currentThread().getName(), "Firebase Background Thread #", false)) {
            return;
        }
        Thread.currentThread().getName();
        Log.isLoggable("FirebaseCrashlytics", 3);
    }

    public static final void o() {
        if (Za0.P(Thread.currentThread().getName(), "Firebase Blocking Thread #", false)) {
            return;
        }
        Thread.currentThread().getName();
        Log.isLoggable("FirebaseCrashlytics", 3);
    }

    public static String p(String str, HashMap map) {
        StringBuilder sb = new StringBuilder();
        Iterator it = map.entrySet().iterator();
        Map.Entry entry = (Map.Entry) it.next();
        sb.append((String) entry.getKey());
        sb.append("=");
        sb.append(entry.getValue() != null ? URLEncoder.encode((String) entry.getValue(), "UTF-8") : "");
        while (it.hasNext()) {
            Map.Entry entry2 = (Map.Entry) it.next();
            sb.append("&");
            sb.append((String) entry2.getKey());
            sb.append("=");
            sb.append(entry2.getValue() != null ? URLEncoder.encode((String) entry2.getValue(), "UTF-8") : "");
        }
        String string = sb.toString();
        if (string.isEmpty()) {
            return str;
        }
        if (str.contains("?")) {
            if (!str.endsWith("&")) {
                string = "&".concat(string);
            }
            return AbstractC2462sn.i(str, string);
        }
        return str + "?" + string;
    }

    public static boolean q(Editable editable, KeyEvent keyEvent, boolean z) {
        C2736vh0[] c2736vh0Arr;
        if (KeyEvent.metaStateHasNoModifiers(keyEvent.getMetaState())) {
            int selectionStart = Selection.getSelectionStart(editable);
            int selectionEnd = Selection.getSelectionEnd(editable);
            if (selectionStart != -1 && selectionEnd != -1 && selectionStart == selectionEnd && (c2736vh0Arr = (C2736vh0[]) editable.getSpans(selectionStart, selectionEnd, C2736vh0.class)) != null && c2736vh0Arr.length > 0) {
                for (C2736vh0 c2736vh0 : c2736vh0Arr) {
                    int spanStart = editable.getSpanStart(c2736vh0);
                    int spanEnd = editable.getSpanEnd(c2736vh0);
                    if ((z && spanStart == selectionStart) || ((!z && spanEnd == selectionStart) || (selectionStart > spanStart && selectionStart < spanEnd))) {
                        editable.delete(spanStart, spanEnd);
                        return true;
                    }
                }
            }
        }
        return false;
    }

    public C2138pM A() {
        LocaleList localeList = LocaleList.getDefault();
        synchronized (((BP) this.f831o)) {
            try {
                C2138pM c2138pM = (C2138pM) this.n;
                if (c2138pM != null && localeList == ((LocaleList) this.m)) {
                    return c2138pM;
                }
                int size = localeList.size();
                ArrayList arrayList = new ArrayList(size);
                for (int i = 0; i < size; i++) {
                    arrayList.add(new C2043oM(localeList.get(i)));
                }
                C2138pM c2138pM2 = new C2138pM(arrayList);
                this.m = localeList;
                this.n = c2138pM2;
                return c2138pM2;
            } catch (Throwable th) {
                throw th;
            }
        }
    }

    public int C(int i) {
        C0189Hh c0189Hh = (C0189Hh) this.n;
        if (i < 0) {
            return -1;
        }
        int childCount = ((W00) this.m).a.getChildCount();
        int i2 = i;
        while (i2 < childCount) {
            int iC = i - (i2 - c0189Hh.c(i2));
            if (iC == 0) {
                while (c0189Hh.f(i2)) {
                    i2++;
                }
                return i2;
            }
            i2 += iC;
        }
        return -1;
    }

    public long D() {
        return ((C3113zg) this.f831o).l.d;
    }

    public View E(int i) {
        return ((W00) this.m).a.getChildAt(i);
    }

    public int F() {
        return ((W00) this.m).a.getChildCount();
    }

    /* JADX WARN: Multi-variable type inference failed */
    /* JADX WARN: Removed duplicated region for block: B:35:0x00ba  */
    /* JADX WARN: Removed duplicated region for block: B:38:0x00c9  */
    /* JADX WARN: Type inference failed for: r0v117 */
    /* JADX WARN: Type inference failed for: r0v166 */
    /* JADX WARN: Type inference failed for: r0v167 */
    /* JADX WARN: Type inference failed for: r0v91, types: [int] */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
        To view partially-correct add '--show-bad-code' argument
    */
    public boolean G() throws org.json.JSONException, android.content.pm.PackageManager.NameNotFoundException {
        /*
            Method dump skipped, instructions count: 1237
            To view this dump add '--comments-level debug' option
        */
        throw new UnsupportedOperationException("Method not decompiled: o.C3126zm0.G():boolean");
    }

    public boolean H(CharSequence charSequence, int i, int i2, C2641uh0 c2641uh0) {
        if ((c2641uh0.c & 3) == 0) {
            InterfaceC1719kv interfaceC1719kv = (InterfaceC1719kv) this.f831o;
            C2995yP c2995yPB = c2641uh0.b();
            int iA = c2995yPB.a(8);
            if (iA != 0) {
                ((ByteBuffer) c2995yPB.f756o).getShort(iA + c2995yPB.l);
            }
            C0638Yp c0638Yp = (C0638Yp) interfaceC1719kv;
            c0638Yp.getClass();
            ThreadLocal threadLocal = C0638Yp.b;
            if (threadLocal.get() == null) {
                threadLocal.set(new StringBuilder());
            }
            StringBuilder sb = (StringBuilder) threadLocal.get();
            sb.setLength(0);
            while (i < i2) {
                sb.append(charSequence.charAt(i));
                i++;
            }
            TextPaint textPaint = c0638Yp.a;
            String string = sb.toString();
            int i3 = AbstractC2716vV.a;
            boolean zHasGlyph = textPaint.hasGlyph(string);
            int i4 = c2641uh0.c & 4;
            c2641uh0.c = zHasGlyph ? i4 | 2 : i4 | 1;
        }
        return (c2641uh0.c & 3) == 2;
    }

    public void I(String str, String str2) {
        ((HashMap) this.f831o).put(str, str2);
    }

    public void J(View view) {
        ((ArrayList) this.f831o).add(view);
        W00 w00 = (W00) this.m;
        AbstractC2488t10 abstractC2488t10I = RecyclerView.I(view);
        if (abstractC2488t10I != null) {
            View view2 = abstractC2488t10I.a;
            RecyclerView recyclerView = w00.a;
            int i = abstractC2488t10I.q;
            if (i != -1) {
                abstractC2488t10I.p = i;
            } else {
                WeakHashMap weakHashMap = Oj0.a;
                abstractC2488t10I.p = view2.getImportantForAccessibility();
            }
            if (recyclerView.L()) {
                abstractC2488t10I.q = 4;
                recyclerView.A0.add(abstractC2488t10I);
            } else {
                WeakHashMap weakHashMap2 = Oj0.a;
                view2.setImportantForAccessibility(4);
            }
        }
    }

    public boolean K() {
        return !(((S90) ((C0247Jn) this.m).m).isEmpty() && ((S90) ((C0247Jn) this.f831o).m).isEmpty() && ((S90) ((C0247Jn) this.n).m).isEmpty());
    }

    public boolean L(int i, C0167Gl c0167Gl, C0530Ul c0530Ul) {
        C1778ld c1778ld = (C1778ld) this.n;
        int[] iArr = c0530Ul.p0;
        int[] iArr2 = c0530Ul.t;
        c1778ld.a = iArr[0];
        c1778ld.b = iArr[1];
        c1778ld.c = c0530Ul.q();
        c1778ld.d = c0530Ul.k();
        c1778ld.i = false;
        c1778ld.j = i;
        boolean z = c1778ld.a == 3;
        boolean z2 = c1778ld.b == 3;
        boolean z3 = z && c0530Ul.W > 0.0f;
        boolean z4 = z2 && c0530Ul.W > 0.0f;
        if (z3 && iArr2[0] == 4) {
            c1778ld.a = 1;
        }
        if (z4 && iArr2[1] == 4) {
            c1778ld.b = 1;
        }
        c0167Gl.b(c0530Ul, c1778ld);
        c0530Ul.O(c1778ld.e);
        c0530Ul.L(c1778ld.f);
        c0530Ul.E = c1778ld.h;
        c0530Ul.I(c1778ld.g);
        c1778ld.j = 0;
        return c1778ld.i;
    }

    public void M(UK uk) {
        RunnableC0016Aq runnableC0016Aq = (RunnableC0016Aq) this.f831o;
        if (runnableC0016Aq != null) {
            runnableC0016Aq.run();
        }
        RunnableC0016Aq runnableC0016Aq2 = new RunnableC0016Aq((C1089eL) this.m, uk);
        this.f831o = runnableC0016Aq2;
        ((Handler) this.n).postAtFrontOfQueue(runnableC0016Aq2);
    }

    public Object N(CharSequence charSequence, int i, int i2, int i3, boolean z, InterfaceC3048yv interfaceC3048yv) {
        int i4;
        char c;
        C0021Av c0021Av = new C0021Av((AP) ((C2062oc0) this.n).c);
        int iCodePointAt = Character.codePointAt(charSequence, i);
        int i5 = 0;
        boolean zF = true;
        int iCharCount = i;
        loop0: while (true) {
            i4 = iCharCount;
            while (iCharCount < i2 && i5 < i3 && zF) {
                SparseArray sparseArray = c0021Av.c.a;
                AP ap = sparseArray == null ? null : (AP) sparseArray.get(iCodePointAt);
                if (c0021Av.a == 2) {
                    if (ap != null) {
                        c0021Av.c = ap;
                        c0021Av.f++;
                    } else {
                        if (iCodePointAt == 65038) {
                            c0021Av.a();
                        } else if (iCodePointAt != 65039) {
                            AP ap2 = c0021Av.c;
                            if (ap2.b != null) {
                                if (c0021Av.f != 1) {
                                    c0021Av.d = ap2;
                                    c0021Av.a();
                                } else if (c0021Av.b()) {
                                    c0021Av.d = c0021Av.c;
                                    c0021Av.a();
                                } else {
                                    c0021Av.a();
                                }
                                c = 3;
                            } else {
                                c0021Av.a();
                            }
                        }
                        c = 1;
                    }
                    c = 2;
                } else if (ap == null) {
                    c0021Av.a();
                    c = 1;
                } else {
                    c0021Av.a = 2;
                    c0021Av.c = ap;
                    c0021Av.f = 1;
                    c = 2;
                }
                c0021Av.e = iCodePointAt;
                if (c == 1) {
                    iCharCount = Character.charCount(Character.codePointAt(charSequence, i4)) + i4;
                    if (iCharCount < i2) {
                        iCodePointAt = Character.codePointAt(charSequence, iCharCount);
                    }
                } else if (c == 2) {
                    int iCharCount2 = Character.charCount(iCodePointAt) + iCharCount;
                    if (iCharCount2 < i2) {
                        iCodePointAt = Character.codePointAt(charSequence, iCharCount2);
                    }
                    iCharCount = iCharCount2;
                } else if (c == 3) {
                    if (z || !H(charSequence, i4, iCharCount, c0021Av.d.b)) {
                        zF = interfaceC3048yv.f(charSequence, i4, iCharCount, c0021Av.d.b);
                        i5++;
                    }
                }
            }
            break loop0;
        }
        if (c0021Av.a == 2 && c0021Av.c.b != null && ((c0021Av.f > 1 || c0021Av.b()) && i5 < i3 && zF && (z || !H(charSequence, i4, iCharCount, c0021Av.c.b)))) {
            interfaceC3048yv.f(charSequence, i4, iCharCount, c0021Av.c.b);
        }
        return interfaceC3048yv.getResult();
    }

    public void O(C2156pc c2156pc, int i, boolean z) {
        C1396hc c1396hc = (C1396hc) this.f831o;
        Context context = (Context) this.m;
        ComponentName componentName = new ComponentName(context, (Class<?>) JobInfoSchedulerService.class);
        JobScheduler jobScheduler = (JobScheduler) context.getSystemService("jobscheduler");
        Adler32 adler32 = new Adler32();
        adler32.update(context.getPackageName().getBytes(Charset.forName("UTF-8")));
        String str = c2156pc.a;
        String str2 = c2156pc.a;
        adler32.update(str.getBytes(Charset.forName("UTF-8")));
        ByteBuffer byteBufferAllocate = ByteBuffer.allocate(4);
        HY hy = c2156pc.c;
        adler32.update(byteBufferAllocate.putInt(JY.a(hy)).array());
        byte[] bArr = c2156pc.b;
        if (bArr != null) {
            adler32.update(bArr);
        }
        int value = (int) adler32.getValue();
        if (!z) {
            Iterator<JobInfo> it = jobScheduler.getAllPendingJobs().iterator();
            while (true) {
                if (!it.hasNext()) {
                    break;
                }
                JobInfo next = it.next();
                int i2 = next.getExtras().getInt("attemptNumber");
                if (next.getId() == value) {
                    if (i2 >= i) {
                        IJ.j("JobInfoScheduler", "Upload for context %s is already scheduled. Returning...", c2156pc);
                        return;
                    }
                }
            }
        }
        Cursor cursorRawQuery = ((L30) ((InterfaceC0463Rw) this.n)).b().rawQuery("SELECT next_request_ms FROM transport_contexts WHERE backend_name = ? and priority = ?", new String[]{str2, String.valueOf(JY.a(hy))});
        try {
            Long lValueOf = cursorRawQuery.moveToNext() ? Long.valueOf(cursorRawQuery.getLong(0)) : 0L;
            cursorRawQuery.close();
            long jLongValue = lValueOf.longValue();
            JobInfo.Builder builder = new JobInfo.Builder(value, componentName);
            builder.setMinimumLatency(c1396hc.a(hy, jLongValue, i));
            Set set = ((C1492ic) c1396hc.b.get(hy)).c;
            if (set.contains(E40.l)) {
                builder.setRequiredNetworkType(2);
            } else {
                builder.setRequiredNetworkType(1);
            }
            if (set.contains(E40.n)) {
                builder.setRequiresCharging(true);
            }
            if (set.contains(E40.m)) {
                builder.setRequiresDeviceIdle(true);
            }
            PersistableBundle persistableBundle = new PersistableBundle();
            persistableBundle.putInt("attemptNumber", i);
            persistableBundle.putString("backendName", str2);
            persistableBundle.putInt("priority", JY.a(hy));
            if (bArr != null) {
                persistableBundle.putString("extras", Base64.encodeToString(bArr, 0));
            }
            builder.setExtras(persistableBundle);
            Object[] objArr = {c2156pc, Integer.valueOf(value), Long.valueOf(c1396hc.a(hy, jLongValue, i)), lValueOf, Integer.valueOf(i)};
            if (Log.isLoggable(IJ.u("JobInfoScheduler"), 3)) {
                String.format("Scheduling upload for context %s with jobId=%d in %dms(Backend next call timestamp %d). Attempt %d", objArr);
            }
            jobScheduler.schedule(builder.build());
        } catch (Throwable th) {
            cursorRawQuery.close();
            throw th;
        }
    }

    public void P(String str) {
        if (str == null) {
            throw new NullPointerException("Null backendName");
        }
        this.m = str;
    }

    public void Q(InterfaceC2923xg interfaceC2923xg) {
        ((C3113zg) this.f831o).l.c = interfaceC2923xg;
    }

    public void R(InterfaceC2281qr interfaceC2281qr) {
        ((C3113zg) this.f831o).l.a = interfaceC2281qr;
    }

    public void S(EnumC1280gK enumC1280gK) {
        ((C3113zg) this.f831o).l.b = enumC1280gK;
    }

    public void T(long j) {
        ((C3113zg) this.f831o).l.d = j;
    }

    public void U(C0556Vl c0556Vl, int i, int i2, int i3) {
        c0556Vl.getClass();
        int i4 = c0556Vl.b0;
        int i5 = c0556Vl.c0;
        c0556Vl.b0 = 0;
        c0556Vl.c0 = 0;
        c0556Vl.O(i2);
        c0556Vl.L(i3);
        if (i4 < 0) {
            c0556Vl.b0 = 0;
        } else {
            c0556Vl.b0 = i4;
        }
        if (i5 < 0) {
            c0556Vl.c0 = 0;
        } else {
            c0556Vl.c0 = i5;
        }
        C0556Vl c0556Vl2 = (C0556Vl) this.f831o;
        c0556Vl2.t0 = i;
        c0556Vl2.U();
    }

    public void V(View view) {
        if (((ArrayList) this.f831o).remove(view)) {
            W00 w00 = (W00) this.m;
            AbstractC2488t10 abstractC2488t10I = RecyclerView.I(view);
            if (abstractC2488t10I != null) {
                RecyclerView recyclerView = w00.a;
                int i = abstractC2488t10I.p;
                if (recyclerView.L()) {
                    abstractC2488t10I.q = i;
                    recyclerView.A0.add(abstractC2488t10I);
                } else {
                    View view2 = abstractC2488t10I.a;
                    WeakHashMap weakHashMap = Oj0.a;
                    view2.setImportantForAccessibility(i);
                }
                abstractC2488t10I.p = 0;
            }
        }
    }

    public void W() {
        ZQ zq = (ZQ) this.m;
        String str = (String) this.n;
        List list = (List) zq.k(str);
        if (list != null) {
            list.remove((NC) this.f831o);
        }
        if (list == null || list.isEmpty()) {
            return;
        }
        zq.m(str, list);
    }

    public void X(C0556Vl c0556Vl) {
        ArrayList arrayList = (ArrayList) this.m;
        arrayList.clear();
        int size = c0556Vl.q0.size();
        for (int i = 0; i < size; i++) {
            C0530Ul c0530Ul = (C0530Ul) c0556Vl.q0.get(i);
            int[] iArr = c0530Ul.p0;
            if (iArr[0] == 3 || iArr[1] == 3) {
                arrayList.add(c0530Ul);
            }
        }
        c0556Vl.s0.b = true;
    }

    @Override // o.AH
    public ClipDescription a() {
        return (ClipDescription) this.n;
    }

    @Override // o.AH
    public Object b() {
        return null;
    }

    @Override // o.AH
    public Uri c() {
        return (Uri) this.m;
    }

    @Override // o.AH
    public Uri e() {
        return (Uri) this.f831o;
    }

    @Override // o.InterfaceC0810bS
    public boolean f() {
        ConnectivityManager connectivityManager = (ConnectivityManager) this.m;
        for (Network network : connectivityManager.getAllNetworks()) {
            NetworkCapabilities networkCapabilities = connectivityManager.getNetworkCapabilities(network);
            if (networkCapabilities != null && networkCapabilities.hasCapability(12)) {
                return true;
            }
        }
        return false;
    }

    @Override // o.CZ
    public Object get() {
        switch (this.l) {
            case 16:
                Context context = (Context) ((G0) this.m).m;
                InterfaceC2747vn interfaceC2747vn = (InterfaceC2747vn) ((CZ) this.n).get();
                Z60 z60 = (Z60) ((BZ) this.f831o).get();
                return ME.m(z60, new C2000nt(new S1(7, z60)), C80.e(interfaceC2747vn), new C0626Yd(context, 2));
            default:
                return new C3126zm0((Context) ((CZ) this.m).get(), (InterfaceC0463Rw) ((CZ) this.n).get(), (C1396hc) ((C2616uQ) this.f831o).get(), 21);
        }
    }

    @Override // o.E2
    public void h(Bundle bundle) {
        synchronized (this.n) {
            Objects.toString(bundle);
            Log.isLoggable("FirebaseCrashlytics", 2);
            this.f831o = new CountDownLatch(1);
            ((C0247Jn) this.m).h(bundle);
            Log.isLoggable("FirebaseCrashlytics", 2);
            try {
                if (((CountDownLatch) this.f831o).await(500, TimeUnit.MILLISECONDS)) {
                    Log.isLoggable("FirebaseCrashlytics", 2);
                }
            } catch (InterruptedException unused) {
            }
            this.f831o = null;
        }
    }

    public void i(int i, C2420sK c2420sK) {
        C0247Jn c0247Jn = (C0247Jn) this.m;
        C0247Jn c0247Jn2 = (C0247Jn) this.n;
        C0247Jn c0247Jn3 = (C0247Jn) this.f831o;
        int iW = AbstractC2462sn.w(i);
        if (iW == 0) {
            c0247Jn.a(c2420sK);
            c0247Jn3.a(c2420sK);
            return;
        }
        if (iW == 1) {
            c0247Jn2.a(c2420sK);
            c0247Jn3.a(c2420sK);
            return;
        }
        if (iW == 2) {
            if (c2420sK.r != null) {
                c0247Jn3.a(c2420sK);
                return;
            } else {
                c0247Jn.a(c2420sK);
                return;
            }
        }
        if (iW != 3) {
            throw new C2170pj();
        }
        if (c2420sK.r != null) {
            c0247Jn3.a(c2420sK);
        } else {
            c0247Jn2.a(c2420sK);
        }
    }

    public void j(String str, String str2) {
        byte[] bytes = str2.getBytes(AbstractC2355rh.a);
        int length = bytes.length;
        AbstractC2264qi0.c(bytes.length, 0, length);
        ((ArrayList) this.f831o).add(IJ.i(str, null, new C1636k20(null, length, bytes)));
    }

    public void k(View view, int i, boolean z) {
        RecyclerView recyclerView = ((W00) this.m).a;
        int childCount = i < 0 ? recyclerView.getChildCount() : C(i);
        ((C0189Hh) this.n).g(childCount, z);
        if (z) {
            J(view);
        }
        recyclerView.addView(view, childCount);
        RecyclerView.I(view);
    }

    public void l(View view, int i, ViewGroup.LayoutParams layoutParams, boolean z) {
        RecyclerView recyclerView = ((W00) this.m).a;
        int childCount = i < 0 ? recyclerView.getChildCount() : C(i);
        ((C0189Hh) this.n).g(childCount, z);
        if (z) {
            J(view);
        }
        AbstractC2488t10 abstractC2488t10I = RecyclerView.I(view);
        if (abstractC2488t10I != null) {
            if (!abstractC2488t10I.j() && !abstractC2488t10I.o()) {
                throw new IllegalArgumentException("Called attach on a child which is not detached: " + abstractC2488t10I + recyclerView.y());
            }
            abstractC2488t10I.j &= -257;
        }
        recyclerView.attachViewToParent(view, childCount, layoutParams);
    }

    public C2156pc m() {
        String strConcat = ((String) this.m) == null ? " backendName" : "";
        if (((HY) this.f831o) == null) {
            strConcat = strConcat.concat(" priority");
        }
        if (strConcat.isEmpty()) {
            return new C2156pc((String) this.m, (byte[]) this.n, (HY) this.f831o);
        }
        throw new IllegalStateException("Missing required properties:".concat(strConcat));
    }

    @Override // o.F2
    public void r(String str, Bundle bundle) {
        CountDownLatch countDownLatch = (CountDownLatch) this.f831o;
        if (countDownLatch != null && "_ae".equals(str)) {
            countDownLatch.countDown();
        }
    }

    public void s(int i) {
        AbstractC2488t10 abstractC2488t10I;
        int iC = C(i);
        ((C0189Hh) this.n).j(iC);
        RecyclerView recyclerView = ((W00) this.m).a;
        View childAt = recyclerView.getChildAt(iC);
        if (childAt != null && (abstractC2488t10I = RecyclerView.I(childAt)) != null) {
            if (abstractC2488t10I.j() && !abstractC2488t10I.o()) {
                throw new IllegalArgumentException("called detach on an already detached child " + abstractC2488t10I + recyclerView.y());
            }
            abstractC2488t10I.a(256);
        }
        recyclerView.detachViewFromParent(iC);
    }

    @Override // o.InterfaceC0810bS
    public void shutdown() {
        ((ConnectivityManager) this.m).unregisterNetworkCallback((C1001dS) this.f831o);
    }

    public void t(Bundle bundle) throws ClassNotFoundException {
        HashSet hashSet = (HashSet) this.n;
        String string = ((Context) this.f831o).getString(R.string.androidx_startup);
        if (bundle != null) {
            try {
                HashSet hashSet2 = new HashSet();
                for (String str : bundle.keySet()) {
                    if (string.equals(bundle.getString(str, null))) {
                        Class<?> cls = Class.forName(str);
                        if (InterfaceC1848mH.class.isAssignableFrom(cls)) {
                            hashSet.add(cls);
                        }
                    }
                }
                Iterator it = hashSet.iterator();
                while (it.hasNext()) {
                    u((Class) it.next(), hashSet2);
                }
            } catch (ClassNotFoundException e) {
                throw new C2170pj(e);
            }
        }
    }

    public String toString() {
        switch (this.l) {
            case ConnectionResult.LICENSE_CHECK_FAILED /* 11 */:
                return ((C0189Hh) this.n).toString() + ", hidden list:" + ((ArrayList) this.f831o).size();
            case ConnectionResult.API_DISABLED /* 23 */:
                StringBuilder sb = new StringBuilder(32);
                sb.append((String) this.m);
                sb.append('{');
                Gm0 gm0 = (Gm0) ((Gm0) this.n).n;
                String str = "";
                while (gm0 != null) {
                    Object obj = gm0.m;
                    sb.append(str);
                    if (obj == null || !obj.getClass().isArray()) {
                        sb.append(obj);
                    } else {
                        String strDeepToString = Arrays.deepToString(new Object[]{obj});
                        sb.append((CharSequence) strDeepToString, 1, strDeepToString.length() - 1);
                    }
                    gm0 = (Gm0) gm0.n;
                    str = ", ";
                }
                sb.append('}');
                return sb.toString();
            default:
                return super.toString();
        }
    }

    public Object u(Class cls, HashSet hashSet) {
        Object objB;
        HashMap map = (HashMap) this.m;
        if (AbstractC2798wI.p()) {
            try {
                AbstractC2798wI.f(cls.getSimpleName());
            } catch (Throwable th) {
                Trace.endSection();
                throw th;
            }
        }
        if (hashSet.contains(cls)) {
            throw new IllegalStateException("Cannot initialize " + cls.getName() + ". Cycle detected.");
        }
        if (map.containsKey(cls)) {
            objB = map.get(cls);
        } else {
            hashSet.add(cls);
            try {
                InterfaceC1848mH interfaceC1848mH = (InterfaceC1848mH) cls.getDeclaredConstructor(null).newInstance(null);
                List<Class> listA = interfaceC1848mH.a();
                if (!listA.isEmpty()) {
                    for (Class cls2 : listA) {
                        if (!map.containsKey(cls2)) {
                            u(cls2, hashSet);
                        }
                    }
                }
                objB = interfaceC1848mH.b((Context) this.f831o);
                hashSet.remove(cls);
                map.put(cls, objB);
            } catch (Throwable th2) {
                throw new C2170pj(th2);
            }
        }
        Trace.endSection();
        return objB;
    }

    public void v(Object obj, ByteArrayOutputStream byteArrayOutputStream) {
        HashMap map = (HashMap) this.m;
        C2720vZ c2720vZ = new C2720vZ(byteArrayOutputStream, map, (HashMap) this.n, (InterfaceC0906cT) this.f831o);
        InterfaceC0906cT interfaceC0906cT = (InterfaceC0906cT) map.get(obj.getClass());
        if (interfaceC0906cT != null) {
            interfaceC0906cT.a(obj, c2720vZ);
        } else {
            throw new C0644Yv("No encoder for " + obj.getClass());
        }
    }

    /* JADX WARN: Removed duplicated region for block: B:35:0x00a8  */
    /* JADX WARN: Removed duplicated region for block: B:37:0x00ad  */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
        To view partially-correct add '--show-bad-code' argument
    */
    public o.C1254g2 w() throws java.lang.Throwable {
        /*
            r8 = this;
            o()
            r0 = 0
            java.lang.Object r1 = r8.m     // Catch: java.lang.Throwable -> La3
            java.lang.String r1 = (java.lang.String) r1     // Catch: java.lang.Throwable -> La3
            java.lang.Object r2 = r8.n     // Catch: java.lang.Throwable -> La3
            java.util.HashMap r2 = (java.util.HashMap) r2     // Catch: java.lang.Throwable -> La3
            java.lang.String r1 = p(r1, r2)     // Catch: java.lang.Throwable -> La0
            java.lang.String r2 = "FirebaseCrashlytics"
            r3 = 2
            android.util.Log.isLoggable(r2, r3)     // Catch: java.lang.Throwable -> La3
            java.net.URL r2 = new java.net.URL     // Catch: java.lang.Throwable -> La0
            r2.<init>(r1)     // Catch: java.lang.Throwable -> La0
            java.net.URLConnection r1 = r2.openConnection()     // Catch: java.lang.Throwable -> La0
            javax.net.ssl.HttpsURLConnection r1 = (javax.net.ssl.HttpsURLConnection) r1     // Catch: java.lang.Throwable -> La0
            r2 = 10000(0x2710, float:1.4013E-41)
            r1.setReadTimeout(r2)     // Catch: java.lang.Throwable -> L56
            r1.setConnectTimeout(r2)     // Catch: java.lang.Throwable -> L56
            java.lang.String r2 = "GET"
            r1.setRequestMethod(r2)     // Catch: java.lang.Throwable -> L56
            java.lang.Object r2 = r8.f831o     // Catch: java.lang.Throwable -> L56
            java.util.HashMap r2 = (java.util.HashMap) r2     // Catch: java.lang.Throwable -> L56
            java.util.Set r2 = r2.entrySet()     // Catch: java.lang.Throwable -> L56
            java.util.Iterator r2 = r2.iterator()     // Catch: java.lang.Throwable -> L56
        L3a:
            boolean r3 = r2.hasNext()     // Catch: java.lang.Throwable -> L56
            if (r3 == 0) goto L58
            java.lang.Object r3 = r2.next()     // Catch: java.lang.Throwable -> L56
            java.util.Map$Entry r3 = (java.util.Map.Entry) r3     // Catch: java.lang.Throwable -> L56
            java.lang.Object r4 = r3.getKey()     // Catch: java.lang.Throwable -> L56
            java.lang.String r4 = (java.lang.String) r4     // Catch: java.lang.Throwable -> L56
            java.lang.Object r3 = r3.getValue()     // Catch: java.lang.Throwable -> L56
            java.lang.String r3 = (java.lang.String) r3     // Catch: java.lang.Throwable -> L56
            r1.addRequestProperty(r4, r3)     // Catch: java.lang.Throwable -> L56
            goto L3a
        L56:
            r2 = move-exception
            goto La6
        L58:
            r1.connect()     // Catch: java.lang.Throwable -> L56
            int r2 = r1.getResponseCode()     // Catch: java.lang.Throwable -> L56
            java.io.InputStream r3 = r1.getInputStream()     // Catch: java.lang.Throwable -> L56
            if (r3 == 0) goto L91
            java.io.BufferedReader r0 = new java.io.BufferedReader     // Catch: java.lang.Throwable -> L8d
            java.io.InputStreamReader r4 = new java.io.InputStreamReader     // Catch: java.lang.Throwable -> L8d
            java.lang.String r5 = "UTF-8"
            r4.<init>(r3, r5)     // Catch: java.lang.Throwable -> L8d
            r0.<init>(r4)     // Catch: java.lang.Throwable -> L8d
            r4 = 8192(0x2000, float:1.148E-41)
            char[] r4 = new char[r4]     // Catch: java.lang.Throwable -> L8d
            java.lang.StringBuilder r5 = new java.lang.StringBuilder     // Catch: java.lang.Throwable -> L8d
            r5.<init>()     // Catch: java.lang.Throwable -> L8d
        L7a:
            int r6 = r0.read(r4)     // Catch: java.lang.Throwable -> L8d
            r7 = -1
            if (r6 == r7) goto L86
            r7 = 0
            r5.append(r4, r7, r6)     // Catch: java.lang.Throwable -> L8d
            goto L7a
        L86:
            java.lang.String r0 = r5.toString()     // Catch: java.lang.Throwable -> L8d
            goto L91
        L8b:
            r2 = r0
            goto L8f
        L8d:
            r0 = move-exception
            goto L8b
        L8f:
            r0 = r3
            goto La6
        L91:
            if (r3 == 0) goto L96
            r3.close()
        L96:
            r1.disconnect()
            o.g2 r1 = new o.g2
            r3 = 3
            r1.<init>(r2, r0, r3)
            return r1
        La0:
            r2 = move-exception
        La1:
            r1 = r0
            goto La6
        La3:
            r1 = move-exception
            r2 = r1
            goto La1
        La6:
            if (r0 == 0) goto Lab
            r0.close()
        Lab:
            if (r1 == 0) goto Lb0
            r1.disconnect()
        Lb0:
            throw r2
        */
        throw new UnsupportedOperationException("Method not decompiled: o.C3126zm0.w():o.g2");
    }

    public InterfaceC2923xg x() {
        return ((C3113zg) this.f831o).l.c;
    }

    public View y(int i) {
        return ((W00) this.m).a.getChildAt(C(i));
    }

    public int z() {
        return ((W00) this.m).a.getChildCount() - ((ArrayList) this.f831o).size();
    }

    public /* synthetic */ C3126zm0(Object obj, Object obj2, Object obj3, int i) {
        this.l = i;
        this.m = obj;
        this.n = obj2;
        this.f831o = obj3;
    }

    public C3126zm0(LifecycleService lifecycleService) {
        this.l = 29;
        this.m = new C1089eL(lifecycleService);
        this.n = new Handler();
    }

    public C3126zm0(ExecutorService executorService, ExecutorService executorService2) {
        this.l = 3;
        this.m = new ExecutorC0014Ao(executorService);
        this.n = new ExecutorC0014Ao(executorService);
        AbstractC0752ap.K(null);
        this.f831o = new ExecutorC0014Ao(executorService2);
    }

    public C3126zm0(WorkDatabase_Impl workDatabase_Impl) {
        this.l = 0;
        this.m = workDatabase_Impl;
        new C2945xr(workDatabase_Impl, 4);
        this.n = new C1967nc0(workDatabase_Impl, 2);
        this.f831o = new C1967nc0(workDatabase_Impl, 3);
    }

    public C3126zm0(String str, HashMap map) {
        this.l = 17;
        this.m = str;
        this.n = map;
        this.f831o = new HashMap();
    }

    public C3126zm0(C0247Jn c0247Jn) {
        this.l = 7;
        TimeUnit timeUnit = TimeUnit.MILLISECONDS;
        this.n = new Object();
        this.m = c0247Jn;
    }

    public C3126zm0(int i) {
        this.l = i;
        switch (i) {
            case 13:
                this.m = new C0247Jn(9);
                this.n = new C0247Jn(9);
                this.f831o = new C0247Jn(9);
                break;
            case ConnectionResult.API_DISABLED_FOR_CONNECTION /* 24 */:
                String string = UUID.randomUUID().toString();
                C0135Ff c0135Ff = new C0135Ff(string.getBytes(AbstractC2355rh.a));
                c0135Ff.n = string;
                this.m = c0135Ff;
                this.n = EQ.m;
                this.f831o = new ArrayList();
                break;
            default:
                this.f831o = new BP(18);
                break;
        }
    }

    @Override // o.AH
    public void d() {
    }

    public C3126zm0(W00 w00) {
        this.l = 11;
        this.m = w00;
        this.n = new C0189Hh();
        this.f831o = new ArrayList();
    }

    public C3126zm0(C1533iy c1533iy) {
        this.l = 2;
        this.n = null;
        this.f831o = null;
        this.m = c1533iy;
    }

    public C3126zm0(FirebaseMessagingService firebaseMessagingService, C0247Jn c0247Jn, ExecutorService executorService) {
        this.l = 14;
        this.m = executorService;
        this.n = firebaseMessagingService;
        this.f831o = c0247Jn;
    }

    public C3126zm0(View view) {
        this.l = 20;
        this.m = view;
        this.n = AbstractC2001nt0.y(3, new U4(12, this));
        this.f831o = new WT(view);
    }

    public C3126zm0(C3113zg c3113zg) {
        this.l = 9;
        this.f831o = c3113zg;
        this.m = new OD(20, this);
    }

    public C3126zm0(ConnectivityManager connectivityManager, ComponentCallbacks2C1301gc0 componentCallbacks2C1301gc0) {
        this.l = 26;
        this.m = connectivityManager;
        this.n = componentCallbacks2C1301gc0;
        C1001dS c1001dS = new C1001dS(1, this);
        this.f831o = c1001dS;
        connectivityManager.registerNetworkCallback(new NetworkRequest.Builder().addCapability(12).build(), c1001dS);
    }

    public C3126zm0(Context context, int i) {
        this.l = i;
        switch (i) {
            case ConnectionResult.SERVICE_UPDATING /* 18 */:
                this.m = context.getApplicationContext();
                this.n = AbstractC1249g.a;
                this.f831o = new J7(25);
                break;
            default:
                this.f831o = context.getApplicationContext();
                this.n = new HashSet();
                this.m = new HashMap();
                break;
        }
    }

    public C3126zm0(C0556Vl c0556Vl) {
        this.l = 6;
        this.m = new ArrayList();
        this.n = new C1778ld();
        this.f831o = c0556Vl;
    }

    public C3126zm0(C2062oc0 c2062oc0, C0688a6 c0688a6, C0638Yp c0638Yp, Set set) {
        this.l = 15;
        this.m = c0688a6;
        this.n = c2062oc0;
        this.f831o = c0638Yp;
        if (set.isEmpty()) {
            return;
        }
        Iterator it = set.iterator();
        while (it.hasNext()) {
            int[] iArr = (int[]) it.next();
            String str = new String(iArr, 0, iArr.length);
            N(str, 0, str.length(), 1, true, new C2943xq(str, 1));
        }
    }

    public C3126zm0(String str) {
        this.l = 23;
        Gm0 gm0 = new Gm0(7, false);
        this.n = gm0;
        this.f831o = gm0;
        this.m = str;
    }
}
