APK反编译源代码展示 - 南明离火平台提供

应用版本信息
应用名称:Ghostify
版本号:4.0
包名称:com.getghostify

MD5 校验值:a9a821418db4ad35214aeeb08c2f5902

反编译源代码说明

n.java 文件包含反编译后的源代码,请注意,该内容仅供学习和参考使用,不得用于非法用途。


package d5;

import a5.c;
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.JsonReader;
import android.util.Log;
import d5.e;
import f5.a0;
import f5.b;
import f5.c;
import f5.g;
import f5.j;
import f5.k;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStreamWriter;
import java.io.StringReader;
import java.nio.charset.Charset;
import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Locale;
import java.util.Objects;
import java.util.SortedSet;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.ScheduledThreadPoolExecutor;
import java.util.concurrent.atomic.AtomicBoolean;

public class n {

    public final Context f3904a;

    public final z f3905b;

    public final androidx.appcompat.widget.l f3906c;

    public final f f3907d;

    public final d0 f3908e;

    public final i5.d f3909f;

    public final d5.a f3910g;

    public final e5.c f3911h;

    public final a5.a f3912i;

    public final b5.a f3913j;

    public final g0 f3914k;

    public y f3915l;

    public final e3.j<Boolean> f3916m = new e3.j<>();

    public final e3.j<Boolean> f3917n = new e3.j<>();

    public final e3.j<Void> f3918o = new e3.j<>();

    public class a implements e3.h<Boolean, Void> {

        public final e3.i f3919k;

        public a(e3.i iVar) {
            this.f3919k = iVar;
        }

        @Override
        public e3.i<Void> h(Boolean bool) {
            return n.this.f3907d.c(new m(this, bool));
        }
    }

    public n(Context context, f fVar, d0 d0Var, z zVar, i5.d dVar, androidx.appcompat.widget.l lVar, d5.a aVar, e5.g gVar, e5.c cVar, g0 g0Var, a5.a aVar2, b5.a aVar3) {
        new AtomicBoolean(false);
        this.f3904a = context;
        this.f3907d = fVar;
        this.f3908e = d0Var;
        this.f3905b = zVar;
        this.f3909f = dVar;
        this.f3906c = lVar;
        this.f3910g = aVar;
        this.f3911h = cVar;
        this.f3912i = aVar2;
        this.f3913j = aVar3;
        this.f3914k = g0Var;
    }

