package p138.p176.p291.p296.p297.p299;

import android.app.ActivityManager;
import android.content.Context;
import android.os.Build;
import android.os.Environment;
import android.os.StatFs;
import android.text.TextUtils;
import android.util.JsonReader;
import android.util.Log;
import java.io.Closeable;
import java.io.File;
import java.io.FileFilter;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.FilenameFilter;
import java.io.Flushable;
import java.io.IOException;
import java.io.InputStream;
import java.io.StringReader;
import java.io.StringWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.Date;
import java.util.HashSet;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.TreeMap;
import java.util.concurrent.Callable;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.Executor;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.ScheduledThreadPoolExecutor;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import p138.p139.p143.p144.C2803;
import p138.p176.p177.p242.p246.p251.C4303;
import p138.p176.p177.p242.p270.AbstractC5062;
import p138.p176.p177.p242.p270.C5063;
import p138.p176.p177.p242.p270.C5064;
import p138.p176.p177.p242.p270.C5085;
import p138.p176.p177.p242.p270.InterfaceC5061;
import p138.p176.p291.p292.p293.InterfaceC5566;
import p138.p176.p291.p296.p297.C5608;
import p138.p176.p291.p296.p297.C5609;
import p138.p176.p291.p296.p297.InterfaceC5607;
import p138.p176.p291.p296.p297.p298.C5617;
import p138.p176.p291.p296.p297.p298.InterfaceC5619;
import p138.p176.p291.p296.p297.p300.C5701;
import p138.p176.p291.p296.p297.p301.AbstractC5781;
import p138.p176.p291.p296.p297.p301.C5734;
import p138.p176.p291.p296.p297.p301.C5737;
import p138.p176.p291.p296.p297.p301.C5743;
import p138.p176.p291.p296.p297.p301.C5746;
import p138.p176.p291.p296.p297.p301.C5749;
import p138.p176.p291.p296.p297.p301.C5752;
import p138.p176.p291.p296.p297.p301.C5755;
import p138.p176.p291.p296.p297.p301.C5757;
import p138.p176.p291.p296.p297.p301.C5760;
import p138.p176.p291.p296.p297.p301.C5764;
import p138.p176.p291.p296.p297.p301.C5771;
import p138.p176.p291.p296.p297.p301.C5774;
import p138.p176.p291.p296.p297.p301.C5776;
import p138.p176.p291.p296.p297.p301.C5810;
import p138.p176.p291.p296.p297.p301.p302.C5816;
import p138.p176.p291.p296.p297.p303.C5820;
import p138.p176.p291.p296.p297.p304.C5828;
import p138.p176.p291.p296.p297.p304.C5829;
import p138.p176.p291.p296.p297.p305.C5831;
import p138.p176.p291.p296.p297.p305.C5833;
import p138.p176.p291.p296.p297.p305.C5835;
import p138.p176.p291.p296.p297.p306.C5836;
import p138.p176.p291.p296.p297.p306.C5837;
import p138.p176.p291.p296.p297.p306.p307.InterfaceC5844;
import p138.p176.p291.p296.p297.p309.C5853;
import p138.p176.p291.p296.p297.p310.C5857;
import p138.p176.p291.p296.p297.p310.InterfaceC5859;
import p138.p176.p291.p296.p297.p310.p311.C5864;
import p138.p176.p291.p296.p297.p310.p311.InterfaceC5867;
import p138.p176.p291.p296.p297.p313.C5875;
import p138.p176.p291.p296.p297.p313.C5877;
import p138.p176.p291.p296.p297.p313.C5879;
import p138.p176.p291.p296.p297.p313.InterfaceC5878;
import p138.p176.p291.p296.p297.p314.C5880;
import p138.p176.p291.p315.p317.C5892;

/* JADX INFO: renamed from: ދ.ހ.ށ.ބ.ށ.އ.ސ, reason: contains not printable characters */
/* JADX INFO: loaded from: classes.dex */
public class C5642 {

    /* JADX INFO: renamed from: ޖ, reason: contains not printable characters */
    public static final FilenameFilter f16149 = new C5643("BeginSession");

    /* JADX INFO: renamed from: ޗ, reason: contains not printable characters */
    public static final FilenameFilter f16150 = new C5644();

    /* JADX INFO: renamed from: ޘ, reason: contains not printable characters */
    public static final Comparator<File> f16151 = new C5645();

    /* JADX INFO: renamed from: ޙ, reason: contains not printable characters */
    public static final Comparator<File> f16152 = new C5646();

    /* JADX INFO: renamed from: ޚ, reason: contains not printable characters */
    public static final Pattern f16153 = Pattern.compile("([\\d|A-Z|a-z]{12}\\-[\\d|A-Z|a-z]{4}\\-[\\d|A-Z|a-z]{4}\\-[\\d|A-Z|a-z]{12}).+");

    /* JADX INFO: renamed from: ޛ, reason: contains not printable characters */
    public static final Map<String, String> f16154 = Collections.singletonMap("X-CRASHLYTICS-SEND-FLAGS", "1");

    /* JADX INFO: renamed from: ޜ, reason: contains not printable characters */
    public static final String[] f16155 = {"SessionUser", "SessionApp", "SessionOS", "SessionDevice"};

    /* JADX INFO: renamed from: ֏, reason: contains not printable characters */
    public final Context f16156;

    /* JADX INFO: renamed from: ؠ, reason: contains not printable characters */
    public final C5679 f16157;

    /* JADX INFO: renamed from: ހ, reason: contains not printable characters */
    public final C5674 f16158;

    /* JADX INFO: renamed from: ށ, reason: contains not printable characters */
    public final C5693 f16159;

    /* JADX INFO: renamed from: ނ, reason: contains not printable characters */
    public final C5630 f16160;

    /* JADX INFO: renamed from: ރ, reason: contains not printable characters */
    public final C5820 f16161;

    /* JADX INFO: renamed from: ބ, reason: contains not printable characters */
    public final C5685 f16162;

    /* JADX INFO: renamed from: ޅ, reason: contains not printable characters */
    public final C5829 f16163;

    /* JADX INFO: renamed from: ކ, reason: contains not printable characters */
    public final C5622 f16164;

    /* JADX INFO: renamed from: އ, reason: contains not printable characters */
    public final C5837.InterfaceC5839 f16165;

    /* JADX INFO: renamed from: ވ, reason: contains not printable characters */
    public final C5654 f16166;

    /* JADX INFO: renamed from: މ, reason: contains not printable characters */
    public final C5701 f16167;

    /* JADX INFO: renamed from: ފ, reason: contains not printable characters */
    public final C5836 f16168;

    /* JADX INFO: renamed from: ދ, reason: contains not printable characters */
    public final C5837.InterfaceC5838 f16169;

    /* JADX INFO: renamed from: ތ, reason: contains not printable characters */
    public final InterfaceC5607 f16170;

    /* JADX INFO: renamed from: ލ, reason: contains not printable characters */
    public final InterfaceC5878 f16171;

    /* JADX INFO: renamed from: ގ, reason: contains not printable characters */
    public final String f16172;

    /* JADX INFO: renamed from: ޏ, reason: contains not printable characters */
    public final InterfaceC5619 f16173;

    /* JADX INFO: renamed from: ސ, reason: contains not printable characters */
    public final InterfaceC5566 f16174;

    /* JADX INFO: renamed from: ޑ, reason: contains not printable characters */
    public final C5691 f16175;

    /* JADX INFO: renamed from: ޒ, reason: contains not printable characters */
    public C5677 f16176;

    /* JADX INFO: renamed from: ޓ, reason: contains not printable characters */
    public C5063<Boolean> f16177;

    /* JADX INFO: renamed from: ޔ, reason: contains not printable characters */
    public C5063<Boolean> f16178;

    /* JADX INFO: renamed from: ޕ, reason: contains not printable characters */
    public C5063<Void> f16179;

    /* JADX INFO: renamed from: ދ.ހ.ށ.ބ.ށ.އ.ސ$֏, reason: contains not printable characters */
    public class C5643 extends C5652 {
        public C5643(String str) {
            super(str);
        }

        @Override // p138.p176.p291.p296.p297.p299.C5642.C5652, java.io.FilenameFilter
        public boolean accept(File file, String str) {
            return super.accept(file, str) && str.endsWith(".cls");
        }
    }

    /* JADX INFO: renamed from: ދ.ހ.ށ.ބ.ށ.އ.ސ$ؠ, reason: contains not printable characters */
    public class C5644 implements FilenameFilter {
        @Override // java.io.FilenameFilter
        public boolean accept(File file, String str) {
            return str.length() == 39 && str.endsWith(".cls");
        }
    }

    /* JADX INFO: renamed from: ދ.ހ.ށ.ބ.ށ.އ.ސ$ހ, reason: contains not printable characters */
    public class C5645 implements Comparator<File> {
        @Override // java.util.Comparator
        public int compare(File file, File file2) {
            return file2.getName().compareTo(file.getName());
        }
    }

