package defpackage;

import android.app.ActivityManager;
import android.app.ApplicationExitInfo;
import android.content.Context;
import android.os.Build;
import android.os.Environment;
import android.os.StatFs;
import android.text.TextUtils;
import android.util.Base64;
import android.util.JsonReader;
import android.util.Log;
import ar.tvplayer.tv.ProtectedTvPlayerApplication;
import j$.util.DesugarCollections;
import j$.util.Objects;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.FilenameFilter;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStreamWriter;
import java.io.StringReader;
import java.nio.charset.Charset;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Iterator;
import java.util.List;
import java.util.Locale;
import java.util.NavigableSet;
import java.util.concurrent.ScheduledThreadPoolExecutor;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.atomic.AtomicMarkableReference;

/* JADX INFO: renamed from: ᵪᵻᵜᵜ, reason: contains not printable characters */
/* JADX INFO: loaded from: classes3.dex */
public final class C3938 {

    /* JADX INFO: renamed from: ʽˈˋ, reason: contains not printable characters */
    public final ᵕˁـ f15039;

    /* JADX INFO: renamed from: ˊᵫᵗ, reason: contains not printable characters */
    public final C0680 f15040;

    /* JADX INFO: renamed from: ˋˈ, reason: contains not printable characters */
    public C0500 f15041;

    /* JADX INFO: renamed from: ːˏᵟᵯ, reason: contains not printable characters */
    public final ˊˊᵞᵽ f15042;

    /* JADX INFO: renamed from: ᵝᵶ, reason: contains not printable characters */
    public final C2781 f15043;

    /* JADX INFO: renamed from: ᵨᵣ, reason: contains not printable characters */
    public final ᵯᵨᵲ f15045;

    /* JADX INFO: renamed from: ᵮᵣᵗˈ, reason: contains not printable characters */
    public final C1679 f15047;

    /* JADX INFO: renamed from: ᵱᵽʡᵚ, reason: contains not printable characters */
    public final C3597 f15049;

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

    /* JADX INFO: renamed from: ᵵᵽ, reason: contains not printable characters */
    public final ˁᵦ f15051;

    /* JADX INFO: renamed from: ᵶᵥᵝ, reason: contains not printable characters */
    public final InterfaceC0431 f15052;

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

    /* JADX INFO: renamed from: ᵻʽᵯ, reason: contains not printable characters */
    public final C0767 f15054;

    /* JADX INFO: renamed from: ᵻˈᵦʼ, reason: contains not printable characters */
    public final C2869 f15055;

    /* JADX INFO: renamed from: ˊᵙᵾᵲ, reason: contains not printable characters */
    public static final C1086 f15038 = new C1086(1);

    /* JADX INFO: renamed from: ˉᵲ, reason: contains not printable characters */
    public static final Charset f15037 = Charset.forName("UTF-8");

    /* JADX INFO: renamed from: ᵪᵹᵥᵻ, reason: contains not printable characters */
    public final C0589 f15046 = new C0589();

    /* JADX INFO: renamed from: ᵟᵹᵙ, reason: contains not printable characters */
    public final C0589 f15044 = new C0589();

    /* JADX INFO: renamed from: ᵱʡˏ, reason: contains not printable characters */
    public final C0589 f15048 = new C0589();

    public C3938(Context context, C2869 c2869, ᵕˁـ r5, ˁᵦ r6, ˊˊᵞᵽ r7, C0680 c0680, C1356 c1356, C0767 c0767, C2781 c2781, C3597 c3597, InterfaceC0431 interfaceC0431, C1679 c1679, ᵯᵨᵲ r15) {
        new AtomicBoolean(false);
        this.f15050 = context;
        this.f15055 = c2869;
        this.f15039 = r5;
        this.f15051 = r6;
        this.f15042 = r7;
        this.f15040 = c0680;
        this.f15053 = c1356;
        this.f15054 = c0767;
        this.f15049 = c3597;
        this.f15052 = interfaceC0431;
        this.f15047 = c1679;
        this.f15043 = c2781;
        this.f15045 = r15;
    }

    /* JADX INFO: renamed from: ᵲᵶᵳˈ, reason: contains not printable characters */
    public static C1300 m8669(C3938 c3938) {
        C1300 c1300;
        c3938.getClass();
        ArrayList arrayList = new ArrayList();
        for (File file : ˁᵦ.ᵱᵽʡᵚ(((File) c3938.f15051.ʽˈˋ).listFiles(f15038))) {
            try {
                long j = Long.parseLong(file.getName().substring(3));
                try {
                    Class.forName("com.google.firebase.crash.FirebaseCrash");
                    c1300 = ᵥˈᵛ.ᵸˆˁ((Object) null);
                } catch (ClassNotFoundException unused) {
                    Log.isLoggable("FirebaseCrashlytics", 3);
                    c1300 = ᵥˈᵛ.ᵶᵥᵝ(new CallableC0305(c3938, j), new ScheduledThreadPoolExecutor(1));
                }
                arrayList.add(c1300);
            } catch (NumberFormatException unused2) {
                file.getName();
            }
            file.delete();
        }
        return ᵥˈᵛ.ᵡᵶᵬʤ(arrayList);
    }