    public static void a(n nVar, String str) {
        c.a aVar;
        Integer num;
        Objects.requireNonNull(nVar);
        long currentTimeMillis = System.currentTimeMillis() / 1000;
        String n9 = androidx.activity.b.n("Opening a new session with ID ", str);
        Integer num2 = 3;
        if (Log.isLoggable("FirebaseCrashlytics", 3)) {
            Log.d("FirebaseCrashlytics", n9, null);
        }
        Locale locale = Locale.US;
        String format = String.format(locale, "Crashlytics Android SDK/%s", "18.2.12");
        d0 d0Var = nVar.f3908e;
        d5.a aVar2 = nVar.f3910g;
        f5.x xVar = new f5.x(d0Var.f3851c, aVar2.f3832e, aVar2.f3833f, d0Var.c(), androidx.activity.b.e(aVar2.f3830c != null ? 4 : 1), aVar2.f3834g);
        String str2 = Build.VERSION.RELEASE;
        String str3 = Build.VERSION.CODENAME;
        f5.z zVar = new f5.z(str2, str3, e.k());
        StatFs statFs = new StatFs(Environment.getDataDirectory().getPath());
        long blockCount = statFs.getBlockCount() * statFs.getBlockSize();
        e.a aVar3 = e.a.UNKNOWN;
        String str4 = Build.CPU_ABI;
        if (!TextUtils.isEmpty(str4)) {
            e.a aVar4 = (e.a) ((HashMap) e.a.f3858l).get(str4.toLowerCase(locale));
            if (aVar4 != null) {
                aVar3 = aVar4;
            }
        } else if (Log.isLoggable("FirebaseCrashlytics", 2)) {
            Log.v("FirebaseCrashlytics", "Architecture#getValue()::Build.CPU_ABI returned null or empty", null);
        }
        int ordinal = aVar3.ordinal();
        String str5 = Build.MODEL;
        int availableProcessors = Runtime.getRuntime().availableProcessors();
        long h9 = e.h();
        boolean j9 = e.j();
        int d9 = e.d();
        String str6 = Build.MANUFACTURER;
        String str7 = Build.PRODUCT;
        nVar.f3912i.a(str, format, currentTimeMillis, new f5.w(xVar, zVar, new f5.y(ordinal, str5, availableProcessors, h9, blockCount, j9, d9, str6, str7)));
        nVar.f3911h.a(str);
        g0 g0Var = nVar.f3914k;
        w wVar = g0Var.f3876a;
        Objects.requireNonNull(wVar);
        Charset charset = f5.a0.f4649a;
        b.C0071b c0071b = new b.C0071b();
        c0071b.f4658a = "18.2.12";
        String str8 = wVar.f3953c.f3828a;
        Objects.requireNonNull(str8, "Null gmpAppId");
        c0071b.f4659b = str8;
        String c9 = wVar.f3952b.c();
        Objects.requireNonNull(c9, "Null installationUuid");
        c0071b.f4661d = c9;
        String str9 = wVar.f3953c.f3832e;
        Objects.requireNonNull(str9, "Null buildVersion");
        c0071b.f4662e = str9;
        String str10 = wVar.f3953c.f3833f;
        Objects.requireNonNull(str10, "Null displayVersion");
        c0071b.f4663f = str10;
        c0071b.f4660c = 4;
        g.b bVar = new g.b();
        bVar.b(false);
        bVar.f4702c = Long.valueOf(currentTimeMillis);
        Objects.requireNonNull(str, "Null identifier");
        bVar.f4701b = str;
        String str11 = w.f3950f;
        Objects.requireNonNull(str11, "Null generator");
        bVar.f4700a = str11;
        String str12 = wVar.f3952b.f3851c;
        Objects.requireNonNull(str12, "Null identifier");
        String str13 = wVar.f3953c.f3832e;
        Objects.requireNonNull(str13, "Null version");
        String str14 = wVar.f3953c.f3833f;
        String c10 = wVar.f3952b.c();
        a5.c cVar = wVar.f3953c.f3834g;
        if (cVar.f115b == null) {
            aVar = null;
            cVar.f115b = new c.b(cVar, null);
        } else {
            aVar = null;
        }
        String str15 = cVar.f115b.f116a;
        a5.c cVar2 = wVar.f3953c.f3834g;
        if (cVar2.f115b == null) {
            cVar2.f115b = new c.b(cVar2, aVar);
        }
        bVar.f4705f = new f5.h(str12, str13, str14, null, c10, str15, cVar2.f115b.f117b, null);
        Boolean valueOf = Boolean.valueOf(e.k());
        String str16 = num2 == null ? " platform" : "";
        if (valueOf == null) {
            str16 = androidx.activity.b.n(str16, " jailbroken");
        }
        if (str16.isEmpty()) {
            bVar.f4707h = new f5.u(num2.intValue(), str2, str3, valueOf.booleanValue(), null);
            StatFs statFs2 = new StatFs(Environment.getDataDirectory().getPath());
            int i9 = 7;
            if (!TextUtils.isEmpty(str4) && (num = (Integer) ((HashMap) w.f3949e).get(str4.toLowerCase(locale))) != null) {
                i9 = num.intValue();
            }
            int availableProcessors2 = Runtime.getRuntime().availableProcessors();
            long h10 = e.h();
            long blockCount2 = statFs2.getBlockCount() * statFs2.getBlockSize();
            boolean j10 = e.j();
            int d10 = e.d();
            j.b bVar2 = new j.b();
            bVar2.f4727a = Integer.valueOf(i9);
            bVar2.f4728b = str5;
            bVar2.f4729c = Integer.valueOf(availableProcessors2);
            bVar2.f4730d = Long.valueOf(h10);
            bVar2.f4731e = Long.valueOf(blockCount2);
            bVar2.f4732f = Boolean.valueOf(j10);
            bVar2.f4733g = Integer.valueOf(d10);
            bVar2.f4734h = str6;
            bVar2.f4735i = str7;
            bVar.f4708i = bVar2.a();
            bVar.f4710k = num2;
            c0071b.f4664g = bVar.a();
            f5.a0 a9 = c0071b.a();
            i5.c cVar3 = g0Var.f3877b;
            Objects.requireNonNull(cVar3);
            a0.e eVar = ((f5.b) a9).f4656h;
            if (eVar == null) {
                if (Log.isLoggable("FirebaseCrashlytics", 3)) {
                    Log.d("FirebaseCrashlytics", "Could not get session for report", null);
                    return;
                }
                return;
            }
            String g9 = eVar.g();
            try {
                i5.c.f(cVar3.f5561b.g(g9, "report"), i5.c.f5557f.h(a9));
                File g10 = cVar3.f5561b.g(g9, "start-time");
                long i10 = eVar.i();
                OutputStreamWriter outputStreamWriter = new OutputStreamWriter(new FileOutputStream(g10), i5.c.f5555d);
                try {
                    outputStreamWriter.write("");
                    g10.setLastModified(i10 * 1000);
                    outputStreamWriter.close();
                } finally {
                }
            } catch (IOException e9) {
                String n10 = androidx.activity.b.n("Could not persist report for session ", g9);
                if (Log.isLoggable("FirebaseCrashlytics", 3)) {
                    Log.d("FirebaseCrashlytics", n10, e9);
                }
            }
        } else {
            throw new IllegalStateException(androidx.activity.b.n("Missing required properties:", str16));
        }
    }