    /* JADX INFO: renamed from: ދ.ހ.ށ.ބ.ށ.އ.ސ$ށ, reason: contains not printable characters */
    public class C5646 implements Comparator<File> {
        @Override // java.util.Comparator
        public int compare(File file, File file2) {
            return file.getName().compareTo(file2.getName());
        }
    }

    /* JADX INFO: renamed from: ދ.ހ.ށ.ބ.ށ.އ.ސ$ނ, reason: contains not printable characters */
    public class CallableC5647 implements Callable<AbstractC5062<Void>> {

        /* JADX INFO: renamed from: ֏, reason: contains not printable characters */
        public final /* synthetic */ Date f16180;

        /* JADX INFO: renamed from: ؠ, reason: contains not printable characters */
        public final /* synthetic */ Throwable f16181;

        /* JADX INFO: renamed from: ހ, reason: contains not printable characters */
        public final /* synthetic */ Thread f16182;

        /* JADX INFO: renamed from: ށ, reason: contains not printable characters */
        public final /* synthetic */ InterfaceC5859 f16183;

        /* JADX INFO: renamed from: ނ, reason: contains not printable characters */
        public final /* synthetic */ AbstractC5062 f16184;

        public CallableC5647(Date date, Throwable th, Thread thread, InterfaceC5859 interfaceC5859, AbstractC5062 abstractC5062) {
            this.f16180 = date;
            this.f16181 = th;
            this.f16182 = thread;
            this.f16183 = interfaceC5859;
            this.f16184 = abstractC5062;
        }