    /* JADX WARN: Multi-variable type inference failed */
    /* JADX WARN: Removed duplicated region for block: B:153:0x049f  */
    /* JADX WARN: Type inference failed for: r11v17 */
    /* JADX WARN: Type inference failed for: r11v18, types: [int] */
    /* JADX WARN: Type inference failed for: r11v33 */
    /* JADX WARN: Type inference failed for: r32v0, types: [boolean] */
    /* JADX INFO: renamed from: ʽˈˋ, reason: contains not printable characters */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public final void m8670(boolean z, C3420 c3420, boolean z2) throws Throwable {
        C3597 c3597;
        C2781 c2781;
        int i;
        boolean z3;
        int i2;
        int i3;
        boolean z4;
        String str;
        String strSubstring;
        C3245 c3245Mo6853;
        String strM5470;
        String[] list;
        boolean z5;
        List listM6491;
        ApplicationExitInfo next;
        int i4;
        List listUnmodifiableList;
        InputStream traceInputStream;
        FileInputStream fileInputStream;
        FileInputStream fileInputStream2;
        C3597 c35972 = this.f15049;
        ᵯᵨᵲ.ˊᵾʽʼ();
        C2781 c27812 = this.f15043;
        ArrayList arrayList = new ArrayList(((C2054) c27812.f10704).m5474());
        if (arrayList.size() <= z) {
            Log.isLoggable("FirebaseCrashlytics", 2);
            return;
        }
        String str2 = (String) arrayList.get(z == true ? 1 : 0);
        if (z2 && c3420.m7835().f6444.f18641) {
            ˁᵦ r0 = this.f15051;
            i2 = 4;
            if (Build.VERSION.SDK_INT >= 30) {
                List<ApplicationExitInfo> historicalProcessExitReasons = ((ActivityManager) this.f15050.getSystemService("activity")).getHistoricalProcessExitReasons(null, 0, 0);
                if (historicalProcessExitReasons.size() != 0) {
                    C0767 c0767 = new C0767(r0);
                    i3 = 8;
                    c0767.f3432 = C0767.f3430;
                    if (str2 != null) {
                        c0767.f3432 = new C4337(r0.ᵷᵺʾᵖ(str2, "userlog"));
                    }
                    ᵯᵨᵲ r9 = this.f15045;
                    C2692 c2692 = new C2692(r0);
                    C1356 c1356 = new C1356(str2, r0, r9);
                    ((C0107) ((AtomicMarkableReference) ((C0764) c1356.f5618).f3428).getReference()).m1179(c2692.m6496(str2, false));
                    ((C0107) ((AtomicMarkableReference) ((C0764) c1356.f5619).f3428).getReference()).m1179(c2692.m6496(str2, true));
                    ((AtomicMarkableReference) c1356.f5614).set(c2692.m6498(str2), false);
                    C1486 c1486 = (C1486) c1356.f5620;
                    File file = r0.ᵷᵺʾᵖ(str2, "rollouts-state");
                    if (!file.exists() || file.length() == 0) {
                        z5 = true;
                        if (file.exists() && file.delete()) {
                            file.getAbsolutePath();
                        }
                        listM6491 = Collections.EMPTY_LIST;
                    } else {
                        try {
                            fileInputStream2 = new FileInputStream(file);
                            try {
                                try {
                                    listM6491 = C2692.m6491(ᵥˇᵛˎ.ˆˀᵯ(fileInputStream2));
                                    listM6491.toString();
                                    z5 = true;
                                } catch (Exception unused) {
                                    z5 = true;
                                }
                                try {
                                    Log.isLoggable("FirebaseCrashlytics", 3);
                                    ᵥˇᵛˎ.ᵻˈᵦʼ(fileInputStream2);
                                } catch (Exception unused2) {
                                    C2692.m6494(file);
                                    ᵥˇᵛˎ.ᵻˈᵦʼ(fileInputStream2);
                                    listM6491 = Collections.EMPTY_LIST;
                                }
                            } catch (Throwable th) {
                                th = th;
                                fileInputStream = fileInputStream2;
                                ᵥˇᵛˎ.ᵻˈᵦʼ(fileInputStream);
                                throw th;
                            }
                        } catch (Exception unused3) {
                            z5 = true;
                            fileInputStream2 = null;
                        } catch (Throwable th2) {
                            th = th2;
                            fileInputStream = null;
                            ᵥˇᵛˎ.ᵻˈᵦʼ(fileInputStream);
                            throw th;
                        }
                    }
                    c1486.m4261(listM6491);
                    C2054 c2054 = (C2054) c27812.f10704;
                    long jLastModified = c2054.f8143.ᵷᵺʾᵖ(str2, "start-time").lastModified();
                    Iterator<ApplicationExitInfo> it = historicalProcessExitReasons.iterator();
                    while (it.hasNext()) {
                        next = it.next();
                        if (next.getTimestamp() < jLastModified) {
                            break;
                        }
                        if (next.getReason() == 6) {
                            break;
                        }
                    }
                    next = null;
                    if (next == null) {
                        Log.isLoggable("FirebaseCrashlytics", 2);
                        c3597 = c35972;
                        c2781 = c27812;
                        z3 = z5;
                    } else {
                        C4564 c4564 = (C4564) c27812.f10705;
                        try {
                            traceInputStream = next.getTraceInputStream();
                        } catch (IOException e) {
                            next.toString();
                            e.toString();
                        }
                        String strM6751 = traceInputStream != null ? C2781.m6751(traceInputStream) : null;
                        C0490 c0490 = new C0490();
                        c0490.f2598 = next.getImportance();
                        c0490.f2595 = (byte) (c0490.f2595 | 4);
                        String processName = next.getProcessName();
                        if (processName == null) {
                            C4935.m10233("Null processName");
                            return;
                        }
                        c0490.f2591 = processName;
                        c0490.f2593 = next.getReason();
                        c0490.f2595 = (byte) (c0490.f2595 | 2);
                        c0490.f2597 = next.getTimestamp();
                        c0490.f2595 = (byte) (c0490.f2595 | 32);
                        c0490.f2596 = next.getPid();
                        c0490.f2595 = (byte) (c0490.f2595 | 1);
                        c0490.f2594 = next.getPss();
                        c0490.f2595 = (byte) (c0490.f2595 | 8);
                        c0490.f2600 = next.getRss();
                        c0490.f2595 = (byte) (c0490.f2595 | 16);
                        c0490.f2592 = strM6751;
                        C1897 c1897M1963 = c0490.m1963();
                        int i5 = c4564.f17356.getResources().getConfiguration().orientation;
                        C3887 c3887 = new C3887();
                        c3887.f14825 = "anr";
                        long j = c1897M1963.f7517;
                        c3887.f14828 = j;
                        c3887.f14829 = (byte) (c3887.f14829 | 1);
                        C0680 c0680 = c4564.f17354;
                        c3597 = c35972;
                        if (!c4564.f17355.m7835().f6444.f18642 || c0680.f3121.size() <= 0) {
                            c2781 = c27812;
                            i4 = i5;
                            listUnmodifiableList = null;
                        } else {
                            ArrayList arrayList2 = new ArrayList();
                            ArrayList arrayList3 = c0680.f3121;
                            i4 = i5;
                            int size = arrayList3.size();
                            c2781 = c27812;
                            int i6 = 0;
                            while (i6 < size) {
                                Object obj = arrayList3.get(i6);
                                int i7 = i6 + 1;
                                ArrayList arrayList4 = arrayList3;
                                C4594 c4594 = (C4594) obj;
                                String str3 = c4594.f17484;
                                if (str3 == null) {
                                    C4935.m10233("Null libraryName");
                                    return;
                                }
                                int i8 = size;
                                String str4 = c4594.f17482;
                                if (str4 == null) {
                                    C4935.m10233("Null arch");
                                    return;
                                }
                                String str5 = c4594.f17483;
                                if (str5 == null) {
                                    C4935.m10233("Null buildId");
                                    return;
                                }
                                arrayList2.add(new C2500(str4, str3, str5));
                                i6 = i7;
                                size = i8;
                                arrayList3 = arrayList4;
                            }
                            listUnmodifiableList = DesugarCollections.unmodifiableList(arrayList2);
                        }
                        C0490 c04902 = new C0490();
                        c04902.f2598 = c1897M1963.f7518;
                        byte b = (byte) (c04902.f2595 | 4);
                        c04902.f2595 = b;
                        String str6 = c1897M1963.f7512;
                        if (str6 == null) {
                            C4935.m10233("Null processName");
                            return;
                        }
                        c04902.f2591 = str6;
                        c04902.f2593 = c1897M1963.f7514;
                        c04902.f2597 = j;
                        c04902.f2596 = c1897M1963.f7516;
                        c04902.f2594 = c1897M1963.f7515;
                        c04902.f2600 = c1897M1963.f7520;
                        c04902.f2595 = (byte) (((byte) (((byte) (((byte) (((byte) (b | 2)) | 32)) | 1)) | 8)) | 16);
                        c04902.f2592 = c1897M1963.f7513;
                        c04902.f2599 = listUnmodifiableList;
                        C1897 c1897M19632 = c04902.m1963();
                        int i9 = c1897M19632.f7518;
                        Boolean boolValueOf = Boolean.valueOf(i9 != 100 ? z5 : false);
                        String str7 = c1897M19632.f7512;
                        int i10 = c1897M19632.f7516;
                        C2701 c2701 = new C2701();
                        c2701.f10394 = str7;
                        c2701.f10391 = i10;
                        byte b2 = (byte) (c2701.f10393 | 1);
                        c2701.f10392 = i9;
                        c2701.f10395 = false;
                        c2701.f10393 = (byte) (((byte) (b2 | 2)) | 4);
                        C2940 c2940M6512 = c2701.m6512();
                        C4160 c4160M9648 = C4564.m9648();
                        List listM9651 = c4564.m9651();
                        if (listM9651 == null) {
                            C4935.m10233("Null binaries");
                            return;
                        }
                        c3887.f14826 = new C3746(new C0858(null, null, c1897M19632, c4160M9648, listM9651), null, null, boolValueOf, c2940M6512, null, i4);
                        c3887.f14830 = c4564.m9650(i4);
                        C1550 c1550M8591 = c3887.m8591();
                        Log.isLoggable("FirebaseCrashlytics", 3);
                        z3 = z5;
                        c2054.m5475(C2781.m6740(C2781.m6746(c1550M8591, c0767, c1356, Collections.EMPTY_MAP), c1356), str2, z3);
                    }
                    i = 2;
                } else {
                    c3597 = c35972;
                    c2781 = c27812;
                    i = 2;
                    z3 = true;
                    i3 = 8;
                    Log.isLoggable("FirebaseCrashlytics", 2);
                }
            } else {
                c3597 = c35972;
                c2781 = c27812;
                i = 2;
                z3 = true;
                i3 = 8;
                Log.isLoggable("FirebaseCrashlytics", 2);
            }
        } else {
            c3597 = c35972;
            c2781 = c27812;
            i = 2;
            z3 = true;
            i2 = 4;
            i3 = 8;
            Log.isLoggable("FirebaseCrashlytics", 2);
        }
        if (z2 && c3597.m8128()) {
            Log.isLoggable("FirebaseCrashlytics", i);
            c3597.m8129().getClass();
        }
        if (z != 0) {
            z4 = false;
            str = (String) arrayList.get(0);
        } else {
            z4 = false;
            this.f15047.m4552(null);
            str = null;
        }
        long jCurrentTimeMillis = System.currentTimeMillis() / 1000;
        C2054 c20542 = (C2054) c2781.f10704;
        ˁᵦ r8 = c20542.f8143;
        r8.ᵲᵶᵳˈ(".com.google.firebase.crashlytics");
        r8.ᵲᵶᵳˈ(".com.google.firebase.crashlytics-ndk");
        if (!((String) r8.ːˏᵟᵯ).isEmpty()) {
            r8.ᵲᵶᵳˈ(".com.google.firebase.crashlytics.files.v1");
            final String str8 = ".com.google.firebase.crashlytics.files.v2" + File.pathSeparator;
            File file2 = (File) r8.ᵲᵶᵳˈ;
            if (file2.exists() && (list = file2.list(new FilenameFilter() { // from class: ᵛᵠᵎ
                @Override // java.io.FilenameFilter
                public final boolean accept(File file3, String str9) {
                    return str9.startsWith(str8);
                }
            })) != null) {
                int length = list.length;
                for (?? r11 = z4; r11 < length; r11++) {
                    r8.ᵲᵶᵳˈ(list[r11]);
                }
            }
        }
        NavigableSet<String> navigableSetM5474 = c20542.m5474();
        if (str != null) {
            navigableSetM5474.remove(str);
        }
        int i11 = i3;
        if (navigableSetM5474.size() > i11) {
            while (navigableSetM5474.size() > i11) {
                String str9 = (String) navigableSetM5474.last();
                Log.isLoggable("FirebaseCrashlytics", 3);
                ˁᵦ.ˊᵫᵗ(new File((File) r8.ᵷᵺʾᵖ, str9));
                navigableSetM5474.remove(str9);
            }
        }
        for (String str10 : navigableSetM5474) {
            Log.isLoggable("FirebaseCrashlytics", 2);
            C2716 c2716 = C2054.f8140;
            C1086 c1086 = C2054.f8141;
            File file3 = new File((File) r8.ᵷᵺʾᵖ, str10);
            file3.mkdirs();
            List<File> list2 = ˁᵦ.ᵱᵽʡᵚ(file3.listFiles(c1086));
            if (list2.isEmpty()) {
                Log.isLoggable("FirebaseCrashlytics", 2);
            } else {
                Collections.sort(list2);
                ArrayList arrayList5 = new ArrayList();
                boolean z6 = z4;
                for (File file4 : list2) {
                    try {
                        strM5470 = C2054.m5470(file4);
                        c2716.getClass();
                    } catch (IOException unused4) {
                        Objects.toString(file4);
                    }
                    try {
                        JsonReader jsonReader = new JsonReader(new StringReader(strM5470));
                        try {
                            C1550 c1550M6608 = C2716.m6608(jsonReader);
                            jsonReader.close();
                            arrayList5.add(c1550M6608);
                            if (!z6) {
                                String name = file4.getName();
                                boolean z7 = (name.startsWith("event") && name.endsWith("_")) ? z3 : false;
                                z6 = z7;
                            }
                        } finally {
                        }
                    } catch (IllegalStateException e2) {
                        throw new IOException(e2);
                    }
                }
                if (!arrayList5.isEmpty()) {
                    String strM6498 = new C2692(r8).m6498(str10);
                    ᵣˊˈᵪ r1 = c20542.f8146.f6624;
                    synchronized (r1) {
                        if (Objects.equals((String) r1.ᵔᵖᵹᵫ, str10)) {
                            strSubstring = (String) r1.ᵨᵼⁱ;
                        } else {
                            ˁᵦ r2 = (ˁᵦ) r1.ᵜᵪʾ;
                            C1086 c10862 = ᵣˊˈᵪ.ᵯᵷʽ;
                            File file5 = new File((File) r2.ᵷᵺʾᵖ, str10);
                            file5.mkdirs();
                            List list3 = ˁᵦ.ᵱᵽʡᵚ(file5.listFiles(c10862));
                            strSubstring = list3.isEmpty() ? null : ((File) Collections.min(list3, ᵣˊˈᵪ.ᵶˇᵱ)).getName().substring(i2);
                        }
                    }
                    File file6 = r8.ᵷᵺʾᵖ(str10, "report");
                    try {
                        String strM54702 = C2054.m5470(file6);
                        c2716.getClass();
                        C3051 c3051M6612 = C2716.m6612(strM54702);
                        C1703 c1703M7148 = c3051M6612.m7148();
                        AbstractC2866 abstractC2866 = c3051M6612.f11689;
                        if (abstractC2866 != null) {
                            try {
                                c3245Mo6853 = abstractC2866.mo6853();
                                c3245Mo6853.f12346 = Long.valueOf(jCurrentTimeMillis);
                                c3245Mo6853.f12354 = z6;
                            } catch (IOException unused5) {
                            }
                            try {
                                c3245Mo6853.f12345 = (byte) (c3245Mo6853.f12345 | 2);
                                if (strM6498 != null) {
                                    c3245Mo6853.f12343 = new C3066(strM6498);
                                }
                                c1703M7148.f6806 = c3245Mo6853.m7396();
                            } catch (IOException unused6) {
                            }
                        }
                        C3051 c3051M4691 = c1703M7148.m4691();
                        C1703 c1703M71482 = c3051M4691.m7148();
                        c1703M71482.f6808 = strSubstring;
                        AbstractC2866 abstractC28662 = c3051M4691.f11689;
                        if (abstractC28662 != null) {
                            C3245 c3245Mo68532 = abstractC28662.mo6853();
                            c3245Mo68532.f12344 = strSubstring;
                            c1703M71482.f6806 = c3245Mo68532.m7396();
                        }
                        C3051 c3051M46912 = c1703M71482.m4691();
                        AbstractC2866 abstractC28663 = c3051M46912.f11689;
                        if (abstractC28663 == null) {
                            throw new IllegalStateException("Reports without sessions cannot have events added to them.");
                        }
                        C1703 c1703M71483 = c3051M46912.m7148();
                        C3245 c3245Mo68533 = abstractC28663.mo6853();
                        c3245Mo68533.f12351 = arrayList5;
                        c1703M71483.f6806 = c3245Mo68533.m7396();
                        C3051 c3051M46913 = c1703M71483.m4691();
                        AbstractC2866 abstractC28664 = c3051M46913.f11689;
                        if (abstractC28664 != null) {
                            try {
                                Log.isLoggable("FirebaseCrashlytics", 3);
                                C2054.m5472(z6 ? new File((File) r8.ᵻˈᵦʼ, ((C4959) abstractC28664).f18829) : new File((File) r8.ᵨᵣ, ((C4959) abstractC28664).f18829), C2716.f10427.ˊᵡᵗʨ(c3051M46913));
                            } catch (IOException unused7) {
                                Objects.toString(file6);
                            }
                        }
                    } catch (IOException unused8) {
                    }
                    Objects.toString(file6);
                }
                ˁᵦ.ˊᵫᵗ(new File((File) r8.ᵷᵺʾᵖ, str10));
                z4 = false;
                i2 = 4;
            }
            ˁᵦ.ˊᵫᵗ(new File((File) r8.ᵷᵺʾᵖ, str10));
            z4 = false;
            i2 = 4;
        }
        ᵾːʿ r02 = c20542.f8144.m7835().f6447;
        ArrayList arrayListM5473 = c20542.m5473();
        int size2 = arrayListM5473.size();
        if (size2 <= 4) {
            return;
        }
        Iterator it2 = arrayListM5473.subList(4, size2).iterator();
        while (it2.hasNext()) {
            ((File) it2.next()).delete();
        }
    }