    public static e3.i b(n nVar) {
        e3.i c9;
        Objects.requireNonNull(nVar);
        ArrayList arrayList = new ArrayList();
        for (File file : i5.d.j(nVar.f3909f.f5564b.listFiles(h.f3881b))) {
            try {
                long parseLong = Long.parseLong(file.getName().substring(3));
                boolean z8 = false;
                try {
                    Class.forName("com.google.firebase.crash.FirebaseCrash");
                    z8 = true;
                } catch (ClassNotFoundException unused) {
                }
                if (z8) {
                    Log.w("FirebaseCrashlytics", "Skipping logging Crashlytics event to Firebase, FirebaseCrash exists", null);
                    c9 = e3.l.e(null);
                } else {
                    if (Log.isLoggable("FirebaseCrashlytics", 3)) {
                        Log.d("FirebaseCrashlytics", "Logging app exception event to Firebase Analytics", null);
                    }
                    c9 = e3.l.c(new ScheduledThreadPoolExecutor(1), new q(nVar, parseLong));
                }
                arrayList.add(c9);
            } catch (NumberFormatException unused2) {
                StringBuilder t8 = androidx.activity.b.t("Could not parse app exception timestamp from file ");
                t8.append(file.getName());
                Log.w("FirebaseCrashlytics", t8.toString(), null);
            }
            file.delete();
        }
        return e3.l.f(arrayList);
    }

