导航菜单

页面标题

页面副标题

CallApp v2.226 - b.java 源代码

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

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


package com.apm.insight.k;

import android.content.Context;
import android.text.TextUtils;
import androidx.annotation.Nullable;
import com.apm.insight.CrashType;
import com.apm.insight.Npth;
import com.apm.insight.entity.Header;
import com.apm.insight.entity.b;
import com.apm.insight.k.c;
import com.apm.insight.l.n;
import com.apm.insight.nativecrash.NativeImpl;
import com.apm.insight.runtime.m;
import com.apm.insight.runtime.o;
import java.io.File;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import org.json.JSONArray;
import org.json.JSONObject;

public final class b {

    private static volatile b f8010b;

    private Context f8011a;

    private C0054b f8015f;

    private HashMap<String, C0054b> f8016g;

    private List<File> f8012c = new ArrayList();

    private List<File> f8013d = new ArrayList();

    private int f8014e = -1;

    private volatile boolean f8017h = false;

    private Runnable f8018i = new Runnable() {
        @Override
        public final void run() {
            b.this.f();
        }
    };

    private Runnable f8019j = new Runnable() {
        @Override
        public final void run() {
            b.this.d();
        }
    };

    public static class C0054b {

        String f8034a;

        a f8037d;

        a f8038e;

        List<a> f8035b = new ArrayList();

        List<a> f8036c = new ArrayList();

        boolean f8039f = false;

        int f8040g = 0;

        public C0054b(String str) {
            this.f8034a = str;
        }
    }

    private b(Context context) {
        this.f8011a = context;
    }

    public void d() {
        if (this.f8017h || this.f8016g == null) {
            return;
        }
        if (!com.apm.insight.l.k.b(this.f8011a)) {
            e();
        }
        if (this.f8014e == -1) {
            if (com.apm.insight.runtime.a.a() && com.apm.insight.runtime.a.f()) {
                this.f8014e = 1;
            } else {
                this.f8014e = 0;
            }
        }
        boolean z8 = this.f8014e == 1;
        com.apm.insight.runtime.f fVar = new com.apm.insight.runtime.f(this.f8011a);
        Iterator<C0054b> it = this.f8016g.values().iterator();
        while (it.hasNext()) {
            b(it.next(), z8, fVar);
        }
        Iterator<C0054b> it2 = this.f8016g.values().iterator();
        while (it2.hasNext()) {
            a(it2.next(), z8, fVar);
        }
        Iterator<C0054b> it3 = this.f8016g.values().iterator();
        while (it3.hasNext()) {
            com.apm.insight.l.f.a(com.apm.insight.l.j.a(this.f8011a, it3.next().f8034a));
        }
        fVar.a();
        com.apm.insight.runtime.b.a();
        e();
    }

    private void e() {
        this.f8017h = true;
        this.f8016g = null;
        NativeImpl.j();
    }

    public void f() {
        if (this.f8017h) {
            return;
        }
        if (!com.apm.insight.l.k.b(this.f8011a) || (System.currentTimeMillis() - com.apm.insight.e.j() <= 5000 && com.apm.insight.e.i().isApmExists() && !Npth.hasCrash())) {
            m.a().a(this.f8018i, 5000L);
        } else {
            d();
        }
    }

    private void g() {
        File[] listFiles = com.apm.insight.l.j.i(this.f8011a).listFiles();
        if (listFiles == null) {
            return;
        }
        for (int i8 = 0; i8 < listFiles.length && i8 < 5; i8++) {
            File file = listFiles[i8];
            if (file.getName().endsWith(".atmp")) {
                com.apm.insight.a.a.a();
                file.getAbsolutePath();
            } else {
                try {
                    com.apm.insight.f.b c6 = com.apm.insight.l.f.c(file.getAbsolutePath());
                    if (c6 != null) {
                        if (c6.b() != null) {
                            c6.b().put("upload_scene", "launch_scan");
                        }
                        if (e.a(e.d(), c6.e(), c6.d(), c6.f(), c6.g())) {
                            com.apm.insight.l.f.a(file);
                            String c9 = c6.c();
                            if (!TextUtils.isEmpty(c9)) {
                                com.apm.insight.l.f.a(new File(c9));
                            }
                        }
                    } else {
                        com.apm.insight.l.f.a(file);
                    }
                } catch (Throwable th) {
                    com.apm.insight.c.a();
                    com.apm.insight.runtime.j.a(th, "NPTH_CATCH");
                }
            }
        }
    }

    public static b a() {
        if (f8010b == null) {
            synchronized (b.class) {
                try {
                    if (f8010b == null) {
                        f8010b = new b(com.apm.insight.e.g());
                    }
                } finally {
                }
            }
        }
        return f8010b;
    }

