导航菜单

页面标题

页面副标题

CallApp v2.226 - a.java 源代码

正在查看: CallApp v2.226 应用的 a.java JAVA 源代码文件

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


package com.apm.insight.nativecrash;

import a1.d0;
import android.content.Context;
import android.os.Environment;
import androidx.annotation.Nullable;
import com.apm.insight.CrashType;
import com.apm.insight.ICrashFilter;
import com.apm.insight.entity.Header;
import com.apm.insight.l.m;
import com.apm.insight.l.n;
import com.apm.insight.runtime.j;
import com.apm.insight.runtime.o;
import java.io.BufferedReader;
import java.io.Closeable;
import java.io.File;
import java.io.FileReader;
import java.util.HashMap;
import java.util.Map;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

public final class a {

    private static Boolean f8132d;

    private final Context f8133a;

    private JSONObject f8134b = null;

    private b f8135c;

    public static class C0055a {
        public static String b(File file) {
            BufferedReader bufferedReader;
            String readLine;
            BufferedReader bufferedReader2 = null;
            try {
                bufferedReader = new BufferedReader(new FileReader(file));
            } catch (Throwable th) {
                th = th;
            }
            try {
                readLine = bufferedReader.readLine();
            } catch (Throwable th2) {
                th = th2;
                bufferedReader2 = bufferedReader;
                try {
                    com.apm.insight.c.a();
                    j.a(th, "NPTH_CATCH");
                    return "";
                } finally {
                    com.apm.insight.a.a((Closeable) bufferedReader2);
                }
            }
            if (readLine == null) {
                com.apm.insight.a.a((Closeable) bufferedReader);
                return "";
            }
            if (!readLine.startsWith("[FATAL:jni_android.cc") || !readLine.contains("Please include Java exception stack in crash report ttwebview:")) {
                com.apm.insight.a.a((Closeable) bufferedReader);
                return "";
            }
            StringBuilder sb = new StringBuilder();
            int indexOf = readLine.indexOf(" ttwebview:");
            sb.append("Caused by: ");
            sb.append("Please include Java exception stack in crash report");
            sb.append("\n");
            sb.append(readLine.substring(indexOf + 11));
            sb.append("\n");
            while (true) {
                String readLine2 = bufferedReader.readLine();
                if (readLine2 == null) {
                    String sb2 = sb.toString();
                    com.apm.insight.a.a((Closeable) bufferedReader);
                    return sb2;
                }
                sb.append(readLine2);
                sb.append("\n");
            }
        }
    }

    public class b {

        private final com.apm.insight.nativecrash.c f8136a;

        private final com.apm.insight.h.b f8137b;

        private final File f8138c;

        private final File f8139d;

        public b(File file) {
            this.f8138c = file;
            this.f8139d = com.apm.insight.l.j.a(com.apm.insight.e.g(), file.getName());
            com.apm.insight.h.b bVar = new com.apm.insight.h.b(file);
            this.f8137b = bVar;
            com.apm.insight.nativecrash.c cVar = new com.apm.insight.nativecrash.c(file);
            this.f8136a = cVar;
            if (bVar.d() && cVar.a() == null) {
                cVar.a(file);
            }
        }

        public final long a() {
            throw new UnsupportedOperationException("Method not decompiled: com.apm.insight.nativecrash.a.b.a():long");
        }

        public final File b() {
            return this.f8138c;
        }

        public final boolean c() {
            return this.f8137b.d();
        }
    }

    public class c extends e {
        public c() {
            super();
            this.f8144b = "Total FD Count:";
            this.f8143a = com.apm.insight.l.j.i(a.this.f8135c.b());
            this.f8145c = ":";
            this.f8146d = -2;
        }
    }

    public class d extends e {
        public d() {
            super();
            this.f8144b = "VmSize:";
            this.f8143a = com.apm.insight.l.j.k(a.this.f8135c.b());
            this.f8145c = "\\s+";
            this.f8146d = -1;
        }
    }

    public class f extends e {
        public f() {
            super();
            this.f8144b = "Total Threads Count:";
            this.f8143a = com.apm.insight.l.j.j(a.this.f8135c.b());
            this.f8145c = ":";
            this.f8146d = -2;
        }
    }