    /* JADX INFO: renamed from: ːˏᵟᵯ, reason: contains not printable characters */
    public final void m8671(String str, Boolean bool) {
        String str2;
        String str3;
        String str4;
        int i;
        Integer num;
        long jCurrentTimeMillis = System.currentTimeMillis() / 1000;
        Log.isLoggable("FirebaseCrashlytics", 3);
        Locale locale = Locale.US;
        C2869 c2869 = this.f15055;
        C0680 c0680 = this.f15040;
        C4315 c4315 = new C4315(c2869.f10974, c0680.f3126, c0680.f3124, c2869.m6856().f14946, AbstractC3589.m8105(c0680.f3125 != null ? 4 : 1), c0680.f3120);
        String str5 = Build.VERSION.RELEASE;
        String str6 = Build.VERSION.CODENAME;
        C3573 c3573 = new C3573(ᵥˇᵛˎ.ˊˌˊ());
        Context context = this.f15050;
        StatFs statFs = new StatFs(Environment.getDataDirectory().getPath());
        long blockCount = ((long) statFs.getBlockCount()) * ((long) statFs.getBlockSize());
        EnumC4855 enumC4855 = EnumC4855.f18522;
        String str7 = Build.CPU_ABI;
        if (TextUtils.isEmpty(str7)) {
            Log.isLoggable("FirebaseCrashlytics", 2);
        } else {
            EnumC4855 enumC48552 = (EnumC4855) EnumC4855.f18524.get(str7.toLowerCase(locale));
            if (enumC48552 != null) {
                enumC4855 = enumC48552;
            }
        }
        int iOrdinal = enumC4855.ordinal();
        String str8 = Build.MODEL;
        int iAvailableProcessors = Runtime.getRuntime().availableProcessors();
        long j = ᵥˇᵛˎ.ːˏᵟᵯ(context);
        boolean z = ᵥˇᵛˎ.ᵞᵛᵘ();
        int i2 = ᵥˇᵛˎ.ᵯᵷʽ();
        String str9 = Build.MANUFACTURER;
        String str10 = Build.PRODUCT;
        C0439 c0439 = new C0439(iOrdinal, iAvailableProcessors, j, blockCount, z, i2);
        C3597 c3597 = this.f15049;
        C4909 c4909 = new C4909(c4315, c3573, c0439);
        c3597.getClass();
        Log.isLoggable("FirebaseCrashlytics", 2);
        c3597.f13704.m8300(new C3413(str, jCurrentTimeMillis, c4909));
        if (!bool.booleanValue() || str == null) {
            str2 = str9;
            str3 = str10;
            str4 = str8;
            i = 4;
        } else {
            C1356 c1356 = this.f15053;
            synchronized (((String) c1356.f5616)) {
                c1356.f5616 = str;
                str2 = str9;
                str4 = str8;
                str3 = str10;
                i = 4;
                ((ExecutorC5381) ((ᵯᵨᵲ) c1356.f5617).ᵔᵖᵹᵫ).m10975(new RunnableC4553(c1356, str, ((C0107) ((AtomicMarkableReference) ((C0764) c1356.f5618).f3428).getReference()).m1178(), ((C1486) c1356.f5620).m4260(), 2));
            }
        }
        C0767 c0767 = this.f15054;
        ((InterfaceC3441) c0767.f3432).mo7856();
        c0767.f3432 = C0767.f3430;
        if (str != null) {
            c0767.f3432 = new C4337(((ˁᵦ) c0767.f3433).ᵷᵺʾᵖ(str, "userlog"));
        }
        this.f15047.m4552(str);
        C2781 c2781 = this.f15043;
        C4564 c4564 = (C4564) c2781.f10705;
        Charset charset = AbstractC4079.f15663;
        C1703 c1703 = new C1703();
        c1703.f6807 = "20.0.6";
        C0680 c06802 = c4564.f17354;
        String str11 = c06802.f3123;
        if (str11 == null) {
            C4935.m10233("Null gmpAppId");
            return;
        }
        c1703.f6800 = str11;
        C2869 c28692 = c4564.f17353;
        String str12 = c28692.m6856().f14946;
        if (str12 == null) {
            C4935.m10233("Null installationUuid");
            return;
        }
        c1703.f6810 = str12;
        c1703.f6804 = c28692.m6856().f14944;
        c1703.f6812 = c28692.m6856().f14945;
        String str13 = c06802.f3126;
        if (str13 == null) {
            C4935.m10233("Null buildVersion");
            return;
        }
        c1703.f6801 = str13;
        String str14 = c06802.f3124;
        if (str14 == null) {
            C4935.m10233("Null displayVersion");
            return;
        }
        c1703.f6811 = str14;
        c1703.f6802 = i;
        c1703.f6803 = (byte) (c1703.f6803 | 1);
        C3245 c3245 = new C3245();
        c3245.f12354 = false;
        byte b = (byte) (c3245.f12345 | 2);
        c3245.f12352 = jCurrentTimeMillis;
        c3245.f12345 = (byte) (b | 1);
        if (str == null) {
            C4935.m10233("Null identifier");
            return;
        }
        c3245.f12342 = str;
        String str15 = C4564.f17351;
        if (str15 == null) {
            C4935.m10233("Null generator");
            return;
        }
        c3245.f12349 = str15;
        String str16 = c28692.f10974;
        if (str16 == null) {
            C4935.m10233("Null identifier");
            return;
        }
        String str17 = c28692.m6856().f14946;
        C0767 c07672 = c06802.f3120;
        if (((C3790) c07672.f3432) == null) {
            c07672.f3432 = new C3790(c07672);
        }
        C3790 c3790 = (C3790) c07672.f3432;
        String str18 = c3790.f14395;
        if (c3790 == null) {
            c07672.f3432 = new C3790(c07672);
        }
        c3245.f12350 = new C3092(str16, str13, str14, str17, str18, ((C3790) c07672.f3432).f14394);
        C3910 c3910 = new C3910();
        c3910.f14936 = 3;
        c3910.f14935 = (byte) (c3910.f14935 | 1);
        if (str5 == null) {
            C4935.m10233("Null version");
            return;
        }
        c3910.f14933 = str5;
        if (str6 == null) {
            C4935.m10233("Null buildVersion");
            return;
        }
        c3910.f14934 = str6;
        c3910.f14937 = ᵥˇᵛˎ.ˊˌˊ();
        c3910.f14935 = (byte) (c3910.f14935 | 2);
        c3245.f12353 = c3910.m8636();
        StatFs statFs2 = new StatFs(Environment.getDataDirectory().getPath());
        int iIntValue = 7;
        if (!TextUtils.isEmpty(str7) && (num = (Integer) C4564.f17352.get(str7.toLowerCase(locale))) != null) {
            iIntValue = num.intValue();
        }
        int iAvailableProcessors2 = Runtime.getRuntime().availableProcessors();
        long j2 = ᵥˇᵛˎ.ːˏᵟᵯ(c4564.f17356);
        long blockCount2 = ((long) statFs2.getBlockCount()) * ((long) statFs2.getBlockSize());
        boolean z2 = ᵥˇᵛˎ.ᵞᵛᵘ();
        int i3 = ᵥˇᵛˎ.ᵯᵷʽ();
        C1094 c1094 = new C1094();
        c1094.f4657 = iIntValue;
        byte b2 = (byte) (c1094.f4656 | 1);
        c1094.f4656 = b2;
        if (str4 == null) {
            C4935.m10233("Null model");
            return;
        }
        c1094.f4652 = str4;
        c1094.f4654 = iAvailableProcessors2;
        c1094.f4659 = j2;
        c1094.f4655 = blockCount2;
        c1094.f4661 = z2;
        c1094.f4658 = i3;
        c1094.f4656 = (byte) (((byte) (((byte) (((byte) (((byte) (b2 | 2)) | 4)) | 8)) | 16)) | 32);
        if (str2 == null) {
            C4935.m10233("Null manufacturer");
            return;
        }
        c1094.f4653 = str2;
        String str19 = str3;
        if (str19 == null) {
            C4935.m10233("Null modelClass");
            return;
        }
        c1094.f4660 = str19;
        c3245.f12348 = c1094.m3542();
        c3245.f12347 = 3;
        c3245.f12345 = (byte) (c3245.f12345 | 4);
        c1703.f6806 = c3245.m7396();
        C3051 c3051M4691 = c1703.m4691();
        ˁᵦ r0 = ((C2054) c2781.f10704).f8143;
        AbstractC2866 abstractC2866 = c3051M4691.f11689;
        if (abstractC2866 == null) {
            Log.isLoggable("FirebaseCrashlytics", 3);
            return;
        }
        String str20 = ((C4959) abstractC2866).f18829;
        try {
            C2054.f8140.getClass();
            C2054.m5472(r0.ᵷᵺʾᵖ(str20, "report"), C2716.f10427.ˊᵡᵗʨ(c3051M4691));
            File file = r0.ᵷᵺʾᵖ(str20, "start-time");
            long j3 = ((C4959) abstractC2866).f18838;
            OutputStreamWriter outputStreamWriter = new OutputStreamWriter(new FileOutputStream(file), C2054.f8139);
            try {
                outputStreamWriter.write("");
                file.setLastModified(j3 * 1000);
                outputStreamWriter.close();
            } finally {
            }
        } catch (IOException unused) {
            Log.isLoggable("FirebaseCrashlytics", 3);
        }
    }