        /* JADX WARN: Multi-variable type inference failed */
        /* JADX WARN: Removed duplicated region for block: B:126:0x03a8 A[Catch: all -> 0x038c, TRY_LEAVE, TryCatch #6 {all -> 0x038c, blocks: (B:108:0x0382, B:124:0x039d, B:126:0x03a8), top: B:152:0x0382 }] */
        /* JADX WARN: Removed duplicated region for block: B:130:0x0406  */
        /* JADX WARN: Removed duplicated region for block: B:131:0x040c  */
        @Override // java.util.concurrent.Callable
        /*
            Code decompiled incorrectly, please refer to instructions dump.
        */
        public AbstractC5062<Void> call() throws Exception {
            String str;
            String strM4879;
            long j;
            Thread thread;
            C5831 c5831;
            C5833 c5833M9149;
            C5608 c5608;
            C5831 c58312;
            String strM9023;
            C5642.this.f16158.m9047();
            long time = this.f16180.getTime() / 1000;
            C5691 c5691 = C5642.this.f16175;
            Throwable th = this.f16181;
            Thread thread2 = this.f16182;
            String str2 = c5691.f16292;
            if (str2 == null) {
                C5608.f16066.m8972("Cannot persist event, no currently open session");
                j = time;
            } else {
                C5675 c5675 = c5691.f16287;
                int i = c5675.f16244.getResources().getConfiguration().orientation;
                C5879 c5879 = new C5879(th, c5675.f16247);
                C5752.C5754 c5754 = new C5752.C5754();
                c5754.f16423 = "crash";
                c5754.f16422 = Long.valueOf(time);
                ActivityManager.RunningAppProcessInfo runningAppProcessInfoM8993 = C5627.m8993(c5675.f16246.f16100, c5675.f16244);
                Boolean boolValueOf = runningAppProcessInfoM8993 != null ? Boolean.valueOf(runningAppProcessInfoM8993.importance != 100) : null;
                Integer numValueOf = Integer.valueOf(i);
                C5757.C5759 c5759 = new C5757.C5759();
                ArrayList arrayList = new ArrayList();
                arrayList.add(c5675.m9050(thread2, c5879.f16636, 4));
                Iterator<Map.Entry<Thread, StackTraceElement[]>> it = Thread.getAllStackTraces().entrySet().iterator();
                while (it.hasNext()) {
                    Map.Entry<Thread, StackTraceElement[]> next = it.next();
                    Iterator<Map.Entry<Thread, StackTraceElement[]>> it2 = it;
                    Thread key = next.getKey();
                    if (key.equals(thread2)) {
                        thread = thread2;
                    } else {
                        thread = thread2;
                        arrayList.add(c5675.m9050(key, c5675.f16247.mo9216(next.getValue()), 0));
                    }
                    thread2 = thread;
                    it = it2;
                }
                c5759.f16435 = new C5810<>(arrayList);
                c5759.f16436 = c5675.m9049(c5879, 4, 8, 0);
                Long l = 0L;
                String str3 = l == null ? " address" : "";
                if (!str3.isEmpty()) {
                    throw new IllegalStateException(C2803.m4879("Missing required properties:", str3));
                }
                c5759.f16437 = new C5764("0", "0", l.longValue(), null);
                AbstractC5781.AbstractC5786.AbstractC5792.AbstractC5793.AbstractC5794.AbstractC5795[] abstractC5795Arr = new AbstractC5781.AbstractC5786.AbstractC5792.AbstractC5793.AbstractC5794.AbstractC5795[1];
                Long l2 = 0L;
                Long l3 = 0L;
                C5622 c5622 = c5675.f16246;
                String str4 = c5622.f16100;
                if (str4 == null) {
                    throw new NullPointerException("Null name");
                }
                String str5 = c5622.f16098;
                if (l2 == null) {
                    str = "Missing required properties:";
                    strM4879 = " baseAddress";
                } else {
                    str = "Missing required properties:";
                    strM4879 = "";
                }
                j = time;
                if (l3 == null) {
                    strM4879 = C2803.m4879(strM4879, " size");
                }
                if (!strM4879.isEmpty()) {
                    throw new IllegalStateException(C2803.m4879(str, strM4879));
                }
                abstractC5795Arr[0] = new C5760(l2.longValue(), l3.longValue(), str4, str5, null);
                c5759.f16438 = new C5810<>(Arrays.asList(abstractC5795Arr));
                AbstractC5781.AbstractC5786.AbstractC5792.AbstractC5793.AbstractC5794 abstractC5794Mo9103 = c5759.mo9103();
                String str6 = numValueOf == null ? " uiOrientation" : "";
                if (!str6.isEmpty()) {
                    throw new IllegalStateException(C2803.m4879(str, str6));
                }
                String str7 = str;
                c5754.mo9101(new C5755(abstractC5794Mo9103, null, boolValueOf, numValueOf.intValue(), null));
                C5625 c5625M8986 = C5625.m8986(c5675.f16244);
                Float f = c5625M8986.f16105;
                Double dValueOf = f != null ? Double.valueOf(f.doubleValue()) : null;
                int iM8987 = c5625M8986.m8987();
                boolean zM9007 = C5627.m9007(c5675.f16244);
                long jM9003 = C5627.m9003();
                Context context = c5675.f16244;
                ActivityManager.MemoryInfo memoryInfo = new ActivityManager.MemoryInfo();
                ((ActivityManager) context.getSystemService("activity")).getMemoryInfo(memoryInfo);
                long j2 = jM9003 - memoryInfo.availMem;
                long jM8991 = C5627.m8991(Environment.getDataDirectory().getPath());
                C5771.C5773 c5773 = new C5771.C5773();
                c5773.f16470 = dValueOf;
                c5773.f16471 = Integer.valueOf(iM8987);
                c5773.f16472 = Boolean.valueOf(zM9007);
                c5773.f16473 = Integer.valueOf(i);
                c5773.f16474 = Long.valueOf(j2);
                c5773.f16475 = Long.valueOf(jM8991);
                c5754.f16425 = c5773.mo9105();
                C5752 c5752 = (C5752) c5754.mo9102();
                C5752.C5754 c57542 = new C5752.C5754(c5752, null);
                String strMo9074 = c5691.f16290.f16305.mo9074();
                if (strMo9074 != null) {
                    c57542.f16426 = new C5774(strMo9074, null == true ? 1 : 0);
                } else {
                    C5608.f16066.m8972("No log data to include with this event.");
                }
                Map mapUnmodifiableMap = Collections.unmodifiableMap(c5691.f16291.f16294);
                ArrayList arrayList2 = new ArrayList();
                arrayList2.ensureCapacity(mapUnmodifiableMap.size());
                for (Map.Entry entry : mapUnmodifiableMap.entrySet()) {
                    String str8 = (String) entry.getKey();
                    if (str8 == null) {
                        throw new NullPointerException("Null key");
                    }
                    String str9 = (String) entry.getValue();
                    if (str9 == null) {
                        throw new NullPointerException("Null value");
                    }
                    arrayList2.add(new C5737(str8, str9, null));
                }
                Collections.sort(arrayList2, new Comparator() { // from class: ދ.ހ.ށ.ބ.ށ.އ.ࢦ
                    @Override // java.util.Comparator
                    public int compare(Object obj, Object obj2) {
                        return ((C5737) ((AbstractC5781.AbstractC5783) obj)).f16366.compareTo(((C5737) ((AbstractC5781.AbstractC5783) obj2)).f16366);
                    }
                });
                if (!arrayList2.isEmpty()) {
                    C5755 c5755 = (C5755) c5752.f16419;
                    if (c5755 == null) {
                        throw null;
                    }
                    AbstractC5781.AbstractC5786.AbstractC5792.AbstractC5793.AbstractC5794 abstractC5794 = c5755.f16427;
                    Boolean bool = c5755.f16429;
                    Integer numValueOf2 = Integer.valueOf(c5755.f16430);
                    C5810 c5810 = new C5810(arrayList2);
                    String strM48792 = abstractC5794 == null ? " execution" : "";
                    if (numValueOf2 == null) {
                        strM48792 = C2803.m4879(strM48792, " uiOrientation");
                    }
                    if (!strM48792.isEmpty()) {
                        throw new IllegalStateException(C2803.m4879(str7, strM48792));
                    }
                    c57542.mo9101(new C5755(abstractC5794, c5810, bool, numValueOf2.intValue(), null));
                }
                C5828 c5828 = c5691.f16288;
                Object objMo9102 = c57542.mo9102();
                int i2 = ((C5857) c5828.f16528).m9207().mo9209().f16612;
                File fileM9144 = c5828.m9144(str2);
                if (C5828.f16520 == null) {
                    throw null;
                }
                C5892 c5892 = (C5892) C5816.f16497;
                if (c5892 == null) {
                    throw null;
                }
                StringWriter stringWriter = new StringWriter();
                try {
                    c5892.m9223(objMo9102, stringWriter);
                } catch (IOException unused) {
                }
                try {
                    C5828.m9138(new File(fileM9144, C2803.m4880("event", String.format(Locale.US, "%010d", Integer.valueOf(c5828.f16523.getAndIncrement())), "_")), stringWriter.toString());
                } catch (IOException e) {
                    C5608.f16066.m8973("Could not persist event for session " + str2, e);
                }
                List<File> listM9130 = C5828.m9130(fileM9144, new FilenameFilter() { // from class: ދ.ހ.ށ.ބ.ށ.ދ.ހ
                    @Override // java.io.FilenameFilter
                    public boolean accept(File file, String str10) {
                        return C5828.m9133(file, str10);
                    }
                });
                Collections.sort(listM9130, new Comparator() { // from class: ދ.ހ.ށ.ބ.ށ.ދ.ށ
                    @Override // java.util.Comparator
                    public int compare(Object obj, Object obj2) {
                        return ((File) obj).getName().substring(0, C5828.f16519).compareTo(((File) obj2).getName().substring(0, C5828.f16519));
                    }
                });
                int size = listM9130.size();
                for (File file : listM9130) {
                    if (size <= i2) {
                        break;
                    }
                    C5828.m9141(file);
                    size--;
                }
            }
            C5642 c5642 = C5642.this;
            Thread thread3 = this.f16182;
            Throwable th2 = this.f16181;
            if (c5642 == null) {
                throw null;
            }
            try {
                strM9023 = c5642.m9023();
            } catch (Exception e2) {
                e = e2;
                c5831 = null;
            } catch (Throwable th3) {
                th = th3;
                c5831 = null;
            }
            if (strM9023 == null) {
                C5608.f16066.m8975("Tried to write a fatal exception while no session was open.");
                c58312 = null;
                C5627.m8999((Flushable) null, "Failed to flush to session begin file.");
                C5627.m8998((Closeable) c58312, "Failed to close fatal exception file output stream.");
                InterfaceC5867 interfaceC5867M9207 = ((C5857) this.f16183).m9207();
                int i3 = interfaceC5867M9207.mo9209().f16612;
                int i4 = interfaceC5867M9207.mo9209().f16613;
                C5642.this.m9025(i3, true);
                C5642.m9019(C5642.this);
                C5642 c56422 = C5642.this;
                int iM9065 = i4 - C5694.m9065(c56422.m9036(), c56422.m9034(), i4, C5642.f16152);
                C5694.m9066(c56422.m9035(), C5642.f16150, iM9065 - C5694.m9066(c56422.m9037(), C5694.f16295, iM9065, C5642.f16152), C5642.f16152);
                if (!C5642.this.f16157.m9052()) {
                    return C4303.m7054((Object) null);
                }
                ExecutorService executorService = C5642.this.f16160.f16124;
                return ((C5857) this.f16183).m9203().mo8550(executorService, new C5663(this, executorService));
            }
            c5831 = new C5831(c5642.m9035(), strM9023 + "SessionCrash");
            try {
                c5833M9149 = C5833.m9149(c5831);
                try {
                    try {
                        c5642.m9029(c5833M9149, thread3, th2, j, "crash", true);
                    } catch (Exception e3) {
                        e = e3;
                        c5608 = C5608.f16066;
                        if (c5608.m8974(6)) {
                            Log.e(c5608.f16067, "An error occurred in the fatal exception logger", e);
                        }
                    }
                } catch (Throwable th4) {
                    th = th4;
                    C5627.m8999(c5833M9149, "Failed to flush to session begin file.");
                    C5627.m8998((Closeable) c5831, "Failed to close fatal exception file output stream.");
                    throw th;
                }
            } catch (Exception e4) {
                e = e4;
                c5833M9149 = null;
                c5608 = C5608.f16066;
                if (c5608.m8974(6)) {
                }
                c58312 = c5831;
                C5627.m8999(c5833M9149, "Failed to flush to session begin file.");
                C5627.m8998((Closeable) c58312, "Failed to close fatal exception file output stream.");
                InterfaceC5867 interfaceC5867M92072 = ((C5857) this.f16183).m9207();
                int i32 = interfaceC5867M92072.mo9209().f16612;
                int i42 = interfaceC5867M92072.mo9209().f16613;
                C5642.this.m9025(i32, true);
                C5642.m9019(C5642.this);
                C5642 c564222 = C5642.this;
                int iM90652 = i42 - C5694.m9065(c564222.m9036(), c564222.m9034(), i42, C5642.f16152);
                C5694.m9066(c564222.m9035(), C5642.f16150, iM90652 - C5694.m9066(c564222.m9037(), C5694.f16295, iM90652, C5642.f16152), C5642.f16152);
                if (!C5642.this.f16157.m9052()) {
                }
            } catch (Throwable th5) {
                th = th5;
                c5833M9149 = null;
                C5627.m8999(c5833M9149, "Failed to flush to session begin file.");
                C5627.m8998((Closeable) c5831, "Failed to close fatal exception file output stream.");
                throw th;
            }
            c58312 = c5831;
            C5627.m8999(c5833M9149, "Failed to flush to session begin file.");
            C5627.m8998((Closeable) c58312, "Failed to close fatal exception file output stream.");
            InterfaceC5867 interfaceC5867M920722 = ((C5857) this.f16183).m9207();
            int i322 = interfaceC5867M920722.mo9209().f16612;
            int i422 = interfaceC5867M920722.mo9209().f16613;
            C5642.this.m9025(i322, true);
            C5642.m9019(C5642.this);
            C5642 c5642222 = C5642.this;
            int iM906522 = i422 - C5694.m9065(c5642222.m9036(), c5642222.m9034(), i422, C5642.f16152);
            C5694.m9066(c5642222.m9035(), C5642.f16150, iM906522 - C5694.m9066(c5642222.m9037(), C5694.f16295, iM906522, C5642.f16152), C5642.f16152);
            if (!C5642.this.f16157.m9052()) {
            }
        }
    }

    /* JADX INFO: renamed from: ދ.ހ.ށ.ބ.ށ.އ.ސ$ރ, reason: contains not printable characters */
    public class C5648 implements InterfaceC5061<Boolean, Void> {

        /* JADX INFO: renamed from: ֏, reason: contains not printable characters */
        public final /* synthetic */ AbstractC5062 f16186;

        /* JADX INFO: renamed from: ؠ, reason: contains not printable characters */
        public final /* synthetic */ float f16187;

        public C5648(AbstractC5062 abstractC5062, float f) {
            this.f16186 = abstractC5062;
            this.f16187 = f;
        }

        @Override // p138.p176.p177.p242.p270.InterfaceC5061
        /* JADX INFO: renamed from: ֏ */
        public AbstractC5062<Void> mo8542(Boolean bool) {
            return C5642.this.f16160.m9014(new CallableC5666(this, bool));
        }
    }

    /* JADX INFO: renamed from: ދ.ހ.ށ.ބ.ށ.އ.ސ$ބ, reason: contains not printable characters */
    public static class C5649 implements FilenameFilter {
        public /* synthetic */ C5649(C5643 c5643) {
        }