    public final void c(boolean z8, k5.f fVar) {
        boolean z9;
        String str;
        File file;
        JsonReader jsonReader;
        String k9;
        ApplicationExitInfo applicationExitInfo;
        boolean z10;
        String str2;
        f5.c cVar;
        String str3;
        InputStream traceInputStream;
        ArrayList arrayList = new ArrayList(this.f3914k.f3877b.c());
        if (arrayList.size() <= z8) {
            if (Log.isLoggable("FirebaseCrashlytics", 2)) {
                Log.v("FirebaseCrashlytics", "No open sessions to be closed.", null);
                return;
            }
            return;
        }
        String str4 = (String) arrayList.get(z8 ? 1 : 0);
        boolean z11 = true;
        if (((k5.d) fVar).b().f6021b.f6027b) {
            int i9 = Build.VERSION.SDK_INT;
            if (i9 >= 30) {
                List<ApplicationExitInfo> historicalProcessExitReasons = ((ActivityManager) this.f3904a.getSystemService("activity")).getHistoricalProcessExitReasons(null, 0, 0);
                if (historicalProcessExitReasons.size() != 0) {
                    e5.c cVar2 = new e5.c(this.f3909f, str4);
                    i5.d dVar = this.f3909f;
                    f fVar2 = this.f3907d;
                    e5.d dVar2 = new e5.d(dVar);
                    e5.g gVar = new e5.g(str4, dVar, fVar2);
                    gVar.f4265a.f4268a.getReference().a(dVar2.b(str4, false));
                    gVar.f4266b.f4268a.getReference().a(dVar2.b(str4, true));
                    gVar.f4267c.set(dVar2.c(str4), false);
                    g0 g0Var = this.f3914k;
                    long lastModified = g0Var.f3877b.f5561b.g(str4, "start-time").lastModified();
                    Iterator<ApplicationExitInfo> it = historicalProcessExitReasons.iterator();
                    while (it.hasNext()) {
                        applicationExitInfo = it.next();
                        if (applicationExitInfo.getTimestamp() < lastModified) {
                            break;
                        }
                        if (applicationExitInfo.getReason() == 6) {
                            break;
                        }
                    }
                    applicationExitInfo = null;
                    if (applicationExitInfo == null) {
                        String n9 = androidx.activity.b.n("No relevant ApplicationExitInfo occurred during session: ", str4);
                        if (Log.isLoggable("FirebaseCrashlytics", 2)) {
                            Log.v("FirebaseCrashlytics", n9, null);
                        }
                        z11 = true;
                    } else {
                        w wVar = g0Var.f3876a;
                        try {
                            traceInputStream = applicationExitInfo.getTraceInputStream();
                        } catch (IOException e9) {
                            e = e9;
                            z10 = false;
                        }
                        if (traceInputStream != null) {
                            ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
                            byte[] bArr = new byte[8192];
                            while (true) {
                                int read = traceInputStream.read(bArr);
                                if (read == -1) {
                                    break;
                                }
                                z10 = false;
                                try {
                                    byteArrayOutputStream.write(bArr, 0, read);
                                } catch (IOException e10) {
                                    e = e10;
                                }
                                e = e10;
                                StringBuilder t8 = androidx.activity.b.t("Could not get input trace in application exit info: ");
                                t8.append(applicationExitInfo.toString());
                                t8.append(" Error: ");
                                t8.append(e);
                                Log.w("FirebaseCrashlytics", t8.toString(), null);
                                str2 = null;
                                c.b bVar = new c.b();
                                bVar.f4678d = Integer.valueOf(applicationExitInfo.getImportance());
                                String processName = applicationExitInfo.getProcessName();
                                Objects.requireNonNull(processName, "Null processName");
                                bVar.f4676b = processName;
                                bVar.f4677c = Integer.valueOf(applicationExitInfo.getReason());
                                bVar.f4681g = Long.valueOf(applicationExitInfo.getTimestamp());
                                bVar.f4675a = Integer.valueOf(applicationExitInfo.getPid());
                                bVar.f4679e = Long.valueOf(applicationExitInfo.getPss());
                                bVar.f4680f = Long.valueOf(applicationExitInfo.getRss());
                                bVar.f4682h = str2;
                                a0.a a9 = bVar.a();
                                int i10 = wVar.f3951a.getResources().getConfiguration().orientation;
                                k.b bVar2 = new k.b();
                                bVar2.e("anr");
                                cVar = (f5.c) a9;
                                bVar2.d(cVar.f4673g);
                                if (cVar.f4670d != 100) {
                                    z10 = true;
                                }
                                Boolean valueOf = Boolean.valueOf(z10);
                                Integer valueOf2 = Integer.valueOf(i10);
                                f5.m mVar = new f5.m(null, null, a9, wVar.e(), wVar.a(), null);
                                str3 = valueOf2 == null ? " uiOrientation" : "";
                                if (str3.isEmpty()) {
                                    bVar2.f4743c = new f5.l(mVar, null, null, valueOf, valueOf2.intValue(), null);
                                    bVar2.f4744d = wVar.b(i10);
                                    a0.e.d a10 = bVar2.a();
                                    String n10 = androidx.activity.b.n("Persisting anr for session ", str4);
                                    if (Log.isLoggable("FirebaseCrashlytics", 3)) {
                                        Log.d("FirebaseCrashlytics", n10, null);
                                    }
                                    i5.c cVar3 = g0Var.f3877b;
                                    a0.e.d a11 = g0Var.a(a10, cVar2, gVar);
                                    z11 = true;
                                    cVar3.d(a11, str4, true);
                                } else {
                                    throw new IllegalStateException(androidx.activity.b.n("Missing required properties:", str3));
                                }
                            }
                            z10 = false;
                            str2 = byteArrayOutputStream.toString(StandardCharsets.UTF_8.name());
                            c.b bVar3 = new c.b();
                            bVar3.f4678d = Integer.valueOf(applicationExitInfo.getImportance());
                            String processName2 = applicationExitInfo.getProcessName();
                            Objects.requireNonNull(processName2, "Null processName");
                            bVar3.f4676b = processName2;
                            bVar3.f4677c = Integer.valueOf(applicationExitInfo.getReason());
                            bVar3.f4681g = Long.valueOf(applicationExitInfo.getTimestamp());
                            bVar3.f4675a = Integer.valueOf(applicationExitInfo.getPid());
                            bVar3.f4679e = Long.valueOf(applicationExitInfo.getPss());
                            bVar3.f4680f = Long.valueOf(applicationExitInfo.getRss());
                            bVar3.f4682h = str2;
                            a0.a a92 = bVar3.a();
                            int i102 = wVar.f3951a.getResources().getConfiguration().orientation;
                            k.b bVar22 = new k.b();
                            bVar22.e("anr");
                            cVar = (f5.c) a92;
                            bVar22.d(cVar.f4673g);
                            if (cVar.f4670d != 100) {
                            }
                            Boolean valueOf3 = Boolean.valueOf(z10);
                            Integer valueOf22 = Integer.valueOf(i102);
                            f5.m mVar2 = new f5.m(null, null, a92, wVar.e(), wVar.a(), null);
                            if (valueOf22 == null) {
                            }
                            if (str3.isEmpty()) {
                            }
                        } else {
                            z10 = false;
                            str2 = null;
                            c.b bVar32 = new c.b();
                            bVar32.f4678d = Integer.valueOf(applicationExitInfo.getImportance());
                            String processName22 = applicationExitInfo.getProcessName();
                            Objects.requireNonNull(processName22, "Null processName");
                            bVar32.f4676b = processName22;
                            bVar32.f4677c = Integer.valueOf(applicationExitInfo.getReason());
                            bVar32.f4681g = Long.valueOf(applicationExitInfo.getTimestamp());
                            bVar32.f4675a = Integer.valueOf(applicationExitInfo.getPid());
                            bVar32.f4679e = Long.valueOf(applicationExitInfo.getPss());
                            bVar32.f4680f = Long.valueOf(applicationExitInfo.getRss());
                            bVar32.f4682h = str2;
                            a0.a a922 = bVar32.a();
                            int i1022 = wVar.f3951a.getResources().getConfiguration().orientation;
                            k.b bVar222 = new k.b();
                            bVar222.e("anr");
                            cVar = (f5.c) a922;
                            bVar222.d(cVar.f4673g);
                            if (cVar.f4670d != 100) {
                            }
                            Boolean valueOf32 = Boolean.valueOf(z10);
                            Integer valueOf222 = Integer.valueOf(i1022);
                            f5.m mVar22 = new f5.m(null, null, a922, wVar.e(), wVar.a(), null);
                            if (valueOf222 == null) {
                            }
                            if (str3.isEmpty()) {
                            }
                        }
                    }
                } else {
                    k9 = androidx.activity.b.n("No ApplicationExitInfo available. Session: ", str4);
                }
            } else {
                k9 = androidx.activity.b.k("ANR feature enabled, but device is API ", i9);
            }
        } else if (Log.isLoggable("FirebaseCrashlytics", 2)) {
            Log.v("FirebaseCrashlytics", "ANR feature disabled.", null);
        }
        if (this.f3912i.c(str4)) {
            String n11 = androidx.activity.b.n("Finalizing native report for session ", str4);
            if (Log.isLoggable("FirebaseCrashlytics", 2)) {
                Log.v("FirebaseCrashlytics", n11, null);
            }
            Objects.requireNonNull(this.f3912i.b(str4));
            Log.w("FirebaseCrashlytics", "No minidump data found for session " + str4, null);
        }
        if (z8 != 0) {
            z9 = false;
            str = (String) arrayList.get(0);
        } else {
            z9 = false;
            str = null;
        }
        g0 g0Var2 = this.f3914k;
        long currentTimeMillis = System.currentTimeMillis() / 1000;
        i5.c cVar4 = g0Var2.f3877b;
        i5.d dVar3 = cVar4.f5561b;
        Objects.requireNonNull(dVar3);
        dVar3.a(new File(dVar3.f5563a, ".com.google.firebase.crashlytics"));
        dVar3.a(new File(dVar3.f5563a, ".com.google.firebase.crashlytics-ndk"));
        if (Build.VERSION.SDK_INT < 28) {
            z11 = z9;
        }
        if (z11) {
            dVar3.a(new File(dVar3.f5563a, ".com.google.firebase.crashlytics.files.v1"));
        }
        SortedSet<String> c9 = cVar4.c();
        if (str != null) {
            c9.remove(str);
        }
        if (c9.size() > 8) {
            while (c9.size() > 8) {
                String last = c9.last();
                String n12 = androidx.activity.b.n("Removing session over cap: ", last);
                if (Log.isLoggable("FirebaseCrashlytics", 3)) {
                    Log.d("FirebaseCrashlytics", n12, null);
                }
                i5.d dVar4 = cVar4.f5561b;
                Objects.requireNonNull(dVar4);
                i5.d.i(new File(dVar4.f5565c, last));
                c9.remove(last);
            }
        }
        loop2: for (String str5 : c9) {
            String n13 = androidx.activity.b.n("Finalizing report for session ", str5);
            if (Log.isLoggable("FirebaseCrashlytics", 2)) {
                Log.v("FirebaseCrashlytics", n13, null);
            }
            List<File> j9 = i5.d.j(cVar4.f5561b.f(str5).listFiles(i5.c.f5559h));
            if (j9.isEmpty()) {
                String o9 = androidx.activity.b.o("Session ", str5, " has no events.");
                if (Log.isLoggable("FirebaseCrashlytics", 2)) {
                    Log.v("FirebaseCrashlytics", o9, null);
                }
            } else {
                Collections.sort(j9);
                ArrayList arrayList2 = new ArrayList();
                while (true) {
                    boolean z12 = z9;
                    for (File file2 : j9) {
                        try {
                            g5.a aVar = i5.c.f5557f;
                            String e11 = i5.c.e(file2);
                            Objects.requireNonNull(aVar);
                            try {
                                jsonReader = new JsonReader(new StringReader(e11));
                            } catch (IllegalStateException e12) {
                                throw new IOException(e12);
                            }
                        } catch (IOException e13) {
                            Log.w("FirebaseCrashlytics", "Could not add event to report for " + file2, e13);
                        }
                        try {
                            a0.e.d d9 = g5.a.d(jsonReader);
                            jsonReader.close();
                            arrayList2.add(d9);
                            if (!z12) {
                                String name = file2.getName();
                                if (!(name.startsWith("event") && name.endsWith("_"))) {
                                    break;
                                }
                            }
                            z12 = true;
                        } finally {
                            break loop2;
                        }
                    }
                    if (arrayList2.isEmpty()) {
                        Log.w("FirebaseCrashlytics", "Could not parse event files for session " + str5, null);
                    } else {
                        String c10 = new e5.d(cVar4.f5561b).c(str5);
                        File g9 = cVar4.f5561b.g(str5, "report");
                        try {
                            g5.a aVar2 = i5.c.f5557f;
                            f5.a0 j10 = aVar2.g(i5.c.e(g9)).j(currentTimeMillis, z12, c10);
                            f5.b0<a0.e.d> b0Var = new f5.b0<>(arrayList2);
                            if (((f5.b) j10).f4656h != null) {
                                a0.b i11 = j10.i();
                                g.b bVar4 = (g.b) ((f5.b) j10).f4656h.l();
                                bVar4.f4709j = b0Var;
                                b.C0071b c0071b = (b.C0071b) i11;
                                c0071b.f4664g = bVar4.a();
                                f5.a0 a12 = c0071b.a();
                                a0.e eVar = ((f5.b) a12).f4656h;
                                if (eVar != null) {
                                    if (z12) {
                                        i5.d dVar5 = cVar4.f5561b;
                                        String g10 = eVar.g();
                                        Objects.requireNonNull(dVar5);
                                        file = new File(dVar5.f5567e, g10);
                                    } else {
                                        i5.d dVar6 = cVar4.f5561b;
                                        String g11 = eVar.g();
                                        Objects.requireNonNull(dVar6);
                                        file = new File(dVar6.f5566d, g11);
                                    }
                                    i5.c.f(file, aVar2.h(a12));
                                }
                            } else {
                                throw new IllegalStateException("Reports without sessions cannot have events added to them.");
                                break;
                            }
                        } catch (IOException e14) {
                            Log.w("FirebaseCrashlytics", "Could not synthesize final report file for " + g9, e14);
                        }
                    }
                    z9 = false;
                }
            }
            i5.d dVar7 = cVar4.f5561b;
            Objects.requireNonNull(dVar7);
            i5.d.i(new File(dVar7.f5565c, str5));
            z9 = false;
        }
        Objects.requireNonNull(((k5.d) cVar4.f5562c).b().f6020a);
        ArrayList arrayList3 = (ArrayList) cVar4.b();
        int size = arrayList3.size();
        if (size <= 4) {
            return;
        }
        Iterator it2 = arrayList3.subList(4, size).iterator();
        while (it2.hasNext()) {
            ((File) it2.next()).delete();
        }
    }

