导航菜单

页面标题

页面副标题

Namma Yatri v3.3.7 - f.java 源代码

正在查看: Namma Yatri v3.3.7 应用的 f.java JAVA 源代码文件

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


package io.sentry.cache;

import io.sentry.AbstractC0926j;
import io.sentry.B;
import io.sentry.C0953p2;
import io.sentry.C0985w1;
import io.sentry.C0997z1;
import io.sentry.C2;
import io.sentry.EnumC0917g2;
import io.sentry.EnumC0921h2;
import io.sentry.ILogger;
import io.sentry.UncaughtExceptionHandlerIntegration;
import io.sentry.W1;
import io.sentry.Y;
import io.sentry.transport.s;
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 g {
    private final CountDownLatch f;
    private final Map g;

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

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

    public static g D(C0953p2 c0953p2) {
        String cacheDirPath = c0953p2.getCacheDirPath();
        int maxCacheItems = c0953p2.getMaxCacheItems();
        if (cacheDirPath != null) {
            return new f(c0953p2, cacheDirPath, maxCacheItems);
        }
        c0953p2.getLogger().c(EnumC0921h2.WARNING, "cacheDirPath is null, returning NoOpEnvelopeCache", new Object[0]);
        return s.c();
    }

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

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

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

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

    private void K(B b) {
        Date date;
        Object g = io.sentry.util.j.g(b);
        if (g instanceof io.sentry.hints.a) {
            File I = I(this.c.getAbsolutePath());
            if (!I.exists()) {
                this.a.getLogger().c(EnumC0921h2.DEBUG, "No previous session file to end.", new Object[0]);
                return;
            }
            ILogger logger = this.a.getLogger();
            EnumC0921h2 enumC0921h2 = EnumC0921h2.WARNING;
            logger.c(enumC0921h2, "Previous session is not ended, we'd need to end it.", new Object[0]);
            try {
                BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(new FileInputStream(I), c.e));
                try {
                    C2 c2 = (C2) ((Y) this.b.a()).c(bufferedReader, C2.class);
                    if (c2 != null) {
                        io.sentry.hints.a aVar = (io.sentry.hints.a) g;
                        Long e = aVar.e();
                        if (e != null) {
                            date = AbstractC0926j.d(e.longValue());
                            Date k = c2.k();
                            if (k != null) {
                                if (date.before(k)) {
                                }
                            }
                            this.a.getLogger().c(enumC0921h2, "Abnormal exit happened before previous session start, not ending the session.", new Object[0]);
                            bufferedReader.close();
                            return;
                        }
                        date = null;
                        c2.q(C2.b.Abnormal, null, true, aVar.h());
                        c2.d(date);
                        S(I, c2);
                    }
                    bufferedReader.close();
                } finally {
                }
            } catch (Throwable th) {
                this.a.getLogger().b(EnumC0921h2.ERROR, "Error processing previous session.", th);
            }
        }
    }

    private void L(File file, C0997z1 c0997z1) {
        Iterable c = c0997z1.c();
        if (!c.iterator().hasNext()) {
            this.a.getLogger().c(EnumC0921h2.INFO, "Current envelope %s is empty", file.getAbsolutePath());
            return;
        }
        W1 w1 = (W1) c.iterator().next();
        if (!EnumC0917g2.Session.equals(w1.G().b())) {
            this.a.getLogger().c(EnumC0921h2.INFO, "Current envelope has a different envelope type %s", w1.G().b());
            return;
        }
        try {
            BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(new ByteArrayInputStream(w1.E()), c.e));
            try {
                C2 c2 = (C2) ((Y) this.b.a()).c(bufferedReader, C2.class);
                if (c2 == null) {
                    this.a.getLogger().c(EnumC0921h2.ERROR, "Item of type %s returned null by the parser.", w1.G().b());
                } else {
                    S(file, c2);
                }
                bufferedReader.close();
            } finally {
            }
        } catch (Throwable th) {
            this.a.getLogger().b(EnumC0921h2.ERROR, "Item failed to process.", th);
        }
    }

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

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

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

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

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

    public void R(C0997z1 c0997z1, B b) {
        io.sentry.util.q.c(c0997z1, "Envelope is required.");
        x(C());
        File F = F(this.c.getAbsolutePath());
        File I = I(this.c.getAbsolutePath());
        if (io.sentry.util.j.h(b, io.sentry.hints.l.class) && !F.delete()) {
            this.a.getLogger().c(EnumC0921h2.WARNING, "Current envelope doesn't exist.", new Object[0]);
        }
        if (io.sentry.util.j.h(b, io.sentry.hints.a.class)) {
            K(b);
        }
        if (io.sentry.util.j.h(b, io.sentry.hints.n.class)) {
            if (F.exists()) {
                this.a.getLogger().c(EnumC0921h2.WARNING, "Current session is not ended, we'd need to end it.", new Object[0]);
                try {
                    BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(new FileInputStream(F), c.e));
                    try {
                        C2 c2 = (C2) ((Y) this.b.a()).c(bufferedReader, C2.class);
                        if (c2 != null) {
                            S(I, c2);
                        }
                        bufferedReader.close();
                    } finally {
                    }
                } catch (Throwable th) {
                    this.a.getLogger().b(EnumC0921h2.ERROR, "Error processing session.", th);
                }
            }
            L(F, c0997z1);
            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(EnumC0921h2.INFO, "Crash marker file exists, crashedLastRun will return true.", new Object[0]);
                    if (!file.delete()) {
                        this.a.getLogger().c(EnumC0921h2.ERROR, "Failed to delete the crash marker file. %s.", file.getAbsolutePath());
                    }
                    exists = true;
                }
            }
            C0985w1.a().c(exists);
            E();
        }
        File G = G(c0997z1);
        if (G.exists()) {
            this.a.getLogger().c(EnumC0921h2.WARNING, "Not adding Envelope to offline storage because it already exists: %s", G.getAbsolutePath());
            return;
        }
        this.a.getLogger().c(EnumC0921h2.DEBUG, "Adding Envelope to offline storage: %s", G.getAbsolutePath());
        Q(G, c0997z1);
        if (io.sentry.util.j.h(b, UncaughtExceptionHandlerIntegration.a.class)) {
            O();
        }
    }

    @Override
    public Iterator iterator() {
        File[] C = C();
        ArrayList arrayList = new ArrayList(C.length);
        for (File file : C) {
            try {
                BufferedInputStream bufferedInputStream = new BufferedInputStream(new FileInputStream(file));
                try {
                    arrayList.add(((Y) 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(EnumC0921h2.DEBUG, "Envelope file '%s' disappeared while converting all cached files to envelopes.", file.getAbsolutePath());
            } catch (IOException e) {
                this.a.getLogger().b(EnumC0921h2.ERROR, String.format("Error while reading cached envelope from file %s", file.getAbsolutePath()), e);
            }
        }
        return arrayList.iterator();
    }

    @Override
    public void o(C0997z1 c0997z1) {
        io.sentry.util.q.c(c0997z1, "Envelope is required.");
        File G = G(c0997z1);
        if (!G.exists()) {
            this.a.getLogger().c(EnumC0921h2.DEBUG, "Envelope was not cached: %s", G.getAbsolutePath());
            return;
        }
        this.a.getLogger().c(EnumC0921h2.DEBUG, "Discarding envelope from cache: %s", G.getAbsolutePath());
        if (G.delete()) {
            return;
        }
        this.a.getLogger().c(EnumC0921h2.ERROR, "Failed to delete envelope: %s", G.getAbsolutePath());
    }
}