导航菜单

页面标题

页面副标题

CityMall v1.42.1 - f.java 源代码

正在查看: CityMall v1.42.1 应用的 f.java JAVA 源代码文件

本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。


package io.sentry.cache;

import io.sentry.AbstractC0383i;
import io.sentry.C0400n1;
import io.sentry.C0437z;
import io.sentry.EnumC0430w1;
import io.sentry.EnumC0433x1;
import io.sentry.ILogger;
import io.sentry.ISerializer;
import io.sentry.O0;
import io.sentry.Q0;
import io.sentry.S1;
import io.sentry.SentryOptions;
import io.sentry.UncaughtExceptionHandlerIntegration;
import io.sentry.hints.AbnormalExit;
import io.sentry.hints.SessionEnd;
import io.sentry.hints.SessionStart;
import io.sentry.util.HintUtils;
import java.io.BufferedInputStream;
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.ByteArrayInputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.FilenameFilter;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.util.ArrayList;
import java.util.Date;
import java.util.Iterator;
import java.util.Map;
import java.util.UUID;
import java.util.WeakHashMap;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit;

public class f extends c implements IEnvelopeCache {
    private final CountDownLatch f;
    private final Map g;

    public f(SentryOptions sentryOptions, String str, int i) {
        super(sentryOptions, str, i);
        this.g = new WeakHashMap();
        this.f = new CountDownLatch(1);
    }

    private File[] J() {
        File[] listFiles;
        return (!q() || (listFiles = this.c.listFiles(new FilenameFilter() {
            @Override
            public final boolean accept(File file, String str) {
                boolean P;
                P = f.P(file, str);
                return P;
            }
        })) == null) ? new File[0] : listFiles;
    }

    public static IEnvelopeCache K(SentryOptions sentryOptions) {
        String cacheDirPath = sentryOptions.getCacheDirPath();
        int maxCacheItems = sentryOptions.getMaxCacheItems();
        if (cacheDirPath != null) {
            return new f(sentryOptions, cacheDirPath, maxCacheItems);
        }
        sentryOptions.getLogger().c(EnumC0433x1.WARNING, "cacheDirPath is null, returning NoOpEnvelopeCache", new Object[0]);
        return io.sentry.transport.p.g();
    }

    public static File M(String str) {
        return new File(str, "session.json");
    }

    private synchronized File N(Q0 q0) {
        String str;
        try {
            if (this.g.containsKey(q0)) {
                str = (String) this.g.get(q0);
            } else {
                String str2 = UUID.randomUUID() + ".envelope";
                this.g.put(q0, str2);
                str = str2;
            }
        } catch (Throwable th) {
            throw th;
        }
        return new File(this.c.getAbsolutePath(), str);
    }

    public static File O(String str) {
        return new File(str, "previous_session.json");
    }

    public static boolean P(File file, String str) {
        return str.endsWith(".envelope");
    }