    /* JADX INFO: renamed from: ᵨᵣ, reason: contains not printable characters */
    public final void m8672() {
        try {
            String strM8673 = m8673();
            if (strM8673 != null) {
                try {
                    this.f15053.m3895(strM8673);
                } catch (IllegalArgumentException e) {
                    Context context = this.f15050;
                    if (context != null && (context.getApplicationInfo().flags & 2) != 0) {
                        throw e;
                    }
                }
            }
        } catch (IOException unused) {
        }
    }

    /* JADX INFO: renamed from: ᵷᵺʾᵖ, reason: contains not printable characters */
    public final String m8673() throws IOException {
        ByteArrayOutputStream byteArrayOutputStream;
        byte[] bArr;
        Context context = this.f15050;
        int i = ᵥˇᵛˎ.ˀᵭ(context, "com.google.firebase.crashlytics.version_control_info", "string");
        String string = i == 0 ? null : context.getResources().getString(i);
        if (string != null) {
            Log.isLoggable("FirebaseCrashlytics", 3);
            return Base64.encodeToString(string.getBytes(f15037), 0);
        }
        ClassLoader classLoader = C3938.class.getClassLoader();
        InputStream inputStreamA = classLoader == null ? null : ProtectedTvPlayerApplication.a(classLoader, "META-INF/version-control-info.textproto");
        if (inputStreamA == null) {
            if (inputStreamA != null) {
                inputStreamA.close();
            }
            return null;
        }
        try {
            Log.isLoggable("FirebaseCrashlytics", 3);
            byteArrayOutputStream = new ByteArrayOutputStream();
            try {
                bArr = new byte[1024];
            } finally {
            }
        } catch (Throwable th) {
            try {
                inputStreamA.close();
            } catch (Throwable th2) {
                th.addSuppressed(th2);
            }
            throw th;
        }
        while (true) {
            int i2 = inputStreamA.read(bArr);
            if (i2 == -1) {
                byte[] byteArray = byteArrayOutputStream.toByteArray();
                byteArrayOutputStream.close();
                String strEncodeToString = Base64.encodeToString(byteArray, 0);
                inputStreamA.close();
                return strEncodeToString;
            }
            byteArrayOutputStream.write(bArr, 0, i2);
            inputStreamA.close();
            throw th;
        }
    }

