package defpackage;

import android.content.Context;
import android.util.Log;
import j$.util.DesugarCollections;
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
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;

/* JADX INFO: renamed from: ᵕᵟʤʼ, reason: contains not printable characters */
/* JADX INFO: loaded from: classes3.dex */
public final class CallableC2337 implements Callable {

    /* JADX INFO: renamed from: ʽˈˋ, reason: contains not printable characters */
    public final /* synthetic */ Throwable f9186;

    /* JADX INFO: renamed from: ːˏᵟᵯ, reason: contains not printable characters */
    public final /* synthetic */ Thread f9187;

    /* JADX INFO: renamed from: ᵨᵣ, reason: contains not printable characters */
    public final /* synthetic */ C3938 f9188;

    /* JADX INFO: renamed from: ᵲᵶᵳˈ, reason: contains not printable characters */
    public final /* synthetic */ long f9189;

    /* JADX INFO: renamed from: ᵷᵺʾᵖ, reason: contains not printable characters */
    public final /* synthetic */ C3420 f9190;

    public CallableC2337(C3938 c3938, long j, Throwable th, Thread thread, C3420 c3420) {
        this.f9188 = c3938;
        this.f9189 = j;
        this.f9186 = th;
        this.f9187 = thread;
        this.f9190 = c3420;
    }

    @Override // java.util.concurrent.Callable
    public final Object call() throws Throwable {
        Iterator<Map.Entry<Thread, StackTraceElement[]>> it;
        long j = this.f9189;
        long j2 = j / 1000;
        C3938 c3938 = this.f9188;
        NavigableSet navigableSetM5474 = ((C2054) c3938.f15043.f10704).m5474();
        String str = !navigableSetM5474.isEmpty() ? (String) navigableSetM5474.first() : null;
        if (str == null) {
            return ᵥˈᵛ.ᵸˆˁ((Object) null);
        }
        ˊˊᵞᵽ r7 = c3938.f15042;
        r7.getClass();
        try {
            ˁᵦ r9 = (ˁᵦ) r7.ᵔᵖᵹᵫ;
            String str2 = (String) r7.ᵜᵪʾ;
            r9.getClass();
            new File((File) r9.ʽˈˋ, str2).createNewFile();
        } catch (IOException unused) {
        }
        C2781 c2781 = c3938.f15043;
        c2781.getClass();
        Log.isLoggable("FirebaseCrashlytics", 2);
        C4564 c4564 = (C4564) c2781.f10705;
        Context context = c4564.f17356;
        int i = context.getResources().getConfiguration().orientation;
        C3714 c3714 = c4564.f17357;
        Stack stack = new Stack();
        for (Throwable cause = this.f9186; cause != null; cause = cause.getCause()) {
            stack.push(cause);
        }
        C4055 c4055 = null;
        while (!stack.isEmpty()) {
            Throwable th = (Throwable) stack.pop();
            c4055 = new C4055(th.getLocalizedMessage(), th.getClass().getName(), c3714.mo3528(th.getStackTrace()), c4055, 2);
        }
        C4055 c40552 = c4055;
        C3887 c3887 = new C3887();
        c3887.f14825 = "crash";
        c3887.f14828 = j2;
        c3887.f14829 = (byte) (c3887.f14829 | 1);
        AbstractC0175 abstractC0175M9231 = C4265.f16270.m9231(context);
        int i2 = ((C2940) abstractC0175M9231).f11329;
        Boolean boolValueOf = i2 > 0 ? Boolean.valueOf(i2 != 100) : null;
        ArrayList arrayListM9230 = C4265.m9230(context);
        ArrayList arrayList = new ArrayList();
        StackTraceElement[] stackTraceElementArr = (StackTraceElement[]) c40552.f15559;
        Thread thread = this.f9187;
        String name = thread.getName();
        if (name == null) {
            C4935.m10233("Null name");
            return null;
        }
        List listM9649 = C4564.m9649(stackTraceElementArr, 4);
        if (listM9649 == null) {
            C4935.m10233("Null frames");
            return null;
        }
        arrayList.add(new C1564(name, 4, listM9649));
        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[] stackTraceElementArrMo3528 = c3714.mo3528(next.getValue());
                String name2 = key.getName();
                if (name2 == null) {
                    C4935.m10233("Null name");
                    return null;
                }
                List listM96492 = C4564.m9649(stackTraceElementArrMo3528, 0);
                if (listM96492 == null) {
                    C4935.m10233("Null frames");
                    return null;
                }
                it = it2;
                arrayList.add(new C1564(name2, 0, listM96492));
            }
            it2 = it;
        }
        List listUnmodifiableList = DesugarCollections.unmodifiableList(arrayList);
        C1490 c1490M9647 = C4564.m9647(c40552, 0);
        C4160 c4160M9648 = C4564.m9648();
        List listM9651 = c4564.m9651();
        if (listM9651 == null) {
            C4935.m10233("Null binaries");
            return null;
        }
        c3887.f14826 = new C3746(new C0858(listUnmodifiableList, c1490M9647, null, c4160M9648, listM9651), null, null, boolValueOf, abstractC0175M9231, arrayListM9230, i);
        c3887.f14830 = c4564.m9650(i);
        C1550 c1550M8591 = c3887.m8591();
        C0767 c0767 = (C0767) c2781.f10707;
        C1356 c1356 = (C1356) c2781.f10708;
        ((C2054) c2781.f10704).m5475(C2781.m6740(C2781.m6746(c1550M8591, c0767, c1356, C2561.f9904), c1356), str, true);
        try {
            ˁᵦ r72 = c3938.f15051;
            String str3 = ".ae" + j;
            r72.getClass();
            if (!new File((File) r72.ʽˈˋ, str3).createNewFile()) {
                throw new IOException("Create new file failed.");
            }
        } catch (IOException unused2) {
        }
        C3420 c3420 = this.f9190;
        c3938.m8670(false, c3420, false);
        c3938.m8671(new C1941().f7725, Boolean.FALSE);
        return !c3938.f15039.ˊᵙᵾᵲ() ? ᵥˈᵛ.ᵸˆˁ((Object) null) : ((C0589) ((AtomicReference) c3420.f13172).get()).f2890.m3824((ExecutorC5381) c3938.f15045.ᵜᵪʾ, new ᵧᵙᵤ(this, str));
    }
}