    public final void b() {
        try {
            if (!this.f8017h && com.apm.insight.l.a.c(com.apm.insight.e.g())) {
                m.a().a(this.f8019j);
            }
        } catch (Throwable unused) {
        }
    }

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

    private void b(HashMap<String, C0054b> hashMap) {
        File[] listFiles = com.apm.insight.l.j.d(this.f8011a).listFiles();
        if (listFiles == null || listFiles.length == 0) {
            return;
        }
        for (int i8 = 0; i8 < listFiles.length && i8 < 5; i8++) {
            File file = listFiles[i8];
            try {
                if (!file.isDirectory()) {
                    com.apm.insight.l.f.a(file);
                } else if (file.getName().endsWith("G")) {
                    String name = file.getName();
                    C0054b c0054b = hashMap.get(name);
                    if (c0054b == null) {
                        c0054b = new C0054b(name);
                        hashMap.put(name, c0054b);
                    }
                    c0054b.f8036c.add(new a(file, CrashType.NATIVE));
                } else {
                    com.apm.insight.l.f.a(file);
                }
            } catch (Throwable th) {
                com.apm.insight.c.a();
                com.apm.insight.runtime.j.a(th, "NPTH_CATCH");
                com.apm.insight.l.f.a(file);
            }
        }
    }

    public static class a {

        File f8029a;

        long f8030b;

        long f8031c;

        @Nullable
        CrashType f8032d;

        String f8033e;

        public a(File file, @Nullable CrashType crashType) {
            this.f8030b = -1L;
            this.f8031c = -1L;
            this.f8029a = file;
            this.f8032d = crashType;
            this.f8033e = file.getName();
        }

        public a(File file, long j8, @Nullable CrashType crashType) {
            this.f8031c = -1L;
            this.f8029a = file;
            this.f8030b = j8;
            this.f8032d = crashType;
            this.f8033e = file.getName();
        }
    }

    public final void a(boolean z8) {
        if (!Npth.isStopUpload() && z8) {
            if (this.f8015f == null) {
                this.f8015f = new C0054b("old_uuid");
                HashMap<String, C0054b> hashMap = new HashMap<>();
                this.f8016g = hashMap;
                a(hashMap);
                a(this.f8016g, this.f8015f);
                com.apm.insight.l.f.a(com.apm.insight.l.j.b(this.f8011a));
                b(this.f8016g);
                b(this.f8015f, true, null);
                a(this.f8015f, true, null);
                this.f8015f = null;
                if (this.f8016g.isEmpty()) {
                    e();
                } else {
                    f();
                }
            }
            g();
            com.apm.insight.a.c();
        }
    }

    private void b(final C0054b c0054b, boolean z8, @Nullable com.apm.insight.runtime.f fVar) {
        boolean z9;
        JSONObject a8;
        a aVar;
        if (c0054b.f8036c.size() <= 1 && c0054b.f8036c.isEmpty()) {
            c0054b.f8038e = c0054b.f8037d;
            return;
        }
        boolean b6 = com.apm.insight.l.k.b(this.f8011a);
        c0054b.f8038e = c0054b.f8037d;
        com.apm.insight.nativecrash.a aVar2 = new com.apm.insight.nativecrash.a(this.f8011a);
        for (a aVar3 : c0054b.f8036c) {
            final File file = aVar3.f8029a;
            try {
                aVar2.a(file);
                a8 = a(aVar2);
            } catch (Throwable th) {
                th = th;
                z9 = b6;
            }
            if (a8 != null && a8.length() != 0) {
                if (a8.length() != 0) {
                    if (!z8) {
                        long optLong = a8.optLong("crash_time");
                        try {
                            aVar = c0054b.f8038e;
                        } catch (Throwable th2) {
                            th = th2;
                            z9 = b6;
                        }
                        if (aVar == null) {
                            c0054b.f8038e = aVar3;
                            c0054b.f8039f = true;
                            if (fVar == null || fVar.a("default")) {
                                z9 = b6;
                            } else {
                                aVar2.i();
                            }
                        } else {
                            z9 = b6;
                            try {
                            } catch (Throwable th3) {
                                th = th3;
                                com.apm.insight.c.a();
                                com.apm.insight.runtime.j.a(th, "NPTH_CATCH");
                                com.apm.insight.l.f.a(file);
                                b6 = z9;
                            }
                            if (!c0054b.f8039f && optLong < aVar.f8030b) {
                                c0054b.f8038e = aVar3;
                                if (fVar != null && !fVar.a("default")) {
                                    aVar2.i();
                                    b6 = z9;
                                } else {
                                    a(file);
                                    c0054b.f8039f = true;
                                }
                            } else {
                                com.apm.insight.entity.a.a(a8, "filters", "aid", String.valueOf(a8.optJSONObject("header").opt("aid")));
                                a8.optJSONObject("header").put("aid", 2010);
                            }
                        }
                    } else {
                        z9 = b6;
                        if (fVar != null && !fVar.a("default")) {
                            aVar2.i();
                        }
                    }
                    com.apm.insight.entity.a.a(a8, "filters", "start_uuid", c0054b.f8034a);
                    com.apm.insight.entity.a.a(a8, "filters", "crash_thread_name", a8.optString("crash_thread_name", "unknown"));
                    if (z9) {
                        try {
                            c.a aVar4 = new c.a(a8, CrashType.NATIVE);
                            com.apm.insight.entity.b.a(a8, com.apm.insight.entity.b.a(aVar4.c(), aVar4.a(), o.a().b(aVar4.b() == -1 ? System.currentTimeMillis() : aVar4.b())), new b.a() {
                                @Override
                                public final void a(JSONObject jSONObject) {
                                    d.a();
                                    d.a(jSONObject, file, com.apm.insight.l.j.a(b.this.f8011a, c0054b.f8034a));
                                }
                            });
                            if (!aVar2.i()) {
                                aVar2.f();
                            }
                        } catch (Throwable th4) {
                            th = th4;
                            com.apm.insight.c.a();
                            com.apm.insight.runtime.j.a(th, "NPTH_CATCH");
                            com.apm.insight.l.f.a(file);
                            b6 = z9;
                        }
                    }
                    c.a(CrashType.NATIVE, a8);
                } else {
                    z9 = b6;
                }
            } else {
                z9 = b6;
                aVar2.i();
            }
            b6 = z9;
        }
    }