    public a(Context context) {
        this.f8133a = context;
    }

    public static long g() {
        if (NativeImpl.f()) {
            return Long.MAX_VALUE;
        }
        return Header.a() ? 3891200L : 2867200L;
    }

    public static boolean k() {
        Boolean bool = f8132d;
        if (bool != null) {
            return bool.booleanValue();
        }
        String[] strArr = {"/data/local/su", "/data/local/bin/su", "/data/local/xbin/su", "/system/xbin/su", "/system/bin/su", "/system/bin/.ext/su", "/system/bin/failsafe/su", "/system/sd/xbin/su", "/system/usr/we-need-root/su", "/sbin/su", "/su/bin/su"};
        for (int i8 = 0; i8 < 11; i8++) {
            try {
            } catch (Throwable th) {
                com.apm.insight.c.a();
                j.a(th, "NPTH_CATCH");
            }
            if (new File(strArr[i8]).exists()) {
                f8132d = Boolean.TRUE;
                return true;
            }
            continue;
        }
        f8132d = Boolean.FALSE;
        return false;
    }

    @Nullable
    private String l() {
        b bVar = this.f8135c;
        if (bVar == null) {
            return null;
        }
        String c6 = bVar.f8136a.c();
        return (c6 == null || c6.isEmpty()) ? this.f8135c.f8137b.e() : c6;
    }

    public final JSONObject b() {
        File f6 = com.apm.insight.l.j.f(this.f8135c.b());
        if (!f6.exists()) {
            return null;
        }
        try {
            String a8 = com.apm.insight.l.f.a(f6.getAbsolutePath(), "\n");
            if (a8 != null && !a8.isEmpty()) {
                return new JSONObject(a8);
            }
        } catch (Throwable th) {
            com.apm.insight.c.a();
            j.a(th, "NPTH_CATCH");
        }
        return null;
    }

    public final void c() {
        throw new UnsupportedOperationException("Method not decompiled: com.apm.insight.nativecrash.a.c():void");
    }

    public final boolean d() {
        ICrashFilter b6 = com.apm.insight.e.b().b();
        if (b6 == null) {
            return true;
        }
        try {
            return b6.onNativeCrashFilter(l(), "");
        } catch (Throwable th) {
            com.apm.insight.c.a();
            j.a(th, "NPTH_CATCH");
            return true;
        }
    }

    public final boolean e() {
        return com.apm.insight.e.a.a().a(com.apm.insight.l.j.f(this.f8135c.b()).getAbsolutePath());
    }

    public final void f() {
        com.apm.insight.e.a.a().a(com.apm.insight.d.a.b(com.apm.insight.l.j.f(this.f8135c.b()).getAbsolutePath()));
    }