    /* JADX INFO: renamed from: ᵻˈᵦʼ, reason: contains not printable characters */
    public final void m8674(C1300 c1300) {
        C1300 c13002;
        C1300 c13003;
        C0589 c0589 = this.f15046;
        ˁᵦ r2 = ((C2054) this.f15043.f10704).f8143;
        if (ˁᵦ.ᵱᵽʡᵚ(((File) r2.ᵨᵣ).listFiles()).isEmpty() && ˁᵦ.ᵱᵽʡᵚ(((File) r2.ᵻˈᵦʼ).listFiles()).isEmpty() && ˁᵦ.ᵱᵽʡᵚ(((File) r2.ᵵᵽ).listFiles()).isEmpty()) {
            Log.isLoggable("FirebaseCrashlytics", 2);
            c0589.m2219(Boolean.FALSE);
            return;
        }
        Log.isLoggable("FirebaseCrashlytics", 2);
        ᵕˁـ r22 = this.f15039;
        if (r22.ˊᵙᵾᵲ()) {
            Log.isLoggable("FirebaseCrashlytics", 3);
            c0589.m2219(Boolean.FALSE);
            c13003 = ᵥˈᵛ.ᵸˆˁ(Boolean.TRUE);
        } else {
            Log.isLoggable("FirebaseCrashlytics", 3);
            Log.isLoggable("FirebaseCrashlytics", 2);
            c0589.m2219(Boolean.TRUE);
            synchronized (r22.ᵔᵖᵹᵫ) {
                c13002 = ((C0589) r22.ᵨᵼⁱ).f2890;
            }
            ᵠʽᵲ r0 = new ᵠʽᵲ(16);
            c13002.getClass();
            ˆـᵨʾ r3 = AbstractC5099.f19213;
            C1300 c13004 = new C1300();
            c13002.f5419.m10701(new C4805(r3, r0, c13004));
            c13002.m3820();
            Log.isLoggable("FirebaseCrashlytics", 3);
            c13003 = ᵫﾞˌ.ˊᵨᵧ(c13004, this.f15044.f2890);
        }
        c13003.m3824((ExecutorC5381) this.f15045.ᵜᵪʾ, new C0767(this, 14, c1300));
    }
}