        @Override // java.io.FilenameFilter
        public boolean accept(File file, String str) {
            return !C5642.f16150.accept(file, str) && C5642.f16153.matcher(str).matches();
        }
    }

    /* JADX INFO: renamed from: ދ.ހ.ށ.ބ.ށ.އ.ސ$ޅ, reason: contains not printable characters */
    public static class C5650 implements InterfaceC5619.InterfaceC5620 {

        /* JADX INFO: renamed from: ֏, reason: contains not printable characters */
        public final CountDownLatch f16189 = new CountDownLatch(1);

        public C5650() {
        }

        public /* synthetic */ C5650(C5643 c5643) {
        }
    }

    /* JADX INFO: renamed from: ދ.ހ.ށ.ބ.ށ.އ.ސ$ކ, reason: contains not printable characters */
    public interface InterfaceC5651 {
        /* JADX INFO: renamed from: ֏ */
        void mo9015(C5833 c5833);
    }

    /* JADX INFO: renamed from: ދ.ހ.ށ.ބ.ށ.އ.ސ$އ, reason: contains not printable characters */
    public static class C5652 implements FilenameFilter {

        /* JADX INFO: renamed from: ֏, reason: contains not printable characters */
        public final String f16190;

        public C5652(String str) {
            this.f16190 = str;
        }

        @Override // java.io.FilenameFilter
        public boolean accept(File file, String str) {
            return str.contains(this.f16190) && !str.endsWith(".cls_temp");
        }
    }

    /* JADX INFO: renamed from: ދ.ހ.ށ.ބ.ށ.އ.ސ$ވ, reason: contains not printable characters */
    public static class C5653 implements FilenameFilter {
        @Override // java.io.FilenameFilter
        public boolean accept(File file, String str) {
            return C5831.f16532.accept(file, str) || str.contains("SessionMissingBinaryImages");
        }
    }

    /* JADX INFO: renamed from: ދ.ހ.ށ.ބ.ށ.އ.ސ$މ, reason: contains not printable characters */
    public static final class C5654 implements C5701.InterfaceC5703 {

        /* JADX INFO: renamed from: ֏, reason: contains not printable characters */
        public final C5829 f16191;

        public C5654(C5829 c5829) {
            this.f16191 = c5829;
        }

        /* JADX INFO: renamed from: ֏, reason: contains not printable characters */
        public File m9042() {
            File file = new File(this.f16191.m9146(), "log-files");
            if (!file.exists()) {
                file.mkdirs();
            }
            return file;
        }
    }

    /* JADX INFO: renamed from: ދ.ހ.ށ.ބ.ށ.އ.ސ$ފ, reason: contains not printable characters */
    public final class C5655 implements C5837.InterfaceC5840 {
        public /* synthetic */ C5655(C5643 c5643) {
        }
    }

    /* JADX INFO: renamed from: ދ.ހ.ށ.ބ.ށ.އ.ސ$ދ, reason: contains not printable characters */
    public final class C5656 implements C5837.InterfaceC5838 {
        public /* synthetic */ C5656(C5643 c5643) {
        }
    }

    /* JADX INFO: renamed from: ދ.ހ.ށ.ބ.ށ.އ.ސ$ތ, reason: contains not printable characters */
    public static final class RunnableC5657 implements Runnable {

        /* JADX INFO: renamed from: ރ, reason: contains not printable characters */
        public final Context f16194;

        /* JADX INFO: renamed from: ބ, reason: contains not printable characters */
        public final InterfaceC5844 f16195;

        /* JADX INFO: renamed from: ޅ, reason: contains not printable characters */
        public final C5837 f16196;

        /* JADX INFO: renamed from: ކ, reason: contains not printable characters */
        public final boolean f16197;

        public RunnableC5657(Context context, InterfaceC5844 interfaceC5844, C5837 c5837, boolean z) {
            this.f16194 = context;
            this.f16195 = interfaceC5844;
            this.f16196 = c5837;
            this.f16197 = z;
        }

        @Override // java.lang.Runnable
        public void run() {
            if (C5627.m9000(this.f16194)) {
                C5608.f16066.m8972("Attempting to send crash report at time of crash...");
                this.f16196.m9187(this.f16195, this.f16197);
            }
        }
    }

    /* JADX INFO: renamed from: ދ.ހ.ށ.ބ.ށ.އ.ސ$ލ, reason: contains not printable characters */
    public static class C5658 implements FilenameFilter {

        /* JADX INFO: renamed from: ֏, reason: contains not printable characters */
        public final String f16198;

        public C5658(String str) {
            this.f16198 = str;
        }

        @Override // java.io.FilenameFilter
        public boolean accept(File file, String str) {
            StringBuilder sb = new StringBuilder();
            sb.append(this.f16198);
            sb.append(".cls");
            return (str.equals(sb.toString()) || !str.contains(this.f16198) || str.endsWith(".cls_temp")) ? false : true;
        }
    }

    public C5642(Context context, C5630 c5630, C5820 c5820, C5685 c5685, C5679 c5679, C5829 c5829, C5674 c5674, C5622 c5622, C5836 c5836, C5837.InterfaceC5839 interfaceC5839, InterfaceC5607 interfaceC5607, C5880 c5880, InterfaceC5619 interfaceC5619, InterfaceC5566 interfaceC5566, InterfaceC5859 interfaceC5859) {
        String string;
        new AtomicInteger(0);
        this.f16177 = new C5063<>();
        this.f16178 = new C5063<>();
        this.f16179 = new C5063<>();
        new AtomicBoolean(false);
        this.f16156 = context;
        this.f16160 = c5630;
        this.f16161 = c5820;
        this.f16162 = c5685;
        this.f16157 = c5679;
        this.f16163 = c5829;
        this.f16158 = c5674;
        this.f16164 = c5622;
        if (interfaceC5839 != null) {
            this.f16165 = interfaceC5839;
        } else {
            this.f16165 = new C5667(this);
        }
        this.f16170 = interfaceC5607;
        C5643 c5643 = null;
        if (!c5880.f16639) {
            Context context2 = c5880.f16638;
            int iM8990 = C5627.m8990(context2, "com.google.firebase.crashlytics.unity_version", "string");
            if (iM8990 != 0) {
                string = context2.getResources().getString(iM8990);
                C2803.m4892("Unity Editor version is: ", string, C5608.f16066);
            } else {
                string = null;
            }
            c5880.f16640 = string;
            c5880.f16639 = true;
        }
        String str = c5880.f16640;
        this.f16172 = str == null ? null : str;
        this.f16173 = interfaceC5619;
        this.f16174 = interfaceC5566;
        this.f16159 = new C5693();
        this.f16166 = new C5654(c5829);
        this.f16167 = new C5701(context, this.f16166);
        this.f16168 = c5836 == null ? new C5836(new C5655(c5643)) : c5836;
        this.f16169 = new C5656(c5643);
        C5875 c5875 = new C5875(1024, new C5877(10));
        this.f16171 = c5875;
        C5701 c5701 = this.f16167;
        C5693 c5693 = this.f16159;
        if (c5829 == null) {
            throw null;
        }
        this.f16175 = new C5691(new C5675(context, c5685, c5622, c5875), new C5828(new File(new File(c5829.f16529.getFilesDir(), ".com.google.firebase.crashlytics").getPath()), interfaceC5859), C5853.m9198(context), c5701, c5693);
    }

    /* JADX INFO: renamed from: ֏, reason: contains not printable characters */
    public static String m9016(File file) {
        return file.getName().substring(0, 35);
    }

    /* JADX INFO: renamed from: ֏, reason: contains not printable characters */
    public static void m9017(InputStream inputStream, C5833 c5833, int i) throws IOException {
        byte[] bArr = new byte[i];
        int i2 = 0;
        while (i2 < i) {
            int i3 = inputStream.read(bArr, i2, i - i2);
            if (i3 < 0) {
                break;
            } else {
                i2 += i3;
            }
        }
        if (c5833 == null) {
            throw null;
        }
        int i4 = c5833.f16537;
        int i5 = c5833.f16538;
        int i6 = i4 - i5;
        if (i6 >= i) {
            System.arraycopy(bArr, 0, c5833.f16536, i5, i);
            c5833.f16538 += i;
            return;
        }
        System.arraycopy(bArr, 0, c5833.f16536, i5, i6);
        int i7 = i6 + 0;
        int i8 = i - i6;
        c5833.f16538 = c5833.f16537;
        c5833.m9157();
        if (i8 > c5833.f16537) {
            c5833.f16539.write(bArr, i7, i8);
        } else {
            System.arraycopy(bArr, i7, c5833.f16536, 0, i8);
            c5833.f16538 = i8;
        }
    }