    public final void d(long j9) {
        try {
            if (this.f3909f.b(".ae" + j9).createNewFile()) {
            } else {
                throw new IOException("Create new file failed.");
            }
        } catch (IOException e9) {
            Log.w("FirebaseCrashlytics", "Could not create app exception marker file.", e9);
        }
    }

    public boolean e(k5.f fVar) {
        this.f3907d.a();
        y yVar = this.f3915l;
        if (yVar != null && yVar.f3959e.get()) {
            Log.w("FirebaseCrashlytics", "Skipping session finalization because a crash has already occurred.", null);
            return false;
        }
        if (Log.isLoggable("FirebaseCrashlytics", 2)) {
            Log.v("FirebaseCrashlytics", "Finalizing previously open sessions.", null);
        }
        try {
            c(true, fVar);
            if (Log.isLoggable("FirebaseCrashlytics", 2)) {
                Log.v("FirebaseCrashlytics", "Closed all previously open sessions.", null);
            }
            return true;
        } catch (Exception e9) {
            Log.e("FirebaseCrashlytics", "Unable to finalize previously open sessions.", e9);
            return false;
        }
    }

    public final String f() {
        SortedSet<String> c9 = this.f3914k.f3877b.c();
        if (c9.isEmpty()) {
            return null;
        }
        return c9.first();
    }