    public final JSONObject h() {
        try {
            com.apm.insight.entity.a aVar = new com.apm.insight.entity.a();
            Header header = new Header(this.f8133a);
            JSONObject a8 = o.a().a(this.f8135c.a());
            if (a8 != null) {
                header.a(a8);
                header.d();
                header.e();
            }
            Header.b(header);
            aVar.a(header);
            boolean z8 = true;
            aVar.a("is_native_crash", (Object) 1);
            aVar.a("repack_time", Long.valueOf(System.currentTimeMillis()));
            aVar.a("crash_uuid", this.f8135c.b().getName());
            b bVar = this.f8135c;
            Map<String, String> f6 = bVar != null ? bVar.f8137b.f() : null;
            if (f6 != null) {
                Object obj = (String) f6.get("process_name");
                if (obj != null) {
                    aVar.a("process_name", obj);
                }
                String str = f6.get("start_time");
                if (str != null) {
                    try {
                        aVar.a(Long.decode(str).longValue());
                    } catch (Throwable th) {
                        com.apm.insight.c.a();
                        j.a(th, "NPTH_CATCH");
                    }
                }
                String str2 = f6.get("pid");
                if (str2 != null) {
                    try {
                        aVar.a("pid", Long.decode(str2));
                    } catch (Throwable th2) {
                        com.apm.insight.c.a();
                        j.a(th2, "NPTH_CATCH");
                    }
                }
                Object obj2 = (String) f6.get("crash_thread_name");
                if (obj2 != null) {
                    aVar.a("crash_thread_name", obj2);
                }
                String str3 = f6.get("crash_time");
                if (str3 != null) {
                    try {
                        aVar.a("crash_time", Long.decode(str3));
                    } catch (Throwable th3) {
                        com.apm.insight.c.a();
                        j.a(th3, "NPTH_CATCH");
                    }
                }
                aVar.a("data", l());
            }
            Map<String, String> b6 = this.f8135c.f8136a.b();
            if (!b6.isEmpty()) {
                JSONArray jSONArray = new JSONArray();
                for (String str4 : b6.keySet()) {
                    String a9 = a(b6.get(str4));
                    try {
                        JSONObject jSONObject = new JSONObject();
                        jSONObject.put("lib_name", str4);
                        jSONObject.put("lib_uuid", a9);
                        jSONArray.put(jSONObject);
                    } catch (JSONException e6) {
                        com.apm.insight.c.a();
                        j.a(e6, "NPTH_CATCH");
                    }
                }
                aVar.a("crash_lib_uuid", (Object) jSONArray);
            }
            File e9 = com.apm.insight.l.j.e(this.f8135c.b());
            if (e9.exists() || this.f8134b != null) {
                try {
                    JSONObject jSONObject2 = this.f8134b;
                    if (jSONObject2 == null) {
                        jSONObject2 = new JSONObject(com.apm.insight.l.f.a(e9.getAbsolutePath(), "\n"));
                    }
                    aVar.c(jSONObject2);
                    aVar.a("has_callback", "true");
                    if (aVar.c().opt("storage") == null) {
                        com.apm.insight.e.g();
                        aVar.b(n.a());
                    }
                    com.apm.insight.a.a(aVar, aVar.d(), CrashType.NATIVE);
                } catch (Throwable th4) {
                    com.apm.insight.c.a();
                    j.a(th4, "NPTH_CATCH");
                }
                long j8 = -1;
                long optLong = aVar.c().optLong("crash_time", -1L);
                long optLong2 = aVar.c().optLong("java_end", -1L);
                if (optLong2 != -1 && optLong != -1) {
                    j8 = optLong2 - optLong;
                }
                try {
                    aVar.b("total_cost", String.valueOf(j8));
                    aVar.a("total_cost", String.valueOf(j8 / 1000));
                } catch (Throwable unused) {
                }
            } else {
                com.apm.insight.e.g();
                aVar.b(n.a());
                aVar.a("has_callback", "false");
            }
            File g9 = com.apm.insight.l.j.g(this.f8135c.b());
            String str5 = "";
            if (g9.exists()) {
                try {
                    str5 = m.a(g9.getAbsolutePath());
                } catch (Throwable th5) {
                    com.apm.insight.c.a();
                    j.a(th5, "NPTH_CATCH");
                }
            }
            File o8 = com.apm.insight.l.j.o(this.f8135c.b());
            if (o8.exists()) {
                String b9 = C0055a.b(o8);
                str5 = str5.isEmpty() ? b9 : str5 + "\n" + b9;
            }
            try {
                if (!str5.isEmpty()) {
                    aVar.a("java_data", (Object) str5);
                }
            } catch (Throwable th6) {
                com.apm.insight.c.a();
                j.a(th6, "NPTH_CATCH");
            }
            b(aVar);
            a(aVar);
            com.apm.insight.entity.d.b(aVar.c());
            HashMap hashMap = new HashMap();
            if (k()) {
                hashMap.put("is_root", "true");
                aVar.a("is_root", "true");
            } else {
                hashMap.put("is_root", "false");
                aVar.a("is_root", "false");
            }
            hashMap.put("has_fds_file", com.apm.insight.l.j.i(this.f8135c.b()).exists() ? "true" : "false");
            File h8 = com.apm.insight.l.j.h(this.f8135c.b());
            hashMap.put("has_logcat_file", (!h8.exists() || h8.length() <= 128) ? "false" : "true");
            hashMap.put("has_maps_file", com.apm.insight.l.j.d(this.f8135c.b()).exists() ? "true" : "false");
            hashMap.put("has_tombstone_file", com.apm.insight.l.j.b(this.f8135c.b()).exists() ? "true" : "false");
            hashMap.put("has_meminfo_file", com.apm.insight.l.j.k(this.f8135c.b()).exists() ? "true" : "false");
            hashMap.put("has_threads_file", com.apm.insight.l.j.j(this.f8135c.b()).exists() ? "true" : "false");
            int a10 = new c().a();
            if (a10 > 0) {
                if (a10 > 960) {
                    hashMap.put("fd_leak", "true");
                } else {
                    hashMap.put("fd_leak", "false");
                }
                aVar.a("fd_count", Integer.valueOf(a10));
            }
            int a11 = new f().a();
            if (a11 > 0) {
                if (a11 > 350) {
                    hashMap.put("threads_leak", "true");
                } else {
                    hashMap.put("threads_leak", "false");
                }
                aVar.a("threads_count", Integer.valueOf(a11));
            }
            int a12 = new d().a();
            if (a12 > 0) {
                if (a12 > g()) {
                    hashMap.put("memory_leak", "true");
                } else {
                    hashMap.put("memory_leak", "false");
                }
                aVar.a("memory_size", Integer.valueOf(a12));
            }
            hashMap.put("sdk_version", "2.0.0.3");
            if (aVar.c().opt("java_data") == null) {
                z8 = false;
            }
            hashMap.put("has_java_stack", String.valueOf(z8));
            JSONArray a13 = com.apm.insight.nativecrash.b.a(com.apm.insight.l.j.l(this.f8135c.f8138c), com.apm.insight.l.j.m(this.f8135c.f8138c));
            hashMap.put("leak_threads_count", String.valueOf(a13.length()));
            if (a13.length() > 0) {
                try {
                    com.apm.insight.l.f.a(com.apm.insight.l.j.n(this.f8135c.f8138c), a13);
                } catch (Throwable unused2) {
                }
            }
            aVar.b();
            aVar.a("is_64_devices", String.valueOf(Header.a()));
            aVar.a("is_64_runtime", String.valueOf(NativeImpl.f()));
            aVar.a("is_x86_devices", String.valueOf(Header.b()));
            aVar.c(hashMap);
            File f9 = com.apm.insight.l.j.f(this.f8135c.b());
            JSONObject c6 = aVar.c();
            com.apm.insight.l.f.a(f9, c6);
            return c6;
        } catch (Throwable th7) {
            com.apm.insight.c.a();
            j.a(th7, "NPTH_CATCH");
            return null;
        }
    }