    private void Q(C0437z c0437z) {
        Date date;
        Object g = HintUtils.g(c0437z);
        if (g instanceof AbnormalExit) {
            File O = O(this.c.getAbsolutePath());
            if (!O.exists()) {
                this.a.getLogger().c(EnumC0433x1.DEBUG, "No previous session file to end.", new Object[0]);
                return;
            }
            ILogger logger = this.a.getLogger();
            EnumC0433x1 enumC0433x1 = EnumC0433x1.WARNING;
            logger.c(enumC0433x1, "Previous session is not ended, we'd need to end it.", new Object[0]);
            try {
                BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(new FileInputStream(O), c.e));
                try {
                    S1 s1 = (S1) ((ISerializer) this.b.a()).c(bufferedReader, S1.class);
                    if (s1 != null) {
                        AbnormalExit abnormalExit = (AbnormalExit) g;
                        Long e = abnormalExit.e();
                        if (e != null) {
                            date = AbstractC0383i.d(e.longValue());
                            Date k = s1.k();
                            if (k != null) {
                                if (date.before(k)) {
                                }
                            }
                            this.a.getLogger().c(enumC0433x1, "Abnormal exit happened before previous session start, not ending the session.", new Object[0]);
                            bufferedReader.close();
                            return;
                        }
                        date = null;
                        s1.q(S1.b.Abnormal, null, true, abnormalExit.h());
                        s1.d(date);
                        V(O, s1);
                    }
                    bufferedReader.close();
                } finally {
                }
            } catch (Throwable th) {
                this.a.getLogger().b(EnumC0433x1.ERROR, "Error processing previous session.", th);
            }
        }
    }

    private void R(File file, Q0 q0) {
        Iterable c = q0.c();
        if (!c.iterator().hasNext()) {
            this.a.getLogger().c(EnumC0433x1.INFO, "Current envelope %s is empty", file.getAbsolutePath());
            return;
        }
        C0400n1 c0400n1 = (C0400n1) c.iterator().next();
        if (!EnumC0430w1.Session.equals(c0400n1.G().b())) {
            this.a.getLogger().c(EnumC0433x1.INFO, "Current envelope has a different envelope type %s", c0400n1.G().b());
            return;
        }
        try {
            BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(new ByteArrayInputStream(c0400n1.E()), c.e));
            try {
                S1 s1 = (S1) ((ISerializer) this.b.a()).c(bufferedReader, S1.class);
                if (s1 == null) {
                    this.a.getLogger().c(EnumC0433x1.ERROR, "Item of type %s returned null by the parser.", c0400n1.G().b());
                } else {
                    V(file, s1);
                }
                bufferedReader.close();
            } finally {
            }
        } catch (Throwable th) {
            this.a.getLogger().b(EnumC0433x1.ERROR, "Item failed to process.", th);
        }
    }

    private void T() {
        try {
            FileOutputStream fileOutputStream = new FileOutputStream(new File(this.a.getCacheDirPath(), "last_crash"));
            try {
                fileOutputStream.write(AbstractC0383i.g(AbstractC0383i.c()).getBytes(c.e));
                fileOutputStream.flush();
                fileOutputStream.close();
            } finally {
            }
        } catch (Throwable th) {
            this.a.getLogger().b(EnumC0433x1.ERROR, "Error writing the crash marker file to the disk", th);
        }
    }

    private void U(File file, Q0 q0) {
        if (file.exists()) {
            this.a.getLogger().c(EnumC0433x1.DEBUG, "Overwriting envelope to offline storage: %s", file.getAbsolutePath());
            if (!file.delete()) {
                this.a.getLogger().c(EnumC0433x1.ERROR, "Failed to delete: %s", file.getAbsolutePath());
            }
        }
        try {
            FileOutputStream fileOutputStream = new FileOutputStream(file);
            try {
                ((ISerializer) this.b.a()).b(q0, fileOutputStream);
                fileOutputStream.close();
            } finally {
            }
        } catch (Throwable th) {
            this.a.getLogger().a(EnumC0433x1.ERROR, th, "Error writing Envelope %s to offline storage", file.getAbsolutePath());
        }
    }

    private void V(File file, S1 s1) {
        if (file.exists()) {
            this.a.getLogger().c(EnumC0433x1.DEBUG, "Overwriting session to offline storage: %s", s1.j());
            if (!file.delete()) {
                this.a.getLogger().c(EnumC0433x1.ERROR, "Failed to delete: %s", file.getAbsolutePath());
            }
        }
        try {
            FileOutputStream fileOutputStream = new FileOutputStream(file);
            try {
                BufferedWriter bufferedWriter = new BufferedWriter(new OutputStreamWriter(fileOutputStream, c.e));
                try {
                    ((ISerializer) this.b.a()).a(s1, bufferedWriter);
                    bufferedWriter.close();
                    fileOutputStream.close();
                } finally {
                }
            } finally {
            }
        } catch (Throwable th) {
            this.a.getLogger().a(EnumC0433x1.ERROR, th, "Error writing Session to offline storage: %s", s1.j());
        }
    }

    public void L() {
        this.f.countDown();
    }

    public boolean S() {
        try {
            return this.f.await(this.a.getSessionFlushTimeoutMillis(), TimeUnit.MILLISECONDS);
        } catch (InterruptedException unused) {
            Thread.currentThread().interrupt();
            this.a.getLogger().c(EnumC0433x1.DEBUG, "Timed out waiting for previous session to flush.", new Object[0]);
            return false;
        }
    }

    @Override
    public Iterator<Q0> iterator() {
        File[] J = J();
        ArrayList arrayList = new ArrayList(J.length);
        for (File file : J) {
            try {
                BufferedInputStream bufferedInputStream = new BufferedInputStream(new FileInputStream(file));
                try {
                    arrayList.add(((ISerializer) this.b.a()).d(bufferedInputStream));
                    bufferedInputStream.close();
                } catch (Throwable th) {
                    try {
                        bufferedInputStream.close();
                    } catch (Throwable th2) {
                        th.addSuppressed(th2);
                    }
                    throw th;
                }
            } catch (FileNotFoundException unused) {
                this.a.getLogger().c(EnumC0433x1.DEBUG, "Envelope file '%s' disappeared while converting all cached files to envelopes.", file.getAbsolutePath());
            } catch (IOException e) {
                this.a.getLogger().b(EnumC0433x1.ERROR, String.format("Error while reading cached envelope from file %s", file.getAbsolutePath()), e);
            }
        }
        return arrayList.iterator();
    }

    @Override
    public void j(Q0 q0) {
        io.sentry.util.n.c(q0, "Envelope is required.");
        File N = N(q0);
        if (!N.exists()) {
            this.a.getLogger().c(EnumC0433x1.DEBUG, "Envelope was not cached: %s", N.getAbsolutePath());
            return;
        }
        this.a.getLogger().c(EnumC0433x1.DEBUG, "Discarding envelope from cache: %s", N.getAbsolutePath());
        if (N.delete()) {
            return;
        }
        this.a.getLogger().c(EnumC0433x1.ERROR, "Failed to delete envelope: %s", N.getAbsolutePath());
    }

    public void w(Q0 q0, C0437z c0437z) {
        io.sentry.util.n.c(q0, "Envelope is required.");
        D(J());
        File M = M(this.c.getAbsolutePath());
        File O = O(this.c.getAbsolutePath());
        if (HintUtils.h(c0437z, SessionEnd.class) && !M.delete()) {
            this.a.getLogger().c(EnumC0433x1.WARNING, "Current envelope doesn't exist.", new Object[0]);
        }
        if (HintUtils.h(c0437z, AbnormalExit.class)) {
            Q(c0437z);
        }
        if (HintUtils.h(c0437z, SessionStart.class)) {
            if (M.exists()) {
                this.a.getLogger().c(EnumC0433x1.WARNING, "Current session is not ended, we'd need to end it.", new Object[0]);
                try {
                    BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(new FileInputStream(M), c.e));
                    try {
                        S1 s1 = (S1) ((ISerializer) this.b.a()).c(bufferedReader, S1.class);
                        if (s1 != null) {
                            V(O, s1);
                        }
                        bufferedReader.close();
                    } finally {
                    }
                } catch (Throwable th) {
                    this.a.getLogger().b(EnumC0433x1.ERROR, "Error processing session.", th);
                }
            }
            R(M, q0);
            boolean exists = new File(this.a.getCacheDirPath(), ".sentry-native/last_crash").exists();
            if (!exists) {
                File file = new File(this.a.getCacheDirPath(), "last_crash");
                if (file.exists()) {
                    this.a.getLogger().c(EnumC0433x1.INFO, "Crash marker file exists, crashedLastRun will return true.", new Object[0]);
                    if (!file.delete()) {
                        this.a.getLogger().c(EnumC0433x1.ERROR, "Failed to delete the crash marker file. %s.", file.getAbsolutePath());
                    }
                    exists = true;
                }
            }
            O0.a().c(exists);
            L();
        }
        File N = N(q0);
        if (N.exists()) {
            this.a.getLogger().c(EnumC0433x1.WARNING, "Not adding Envelope to offline storage because it already exists: %s", N.getAbsolutePath());
            return;
        }
        this.a.getLogger().c(EnumC0433x1.DEBUG, "Adding Envelope to offline storage: %s", N.getAbsolutePath());
        U(N, q0);
        if (HintUtils.h(c0437z, UncaughtExceptionHandlerIntegration.a.class)) {
            T();
        }
    }
}