    /* JADX INFO: renamed from: ֏, reason: contains not printable characters */
    public static void m9018(String str, File file) throws Throwable {
        FileOutputStream fileOutputStream;
        if (str == null) {
            return;
        }
        C5833 c5833M9149 = null;
        try {
            fileOutputStream = new FileOutputStream(file, true);
        } catch (Throwable th) {
            th = th;
            fileOutputStream = null;
        }
        try {
            c5833M9149 = C5833.m9149(fileOutputStream);
            C5835.m9179(c5833M9149, str);
            StringBuilder sbM4889 = C2803.m4889("Failed to flush to append to ");
            sbM4889.append(file.getPath());
            C5627.m8999(c5833M9149, sbM4889.toString());
            C5627.m8998((Closeable) fileOutputStream, "Failed to close " + file.getPath());
        } catch (Throwable th2) {
            th = th2;
            StringBuilder sbM48892 = C2803.m4889("Failed to flush to append to ");
            sbM48892.append(file.getPath());
            C5627.m8999(c5833M9149, sbM48892.toString());
            C5627.m8998((Closeable) fileOutputStream, "Failed to close " + file.getPath());
            throw th;
        }
    }

    /* JADX INFO: renamed from: ֏, reason: contains not printable characters */
    public static /* synthetic */ void m9019(C5642 c5642) throws Throwable {
        Integer num;
        if (c5642 == null) {
            throw null;
        }
        long jM9022 = m9022();
        new C5626(c5642.f16162);
        String str = C5626.f16108;
        C2803.m4892("Opening a new session with ID ", str, C5608.f16066);
        c5642.f16170.mo8970(str);
        String str2 = String.format(Locale.US, "Crashlytics Android SDK/%s", "17.0.0");
        c5642.m9026(str, "BeginSession", new C5639(c5642, str, str2, jM9022));
        c5642.f16170.mo8965(str, str2, jM9022);
        C5685 c5685 = c5642.f16162;
        String str3 = c5685.f16280;
        C5622 c5622 = c5642.f16164;
        String str4 = c5622.f16101;
        String str5 = c5622.f16102;
        String strM9056 = c5685.m9056();
        int i = EnumC5681.m9055(c5642.f16164.f16099).f16268;
        c5642.m9026(str, "SessionApp", new C5640(c5642, str3, str4, str5, strM9056, i));
        c5642.f16170.mo8966(str, str3, str4, str5, strM9056, i, c5642.f16172);
        String str6 = Build.VERSION.RELEASE;
        String str7 = Build.VERSION.CODENAME;
        boolean zM9010 = C5627.m9010(c5642.f16156);
        c5642.m9026(str, "SessionOS", new C5641(c5642, str6, str7, zM9010));
        c5642.f16170.mo8967(str, str6, str7, zM9010);
        Context context = c5642.f16156;
        StatFs statFs = new StatFs(Environment.getDataDirectory().getPath());
        int iM8989 = C5627.m8989();
        String str8 = Build.MODEL;
        int iAvailableProcessors = Runtime.getRuntime().availableProcessors();
        long jM9003 = C5627.m9003();
        long blockCount = ((long) statFs.getBlockCount()) * ((long) statFs.getBlockSize());
        boolean zM9009 = C5627.m9009(context);
        int iM9002 = C5627.m9002(context);
        String str9 = Build.MANUFACTURER;
        String str10 = Build.PRODUCT;
        c5642.m9026(str, "SessionDevice", new C5659(c5642, iM8989, str8, iAvailableProcessors, jM9003, blockCount, zM9009, iM9002, str9, str10));
        c5642.f16170.mo8964(str, iM8989, str8, iAvailableProcessors, jM9003, blockCount, zM9009, iM9002, str9, str10);
        c5642.f16167.m9077(str);
        C5691 c5691 = c5642.f16175;
        String strReplaceAll = str.replaceAll("-", "");
        c5691.f16292 = strReplaceAll;
        C5675 c5675 = c5691.f16287;
        if (c5675 == null) {
            throw null;
        }
        C5734.C5736 c5736 = (C5734.C5736) AbstractC5781.m9107();
        c5736.f16358 = "17.0.0";
        String str11 = c5675.f16246.f16097;
        if (str11 == null) {
            throw new NullPointerException("Null gmpAppId");
        }
        c5736.f16359 = str11;
        String strM90562 = c5675.f16245.m9056();
        if (strM90562 == null) {
            throw new NullPointerException("Null installationUuid");
        }
        c5736.f16361 = strM90562;
        C5622 c56222 = c5675.f16246;
        String str12 = c56222.f16101;
        if (str12 == null) {
            throw new NullPointerException("Null buildVersion");
        }
        c5736.f16362 = str12;
        String str13 = c56222.f16102;
        if (str13 == null) {
            throw new NullPointerException("Null displayVersion");
        }
        c5736.f16363 = str13;
        c5736.f16360 = 4;
        C5743.C5745 c5745 = new C5743.C5745();
        c5745.mo9098(false);
        c5745.f16385 = Long.valueOf(jM9022);
        if (strReplaceAll == null) {
            throw new NullPointerException("Null identifier");
        }
        c5745.f16384 = strReplaceAll;
        String str14 = C5675.f16242;
        if (str14 == null) {
            throw new NullPointerException("Null generator");
        }
        c5745.f16383 = str14;
        C5685 c56852 = c5675.f16245;
        String str15 = c56852.f16280;
        if (str15 == null) {
            throw new NullPointerException("Null identifier");
        }
        C5622 c56223 = c5675.f16246;
        String str16 = c56223.f16101;
        if (str16 == null) {
            throw new NullPointerException("Null version");
        }
        c5745.f16388 = new C5746(str15, str16, c56223.f16102, null, c56852.m9056(), null);
        C5776.C5778 c5778 = new C5776.C5778();
        c5778.f16481 = 3;
        String str17 = Build.VERSION.RELEASE;
        if (str17 == null) {
            throw new NullPointerException("Null version");
        }
        c5778.f16482 = str17;
        String str18 = Build.VERSION.CODENAME;
        if (str18 == null) {
            throw new NullPointerException("Null buildVersion");
        }
        c5778.f16483 = str18;
        c5778.f16484 = Boolean.valueOf(C5627.m9010(c5675.f16244));
        c5745.f16390 = c5778.mo9106();
        StatFs statFs2 = new StatFs(Environment.getDataDirectory().getPath());
        String str19 = Build.CPU_ABI;
        int iIntValue = 7;
        if (!TextUtils.isEmpty(str19) && (num = C5675.f16243.get(str19.toLowerCase(Locale.US))) != null) {
            iIntValue = num.intValue();
        }
        int iAvailableProcessors2 = Runtime.getRuntime().availableProcessors();
        long jM90032 = C5627.m9003();
        long blockCount2 = ((long) statFs2.getBlockCount()) * ((long) statFs2.getBlockSize());
        boolean zM90092 = C5627.m9009(c5675.f16244);
        int iM90022 = C5627.m9002(c5675.f16244);
        String str20 = Build.MANUFACTURER;
        String str21 = Build.PRODUCT;
        C5749.C5751 c5751 = new C5749.C5751();
        c5751.f16408 = Integer.valueOf(iIntValue);
        String str22 = Build.MODEL;
        if (str22 == null) {
            throw new NullPointerException("Null model");
        }
        c5751.f16409 = str22;
        c5751.f16410 = Integer.valueOf(iAvailableProcessors2);
        c5751.f16411 = Long.valueOf(jM90032);
        c5751.f16412 = Long.valueOf(blockCount2);
        c5751.f16413 = Boolean.valueOf(zM90092);
        c5751.f16414 = Integer.valueOf(iM90022);
        if (str20 == null) {
            throw new NullPointerException("Null manufacturer");
        }
        c5751.f16415 = str20;
        if (str21 == null) {
            throw new NullPointerException("Null modelClass");
        }
        c5751.f16416 = str21;
        c5745.f16391 = c5751.mo9100();
        c5745.f16393 = 3;
        c5736.f16364 = c5745.mo9099();
        AbstractC5781 abstractC5781Mo9097 = c5736.mo9097();
        C5828 c5828 = c5691.f16288;
        if (c5828 == null) {
            throw null;
        }
        AbstractC5781.AbstractC5786 abstractC5786 = ((C5734) abstractC5781Mo9097).f16356;
        if (abstractC5786 == null) {
            C5608.f16066.m8972("Could not get session for report");
            return;
        }
        String str23 = ((C5743) abstractC5786).f16373;
        try {
            File fileM9144 = c5828.m9144(str23);
            C5828.m9137(fileM9144);
            C5828.m9138(new File(fileM9144, "report"), C5828.f16520.m9121(abstractC5781Mo9097));
        } catch (IOException e) {
            C5608.f16066.m8973("Could not persist report for session " + str23, e);
        }
    }