    public e3.i<Void> g(e3.i<k5.b> iVar) {
        e3.u<Void> uVar;
        e3.i iVar2;
        i5.c cVar = this.f3914k.f3877b;
        int i9 = 1;
        if (!((cVar.f5561b.e().isEmpty() && cVar.f5561b.d().isEmpty() && cVar.f5561b.c().isEmpty()) ? false : true)) {
            if (Log.isLoggable("FirebaseCrashlytics", 2)) {
                Log.v("FirebaseCrashlytics", "No crash reports are available to be sent.", null);
            }
            this.f3916m.b(Boolean.FALSE);
            return e3.l.e(null);
        }
        b4.e eVar = b4.e.f2198k;
        eVar.s("Crash reports are available to be sent.");
        if (this.f3905b.a()) {
            if (Log.isLoggable("FirebaseCrashlytics", 3)) {
                Log.d("FirebaseCrashlytics", "Automatic data collection is enabled. Allowing upload.", null);
            }
            this.f3916m.b(Boolean.FALSE);
            iVar2 = e3.l.e(Boolean.TRUE);
        } else {
            eVar.f("Automatic data collection is disabled.");
            eVar.s("Notifying that unsent reports are available.");
            this.f3916m.b(Boolean.TRUE);
            z zVar = this.f3905b;
            synchronized (zVar.f3962c) {
                uVar = zVar.f3963d.f4208a;
            }
            e3.i<TContinuationResult> o9 = uVar.o(new b4.e(this));
            eVar.f("Waiting for send/deleteUnsentReports to be called.");
            e3.u<Boolean> uVar2 = this.f3917n.f4208a;
            ExecutorService executorService = j0.f3893a;
            e3.j jVar = new e3.j();
            h0 h0Var = new h0(jVar, i9);
            o9.f(h0Var);
            uVar2.f(h0Var);
            iVar2 = jVar.f4208a;
        }
        return iVar2.o(new a(iVar));
    }
}