    public final boolean i() {
        return com.apm.insight.l.f.a(this.f8135c.b());
    }

    public final void j() {
        try {
            com.apm.insight.l.f.b(this.f8135c.b().getAbsolutePath(), Environment.getExternalStorageDirectory().getAbsolutePath() + "/localDebug/" + com.apm.insight.e.g().getPackageName() + "/" + this.f8135c.b().getName() + ".zip");
        } catch (Throwable th) {
            com.apm.insight.c.a();
            j.a(th, "NPTH_CATCH");
        }
    }

    public final void a(File file) {
        this.f8135c = new b(file);
    }

    public final boolean a() {
        b bVar = this.f8135c;
        if (bVar != null) {
            return bVar.c();
        }
        return false;
    }

    private void a(com.apm.insight.entity.a aVar) {
        File a8 = com.apm.insight.l.j.a(this.f8135c.b());
        if (a8.exists()) {
            try {
                String a9 = com.apm.insight.l.f.a(a8.getAbsolutePath(), "\n");
                JSONArray jSONArray = new JSONArray();
                if (a9 != null) {
                    for (String str : a9.split("\n")) {
                        jSONArray.put(str);
                    }
                }
                aVar.a("native_log", (Object) jSONArray);
            } catch (Throwable th) {
                com.apm.insight.c.a();
                j.a(th, "NPTH_CATCH");
            }
        }
    }