    /* JADX INFO: renamed from: ֏, reason: contains not printable characters */
    public static void m9020(C5833 c5833, File file) throws Throwable {
        if (!file.exists()) {
            C5608 c5608 = C5608.f16066;
            StringBuilder sbM4889 = C2803.m4889("Tried to include a file that doesn't exist: ");
            sbM4889.append(file.getName());
            c5608.m8975(sbM4889.toString());
            return;
        }
        FileInputStream fileInputStream = null;
        try {
            FileInputStream fileInputStream2 = new FileInputStream(file);
            try {
                m9017(fileInputStream2, c5833, (int) file.length());
                C5627.m8998(fileInputStream2, "Failed to close file input stream.");
            } catch (Throwable th) {
                th = th;
                fileInputStream = fileInputStream2;
                C5627.m8998(fileInputStream, "Failed to close file input stream.");
                throw th;
            }
        } catch (Throwable th2) {
            th = th2;
        }
    }

    /* JADX INFO: renamed from: ֏, reason: contains not printable characters */
    public static void m9021(C5833 c5833, File[] fileArr, String str) throws Throwable {
        Arrays.sort(fileArr, C5627.f16111);
        for (File file : fileArr) {
            try {
                C5608.f16066.m8972(String.format(Locale.US, "Found Non Fatal for session ID %s in %s ", str, file.getName()));
                m9020(c5833, file);
            } catch (Exception e) {
                C5608 c5608 = C5608.f16066;
                if (c5608.m8974(6)) {
                    Log.e(c5608.f16067, "Error writting non-fatal to session.", e);
                }
            }
        }
    }

    /* JADX INFO: renamed from: އ, reason: contains not printable characters */
    public static long m9022() {
        return new Date().getTime() / 1000;
    }

    /* JADX INFO: renamed from: ֏, reason: contains not printable characters */
    public final String m9023() {
        File[] fileArrM9040 = m9040();
        if (fileArrM9040.length > 0) {
            return m9016(fileArrM9040[0]);
        }
        return null;
    }

    /* JADX INFO: renamed from: ֏, reason: contains not printable characters */
    public AbstractC5062<Void> m9024(float f, AbstractC5062<C5864> abstractC5062) {
        AbstractC5062 abstractC5062M9070;
        C5836 c5836 = this.f16168;
        File[] fileArrM9039 = C5642.this.m9039();
        File[] fileArrListFiles = C5642.this.m9036().listFiles();
        if (fileArrListFiles == null) {
            fileArrListFiles = new File[0];
        }
        if (!((fileArrM9039 != null && fileArrM9039.length > 0) || fileArrListFiles.length > 0)) {
            C5608.f16066.m8972("No reports are available.");
            this.f16177.m8557(false);
            return C4303.m7054((Object) null);
        }
        C5608.f16066.m8972("Unsent reports are available.");
        if (this.f16157.m9052()) {
            C5608.f16066.m8972("Automatic data collection is enabled. Allowing upload.");
            this.f16177.m8557(false);
            abstractC5062M9070 = C4303.m7054(true);
        } else {
            C5608.f16066.m8972("Automatic data collection is disabled.");
            C5608.f16066.m8972("Notifying that unsent reports are available.");
            this.f16177.m8557(true);
            AbstractC5062<Void> abstractC5062M9053 = this.f16157.m9053();
            C5664 c5664 = new C5664(this);
            C5085 c5085 = (C5085) abstractC5062M9053;
            if (c5085 == null) {
                throw null;
            }
            AbstractC5062 abstractC5062Mo8550 = c5085.mo8550(C5064.f15215, c5664);
            C5608.f16066.m8972("Waiting for send/deleteUnsentReports to be called.");
            abstractC5062M9070 = C5694.m9070(abstractC5062Mo8550, this.f16178.f15214);
        }
        C5648 c5648 = new C5648(abstractC5062, f);
        C5085 c50852 = (C5085) abstractC5062M9070;
        if (c50852 != null) {
            return c50852.mo8550(C5064.f15215, c5648);
        }
        throw null;
    }