    private void a(HashMap<String, C0054b> hashMap) {
        File[] listFiles = com.apm.insight.l.j.f(this.f8011a).listFiles();
        if (listFiles == null || listFiles.length == 0) {
            return;
        }
        for (int i8 = 0; i8 < listFiles.length && i8 < 5; i8++) {
            File file = listFiles[i8];
            try {
                if (!file.isDirectory()) {
                    com.apm.insight.l.f.a(file);
                } else if (file.getName().endsWith("G")) {
                    String name = file.getName();
                    C0054b c0054b = hashMap.get(name);
                    if (c0054b == null) {
                        c0054b = new C0054b(name);
                        hashMap.put(name, c0054b);
                    }
                    JSONArray a8 = com.apm.insight.nativecrash.b.a(com.apm.insight.l.j.l(file), com.apm.insight.l.j.m(file));
                    int length = a8.length();
                    c0054b.f8040g = length;
                    if (length > 0) {
                        try {
                            com.apm.insight.l.f.a(com.apm.insight.l.j.n(file), a8);
                        } catch (Throwable unused) {
                        }
                    }
                } else {
                    com.apm.insight.l.f.a(file);
                }
            } catch (Throwable th) {
                com.apm.insight.c.a();
                com.apm.insight.runtime.j.a(th, "NPTH_CATCH");
                com.apm.insight.l.f.a(file);
            }
        }
    }

    private void a(java.util.HashMap<java.lang.String, com.apm.insight.k.b.C0054b> r17, com.apm.insight.k.b.C0054b r18) {
        throw new UnsupportedOperationException("Method not decompiled: com.apm.insight.k.b.a(java.util.HashMap, com.apm.insight.k.b$b):void");
    }

    private static JSONObject a(com.apm.insight.nativecrash.a aVar) {
        JSONObject b6 = aVar.b();
        if (b6 != null && b6.length() != 0) {
            return b6;
        }
        if (com.apm.insight.e.d()) {
            aVar.j();
        }
        if (!aVar.a()) {
            aVar.i();
            return null;
        }
        if (!aVar.d()) {
            aVar.i();
            return null;
        }
        if (aVar.e()) {
            aVar.i();
            return null;
        }
        aVar.c();
        return aVar.h();
    }

    private void a(final com.apm.insight.k.b.C0054b r19, boolean r20, @androidx.annotation.Nullable com.apm.insight.runtime.f r21) {
        throw new UnsupportedOperationException("Method not decompiled: com.apm.insight.k.b.a(com.apm.insight.k.b$b, boolean, com.apm.insight.runtime.f):void");
    }

    private static boolean a(File file) {
        String[] list = file.list();
        if (list == null) {
            return false;
        }
        for (String str : list) {
            if (!TextUtils.isEmpty(str) && str.endsWith("")) {
                return true;
            }
        }
        return false;
    }

