package o;

import android.content.Context;
import android.util.Log;
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.NavigableSet;
import java.util.Stack;
import java.util.concurrent.Callable;
import java.util.concurrent.atomic.AtomicReference;

/* compiled from: r8-map-id-3b7cc9102578c509342fa2f0fabed2bfc72239cd258d579fc679bfcbc198b048 */
/* renamed from: o.Kn, reason: case insensitive filesystem */
/* loaded from: classes.dex */
public final class CallableC0273Kn implements Callable {
    public final /* synthetic */ long a;
    public final /* synthetic */ Throwable b;
    public final /* synthetic */ Thread c;
    public final /* synthetic */ C0598Xb d;
    public final /* synthetic */ C0324Mn e;

    public CallableC0273Kn(C0324Mn c0324Mn, long j, Throwable th, Thread thread, C0598Xb c0598Xb) {
        this.e = c0324Mn;
        this.a = j;
        this.b = th;
        this.c = thread;
        this.d = c0598Xb;
    }

    @Override // java.util.concurrent.Callable
    public final Object call() throws Throwable {
        Iterator<Map.Entry<Thread, StackTraceElement[]>> it;
        long j = this.a;
        long j2 = j / 1000;
        C0324Mn c0324Mn = this.e;
        NavigableSet navigableSetC = ((C2939xo) c0324Mn.m.n).c();
        Boolean bool = null;
        String str = !navigableSetC.isEmpty() ? (String) navigableSetC.first() : null;
        if (str == null) {
            return AbstractC0752ap.K(null);
        }
        DH dh = c0324Mn.c;
        dh.getClass();
        try {
            C1533iy c1533iy = (C1533iy) dh.m;
            String str2 = (String) dh.l;
            c1533iy.getClass();
            new File((File) c1533iy.n, str2).createNewFile();
        } catch (IOException unused) {
        }
        U7 u7 = c0324Mn.m;
        u7.getClass();
        Log.isLoggable("FirebaseCrashlytics", 2);
        C2749vo c2749vo = (C2749vo) u7.m;
        Context context = c2749vo.a;
        int i = context.getResources().getConfiguration().orientation;
        C3031ym0 c3031ym0 = c2749vo.d;
        Stack stack = new Stack();
        for (Throwable cause = this.b; cause != null; cause = cause.getCause()) {
            stack.push(cause);
        }
        C2062oc0 c2062oc0 = null;
        while (!stack.isEmpty()) {
            Throwable th = (Throwable) stack.pop();
            c2062oc0 = new C2062oc0(th.getLocalizedMessage(), th.getClass().getName(), c3031ym0.d(th.getStackTrace()), c2062oc0);
            stack = stack;
            i = i;
            bool = bool;
        }
        Boolean bool2 = bool;
        int i2 = i;
        C2059ob c2059ob = new C2059ob();
        c2059ob.b = "crash";
        c2059ob.a = j2;
        c2059ob.g = (byte) (c2059ob.g | 1);
        AbstractC1610jo abstractC1610joH = C0669Zu.R.h(context);
        int i3 = ((C3103zb) abstractC1610joH).c;
        Boolean boolValueOf = i3 > 0 ? Boolean.valueOf(i3 != 100) : bool2;
        ArrayList arrayListG = C0669Zu.g(context);
        byte b = (byte) 1;
        ArrayList arrayList = new ArrayList();
        StackTraceElement[] stackTraceElementArr = (StackTraceElement[]) c2062oc0.c;
        Thread thread = this.c;
        String name = thread.getName();
        if (name == null) {
            throw new NullPointerException("Null name");
        }
        byte b2 = (byte) 1;
        List listD = C2749vo.d(stackTraceElementArr, 4);
        if (listD == null) {
            throw new NullPointerException("Null frames");
        }
        String str3 = str;
        if (b2 != 1) {
            StringBuilder sb = new StringBuilder();
            if (b2 == 0) {
                sb.append(" importance");
            }
            throw new IllegalStateException(AbstractC2462sn.k("Missing required properties:", sb));
        }
        arrayList.add(new C2723vb(name, 4, listD));
        Iterator<Map.Entry<Thread, StackTraceElement[]>> it2 = Thread.getAllStackTraces().entrySet().iterator();
        while (it2.hasNext()) {
            Map.Entry<Thread, StackTraceElement[]> next = it2.next();
            Thread key = next.getKey();
            if (key.equals(thread)) {
                it = it2;
            } else {
                StackTraceElement[] stackTraceElementArrD = c3031ym0.d(next.getValue());
                String name2 = key.getName();
                if (name2 == null) {
                    throw new NullPointerException("Null name");
                }
                List listD2 = C2749vo.d(stackTraceElementArrD, 0);
                if (listD2 == null) {
                    throw new NullPointerException("Null frames");
                }
                if (b2 != 1) {
                    StringBuilder sb2 = new StringBuilder();
                    if (b2 == 0) {
                        sb2.append(" importance");
                    }
                    throw new IllegalStateException(AbstractC2462sn.k("Missing required properties:", sb2));
                }
                it = it2;
                arrayList.add(new C2723vb(name2, 0, listD2));
            }
            it2 = it;
        }
        List listUnmodifiableList = Collections.unmodifiableList(arrayList);
        C2533tb c2533tbC = C2749vo.c(c2062oc0, 0);
        C2628ub c2628ubE = C2749vo.e();
        List listA = c2749vo.a();
        if (listA == null) {
            throw new NullPointerException("Null binaries");
        }
        C2343rb c2343rb = new C2343rb(listUnmodifiableList, c2533tbC, null, c2628ubE, listA);
        if (b != 1) {
            StringBuilder sb3 = new StringBuilder();
            if (b == 0) {
                sb3.append(" uiOrientation");
            }
            throw new IllegalStateException(AbstractC2462sn.k("Missing required properties:", sb3));
        }
        c2059ob.c = new C2249qb(c2343rb, null, null, boolValueOf, abstractC1610joH, arrayListG, i2);
        c2059ob.d = c2749vo.b(i2);
        C2154pb c2154pbA = c2059ob.a();
        C1390hY c1390hY = (C1390hY) u7.p;
        Zf0 zf0 = (Zf0) u7.q;
        ((C2939xo) u7.n).d(U7.i(U7.h(c2154pbA, c1390hY, zf0, C0358Nv.l), zf0), str3, true);
        try {
            C1533iy c1533iy2 = c0324Mn.g;
            String str4 = ".ae" + j;
            c1533iy2.getClass();
            if (!new File((File) c1533iy2.n, str4).createNewFile()) {
                throw new IOException("Create new file failed.");
            }
        } catch (IOException unused2) {
        }
        C0598Xb c0598Xb = this.d;
        c0324Mn.b(false, c0598Xb, false);
        c0324Mn.c(new C0213If().a, Boolean.FALSE);
        return !c0324Mn.b.a() ? AbstractC0752ap.K(bool2) : ((Qc0) ((AtomicReference) c0598Xb.i).get()).a.i((ExecutorC0014Ao) c0324Mn.e.m, new C0247Jn(0, this, str3));
    }
}