    /* JADX WARN: Multi-variable type inference failed */
    /* JADX INFO: renamed from: ֏, reason: contains not printable characters */
    public final void m9025(int i, boolean z) throws Exception {
        int i2;
        FileInputStream fileInputStream;
        C5693 c5693;
        String strM9139;
        C5833 c5833;
        C5831 c5831;
        C5833 c5833M9149;
        int i3 = !z ? 1 : 0;
        HashSet hashSet = new HashSet();
        File[] fileArrM9040 = m9040();
        int iMin = Math.min(i3 + 8, fileArrM9040.length);
        char c = 0;
        for (int i4 = 0; i4 < iMin; i4++) {
            hashSet.add(m9016(fileArrM9040[i4]));
        }
        File[] fileArrListFiles = ((C5654) this.f16167.f16304).m9042().listFiles();
        if (fileArrListFiles != null) {
            for (File file : fileArrListFiles) {
                String name = file.getName();
                int iLastIndexOf = name.lastIndexOf(".temp");
                if (iLastIndexOf != -1) {
                    name = name.substring(20, iLastIndexOf);
                }
                if (!hashSet.contains(name)) {
                    file.delete();
                }
            }
        }
        FileInputStream fileInputStream2 = null;
        File[] fileArrM9033 = m9033(new C5649(0 == true ? 1 : 0));
        int length = fileArrM9033.length;
        int i5 = 0;
        while (true) {
            i2 = 1;
            if (i5 >= length) {
                break;
            }
            File file2 = fileArrM9033[i5];
            String name2 = file2.getName();
            Matcher matcher = f16153.matcher(name2);
            if (!matcher.matches()) {
                C5608.f16066.m8972("Deleting unknown file: " + name2);
                file2.delete();
            } else if (!hashSet.contains(matcher.group(1))) {
                C5608.f16066.m8972("Trimming session file: " + name2);
                file2.delete();
            }
            i5++;
        }
        File[] fileArrM90402 = m9040();
        if (fileArrM90402.length <= i3) {
            C5608.f16066.m8972("No open sessions to be closed.");
            return;
        }
        String strM9016 = m9016(fileArrM90402[i3]);
        if (m9038()) {
            c5693 = this.f16159;
        } else {
            File fileM9063 = new C5688(m9035()).m9063(strM9016);
            if (fileM9063.exists()) {
                try {
                    fileInputStream = new FileInputStream(fileM9063);
                    try {
                        c5693 = C5688.m9062(C5627.m8995(fileInputStream));
                        C5627.m8998(fileInputStream, "Failed to close user metadata file.");
                    } catch (Exception e) {
                        e = e;
                        try {
                            C5608 c5608 = C5608.f16066;
                            if (c5608.m8974(6)) {
                                Log.e(c5608.f16067, "Error deserializing user metadata.", e);
                            }
                            C5627.m8998(fileInputStream, "Failed to close user metadata file.");
                            c5693 = new C5693();
                        } catch (Throwable th) {
                            th = th;
                            fileInputStream2 = fileInputStream;
                            fileInputStream = fileInputStream2;
                            C5627.m8998(fileInputStream, "Failed to close user metadata file.");
                            throw th;
                        }
                    } catch (Throwable th2) {
                        th = th2;
                        C5627.m8998(fileInputStream, "Failed to close user metadata file.");
                        throw th;
                    }
                } catch (Exception e2) {
                    e = e2;
                    fileInputStream = null;
                } catch (Throwable th3) {
                    th = th3;
                    fileInputStream = fileInputStream2;
                    C5627.m8998(fileInputStream, "Failed to close user metadata file.");
                    throw th;
                }
            } else {
                c5693 = new C5693();
            }
        }
        m9026(strM9016, "SessionUser", new C5660(this, c5693));
        if (z) {
            this.f16175.f16292 = null;
        } else if (this.f16170.mo8971(strM9016)) {
            C2803.m4892("Finalizing native report for session ", strM9016, C5608.f16066);
            if (((C5609.C5611) this.f16170.mo8969(strM9016)) == null) {
                throw null;
            }
            C5608.f16066.m8977("No minidump data found for session " + strM9016);
            if (!this.f16170.mo8968(strM9016)) {
                C2803.m4892("Could not finalize native session: ", strM9016, C5608.f16066);
            }
        }
        C5608.f16066.m8972("Closing open sessions.");
        while (i3 < fileArrM90402.length) {
            File file3 = fileArrM90402[i3];
            String strM90162 = m9016(file3);
            C2803.m4892("Closing session: ", strM90162, C5608.f16066);
            C5608.f16066.m8972("Collecting session parts for ID " + strM90162);
            File[] fileArrM90332 = m9033(new C5652(C2803.m4879(strM90162, "SessionCrash")));
            boolean z2 = fileArrM90332 != null && fileArrM90332.length > 0;
            C5608 c56082 = C5608.f16066;
            Locale locale = Locale.US;
            Object[] objArr = new Object[2];
            objArr[c] = strM90162;
            objArr[i2] = Boolean.valueOf(z2);
            c56082.m8972(String.format(locale, "Session %s has fatal exception: %s", objArr));
            File[] fileArrM90333 = m9033(new C5652(C2803.m4879(strM90162, "SessionEvent")));
            boolean z3 = fileArrM90333 != null && fileArrM90333.length > 0;
            C5608 c56083 = C5608.f16066;
            Locale locale2 = Locale.US;
            Object[] objArr2 = new Object[2];
            objArr2[c] = strM90162;
            objArr2[i2] = Boolean.valueOf(z3);
            c56083.m8972(String.format(locale2, "Session %s has non-fatal exceptions: %s", objArr2));
            if (z2 || z3) {
                if (fileArrM90333.length > i) {
                    C5608 c56084 = C5608.f16066;
                    Locale locale3 = Locale.US;
                    Object[] objArr3 = new Object[i2];
                    objArr3[0] = Integer.valueOf(i);
                    c56084.m8972(String.format(locale3, "Trimming down to %d logged exceptions.", objArr3));
                    C5694.m9066(m9035(), new C5652(C2803.m4879(strM90162, "SessionEvent")), i, f16152);
                    fileArrM90333 = m9033(new C5652(C2803.m4879(strM90162, "SessionEvent")));
                }
                File file4 = z2 ? fileArrM90332[0] : null;
                boolean z4 = file4 != null;
                File fileM9034 = z4 ? m9034() : m9037();
                if (!fileM9034.exists()) {
                    fileM9034.mkdirs();
                }
                try {
                    c5831 = new C5831(fileM9034, strM90162);
                    try {
                        c5833M9149 = C5833.m9149(c5831);
                        try {
                            try {
                                C5608 c56085 = C5608.f16066;
                                StringBuilder sb = new StringBuilder();
                                try {
                                    sb.append("Collecting SessionStart data for session ID ");
                                    sb.append(strM90162);
                                    c56085.m8972(sb.toString());
                                    m9020(c5833M9149, file3);
                                    c5833M9149.m9160(4, m9022());
                                    c5833M9149.m9162(5, z4);
                                    i2 = 1;
                                    c5833M9149.m9166(11, 1);
                                    c5833M9149.m9159(12, 3);
                                    m9028(c5833M9149, strM90162);
                                    m9021(c5833M9149, fileArrM90333, strM90162);
                                    if (z4) {
                                        m9020(c5833M9149, file4);
                                    }
                                    C5627.m8999(c5833M9149, "Error flushing session file stream");
                                    C5627.m8998((Closeable) c5831, "Failed to close CLS file");
                                } catch (Exception e3) {
                                    e = e3;
                                    i2 = 1;
                                    C5608.f16066.m8976("Failed to write session file for session ID: " + strM90162, e);
                                    C5627.m8999(c5833M9149, "Error flushing session file stream");
                                    m9027(c5831);
                                }
                            } catch (Throwable th4) {
                                th = th4;
                                c5833 = c5833M9149;
                                C5627.m8999(c5833, "Error flushing session file stream");
                                C5627.m8998((Closeable) c5831, "Failed to close CLS file");
                                throw th;
                            }
                        } catch (Exception e4) {
                            e = e4;
                        }
                    } catch (Exception e5) {
                        e = e5;
                        c5833M9149 = null;
                    } catch (Throwable th5) {
                        th = th5;
                        c5833 = null;
                    }
                } catch (Exception e6) {
                    e = e6;
                    c5833M9149 = null;
                    c5831 = null;
                } catch (Throwable th6) {
                    th = th6;
                    c5833 = null;
                    c5831 = null;
                }
            } else {
                C2803.m4892("No events present for session ID ", strM90162, C5608.f16066);
            }
            C5608.f16066.m8972("Removing session part files for ID " + strM90162);
            for (File file5 : m9033(new C5658(strM90162))) {
                file5.delete();
            }
            i3++;
            c = 0;
        }
        C5691 c5691 = this.f16175;
        long jM9022 = m9022();
        C5828 c5828 = c5691.f16288;
        final String str = c5691.f16292;
        if (c5828 == null) {
            throw null;
        }
        List<File> listM9129 = C5828.m9129(c5828.f16524, new FileFilter(str) { // from class: ދ.ހ.ށ.ބ.ށ.ދ.ؠ

            /* JADX INFO: renamed from: ֏, reason: contains not printable characters */
            public final String f16513;

            {
                this.f16513 = str;
            }

            @Override // java.io.FileFilter
            public boolean accept(File file6) {
                return C5828.m9134(this.f16513, file6);
            }
        });
        Collections.sort(listM9129, C5828.f16521);
        if (listM9129.size() > 8) {
            Iterator<File> it = listM9129.subList(8, listM9129.size()).iterator();
            while (it.hasNext()) {
                C5828.m9141(it.next());
            }
            listM9129 = listM9129.subList(0, 8);
        }
        for (File file6 : listM9129) {
            List<File> listM9130 = C5828.m9130(file6, C5828.f16522);
            if (!listM9130.isEmpty()) {
                Collections.sort(listM9130);
                ArrayList arrayList = new ArrayList();
                while (true) {
                    boolean z5 = false;
                    for (File file7 : listM9130) {
                        try {
                            C5816 c5816 = C5828.f16520;
                            String strM91392 = C5828.m9139(file7);
                            if (c5816 == null) {
                                throw null;
                            }
                            try {
                                JsonReader jsonReader = new JsonReader(new StringReader(strM91392));
                                try {
                                    AbstractC5781.AbstractC5786.AbstractC5792 abstractC5792M9117 = C5816.m9117(jsonReader);
                                    C5816.m9113((Throwable) null, jsonReader);
                                    arrayList.add(abstractC5792M9117);
                                    if (!z5) {
                                        String name3 = file7.getName();
                                        if (!(name3.startsWith("event") && name3.endsWith("_"))) {
                                            break;
                                        }
                                    }
                                    z5 = true;
                                } catch (Throwable th7) {
                                    try {
                                        throw th7;
                                    } catch (Throwable th8) {
                                        C5816.m9113(th7, jsonReader);
                                        throw th8;
                                    }
                                }
                            } catch (IllegalStateException e7) {
                                throw new IOException(e7);
                            }
                        } catch (IOException e8) {
                            C5608.f16066.m8973("Could not add event to report for " + file7, e8);
                        }
                    }
                    try {
                        strM9139 = C5828.m9139(new File(file6, "user"));
                    } catch (IOException e9) {
                        C5608 c56086 = C5608.f16066;
                        StringBuilder sbM4889 = C2803.m4889("Could not read user ID file in ");
                        sbM4889.append(file6.getName());
                        c56086.m8973(sbM4889.toString(), e9);
                        strM9139 = null;
                    }
                    File file8 = new File(file6, "report");
                    File file9 = z5 ? c5828.f16525 : c5828.f16526;
                    try {
                        AbstractC5781 abstractC5781M9109 = C5828.f16520.m9122(C5828.m9139(file8)).m9108(jM9022, z5, strM9139).m9109(new C5810<>(arrayList));
                        AbstractC5781.AbstractC5786 abstractC5786 = ((C5734) abstractC5781M9109).f16356;
                        if (abstractC5786 != null) {
                            C5828.m9137(file9);
                            C5828.m9138(new File(file9, ((C5743) abstractC5786).f16373), C5828.f16520.m9121(abstractC5781M9109));
                        }
                    } catch (IOException e10) {
                        C5608.f16066.m8973("Could not synthesize final report file for " + file8, e10);
                    }
                }
            }
            C5828.m9141(file6);
        }
        int i6 = ((C5857) c5828.f16528).m9207().mo9209().f16613;
        List<File> listM9145 = c5828.m9145();
        int size = listM9145.size();
        if (size <= i6) {
            return;
        }
        Iterator<File> it2 = listM9145.subList(i6, size).iterator();
        while (it2.hasNext()) {
            it2.next().delete();
        }
    }

    /* JADX INFO: renamed from: ֏, reason: contains not printable characters */
    public final void m9026(String str, String str2, InterfaceC5651 interfaceC5651) throws Throwable {
        C5831 c5831;
        C5833 c5833M9149 = null;
        try {
            c5831 = new C5831(m9035(), str + str2);
            try {
                c5833M9149 = C5833.m9149(c5831);
                interfaceC5651.mo9015(c5833M9149);
                C5627.m8999(c5833M9149, "Failed to flush to session " + str2 + " file.");
                C5627.m8998((Closeable) c5831, "Failed to close session " + str2 + " file.");
            } catch (Throwable th) {
                th = th;
                C5627.m8999(c5833M9149, "Failed to flush to session " + str2 + " file.");
                C5627.m8998((Closeable) c5831, "Failed to close session " + str2 + " file.");
                throw th;
            }
        } catch (Throwable th2) {
            th = th2;
            c5831 = null;
        }
    }