    @Nullable
    private com.apm.insight.f.b a(File file, CrashType crashType, String str, long j8, long j9) {
        JSONObject b6;
        com.apm.insight.f.b bVar = null;
        try {
            try {
                if (file.isFile()) {
                    com.apm.insight.l.f.a(file);
                    return null;
                }
                boolean z8 = crashType == CrashType.LAUNCH;
                if (crashType == null) {
                    try {
                        return com.apm.insight.l.f.b(new File(file, file.getName()).getAbsolutePath());
                    } catch (Throwable th) {
                        th = th;
                        com.apm.insight.l.f.a(file);
                        com.apm.insight.c.a();
                        com.apm.insight.runtime.j.a(th, "NPTH_CATCH");
                        return bVar;
                    }
                }
                com.apm.insight.f.b a8 = com.apm.insight.l.f.a(file, crashType);
                try {
                    b6 = a8.b();
                } catch (Throwable th2) {
                    th = th2;
                }
                try {
                    if (a8.b() != null) {
                        if (crashType == CrashType.ANR) {
                            return a8;
                        }
                        b6.put("crash_time", j8);
                        boolean z9 = z8;
                        b6.put("app_start_time", j9);
                        JSONObject optJSONObject = b6.optJSONObject("header");
                        if (optJSONObject == null) {
                            optJSONObject = Header.a(j8).f();
                        } else if (z9) {
                            b6.remove("header");
                        }
                        String optString = optJSONObject.optString("sdk_version_name", null);
                        if (optString == null) {
                            optString = "2.0.0.3";
                        }
                        com.apm.insight.entity.a.a(b6, "filters", "sdk_version", optString);
                        JSONArray optJSONArray = b6.optJSONArray("logcat");
                        if (optJSONArray == null || optJSONArray.length() == 0) {
                            b6.put("logcat", com.apm.insight.runtime.h.a(str));
                        }
                        com.apm.insight.entity.a.a(b6, "filters", "has_dump", "true");
                        com.apm.insight.entity.a.a(b6, "filters", "has_logcat", String.valueOf(!com.apm.insight.a.a(b6, "logcat")));
                        com.apm.insight.entity.a.a(b6, "filters", "memory_leak", String.valueOf(com.apm.insight.entity.a.a(str)));
                        com.apm.insight.entity.a.a(b6, "filters", "fd_leak", String.valueOf(com.apm.insight.entity.a.b(str)));
                        com.apm.insight.entity.a.a(b6, "filters", "threads_leak", String.valueOf(com.apm.insight.entity.a.c(str)));
                        com.apm.insight.entity.a.a(b6, "filters", "is_64_devices", String.valueOf(Header.a()));
                        com.apm.insight.entity.a.a(b6, "filters", "is_64_runtime", String.valueOf(NativeImpl.f()));
                        com.apm.insight.entity.a.a(b6, "filters", "is_x86_devices", String.valueOf(Header.b()));
                        com.apm.insight.entity.a.a(b6, "filters", "has_meminfo_file", String.valueOf(com.apm.insight.l.j.d(str).exists()));
                        com.apm.insight.entity.a.a(b6, "filters", "is_root", String.valueOf(com.apm.insight.nativecrash.a.k()));
                        b6.put("launch_did", com.apm.insight.i.a.a(this.f8011a));
                        b6.put("crash_uuid", file.getName());
                        try {
                            long parseLong = Long.parseLong(com.apm.insight.runtime.b.a(j8, str));
                            com.apm.insight.entity.a.a(b6, "filters", "lastAliveTime", Math.abs(parseLong - j8) < 60000 ? "< 60s" : "> 60s");
                            b6.put("lastAliveTime", String.valueOf(parseLong));
                        } catch (Throwable unused) {
                            b6.put("lastAliveTime", "unknown");
                            com.apm.insight.entity.a.a(b6, "filters", "lastAliveTime", "unknown");
                        }
                        b6.put("has_dump", "true");
                        if (b6.opt("storage") == null) {
                            com.apm.insight.e.g();
                            com.apm.insight.entity.a.a(b6, n.a());
                        }
                        if (Header.b(optJSONObject)) {
                            com.apm.insight.entity.a.a(b6, "filters", "unauthentic_version", "unauthentic_version");
                        }
                        com.apm.insight.entity.d.b(b6);
                        a8.b().put("upload_scene", "launch_scan");
                        if (z9) {
                            JSONObject jSONObject = new JSONObject();
                            b6.put("event_type", "start_crash");
                            b6.put("stack", b6.remove("data"));
                            jSONObject.put("data", new JSONArray().put(b6));
                            jSONObject.put("header", optJSONObject);
                            a8.a(jSONObject);
                            return a8;
                        }
                        b6.put("isJava", 1);
                        return a8;
                    }
                    com.apm.insight.l.f.a(file);
                    return a8;
                } catch (Throwable th3) {
                    th = th3;
                    bVar = a8;
                    com.apm.insight.l.f.a(file);
                    com.apm.insight.c.a();
                    com.apm.insight.runtime.j.a(th, "NPTH_CATCH");
                    return bVar;
                }
            } catch (Throwable th4) {
                th = th4;
            }
        } catch (Throwable th5) {
            th = th5;
        }
    }
}