    public class e {

        protected File f8143a;

        protected String f8144b;

        protected String f8145c;

        protected int f8146d;

        public e() {
        }

        public final int a() {
            int i8;
            Throwable th;
            if (!this.f8143a.exists() || !this.f8143a.isFile()) {
                return -1;
            }
            BufferedReader bufferedReader = null;
            try {
                BufferedReader bufferedReader2 = new BufferedReader(new FileReader(this.f8143a));
                int i9 = -1;
                do {
                    try {
                        String readLine = bufferedReader2.readLine();
                        if (readLine == null) {
                            break;
                        }
                        i9 = a(readLine);
                    } catch (Throwable th2) {
                        th = th2;
                        i8 = i9;
                        bufferedReader = bufferedReader2;
                        try {
                            com.apm.insight.c.a();
                            j.a(th, "NPTH_CATCH");
                            return i8;
                        } finally {
                            if (bufferedReader != null) {
                                com.apm.insight.a.a((Closeable) bufferedReader);
                            }
                        }
                    }
                } while (i9 == -1);
                com.apm.insight.a.a((Closeable) bufferedReader2);
                return i9;
            } catch (Throwable th3) {
                i8 = -1;
                th = th3;
            }
        }

        private int a(String str) {
            int i8 = this.f8146d;
            if (!str.startsWith(this.f8144b)) {
                return i8;
            }
            try {
                i8 = Integer.parseInt(str.split(this.f8145c)[1].trim());
            } catch (NumberFormatException e6) {
                com.apm.insight.c.a();
                j.a(e6, "NPTH_CATCH");
            }
            if (i8 < 0) {
                return -2;
            }
            return i8;
        }
    }

    private void b(com.apm.insight.entity.a aVar) {
        BufferedReader bufferedReader;
        File h8 = com.apm.insight.l.j.h(this.f8135c.b());
        if (!h8.exists()) {
            NativeImpl.a(h8.getAbsolutePath(), String.valueOf(com.apm.insight.e.i().getLogcatDumpCount()), String.valueOf(com.apm.insight.e.i().getLogcatLevel()));
        }
        JSONArray jSONArray = new JSONArray();
        String s8 = d0.s(new StringBuilder(" "), this.f8135c.f8137b.f().get("pid"), " ");
        try {
            bufferedReader = new BufferedReader(new FileReader(h8));
            try {
                if (h8.length() > 512000) {
                    bufferedReader.skip(h8.length() - 512000);
                }
                while (true) {
                    String readLine = bufferedReader.readLine();
                    if (readLine == null) {
                        break;
                    }
                    if ((readLine.length() > 32 ? readLine.substring(0, 31) : readLine).contains(s8)) {
                        jSONArray.put(readLine);
                    }
                }
            } catch (Throwable unused) {
            }
        } catch (Throwable unused2) {
            bufferedReader = null;
        }
        com.apm.insight.a.a((Closeable) bufferedReader);
        aVar.a("logcat", (Object) jSONArray);
    }

    private static String a(String str) {
        StringBuilder sb = new StringBuilder();
        try {
            if (str.length() < 16) {
                sb.append(str);
            } else {
                sb.append(str.charAt(6));
                sb.append(str.charAt(7));
                sb.append(str.charAt(4));
                sb.append(str.charAt(5));
                sb.append(str.charAt(2));
                sb.append(str.charAt(3));
                sb.append(str.charAt(0));
                sb.append(str.charAt(1));
                sb.append(str.charAt(10));
                sb.append(str.charAt(11));
                sb.append(str.charAt(8));
                sb.append(str.charAt(9));
                sb.append(str.charAt(14));
                sb.append(str.charAt(15));
                sb.append(str.charAt(12));
                sb.append(str.charAt(13));
                if (str.length() >= 32) {
                    sb.append((CharSequence) str, 16, 32);
                    sb.append('0');
                }
            }
        } catch (Throwable th) {
            com.apm.insight.c.a();
            j.a(th, "NPTH_CATCH");
        }
        return sb.toString().toUpperCase();
    }
}