    /* JADX INFO: renamed from: ֏, reason: contains not printable characters */
    public final void m9027(C5831 c5831) {
        if (c5831 == null) {
            return;
        }
        try {
            c5831.m9148();
        } catch (IOException e) {
            C5608 c5608 = C5608.f16066;
            if (c5608.m8974(6)) {
                Log.e(c5608.f16067, "Error closing session file stream in the presence of an exception", e);
            }
        }
    }

    /* JADX INFO: renamed from: ֏, reason: contains not printable characters */
    public final void m9028(C5833 c5833, String str) throws Throwable {
        for (String str2 : f16155) {
            File[] fileArrM9033 = m9033(new C5652(C2803.m4880(str, str2, ".cls")));
            if (fileArrM9033.length == 0) {
                C5608.f16066.m8972("Can't find " + str2 + " data for session ID " + str);
            } else {
                C5608.f16066.m8972("Collecting " + str2 + " data for session ID " + str);
                m9020(c5833, fileArrM9033[0]);
            }
        }
    }

    /* JADX INFO: renamed from: ֏, reason: contains not printable characters */
    public final void m9029(C5833 c5833, Thread thread, Throwable th, long j, String str, boolean z) throws IOException {
        Thread[] threadArr;
        Map mapUnmodifiableMap;
        Map treeMap;
        C5879 c5879 = new C5879(th, this.f16171);
        Context context = this.f16156;
        C5625 c5625M8986 = C5625.m8986(context);
        Float f = c5625M8986.f16105;
        int iM8987 = c5625M8986.m8987();
        boolean zM9007 = C5627.m9007(context);
        int i = context.getResources().getConfiguration().orientation;
        long jM9003 = C5627.m9003();
        ActivityManager.MemoryInfo memoryInfo = new ActivityManager.MemoryInfo();
        ((ActivityManager) context.getSystemService("activity")).getMemoryInfo(memoryInfo);
        long j2 = jM9003 - memoryInfo.availMem;
        long jM8991 = C5627.m8991(Environment.getDataDirectory().getPath());
        ActivityManager.RunningAppProcessInfo runningAppProcessInfoM8993 = C5627.m8993(context.getPackageName(), context);
        LinkedList linkedList = new LinkedList();
        StackTraceElement[] stackTraceElementArr = c5879.f16636;
        String str2 = this.f16164.f16098;
        String str3 = this.f16162.f16280;
        int i2 = 0;
        if (z) {
            Map<Thread, StackTraceElement[]> allStackTraces = Thread.getAllStackTraces();
            Thread[] threadArr2 = new Thread[allStackTraces.size()];
            for (Map.Entry<Thread, StackTraceElement[]> entry : allStackTraces.entrySet()) {
                threadArr2[i2] = entry.getKey();
                linkedList.add(this.f16171.mo9216(entry.getValue()));
                i2++;
            }
            threadArr = threadArr2;
        } else {
            threadArr = new Thread[0];
        }
        if (C5627.m9001(context, "com.crashlytics.CollectCustomKeys", true)) {
            mapUnmodifiableMap = Collections.unmodifiableMap(this.f16159.f16294);
            if (mapUnmodifiableMap != null && mapUnmodifiableMap.size() > 1) {
                treeMap = new TreeMap(mapUnmodifiableMap);
            }
            C5835.m9178(c5833, j, str, c5879, thread, stackTraceElementArr, threadArr, linkedList, 8, treeMap, this.f16167.f16305.mo9075(), runningAppProcessInfoM8993, i, str3, str2, f, iM8987, zM9007, j2, jM8991);
            this.f16167.f16305.mo9076();
        }
        mapUnmodifiableMap = new TreeMap();
        treeMap = mapUnmodifiableMap;
        C5835.m9178(c5833, j, str, c5879, thread, stackTraceElementArr, threadArr, linkedList, 8, treeMap, this.f16167.f16305.mo9075(), runningAppProcessInfoM8993, i, str3, str2, f, iM8987, zM9007, j2, jM8991);
        this.f16167.f16305.mo9076();
    }

    /* JADX INFO: renamed from: ֏, reason: contains not printable characters */
    public synchronized void m9030(InterfaceC5859 interfaceC5859, Thread thread, Throwable th) {
        C5608.f16066.m8972("Crashlytics is handling uncaught exception \"" + th + "\" from thread " + thread.getName());
        Date date = new Date();
        try {
            C5694.m9068(this.f16160.m9014(new CallableC5647(date, th, thread, interfaceC5859, C4303.m7055((Executor) new ScheduledThreadPoolExecutor(1), (Callable) new CallableC5661(this, date.getTime())))));
        } catch (Exception unused) {
        }
    }

    /* JADX INFO: renamed from: ֏, reason: contains not printable characters */
    public boolean m9031(int i) {
        this.f16160.m9013();
        if (m9038()) {
            C5608.f16066.m8972("Skipping session finalization because a crash has already occurred.");
            return Boolean.FALSE.booleanValue();
        }
        C5608.f16066.m8972("Finalizing previously open sessions.");
        try {
            m9025(i, false);
            C5608.f16066.m8972("Closed all previously open sessions");
            return true;
        } catch (Exception e) {
            C5608 c5608 = C5608.f16066;
            if (c5608.m8974(6)) {
                Log.e(c5608.f16067, "Unable to finalize previously open sessions.", e);
            }
            return false;
        }
    }

    /* JADX INFO: renamed from: ֏, reason: contains not printable characters */
    public final File[] m9032(File file, FilenameFilter filenameFilter) {
        File[] fileArrListFiles = file.listFiles(filenameFilter);
        return fileArrListFiles == null ? new File[0] : fileArrListFiles;
    }

    /* JADX INFO: renamed from: ֏, reason: contains not printable characters */
    public final File[] m9033(FilenameFilter filenameFilter) {
        File[] fileArrListFiles = m9035().listFiles(filenameFilter);
        return fileArrListFiles == null ? new File[0] : fileArrListFiles;
    }

    /* JADX INFO: renamed from: ؠ, reason: contains not printable characters */
    public File m9034() {
        return new File(m9035(), "fatal-sessions");
    }

    /* JADX INFO: renamed from: ހ, reason: contains not printable characters */
    public File m9035() {
        return this.f16163.m9146();
    }

    /* JADX INFO: renamed from: ށ, reason: contains not printable characters */
    public File m9036() {
        return new File(m9035(), "native-sessions");
    }

    /* JADX INFO: renamed from: ނ, reason: contains not printable characters */
    public File m9037() {
        return new File(m9035(), "nonfatal-sessions");
    }

    /* JADX INFO: renamed from: ރ, reason: contains not printable characters */
    public boolean m9038() {
        C5677 c5677 = this.f16176;
        return c5677 != null && c5677.f16251.get();
    }

    /* JADX INFO: renamed from: ބ, reason: contains not printable characters */
    public File[] m9039() {
        LinkedList linkedList = new LinkedList();
        Collections.addAll(linkedList, m9032(m9034(), f16150));
        Collections.addAll(linkedList, m9032(m9037(), f16150));
        Collections.addAll(linkedList, m9032(m9035(), f16150));
        return (File[]) linkedList.toArray(new File[linkedList.size()]);
    }

    /* JADX INFO: renamed from: ޅ, reason: contains not printable characters */
    public final File[] m9040() {
        File[] fileArrM9033 = m9033(f16149);
        Arrays.sort(fileArrM9033, f16151);
        return fileArrM9033;
    }

    /* JADX INFO: renamed from: ކ, reason: contains not printable characters */
    public void m9041() {
        C5617 c5617 = (C5617) this.f16173;
        InterfaceC5566 interfaceC5566 = c5617.f16088;
        boolean z = false;
        if (interfaceC5566 == null) {
            C5608.f16066.m8972("Firebase Analytics is not present; you will not see automatic logging of events before a crash occurs.");
        } else {
            InterfaceC5566.InterfaceC5567 interfaceC5567Mo8936 = interfaceC5566.mo8936("clx", c5617);
            c5617.f16091 = interfaceC5567Mo8936;
            if (interfaceC5567Mo8936 == null) {
                C5608.f16066.m8972("Could not register AnalyticsConnectorListener with Crashlytics origin.");
                InterfaceC5566.InterfaceC5567 interfaceC5567Mo89362 = c5617.f16088.mo8936("crash", c5617);
                c5617.f16091 = interfaceC5567Mo89362;
                if (interfaceC5567Mo89362 != null) {
                    C5608.f16066.m8977("A new version of the Google Analytics for Firebase SDK is now available. For improved performance and compatibility with Crashlytics, please update to the latest version.");
                }
            }
            if (c5617.f16091 != null) {
                z = true;
            }
        }
        C5608.f16066.m8972("Registered Firebase Analytics event listener for breadcrumbs: " + z);
    }
}
