鳯华 v4.0.0版本的 MD5 值为:e66eea5d0a772ef117f7e252dfbb1dfc

以下内容为反编译后的 e.java 源代码,内容仅作参考


package com.uc.crashsdk;

import android.app.ActivityManager;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.os.Build;
import android.os.ConditionVariable;
import android.os.Debug;
import android.os.Environment;
import android.os.Looper;
import android.os.ParcelFileDescriptor;
import android.os.Process;
import android.os.StatFs;
import android.os.StrictMode;
import com.efs.sdk.base.core.util.NetworkUtil;
import com.tencent.mm.opensdk.constants.ConstantsAPI;
import com.uc.crashsdk.a.h;
import com.uc.crashsdk.export.CrashStatKey;
import com.uc.crashsdk.export.LogType;
import io.agora.rtc.Constants;
import java.io.BufferedReader;
import java.io.ByteArrayOutputStream;
import java.io.Closeable;
import java.io.DataInputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintStream;
import java.io.RandomAccessFile;
import java.lang.Thread;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.nio.channels.FileChannel;
import java.nio.channels.FileLock;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Calendar;
import java.util.Comparator;
import java.util.Date;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.Random;
import java.util.Set;
import java.util.UUID;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import org.apache.mina.proxy.handlers.http.ntlm.NTLMConstants;
public class e implements Thread.UncaughtExceptionHandler {
    private static long f11642b;
    private static String f11648i;
    private final List<FileInputStream> f11666e = new ArrayList();
    static final boolean f11641a = true;
    private static final AtomicBoolean f11643c = new AtomicBoolean(false);
    private static boolean f11644d = false;
    private static long f11645f = 0;
    private static long f11646g = -1;
    private static boolean f11647h = true;
    private static String f11649j = "";
    private static String f11650k = null;
    private static String f11651l = null;
    private static String f11652m = null;
    private static final Object f11653n = new Object();
    private static final ConditionVariable f11654o = new ConditionVariable();
    private static final Object f11655p = new Object();
    private static final Object f11656q = new Object();
    private static final Object f11657r = new Object();
    private static final ArrayList<String> f11658s = new ArrayList<>();
    private static int f11659t = 0;
    private static String f11660u = null;
    private static boolean f11661v = false;
    private static String f11662w = null;
    private static String f11663x = null;
    private static final Object f11664y = new Object();
    private static final Object f11665z = new Object();
    private static Map<String, Integer> A = null;
    private static String B = null;
    private static int C = -1;
    private static int D = -1;
    private static int E = -1;
    private static int F = -1;
    private static int G = -1;
    private static int H = -1;
    private static int I = -1;
    private static String J = "?";
    private static boolean K = false;
    private static boolean L = false;
    private static int M = 0;
    private static int N = 0;
    private static boolean O = false;
    private static com.uc.crashsdk.a.e P = new com.uc.crashsdk.a.e(405);
    private static c Q = new c((byte) 0);
    private static boolean R = false;
    private static final com.uc.crashsdk.a.e S = new com.uc.crashsdk.a.e(412);
    private static Thread.UncaughtExceptionHandler T = null;
    private static Throwable U = null;
    private static boolean V = false;
    private static boolean W = false;
    private static Runnable X = null;
    private static final Object Y = new Object();
    private static int Z = 101;
    private static Runnable aa = new com.uc.crashsdk.a.e(407);
    private static final Object ab = new Object();
    private static volatile boolean ac = false;
    private static Object ad = new Object();
    private static ParcelFileDescriptor ae = null;
    private static boolean af = false;
    private static boolean ag = false;

    public static class b implements Comparator<File> {
        private b() {
        }

        @Override
        public final int compare(File file, File file2) {
            File file3 = file;
            File file4 = file2;
            if (file3.lastModified() > file4.lastModified()) {
                return 1;
            }
            return file3.lastModified() < file4.lastModified() ? -1 : 0;
        }

        b(byte b10) {
            this();
        }
    }

    public static class c extends BroadcastReceiver {
        private c() {
        }

        @Override
        public final void onReceive(Context context, Intent intent) {
            String action = intent.getAction();
            if ("android.intent.action.BATTERY_CHANGED".equals(action)) {
                int unused = e.C = intent.getIntExtra("level", -1);
                int unused2 = e.D = intent.getIntExtra("scale", -1);
                int unused3 = e.E = intent.getIntExtra("voltage", -1);
                int unused4 = e.F = intent.getIntExtra("health", -1);
                int unused5 = e.G = intent.getIntExtra("plugged", -1);
                int unused6 = e.H = intent.getIntExtra("status", -1);
                int unused7 = e.I = intent.getIntExtra("temperature", -1);
                String unused8 = e.J = intent.getStringExtra("technology");
                if (e.J() >= 2) {
                    e.K();
                    e.L();
                }
            } else if ("android.intent.action.BATTERY_LOW".equals(action) || "android.intent.action.BATTERY_OKAY".equals(action)) {
                boolean unused9 = e.K = "android.intent.action.BATTERY_LOW".equals(action);
                e.K();
            } else if ("android.intent.action.ANR".equals(action)) {
                try {
                    e.d(context);
                } catch (Throwable th) {
                    com.uc.crashsdk.a.g.a(th);
                }
            }
        }

        c(byte b10) {
            this();
        }
    }

    public e() {
        try {
            M();
        } catch (Throwable th) {
            com.uc.crashsdk.a.g.a(th);
        }
    }

    public static void A() {
        if (g.q()) {
            com.uc.crashsdk.a.f.a(0, new com.uc.crashsdk.a.e(403), 10000L);
        }
    }

    public static void B() {
        if (ac || com.uc.crashsdk.b.L()) {
            return;
        }
        com.uc.crashsdk.a.f.a(1, new com.uc.crashsdk.a.e(408), 1000L);
    }

    public static void C() {
        com.uc.crashsdk.a.f.a(1, new com.uc.crashsdk.a.e(409), 7000L);
    }

    public static void D() {
        int L2 = g.L();
        boolean z9 = true;
        boolean z10 = false;
        if (L2 == 0 || L2 == 3 || L2 == 4) {
            int i9 = Build.VERSION.SDK_INT;
            if (i9 >= 21 && i9 <= 25) {
                boolean z11 = L2 != 0;
                if (L2 == 3) {
                    z11 = System.currentTimeMillis() % 10 == 0;
                }
                if (L2 != 4) {
                    z9 = z11;
                }
            }
        }
        if (!z9) {
            com.uc.crashsdk.a.a.a("crashsdk", "SIG 3 is disabled by settings");
        }
        boolean L3 = com.uc.crashsdk.b.L();
        if (Looper.getMainLooper() == Looper.myLooper() || !z9) {
            z10 = z9;
        } else {
            com.uc.crashsdk.a.f.a(2, new com.uc.crashsdk.a.e(413));
        }
        JNIBridge.nativeCmd(7, L3 ? 1L : 0L, null, null);
        if (z10) {
            JNIBridge.cmd(8);
        }
    }

    public static ParcelFileDescriptor E() {
        if (!com.uc.crashsdk.b.f11609d) {
            com.uc.crashsdk.a.a.d("crashsdk", "Crash so is not loaded!");
            return null;
        }
        synchronized (ad) {
            ParcelFileDescriptor parcelFileDescriptor = ae;
            if (parcelFileDescriptor != null) {
                return parcelFileDescriptor;
            }
            int cmd = (int) JNIBridge.cmd(14);
            if (cmd == -1) {
                return null;
            }
            ParcelFileDescriptor adoptFd = ParcelFileDescriptor.adoptFd(cmd);
            ae = adoptFd;
            af = true;
            return adoptFd;
        }
    }

    public static boolean F() {
        return ag;
    }

    public static void G() {
        String V2 = g.V();
        File file = new File(V2);
        if (file.exists() && file.isDirectory()) {
            File[] listFiles = file.listFiles();
            if (listFiles == null) {
                com.uc.crashsdk.a.a.b("Ucebu can not list folder: " + V2);
                return;
            }
            for (File file2 : listFiles) {
                if (file2.isFile() && file2.getName().contains("ucebu")) {
                    a(false, false);
                    return;
                }
            }
        }
    }

    static boolean I() {
        return O();
    }

    static int J() {
        int i9 = M + 1;
        M = i9;
        return i9;
    }

    static void K() {
        StringBuilder Y2;
        if (com.uc.crashsdk.b.f11609d && (Y2 = Y()) != null) {
            JNIBridge.set(125, Y2.toString());
        }
        L = true;
        Z();
    }

    static int L() {
        M = 0;
        return 0;
    }

    private void M() {
        int G2 = g.G();
        for (int i9 = 0; i9 < G2; i9++) {
            try {
                this.f11666e.add(new FileInputStream("/dev/null"));
            } catch (Exception e9) {
                com.uc.crashsdk.a.g.a(e9);
                return;
            }
        }
    }

    private void N() {
        for (FileInputStream fileInputStream : this.f11666e) {
            com.uc.crashsdk.a.g.a(fileInputStream);
        }
        this.f11666e.clear();
    }

    private static boolean O() {
        if (g.N()) {
            return true;
        }
        return a();
    }

    private static String P() {
        return g.e() + "_";
    }

    private static String Q() {
        return com.uc.crashsdk.b.B() ? "fg" : "bg";
    }

    private static byte[] R() {
        byte[] bArr = null;
        int i9 = 1024;
        while (bArr == null && i9 > 0) {
            try {
                bArr = new byte[i9];
            } catch (Throwable unused) {
                i9 /= 2;
                if (i9 < 16) {
                    break;
                }
            }
        }
        return bArr;
    }

    private static String S() {
        return (!com.uc.crashsdk.b.F() || f11644d) ? LogType.JAVA_TYPE : "ucebujava";
    }

    private static void T() {
        String str;
        BufferedReader bufferedReader;
        Throwable th;
        FileReader fileReader;
        String str2 = "-";
        try {
            str = Build.HARDWARE;
        } catch (Throwable th2) {
            com.uc.crashsdk.a.g.a(th2);
            str = "-";
        }
        try {
            fileReader = new FileReader(new File("/proc/cpuinfo"));
            try {
                bufferedReader = new BufferedReader(fileReader, 512);
                int i9 = 0;
                do {
                    try {
                        String readLine = bufferedReader.readLine();
                        if (readLine == null) {
                            break;
                        }
                        if (readLine.startsWith("Hardware")) {
                            str = readLine.substring(readLine.indexOf(":") + 1).trim();
                        } else if (readLine.startsWith("Processor")) {
                            str2 = readLine.substring(readLine.indexOf(":") + 1).trim();
                        }
                        i9++;
                    } catch (Throwable th3) {
                        th = th3;
                        try {
                            com.uc.crashsdk.a.g.a(th);
                            com.uc.crashsdk.a.g.a(fileReader);
                            com.uc.crashsdk.a.g.a(bufferedReader);
                            f11650k = str;
                            f11651l = str2;
                        } catch (Throwable th4) {
                            com.uc.crashsdk.a.g.a(fileReader);
                            com.uc.crashsdk.a.g.a(bufferedReader);
                            throw th4;
                        }
                    }
                } while (i9 < 2);
                com.uc.crashsdk.a.g.a(fileReader);
            } catch (Throwable th5) {
                bufferedReader = null;
                th = th5;
            }
        } catch (Throwable th6) {
            bufferedReader = null;
            th = th6;
            fileReader = null;
        }
        com.uc.crashsdk.a.g.a(bufferedReader);
        f11650k = str;
        f11651l = str2;
    }

    private static String U() {
        return g.U() + "bytes";
    }

    private static boolean V() {
        return Build.VERSION.SDK_INT < 29;
    }

    private static void W() {
        if (O || com.uc.crashsdk.b.F() || com.uc.crashsdk.b.L()) {
            return;
        }
        JNIBridge.cmd(18);
    }

    private static void X() {
        com.uc.crashsdk.a.f.a(3, new com.uc.crashsdk.a.e(414), 1000L);
    }

    private static StringBuilder Y() {
        String str;
        try {
            StringBuilder sb = new StringBuilder();
            sb.append("level: ");
            sb.append(C);
            sb.append("\n");
            sb.append("scale: ");
            sb.append(D);
            sb.append("\n");
            switch (F) {
                case 1:
                    str = " (Unknown)";
                    break;
                case 2:
                    str = " (Good)";
                    break;
                case 3:
                    str = " (Overheat)";
                    break;
                case 4:
                    str = " (Dead)";
                    break;
                case 5:
                    str = " (Over voltage)";
                    break;
                case 6:
                    str = " (Unspecified failure)";
                    break;
                case 7:
                    str = " (Cold)";
                    break;
                default:
                    str = " (?)";
                    break;
            }
            sb.append("health: ");
            sb.append(F);
            sb.append(str);
            sb.append("\n");
            int i9 = G;
            String str2 = i9 != 0 ? i9 != 1 ? i9 != 2 ? i9 != 4 ? " (?)" : " (Wireless)" : " (USB port)" : " (AC charger)" : " (None)";
            sb.append("pluged: ");
            sb.append(G);
            sb.append(str2);
            sb.append("\n");
            int i10 = H;
            String str3 = i10 != 1 ? i10 != 2 ? i10 != 3 ? i10 != 4 ? i10 != 5 ? " (?)" : " (Full)" : " (Not charging)" : " (Discharging)" : " (Charging)" : " (Unknown)";
            sb.append("status: ");
            sb.append(H);
            sb.append(str3);
            sb.append("\n");
            sb.append("voltage: ");
            sb.append(E);
            sb.append("\n");
            sb.append("temperature: ");
            sb.append(I);
            sb.append("\n");
            sb.append("technology: ");
            sb.append(J);
            sb.append("\n");
            sb.append("battery low: ");
            sb.append(K);
            sb.append("\n");
            return sb;
        } catch (Throwable th) {
            com.uc.crashsdk.a.g.a(th);
            return null;
        }
    }

    private static void Z() {
        if (com.uc.crashsdk.b.f11608c && L && com.uc.crashsdk.a.f11528c) {
            L = false;
            if (com.uc.crashsdk.a.f.b(P)) {
                return;
            }
            com.uc.crashsdk.a.f.a(0, P, 2000L);
        }
    }

    public static boolean a() {
        if (f11645f == 0) {
            f11645f = 2L;
            if (h(com.uc.crashsdk.b.b("logs")) == 1) {
                f11645f = 1L;
            }
        }
        return f11645f == 1;
    }

    private static boolean aa() {
        return com.uc.crashsdk.b.f11609d && JNIBridge.nativeIsCrashing();
    }

    private static void ab() {
        String W2 = g.W();
        File file = new File(W2);
        if (file.isDirectory()) {
            try {
                File[] listFiles = file.listFiles();
                if (listFiles != null && listFiles.length > 150) {
                    Arrays.sort(listFiles, new b((byte) 0));
                    int length = listFiles.length - 150;
                    if (length < 0) {
                        length = 0;
                    }
                    long currentTimeMillis = System.currentTimeMillis();
                    int i9 = 0;
                    int i10 = 0;
                    while (i9 < listFiles.length) {
                        File file2 = listFiles[i9];
                        boolean z9 = i9 < length;
                        if (!z9 && currentTimeMillis - file2.lastModified() >= 432000000) {
                            z9 = true;
                        }
                        if (!z9) {
                            break;
                        }
                        file2.delete();
                        i10++;
                        if (0 >= 3) {
                            break;
                        }
                        i9++;
                    }
                    com.uc.crashsdk.a.a.a("Removed " + i10 + " logs in " + W2);
                }
            } catch (Throwable th) {
                com.uc.crashsdk.a.g.a(th);
            }
        }
    }

    public static long b() {
        if (f11646g == -1) {
            f11646g = h(com.uc.crashsdk.b.b("local"));
        }
        return f11646g;
    }

    private static String j(String str) {
        if (str == null) {
            str = String.valueOf(System.currentTimeMillis()) + new Random().nextInt(NTLMConstants.FLAG_TARGET_TYPE_DOMAIN);
        }
        return String.format(Locale.US, "%s%s_%s_%s_%s_%s_", P(), g.R(), g.T(), i(Build.MODEL), i(Build.VERSION.RELEASE), str);
    }

    private static String k(String str) {
        return String.format(Locale.US, "%s%s_%s_%s.log", d(), n(), Q(), str);
    }

    private static String l(String str) {
        if (com.uc.crashsdk.a.g.b(str)) {
            int indexOf = str.indexOf(0);
            if (indexOf >= 0) {
                str = str.substring(0, indexOf);
            }
            return str.trim();
        }
        return "";
    }

    private static String m(String str) {
        String a10 = com.uc.crashsdk.a.b.a(str, g.w(), g.v());
        if (!str.equals(a10)) {
            File file = new File(str);
            if (file.exists()) {
                file.delete();
            }
        }
        return a10;
    }

    private static boolean[] n(String str) {
        int i9;
        boolean v9 = g.v();
        boolean x9 = g.x();
        if (v9 || x9) {
            if (!str.endsWith(".tmp") && !str.contains(".ec")) {
                int lastIndexOf = str.lastIndexOf(File.separatorChar);
                if (lastIndexOf < 0) {
                    lastIndexOf = 0;
                    i9 = 0;
                } else {
                    i9 = 0;
                }
                do {
                    lastIndexOf = str.indexOf(95, lastIndexOf);
                    if (lastIndexOf >= 0) {
                        i9++;
                        lastIndexOf++;
                        continue;
                    }
                } while (lastIndexOf >= 0);
                if (i9 == 8) {
                    String w9 = g.w();
                    if (!str.endsWith(".log")) {
                        if (!com.uc.crashsdk.a.g.a(w9)) {
                        }
                    } else if (!com.uc.crashsdk.a.g.a(w9)) {
                    }
                    v9 = false;
                }
            }
            v9 = false;
            x9 = false;
        }
        return new boolean[]{v9, x9};
    }

    private static boolean o(String str) {
        boolean z9;
        boolean z10;
        int i9;
        synchronized (f11657r) {
            File file = new File(g.U() + "customlog");
            String a10 = com.uc.crashsdk.a.g.a(file, 1024, false);
            long currentTimeMillis = System.currentTimeMillis();
            StringBuffer stringBuffer = new StringBuffer();
            try {
                if (a10 != null) {
                    stringBuffer.append(a10);
                    Matcher matcher = Pattern.compile("([^\\n\\r\\t\\s]+) (\\d+) (\\d+)").matcher(stringBuffer);
                    for (int i10 = 0; matcher.find(i10); i10 = matcher.end()) {
                        if (str.equals(matcher.group(1))) {
                            long parseLong = Long.parseLong(matcher.group(2));
                            if (currentTimeMillis - parseLong < 86400000) {
                                try {
                                    i9 = Integer.parseInt(matcher.group(3));
                                } catch (Exception e9) {
                                    com.uc.crashsdk.a.g.a(e9);
                                    i9 = 0;
                                }
                            } else {
                                i9 = 0;
                                parseLong = currentTimeMillis;
                            }
                            int D2 = g.D();
                            z10 = D2 >= 0 && i9 >= D2;
                            stringBuffer.replace(matcher.start(), matcher.end(), String.format(Locale.US, "%s %d %d", str, Long.valueOf(parseLong), Integer.valueOf(i9 + 1)));
                            z9 = true;
                            if (!z9) {
                                stringBuffer.append(String.format(Locale.US, "%s %d 1\n", str, Long.valueOf(currentTimeMillis)));
                            }
                            FileWriter fileWriter = null;
                            FileWriter fileWriter2 = null;
                            FileWriter fileWriter3 = new FileWriter(file);
                            String stringBuffer2 = stringBuffer.toString();
                            int length = stringBuffer2.length();
                            fileWriter3.write(stringBuffer2, 0, length);
                            com.uc.crashsdk.a.g.a(fileWriter3);
                            fileWriter = length;
                        }
                    }
                }
                FileWriter fileWriter32 = new FileWriter(file);
                String stringBuffer22 = stringBuffer.toString();
                int length2 = stringBuffer22.length();
                fileWriter32.write(stringBuffer22, 0, length2);
                com.uc.crashsdk.a.g.a(fileWriter32);
                fileWriter = length2;
            } catch (Throwable th) {
                th = th;
            }
            z9 = false;
            z10 = false;
            if (!z9) {
            }
            FileWriter fileWriter4 = null;
            FileWriter fileWriter22 = null;
        }
        return z10;
    }

    private static boolean p(String str) {
        boolean z9;
        boolean z10;
        int i9;
        Integer num;
        synchronized (f11665z) {
            z9 = false;
            if (A == null) {
                A = q(com.uc.crashsdk.a.g.a(com.uc.crashsdk.b.l(), "all:1", false));
            }
            if (A.containsKey("all")) {
                num = A.get("all");
            } else if (A.containsKey(str)) {
                num = A.get(str);
            } else {
                if (!LogType.JAVA_TYPE.equals(str) && !LogType.NATIVE_TYPE.equals(str) && !LogType.ANR_TYPE.equals(str) && !LogType.UNEXP_TYPE.equals(str)) {
                    z10 = false;
                    if (!z10 && A.containsKey("crash")) {
                        num = A.get("crash");
                    } else if (z10 && A.containsKey("nocrash")) {
                        num = A.get("nocrash");
                    } else if (A.containsKey("other")) {
                        i9 = 1;
                        if (i9 != 0) {
                            long j9 = i9;
                            if (j9 < 0) {
                                long j10 = 30;
                                if (j9 == -2) {
                                    j10 = 7;
                                } else if (j9 == -3) {
                                    j10 = 15;
                                } else if (j9 == -4) {
                                    j10 = 60;
                                }
                                long b10 = com.uc.crashsdk.a.b();
                                long currentTimeMillis = b10 == 0 ? -1L : (System.currentTimeMillis() - b10) / 86400000;
                                j9 = currentTimeMillis <= j10 ? 1L : currentTimeMillis - j10;
                            }
                            if (j9 != 1) {
                                if (j9 > 0) {
                                    if (System.currentTimeMillis() % j9 == 0) {
                                    }
                                }
                            }
                            z9 = true;
                        }
                    } else {
                        num = A.get("other");
                    }
                }
                z10 = true;
                if (!z10) {
                }
                if (z10) {
                }
                if (A.containsKey("other")) {
                }
            }
            i9 = num.intValue();
            if (i9 != 0) {
            }
        }
        return z9;
    }

    private static Map<String, Integer> q(String str) {
        HashMap hashMap = new HashMap();
        for (String str2 : str.split("\\|", 30)) {
            String[] split = str2.split(":", 3);
            if (split.length == 2) {
                String trim = split[0].trim();
                if (!com.uc.crashsdk.a.g.a(trim)) {
                    int i9 = 1;
                    try {
                        i9 = Integer.parseInt(split[1].trim(), 10);
                    } catch (Throwable th) {
                        com.uc.crashsdk.a.g.a(th);
                    }
                    hashMap.put(trim, Integer.valueOf(i9));
                }
            }
        }
        return hashMap;
    }

    private static void r(String str) {
        if (g.q()) {
            try {
                ab();
            } catch (Throwable th) {
                com.uc.crashsdk.a.g.a(th);
            }
            if (str == null || "".equals(str)) {
                return;
            }
            try {
                File file = new File(g.W());
                if (!file.exists()) {
                    file.mkdirs();
                }
                com.uc.crashsdk.a.a.a("crashsdk", "copy log to: " + file);
                com.uc.crashsdk.a.g.a(new File(str), file);
            } catch (Throwable th2) {
                com.uc.crashsdk.a.g.a(th2);
            }
        }
    }

    private static String s(String str) {
        return String.format("$^%s^$", str);
    }

    public static void t() {
        Thread.setDefaultUncaughtExceptionHandler(T);
    }

    public static boolean u() {
        return f11643c.get() || aa();
    }

    public static Throwable v() {
        return U;
    }

    public static int w() {
        if (com.uc.crashsdk.b.I() == 5) {
            return Z;
        }
        return 100;
    }

    public static void x() {
        long o9 = g.o();
        if (o9 < 0) {
            return;
        }
        boolean z9 = com.uc.crashsdk.b.I() == 5;
        com.uc.crashsdk.a.f.a(0, new com.uc.crashsdk.a.e(401));
        if (z9) {
            com.uc.crashsdk.a.e eVar = new com.uc.crashsdk.a.e(402);
            X = eVar;
            com.uc.crashsdk.a.f.a(0, eVar, o9);
        }
    }

    public static void y() {
        if (com.uc.crashsdk.b.f11608c && com.uc.crashsdk.a.f11528c && !com.uc.crashsdk.a.f.b(aa)) {
            com.uc.crashsdk.a.f.a(0, aa, 1000L);
        }
    }

    public static boolean z() {
        synchronized (Y) {
            Runnable runnable = X;
            if (runnable == null || W) {
                return false;
            }
            com.uc.crashsdk.a.f.a(runnable);
            X = null;
            return true;
        }
    }

    @Override
    public void uncaughtException(Thread thread, Throwable th) {
        a(thread, th, false);
    }

    public static String d() {
        String str = f11648i;
        if (str != null) {
            return str;
        }
        String j9 = j(null);
        f11648i = j9;
        return j9;
    }

    public static String e() {
        String str;
        String str2;
        Method declaredMethod;
        String str3;
        String str4;
        boolean z9;
        if (!com.uc.crashsdk.a.g.a(f11649j)) {
            return f11649j;
        }
        String str5 = null;
        try {
            if (Build.VERSION.SDK_INT >= 21) {
                Field declaredField = Build.class.getDeclaredField("SUPPORTED_ABIS");
                declaredField.setAccessible(true);
                Object obj = declaredField.get(null);
                if (obj != null && (obj instanceof String[])) {
                    String[] strArr = (String[]) obj;
                    StringBuilder sb = new StringBuilder();
                    int length = strArr.length;
                    int i9 = 0;
                    boolean z10 = true;
                    while (i9 < length) {
                        String str6 = strArr[i9];
                        if (!z10) {
                            sb.append(",");
                        }
                        sb.append(str6);
                        i9++;
                        z10 = false;
                    }
                    f11649j = sb.toString();
                }
            }
        } catch (Throwable unused) {
        }
        if (com.uc.crashsdk.a.g.a(f11649j)) {
            try {
                str3 = Build.CPU_ABI;
            } catch (Throwable unused2) {
                str3 = null;
            }
            try {
                str4 = Build.CPU_ABI2;
            } catch (Throwable unused3) {
                str4 = null;
                z9 = !com.uc.crashsdk.a.g.a(str3);
                if (z9) {
                }
                if (!com.uc.crashsdk.a.g.a(str4)) {
                }
                declaredMethod = Class.forName("android.os.SystemProperties").getDeclaredMethod("get", String.class, String.class);
                if (declaredMethod == null) {
                }
            }
            z9 = !com.uc.crashsdk.a.g.a(str3);
            if (z9) {
                f11649j = str3;
            }
            if (!com.uc.crashsdk.a.g.a(str4)) {
                if (z9) {
                    f11649j += ",";
                    f11649j += str4;
                } else {
                    f11649j = str4;
                }
            }
        }
        try {
            declaredMethod = Class.forName("android.os.SystemProperties").getDeclaredMethod("get", String.class, String.class);
        } catch (Throwable th) {
            th = th;
            str = null;
        }
        if (declaredMethod == null) {
            declaredMethod.setAccessible(true);
            str = (String) declaredMethod.invoke(null, "ro.product.cpu.abi", null);
            try {
                str2 = (String) declaredMethod.invoke(null, "ro.product.cpu.abi2", null);
            } catch (Throwable th2) {
                th = th2;
                com.uc.crashsdk.a.g.a(th);
                str2 = null;
                str5 = str;
                if (!com.uc.crashsdk.a.g.a(str5)) {
                }
                if (!com.uc.crashsdk.a.g.a(str2)) {
                }
                return f11649j;
            }
            str5 = str;
            try {
                if (!com.uc.crashsdk.a.g.a(str5) && !f11649j.contains(str5)) {
                    f11649j += ",";
                    f11649j += str5;
                }
                if (!com.uc.crashsdk.a.g.a(str2) && !f11649j.contains(str2)) {
                    f11649j += ",";
                    f11649j += str2;
                }
            } catch (Throwable th3) {
                com.uc.crashsdk.a.g.a(th3);
            }
            return f11649j;
        }
        str2 = null;
        if (!com.uc.crashsdk.a.g.a(str5)) {
            f11649j += ",";
            f11649j += str5;
        }
        if (!com.uc.crashsdk.a.g.a(str2)) {
            f11649j += ",";
            f11649j += str2;
        }
        return f11649j;
    }

    public static String f() {
        if (com.uc.crashsdk.a.g.a(f11650k)) {
            T();
        }
        return f11650k;
    }

    private static long h(String str) {
        try {
            Method declaredMethod = Class.forName("android.os.SystemProperties").getDeclaredMethod("getLong", String.class, Long.TYPE);
            if (declaredMethod != null) {
                declaredMethod.setAccessible(true);
                return ((Long) declaredMethod.invoke(null, str, 0L)).longValue();
            }
        } catch (Throwable th) {
            com.uc.crashsdk.a.g.a(th);
        }
        return 0L;
    }

    private static String i(String str) {
        try {
            return str.replaceAll("[^0-9a-zA-Z-.]", "-");
        } catch (Throwable unused) {
            return NetworkUtil.NETWORK_CLASS_UNKNOWN;
        }
    }

    public static void s() {
        T = Thread.getDefaultUncaughtExceptionHandler();
        Thread.setDefaultUncaughtExceptionHandler(new e());
    }

    public static void c() {
        f11648i = null;
    }

    public static boolean i() {
        return f11644d;
    }

    public static boolean b(int i9, Object[] objArr) {
        if (i9 == 451) {
            if (f11641a || objArr != null) {
                return a((String) objArr[0], (d) objArr[1]);
            }
            throw new AssertionError();
        } else if (i9 != 452) {
            if (f11641a) {
                return false;
            }
            throw new AssertionError();
        } else if (f11641a || objArr != null) {
            d dVar = (d) objArr[1];
            return com.uc.crashsdk.a.g.a(new File((String) objArr[0]), String.format(Locale.US, "%d %d %d %d", Long.valueOf(dVar.f11672a), Long.valueOf(dVar.f11673b), Integer.valueOf(dVar.f11674c), Integer.valueOf(dVar.f11675d)).getBytes());
        } else {
            throw new AssertionError();
        }
    }

    private static void c(OutputStream outputStream) {
        HashSet hashSet;
        Throwable th;
        File file;
        File[] listFiles;
        try {
            outputStream.write("disk info:\n".getBytes("UTF-8"));
        } catch (Throwable th2) {
            a(th2, outputStream);
        }
        if (ag) {
            f11647h = false;
            try {
                outputStream.write(s("FSSTAT").getBytes("UTF-8"));
            } catch (Throwable th3) {
                a(th3, outputStream);
            }
            f11647h = true;
        } else {
            try {
                hashSet = new HashSet();
                try {
                    a(outputStream, a(new File(com.uc.crashsdk.a.g.b())), hashSet);
                } catch (Throwable th4) {
                    th = th4;
                    a(th, outputStream);
                    a(outputStream, a(Environment.getExternalStorageDirectory()), hashSet);
                    file = new File("/storage");
                    if (file.exists()) {
                        while (r2 < r3) {
                        }
                    }
                    a(outputStream);
                }
            } catch (Throwable th5) {
                hashSet = null;
                th = th5;
            }
            try {
                a(outputStream, a(Environment.getExternalStorageDirectory()), hashSet);
                file = new File("/storage");
                if (file.exists() && (listFiles = file.listFiles()) != null) {
                    for (File file2 : listFiles) {
                        if (file2.isDirectory()) {
                            a(outputStream, a(file2), hashSet);
                        }
                    }
                }
            } catch (Throwable th6) {
                a(th6, outputStream);
            }
        }
        a(outputStream);
    }

    public static String g() {
        try {
            StringBuilder sb = new StringBuilder();
            sb.append("JavaMax:    ");
            sb.append(Runtime.getRuntime().maxMemory() / ConstantsAPI.AppSupportContentFlag.MMAPP_SUPPORT_XLS);
            sb.append(" kB\n");
            sb.append("JavaTotal:  ");
            sb.append(Runtime.getRuntime().totalMemory() / ConstantsAPI.AppSupportContentFlag.MMAPP_SUPPORT_XLS);
            sb.append(" kB\n");
            sb.append("JavaFree:   ");
            sb.append(Runtime.getRuntime().freeMemory() / ConstantsAPI.AppSupportContentFlag.MMAPP_SUPPORT_XLS);
            sb.append(" kB\n");
            sb.append("NativeHeap: ");
            sb.append(Debug.getNativeHeapSize() / ConstantsAPI.AppSupportContentFlag.MMAPP_SUPPORT_XLS);
            sb.append(" kB\n");
            sb.append("NativeAllocated: ");
            sb.append(Debug.getNativeHeapAllocatedSize() / ConstantsAPI.AppSupportContentFlag.MMAPP_SUPPORT_XLS);
            sb.append(" kB\n");
            sb.append("NativeFree: ");
            sb.append(Debug.getNativeHeapFreeSize() / ConstantsAPI.AppSupportContentFlag.MMAPP_SUPPORT_XLS);
            sb.append(" kB\n");
            ActivityManager activityManager = (ActivityManager) com.uc.crashsdk.a.g.a().getSystemService("activity");
            if (activityManager != null) {
                ActivityManager.MemoryInfo memoryInfo = new ActivityManager.MemoryInfo();
                activityManager.getMemoryInfo(memoryInfo);
                sb.append("availMem:   ");
                sb.append(memoryInfo.availMem / ConstantsAPI.AppSupportContentFlag.MMAPP_SUPPORT_XLS);
                sb.append(" kB\n");
                sb.append("threshold:  ");
                sb.append(memoryInfo.threshold / ConstantsAPI.AppSupportContentFlag.MMAPP_SUPPORT_XLS);
                sb.append(" kB\n");
                sb.append("lowMemory:  ");
                sb.append(memoryInfo.lowMemory);
                sb.append("\n");
            }
            return sb.toString();
        } catch (Throwable th) {
            com.uc.crashsdk.a.g.a(th);
            return "";
        }
    }

    private static void d(OutputStream outputStream) {
        if (com.uc.crashsdk.b.f11609d) {
            String o9 = com.uc.crashsdk.b.o();
            f11647h = false;
            if (1 == JNIBridge.cmd(17, o9)) {
                File file = new File(o9);
                try {
                    byte[] e9 = com.uc.crashsdk.a.g.e(file);
                    if (e9 != null) {
                        outputStream.write(e9);
                    }
                } catch (Throwable th) {
                    a(th, outputStream);
                }
                try {
                    file.delete();
                } catch (Throwable th2) {
                    a(th2, outputStream);
                }
                f11647h = true;
                a(outputStream);
            }
            f11647h = true;
            return;
        }
        File[] fileArr = null;
        int i9 = 900;
        try {
            i9 = g.H();
            fileArr = new File("/proc/self/fd").listFiles();
            if (fileArr != null) {
                outputStream.write(String.format(Locale.US, "opened file count: %d, write limit: %d.\n", Integer.valueOf(fileArr.length), Integer.valueOf(i9)).getBytes("UTF-8"));
            } else {
                outputStream.write("[DEBUG] listFiles failed!\n".getBytes("UTF-8"));
            }
        } catch (Throwable th3) {
            a(th3, outputStream);
        }
        if (fileArr != null) {
            try {
                if (fileArr.length >= i9) {
                    outputStream.write("opened files:\n".getBytes("UTF-8"));
                    StringBuilder sb = new StringBuilder();
                    for (File file2 : fileArr) {
                        sb.append(file2.getName());
                        sb.append(" -> ");
                        sb.append(file2.getCanonicalPath());
                        sb.append("\n");
                    }
                    outputStream.write(sb.toString().getBytes("UTF-8"));
                }
            } catch (Throwable th4) {
                a(th4, outputStream);
            }
        }
        a(outputStream);
    }

    private static void f(OutputStream outputStream) {
        BufferedReader bufferedReader;
        int indexOf;
        boolean z9;
        if (com.uc.crashsdk.b.f11609d) {
            try {
                outputStream.write("solib build id:\n".getBytes("UTF-8"));
            } catch (Throwable th) {
                a(th, outputStream);
            }
            FileReader fileReader = null;
            try {
                ArrayList arrayList = new ArrayList();
                FileReader fileReader2 = new FileReader(new File("/proc/self/maps"));
                try {
                    bufferedReader = new BufferedReader(fileReader2, 512);
                    while (true) {
                        try {
                            String readLine = bufferedReader.readLine();
                            if (readLine == null) {
                                break;
                            } else if (readLine.endsWith(".so") && (indexOf = readLine.indexOf(47)) != -1) {
                                String substring = readLine.substring(indexOf);
                                if (!substring.contains("/data/") && !substring.contains(com.uc.crashsdk.a.f11526a)) {
                                    z9 = false;
                                    if (z9 && !arrayList.contains(substring)) {
                                        arrayList.add(substring);
                                        if (!ag) {
                                            outputStream.write((String.format("$^%s`%s^$", "SOBUILDID", substring) + "\n").getBytes("UTF-8"));
                                        } else {
                                            outputStream.write(String.format(Locale.US, "%s: %s\n", substring, JNIBridge.nativeGet(3, 0L, substring)).getBytes("UTF-8"));
                                        }
                                    }
                                }
                                z9 = true;
                                if (z9) {
                                    arrayList.add(substring);
                                    if (!ag) {
                                    }
                                }
                            }
                        } catch (Throwable th2) {
                            th = th2;
                            fileReader = fileReader2;
                            try {
                                a(th, outputStream);
                                com.uc.crashsdk.a.g.a(fileReader);
                                com.uc.crashsdk.a.g.a(bufferedReader);
                                a(outputStream);
                            } catch (Throwable th3) {
                                com.uc.crashsdk.a.g.a(fileReader);
                                com.uc.crashsdk.a.g.a(bufferedReader);
                                throw th3;
                            }
                        }
                    }
                    com.uc.crashsdk.a.g.a(fileReader2);
                } catch (Throwable th4) {
                    th = th4;
                    bufferedReader = null;
                }
            } catch (Throwable th5) {
                th = th5;
                bufferedReader = null;
            }
            com.uc.crashsdk.a.g.a(bufferedReader);
            a(outputStream);
        }
    }

    public static String k() {
        String str = f11663x;
        if (com.uc.crashsdk.a.g.a(str)) {
            synchronized (f11664y) {
                str = com.uc.crashsdk.a.g.a(com.uc.crashsdk.b.i(), g.P() ? "https://errlogos.umeng.com/upload" : "https://errlog.umeng.com/upload", true);
                f11663x = str;
            }
        }
        return str;
    }

    public static void l() {
        synchronized (f11664y) {
            f11663x = null;
        }
    }

    public static void a(int i9, Object[] objArr) {
        int i10;
        switch (i9) {
            case 401:
                JNIBridge.nativeCmd(10, com.uc.crashsdk.b.I() == 5 ? 1L : 0L, null, null);
                com.uc.crashsdk.a.f11528c = true;
                com.uc.crashsdk.a.a(false);
                L = true;
                Z();
                y();
                return;
            case 402:
                Object obj = Y;
                synchronized (obj) {
                    if (X == null) {
                        return;
                    }
                    W = true;
                    if (com.uc.crashsdk.b.q()) {
                        return;
                    }
                    if (!com.uc.crashsdk.a.d.e()) {
                        com.uc.crashsdk.a.a.c("DEBUG", com.uc.crashsdk.a.d.b());
                        return;
                    } else if (!d(LogType.UNEXP_TYPE)) {
                        com.uc.crashsdk.a.a.d("DEBUG", "unexp sample miss");
                        return;
                    } else {
                        int nativeGenerateUnexpLog = JNIBridge.nativeGenerateUnexpLog(g.o(), g.p());
                        if (nativeGenerateUnexpLog != 0) {
                            f.a(11);
                            if ((nativeGenerateUnexpLog & LogType.UNEXP_KILL_PROCESS) != 0) {
                                Z = 105;
                                i10 = 30;
                            } else if ((nativeGenerateUnexpLog & LogType.UNEXP_EXIT) != 0) {
                                Z = 104;
                                i10 = 31;
                            } else if ((nativeGenerateUnexpLog & LogType.UNEXP_RESTART) != 0) {
                                Z = 106;
                                i10 = 32;
                            } else {
                                if ((nativeGenerateUnexpLog & LogType.UNEXP_ANR) != 0) {
                                    Z = 103;
                                    f.a(10);
                                } else if ((nativeGenerateUnexpLog & LogType.UNEXP_LOW_MEMORY) != 0) {
                                    Z = 107;
                                    f.a(29);
                                } else {
                                    Z = 102;
                                }
                                a(true);
                            }
                            f.a(i10);
                            a(true);
                        }
                        synchronized (obj) {
                            X = null;
                        }
                        return;
                    }
                }
            case 403:
                ab();
                return;
            case 404:
            default:
                if (!f11641a) {
                    throw new AssertionError();
                }
                return;
            case 405:
                L = false;
                StringBuilder Y2 = Y();
                String g9 = com.uc.crashsdk.b.g();
                if (Y2 != null) {
                    com.uc.crashsdk.a.g.a(new File(g9), Y2.toString());
                    return;
                }
                return;
            case 406:
                if (!f11641a && objArr == null) {
                    throw new AssertionError();
                }
                a((String) objArr[0], ((Boolean) objArr[1]).booleanValue(), ((Boolean) objArr[2]).booleanValue());
                return;
            case 407:
                try {
                    com.uc.crashsdk.a.d();
                    return;
                } catch (Throwable th) {
                    com.uc.crashsdk.a.g.a(th);
                    return;
                }
            case 408:
                synchronized (ab) {
                    if (!ac && g.O() && com.uc.crashsdk.b.z()) {
                        com.uc.crashsdk.b.s();
                        h.f();
                        f.c();
                        if (com.uc.crashsdk.b.F()) {
                            C();
                        }
                        if (g.O()) {
                            a(Calendar.getInstance());
                        }
                        ac = true;
                        return;
                    }
                    return;
                }
            case 409:
                d(false);
                return;
            case 410:
                a(false, true);
                return;
            case 411:
                if (com.uc.crashsdk.b.f11609d) {
                    JNIBridge.set(28, d(LogType.NATIVE_TYPE));
                    JNIBridge.set(29, d(LogType.ANR_TYPE));
                    return;
                }
                return;
            case 412:
                if (!R && com.uc.crashsdk.b.B() && g.K()) {
                    b(com.uc.crashsdk.a.g.a());
                    return;
                } else if (R) {
                    if (com.uc.crashsdk.b.B() && g.K()) {
                        return;
                    }
                    try {
                        com.uc.crashsdk.a.g.a().unregisterReceiver(Q);
                        R = false;
                        return;
                    } catch (Throwable th2) {
                        com.uc.crashsdk.a.g.a(th2);
                        return;
                    }
                } else {
                    return;
                }
            case 413:
                JNIBridge.cmd(8);
                return;
            case 414:
                try {
                    if (d(com.uc.crashsdk.a.g.a())) {
                        return;
                    }
                    int i11 = N + 1;
                    N = i11;
                    if (i11 < 10) {
                        X();
                        return;
                    } else if (com.uc.crashsdk.b.f11609d) {
                        JNIBridge.set(130, "(get failed)");
                        return;
                    } else {
                        return;
                    }
                } catch (Throwable th3) {
                    com.uc.crashsdk.a.g.a(th3);
                    return;
                }
            case 415:
                if (!f11641a && objArr == null) {
                    throw new AssertionError();
                }
                long longValue = ((Long) objArr[0]).longValue();
                Calendar calendar = Calendar.getInstance();
                if (calendar.getTimeInMillis() >= longValue) {
                    h.g();
                    f.a(100);
                    d(true);
                    f.a(true);
                    h.b();
                } else {
                    h.h();
                    h.i();
                    h.c();
                }
                a(calendar);
                break;
            case 416:
                break;
        }
        W();
    }

    public static class a extends OutputStream {
        private final long f11667a;
        private final OutputStream f11668b;
        private int f11669c = 0;
        private int f11670d = 0;
        private boolean f11671e = false;

        a(long j9, OutputStream outputStream) {
            this.f11667a = j9;
            this.f11668b = outputStream;
        }

        private int a(byte[] bArr, int i9, int i10) {
            int i11;
            this.f11670d += i10;
            if (this.f11671e) {
                return 0;
            }
            int y9 = g.y();
            if (y9 > 0) {
                int i12 = this.f11669c;
                if (i12 + i10 > y9) {
                    i11 = y9 - i12;
                    this.f11669c += i11;
                    if (this.f11667a == 0) {
                        b(new String(bArr, i9, i11));
                    } else {
                        this.f11668b.write(bArr, i9, i11);
                    }
                    if (i11 < i10) {
                        this.f11671e = true;
                    }
                    return i11;
                }
            }
            i11 = i10;
            this.f11669c += i11;
            if (this.f11667a == 0) {
            }
            if (i11 < i10) {
            }
            return i11;
        }

        private void b(String str) {
            if (com.uc.crashsdk.b.f11609d) {
                JNIBridge.nativeClientWriteData(this.f11667a, str);
            }
        }

        @Override
        public final void write(int i9) {
            if (e.f11647h && e.I()) {
                com.uc.crashsdk.a.a.d("DEBUG", String.format(Locale.US, "%c", Integer.valueOf(i9)));
            }
            if (this.f11667a != 0) {
                b(String.format(Locale.US, "%c", Integer.valueOf(i9)));
            } else {
                this.f11668b.write(i9);
            }
            this.f11669c++;
            this.f11670d++;
        }

        @Override
        public final void write(byte[] bArr, int i9, int i10) {
            if (e.f11647h && e.I()) {
                byte[] bArr2 = new byte[i10];
                System.arraycopy(bArr, i9, bArr2, 0, i10);
                if (i10 != 1 || bArr2[0] != 10) {
                    try {
                        com.uc.crashsdk.a.a.d("DEBUG", new String(bArr2));
                    } catch (Throwable unused) {
                    }
                }
            }
            a(bArr, i9, i10);
        }

        final void a() {
            try {
                if (this.f11670d - this.f11669c > 0) {
                    a("\n");
                    a("--- --- --- --- --- --- --- --- --- --- --- --- --- --- --- ---\n");
                }
                a(String.format(Locale.US, "Full: %d bytes, write: %d bytes, limit: %d bytes, reject: %d bytes.\n", Integer.valueOf(this.f11670d), Integer.valueOf(this.f11669c), Integer.valueOf(g.y()), Integer.valueOf(this.f11670d - this.f11669c)));
            } catch (Throwable th) {
                com.uc.crashsdk.a.g.a(th);
            }
        }

        @Override
        public final void write(byte[] bArr) {
            if (e.f11647h && e.I() && (bArr.length != 1 || bArr[0] != 10)) {
                try {
                    com.uc.crashsdk.a.a.d("DEBUG", new String(bArr));
                } catch (Throwable unused) {
                }
            }
            a(bArr, 0, bArr.length);
        }

        final void a(String str) {
            if (e.f11647h && e.I()) {
                com.uc.crashsdk.a.a.d("DEBUG", str);
            }
            if (this.f11667a != 0) {
                b(str);
            } else {
                this.f11668b.write(str.getBytes("UTF-8"));
            }
        }
    }

    public static String h() {
        String str = f11652m;
        if (str != null) {
            return str;
        }
        String a10 = a(Process.myPid());
        f11652m = a10;
        return a10;
    }

    public static class d {
        long f11672a;
        long f11673b;
        int f11674c;
        int f11675d;
        boolean f11676e;
        boolean f11677f;
        boolean f11678g;

        private d() {
            this.f11672a = 0L;
            this.f11673b = 0L;
            this.f11674c = 0;
            this.f11675d = 0;
            this.f11676e = false;
            this.f11677f = false;
            this.f11678g = false;
        }

        d(byte b10) {
            this();
        }
    }

    public static void j() {
        try {
            StrictMode.setThreadPolicy(new StrictMode.ThreadPolicy.Builder(StrictMode.getThreadPolicy()).permitNetwork().build());
        } catch (Throwable th) {
            com.uc.crashsdk.a.g.a(th);
        }
    }

    public static void m() {
        if (ag) {
            return;
        }
        com.uc.crashsdk.a.f.a(1, new com.uc.crashsdk.a.e(411), 1000L);
    }

    public static void p() {
        String str;
        Throwable th;
        if (com.uc.crashsdk.a.g.a(B)) {
            String str2 = null;
            try {
                File file = new File(g.U() + "unique");
                if (file.exists()) {
                    str = com.uc.crashsdk.a.g.a(file, 48, false);
                    try {
                        if (str != null) {
                            try {
                                if (str.length() == 36) {
                                    str2 = str.replaceAll("[^0-9a-zA-Z-]", "-");
                                }
                            } catch (Exception e9) {
                                com.uc.crashsdk.a.g.a(e9);
                            }
                        }
                        str2 = str;
                    } catch (Throwable th2) {
                        th = th2;
                        com.uc.crashsdk.a.g.a(th);
                        str2 = str;
                        B = str2;
                    }
                }
                if (com.uc.crashsdk.a.g.a(str2)) {
                    com.uc.crashsdk.b.G();
                    str2 = UUID.randomUUID().toString();
                    if (!com.uc.crashsdk.a.g.a(str2)) {
                        com.uc.crashsdk.a.g.a(file, str2.getBytes());
                    }
                }
            } catch (Throwable th3) {
                str = str2;
                th = th3;
            }
            B = str2;
        }
    }

    public static String q() {
        return B;
    }

    public static void r() {
        O = false;
        if (!com.uc.crashsdk.b.B()) {
            com.uc.crashsdk.a.f.a(3, new com.uc.crashsdk.a.e(416), 11000L);
        }
        if (V()) {
            return;
        }
        N = 0;
        X();
    }

    private static void b(OutputStream outputStream, String str, String str2) {
        String str3;
        String str4;
        try {
            outputStream.write("*** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***\n".getBytes("UTF-8"));
        } catch (Throwable th) {
            a(th, outputStream);
        }
        try {
            Locale locale = Locale.US;
            outputStream.write(String.format(locale, "Basic Information: 'pid: %d/tid: %d/time: %s'\n", Integer.valueOf(Process.myPid()), Integer.valueOf(Process.myTid()), n()).getBytes("UTF-8"));
            Object[] objArr = new Object[3];
            objArr[0] = e();
            if (com.uc.crashsdk.a.g.a(f11651l)) {
                T();
            }
            objArr[1] = f11651l;
            objArr[2] = f();
            outputStream.write(String.format(locale, "Cpu Information: 'abi: %s/processor: %s/hardware: %s'\n", objArr).getBytes("UTF-8"));
        } catch (Throwable th2) {
            a(th2, outputStream);
        }
        try {
            Locale locale2 = Locale.US;
            outputStream.write(String.format(locale2, "Mobile Information: 'model: %s/version: %s/sdk: %d'\n", Build.MODEL, Build.VERSION.RELEASE, Integer.valueOf(Build.VERSION.SDK_INT)).getBytes("UTF-8"));
            outputStream.write(("Build fingerprint: '" + Build.FINGERPRINT + "'\n").getBytes("UTF-8"));
            Object[] objArr2 = new Object[4];
            objArr2[0] = a(new Date(f11642b));
            objArr2[1] = Long.valueOf(Runtime.getRuntime().maxMemory());
            objArr2[2] = com.uc.crashsdk.a.g.d();
            objArr2[3] = com.uc.crashsdk.b.B() ? "fg" : "bg";
            outputStream.write(String.format(locale2, "Runtime Information: 'start: %s/maxheap: %s/primaryabi: %s/ground: %s'\n", objArr2).getBytes("UTF-8"));
        } catch (Throwable th3) {
            a(th3, outputStream);
        }
        try {
            Locale locale3 = Locale.US;
            outputStream.write(String.format(locale3, "Application Information: 'version: %s/subversion: %s/buildseq: %s/versioncode: %d'\n", g.R(), g.S(), g.T(), Integer.valueOf(com.uc.crashsdk.a.c())).getBytes("UTF-8"));
            String str5 = "0";
            String str6 = "";
            if (com.uc.crashsdk.b.f11609d) {
                String nativeGet = JNIBridge.nativeGet(1, 0L, null);
                str4 = JNIBridge.nativeGet(2, 0L, null);
                str5 = nativeGet;
            } else {
                str4 = "";
            }
            outputStream.write(String.format(locale3, "CrashSDK Information: 'version: %s/nativeseq: %s/javaseq: %s/arch: %s/target: %s'\n", "3.3.1.1", str5, "210916105822", str4, "release").getBytes("UTF-8"));
            if (str != null) {
                str6 = str;
            }
            outputStream.write(("Report Name: " + str6.substring(str6.lastIndexOf(47) + 1) + "\n").getBytes("UTF-8"));
        } catch (Throwable th4) {
            a(th4, outputStream);
        }
        try {
            if (ag) {
                str3 = s("UUID");
            } else {
                str3 = B;
            }
            outputStream.write(String.format("UUID: %s\n", str3).getBytes("UTF-8"));
            outputStream.write(("Log Type: " + str2 + "\n").getBytes("UTF-8"));
        } catch (Throwable th5) {
            a(th5, outputStream);
        }
        try {
            String E2 = com.uc.crashsdk.b.E();
            if (com.uc.crashsdk.a.g.a(E2)) {
                E2 = "(none)";
            }
            outputStream.write(("Activity: " + E2 + "\n").getBytes("UTF-8"));
        } catch (Throwable th6) {
            a(th6, outputStream);
        }
        a(outputStream);
        try {
            com.uc.crashsdk.a.a(outputStream, "UTF-8");
            if (ag) {
                f11647h = false;
                outputStream.write(s("HEADER").getBytes("UTF-8"));
                f11647h = true;
            }
        } catch (Throwable th7) {
            a(th7, outputStream);
        }
        a(outputStream);
    }

    public static String n() {
        return a(new Date());
    }

    private static void g(OutputStream outputStream) {
        String m9;
        try {
            outputStream.write("recent status:\n".getBytes("UTF-8"));
        } catch (Throwable th) {
            a(th, outputStream);
        }
        try {
            if (ag) {
                m9 = s("LASTVER");
            } else {
                m9 = com.uc.crashsdk.a.m();
            }
            outputStream.write(String.format(Locale.US, "last version: '%s'\n", m9).getBytes("UTF-8"));
        } catch (Throwable th2) {
            a(th2, outputStream);
        }
        try {
            ArrayList<String> arrayList = f11658s;
            synchronized (arrayList) {
                if (f11660u != null) {
                    outputStream.write(String.format(Locale.US, "generating log: %s\n", f11660u).getBytes("UTF-8"));
                }
                if (f11659t > 0 || arrayList.size() > 0) {
                    outputStream.write(String.format(Locale.US, "generated %d logs, recent are:\n", Integer.valueOf(f11659t)).getBytes("UTF-8"));
                    Iterator<String> it2 = arrayList.iterator();
                    while (it2.hasNext()) {
                        outputStream.write(String.format(Locale.US, "* %s\n", it2.next()).getBytes("UTF-8"));
                    }
                }
            }
            Locale locale = Locale.US;
            outputStream.write(String.format(locale, "dumping all threads: %s\n", Boolean.valueOf(f11661v)).getBytes("UTF-8"));
            String str = f11662w;
            if (str != null) {
                outputStream.write(String.format(locale, "dumping threads: %s\n", str).getBytes("UTF-8"));
            }
        } catch (Throwable th3) {
            a(th3, outputStream);
        }
        a(outputStream);
    }

    public static void c(String str) {
        synchronized (f11665z) {
            String l9 = com.uc.crashsdk.b.l();
            com.uc.crashsdk.a.b.a(l9, str + "\n");
        }
    }

    public static void c(boolean z9) {
        boolean z10 = true;
        if (!R ? !z9 || !g.K() : z9 && g.K()) {
            z10 = false;
        }
        if (z10) {
            com.uc.crashsdk.a.e eVar = S;
            if (com.uc.crashsdk.a.f.b(eVar)) {
                com.uc.crashsdk.a.f.a(eVar);
            }
            com.uc.crashsdk.a.f.a(0, eVar, 3000L);
        }
    }

    public static void a(boolean z9) {
        File[] listFiles;
        try {
            if (com.uc.crashsdk.b.y() && (listFiles = new File(g.V()).listFiles()) != null) {
                int l9 = g.l();
                int m9 = g.m();
                if (listFiles.length < Math.min(l9, m9)) {
                    return;
                }
                int i9 = 0;
                int i10 = 0;
                for (File file : listFiles) {
                    if (b(file)) {
                        i9++;
                    } else {
                        i10++;
                    }
                }
                int i11 = (!z9 || i9 < l9) ? 0 : (i9 - l9) + 1;
                int i12 = (z9 || i10 < m9) ? 0 : (i10 - m9) + 1;
                if (i11 == 0 && i12 == 0) {
                    return;
                }
                Arrays.sort(listFiles, new b((byte) 0));
                int i13 = i11;
                int i14 = i12;
                for (File file2 : listFiles) {
                    boolean b10 = b(file2);
                    if (b10 && i13 > 0) {
                        com.uc.crashsdk.a.a.a("crashsdk", "Delete oldest crash log: " + file2.getPath());
                        file2.delete();
                        i13 += -1;
                    } else if (!b10 && i14 > 0) {
                        com.uc.crashsdk.a.a.a("crashsdk", "Delete oldest custom log: " + file2.getPath());
                        file2.delete();
                        i14 += -1;
                    }
                    if (i13 == 0 && i14 == 0) {
                        break;
                    }
                }
                f.a(16, i11 + i12);
                if (i11 > 0) {
                    f.a(22, i11);
                }
                if (i12 > 0) {
                    f.a(23, i12);
                }
            }
        } catch (Throwable th) {
            com.uc.crashsdk.a.g.a(th);
        }
    }

    public static int f(boolean z9) {
        int b10;
        if (z9) {
            b10 = f.a(com.uc.crashsdk.b.c()) ? 1 : 0;
        } else {
            b10 = f.b();
        }
        int b11 = f.b(z9);
        return b11 > b10 ? b11 : b10;
    }

    public static void o() {
        f11642b = System.currentTimeMillis();
    }

    public static StringBuilder f(String str) {
        return a(Thread.currentThread().getStackTrace(), str);
    }

    private static void e(OutputStream outputStream) {
        int i9;
        int i10;
        File[] fileArr = null;
        try {
            i9 = g.I();
            try {
                fileArr = new File("/proc/self/task").listFiles();
            } catch (Throwable th) {
                th = th;
                com.uc.crashsdk.a.g.a(th);
                i10 = 0;
                if (fileArr != null) {
                }
            }
        } catch (Throwable th2) {
            th = th2;
            i9 = 300;
        }
        if (fileArr == null) {
            return;
        }
        i10 = fileArr.length;
        if (i10 < i9) {
            return;
        }
        if (fileArr != null) {
            return;
        }
        try {
            outputStream.write("threads info:\n".getBytes("UTF-8"));
            outputStream.write(String.format(Locale.US, "threads count: %d, dump limit: %d.\n", Integer.valueOf(i10), Integer.valueOf(i9)).getBytes("UTF-8"));
            outputStream.write(" tid     name\n".getBytes("UTF-8"));
            for (File file : fileArr) {
                outputStream.write(String.format(Locale.US, "%5s %s\n", file.getName(), l(com.uc.crashsdk.a.g.a(new File(file.getPath(), "comm"), 128, false))).getBytes("UTF-8"));
            }
        } catch (Throwable th3) {
            a(th3, outputStream);
        }
        a(outputStream);
    }

    public static boolean d(String str) {
        if (ag) {
            return true;
        }
        try {
            return p(str);
        } catch (Throwable th) {
            com.uc.crashsdk.a.g.a(th);
            return true;
        }
    }

    public static boolean d(Context context) {
        List<ActivityManager.ProcessErrorStateInfo> processesInErrorState;
        ActivityManager activityManager = (ActivityManager) context.getSystemService("activity");
        boolean z9 = false;
        if (activityManager == null || (processesInErrorState = activityManager.getProcessesInErrorState()) == null) {
            return false;
        }
        int myPid = Process.myPid();
        Iterator<ActivityManager.ProcessErrorStateInfo> it2 = processesInErrorState.iterator();
        while (true) {
            if (!it2.hasNext()) {
                break;
            }
            ActivityManager.ProcessErrorStateInfo next = it2.next();
            if (next.pid == myPid) {
                O = true;
                if (O()) {
                    com.uc.crashsdk.a.a.d("crashsdk", "ANR occurred in process: " + next.processName);
                }
                if (com.uc.crashsdk.b.f11609d) {
                    JNIBridge.set(130, next.longMsg);
                }
                z9 = true;
            }
        }
        if (!z9 && com.uc.crashsdk.b.f11609d) {
            W();
        }
        return true;
    }

    public static String a(String str, String str2) {
        String[] strArr;
        try {
            if (Build.VERSION.SDK_INT >= 26) {
                strArr = new String[]{"ps", "-ef"};
            } else {
                strArr = new String[]{"ps"};
            }
            BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(Runtime.getRuntime().exec(strArr).getInputStream()));
            boolean b10 = com.uc.crashsdk.a.g.b(str);
            boolean b11 = com.uc.crashsdk.a.g.b(str2);
            ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
            while (true) {
                String readLine = bufferedReader.readLine();
                if (readLine != null) {
                    boolean z9 = true;
                    if ((!b10 || !readLine.contains(str)) && ((!b11 || !readLine.contains(str2)) && (readLine.indexOf(47) >= 0 || readLine.indexOf(46) <= 0))) {
                        z9 = false;
                    }
                } else {
                    return byteArrayOutputStream.toString("UTF-8");
                }
            }
        } catch (Throwable th) {
            com.uc.crashsdk.a.g.a(th);
            return "exception exists.";
        }
    }

    public static void d(boolean z9) {
        f.d(false);
        if (z9) {
            f.a(com.uc.crashsdk.b.c(), false);
            h.i();
            return;
        }
        f.a();
        h.i();
    }

    public static boolean e(String str) {
        try {
            if (com.uc.crashsdk.a.g.b(str) && str.startsWith("lib") && str.endsWith(".so")) {
                System.loadLibrary(str.substring(3, str.length() - 3));
                return true;
            }
            return false;
        } catch (Throwable th) {
            com.uc.crashsdk.a.g.a(th);
            return false;
        }
    }

    public static int e(boolean z9) {
        return f.a(z9);
    }

    private static BufferedReader a(InputStreamReader inputStreamReader) {
        BufferedReader bufferedReader = null;
        int i9 = 8192;
        while (bufferedReader == null && i9 > 0) {
            try {
                bufferedReader = new BufferedReader(inputStreamReader, i9);
            } catch (Throwable unused) {
                i9 /= 2;
                if (i9 < 512) {
                    break;
                }
            }
        }
        return bufferedReader;
    }

    private static void a(OutputStream outputStream) {
        try {
            outputStream.write("--- --- --- --- --- --- --- --- --- --- --- --- --- --- --- ---\n".getBytes("UTF-8"));
        } catch (Throwable th) {
            a(th, outputStream);
        }
    }

    private static String a(File file) {
        String str;
        try {
            str = file.getCanonicalPath();
        } catch (Throwable unused) {
            str = null;
        }
        return com.uc.crashsdk.a.g.a(str) ? file.getPath() : str;
    }

    private static void a(OutputStream outputStream, String str, Set<String> set) {
        if (com.uc.crashsdk.a.g.a(str) || set.contains(str) || str.equals("/storage/emulated")) {
            return;
        }
        set.add(str);
        try {
            StatFs statFs = new StatFs(str);
            long a10 = a(statFs, "getBlockCountLong", "getBlockCount");
            long a11 = a(statFs, "getBlockSizeLong", "getBlockSize");
            if ((a10 / ConstantsAPI.AppSupportContentFlag.MMAPP_SUPPORT_XLS) * a11 < 10240) {
                return;
            }
            long a12 = a(statFs, "getAvailableBlocksLong", "getAvailableBlocks");
            long a13 = a(statFs, "getFreeBlocksLong", "getFreeBlocks");
            try {
                Locale locale = Locale.US;
                outputStream.write(String.format(locale, "%s:\n", str).getBytes("UTF-8"));
                double d10 = a11;
                outputStream.write(String.format(locale, "  total:      %d kB\n", Long.valueOf((long) (((a10 * 1.0d) * d10) / 1024.0d))).getBytes("UTF-8"));
                outputStream.write(String.format(locale, "  available:  %d kB\n", Long.valueOf((long) (((a12 * 1.0d) * d10) / 1024.0d))).getBytes("UTF-8"));
                outputStream.write(String.format(locale, "  free:       %d kB\n", Long.valueOf((long) (((a13 * 1.0d) * d10) / 1024.0d))).getBytes("UTF-8"));
                outputStream.write(String.format(locale, "  block size: %d B\n\n", Long.valueOf(a11)).getBytes("UTF-8"));
            } catch (Throwable th) {
                a(th, outputStream);
            }
        } catch (Throwable unused) {
        }
    }

    private static void b(OutputStream outputStream) {
        BufferedReader bufferedReader = null;
        try {
            outputStream.write("logcat:\n".getBytes("UTF-8"));
        } finally {
            try {
                com.uc.crashsdk.a.g.a(bufferedReader);
                a(outputStream);
            } finally {
            }
        }
        if (g.n() <= 0) {
            outputStream.write("[DEBUG] custom java logcat lines count is 0!\n".getBytes("UTF-8"));
            a(outputStream);
            return;
        }
        int n9 = g.n();
        bufferedReader = a(new InputStreamReader(Runtime.getRuntime().exec(new String[]{"logcat", "-d", "-b", "events", "-b", "main", "-v", "threadtime", "-t", String.valueOf(n9)}).getInputStream()));
        if (bufferedReader == null) {
            outputStream.write("[DEBUG] alloc buffer failed!\n".getBytes("UTF-8"));
            a(outputStream);
            return;
        }
        f11647h = false;
        int i9 = 0;
        int i10 = 0;
        while (true) {
            String readLine = bufferedReader.readLine();
            if (readLine == null) {
                break;
            }
            i9++;
            if (i10 < n9 && !readLine.contains(" I auditd ") && !readLine.contains(" I liblog ")) {
                outputStream.write(readLine.getBytes("UTF-8"));
                outputStream.write("\n".getBytes("UTF-8"));
                i10++;
            }
        }
        outputStream.write(String.format(Locale.US, "[DEBUG] Read %d lines, wrote %d lines.\n", Integer.valueOf(i9), Integer.valueOf(i10)).getBytes("UTF-8"));
        f11647h = true;
        com.uc.crashsdk.a.g.a(bufferedReader);
        a(outputStream);
    }

    private static long a(StatFs statFs, String str, String str2) {
        try {
            if (Build.VERSION.SDK_INT >= 18) {
                Method declaredMethod = StatFs.class.getDeclaredMethod(str, new Class[0]);
                declaredMethod.setAccessible(true);
                Object invoke = declaredMethod.invoke(statFs, new Object[0]);
                if (invoke != null && (invoke instanceof Long)) {
                    return ((Long) invoke).longValue();
                }
            }
        } catch (Throwable unused) {
        }
        try {
            Method declaredMethod2 = StatFs.class.getDeclaredMethod(str2, new Class[0]);
            declaredMethod2.setAccessible(true);
            Object invoke2 = declaredMethod2.invoke(statFs, new Object[0]);
            if (invoke2 == null || !(invoke2 instanceof Integer)) {
                return 0L;
            }
            return ((Integer) invoke2).intValue();
        } catch (Throwable th) {
            com.uc.crashsdk.a.g.a(th);
            return 0L;
        }
    }

    private static void b(a aVar) {
        f11647h = false;
        try {
            aVar.write((s("LOG_END") + "\n").getBytes("UTF-8"));
        } catch (Throwable th) {
            com.uc.crashsdk.a.g.a(th);
        }
        f11647h = true;
    }

    private static void a(a aVar) {
        try {
            aVar.a(String.format(Locale.US, "log end: %s\n", n()));
        } catch (Throwable th) {
            a(th, aVar);
        }
    }

    public static int b(OutputStream outputStream, String str, int i9) {
        int i10;
        DataInputStream dataInputStream;
        int i11;
        DataInputStream dataInputStream2 = null;
        int i12 = 0;
        try {
            File file = new File(str);
            if (file.exists()) {
                byte[] R2 = R();
                if (R2 == null) {
                    outputStream.write("(alloc buffer failed!)\n".getBytes("UTF-8"));
                    return 0;
                }
                dataInputStream = new DataInputStream(new FileInputStream(file));
                i11 = 0;
                i10 = 0;
                boolean z9 = false;
                while (true) {
                    try {
                        int read = dataInputStream.read(R2);
                        if (read == -1) {
                            break;
                        }
                        i11 += read;
                        int i13 = i9 - i10;
                        if (read <= i13 + 32) {
                            i13 = read;
                        }
                        if (i13 > 0 && !z9) {
                            outputStream.write(R2, 0, i13);
                            i10 += i13;
                        }
                        if (!z9) {
                            z9 = i13 < read || i10 >= i9;
                        }
                    } catch (Throwable th) {
                        th = th;
                        i12 = i10;
                        dataInputStream2 = dataInputStream;
                        try {
                            a(th, outputStream);
                            com.uc.crashsdk.a.g.a(dataInputStream2);
                            i10 = i12;
                            a(outputStream);
                            return i10;
                        } finally {
                            com.uc.crashsdk.a.g.a(dataInputStream2);
                        }
                    }
                }
            } else {
                outputStream.write(("file: '" + str + "' not exists!\n").getBytes("UTF-8"));
                dataInputStream = null;
                i11 = 0;
                i10 = 0;
            }
            if (i10 > 0) {
                outputStream.write("\n".getBytes("UTF-8"));
            }
            if (i10 < i11) {
                outputStream.write(String.format(Locale.US, "(truncated %d bytes)\n", Integer.valueOf(i11 - i10)).getBytes("UTF-8"));
            }
        } catch (Throwable th2) {
            th = th2;
        }
        a(outputStream);
        return i10;
    }

    public static int a(OutputStream outputStream, String str, int i9) {
        int i10 = 0;
        if (str == null) {
            a(outputStream);
            return 0;
        }
        try {
            String a10 = com.uc.crashsdk.a.b.a(str);
            if (a10 == null) {
                a10 = "file: '" + str + "' not found or decode failed!";
            }
            int length = a10.length();
            if (length <= i9 + 32) {
                i9 = length;
            }
            if (i9 > 0) {
                try {
                    outputStream.write(a10.getBytes("UTF-8"), 0, i9);
                    outputStream.write("\n".getBytes("UTF-8"));
                } catch (Throwable th) {
                    th = th;
                    i10 = i9;
                    a(th, outputStream);
                    i9 = i10;
                    a(outputStream);
                    return i9;
                }
            }
            if (i9 < a10.length()) {
                outputStream.write(String.format(Locale.US, "(truncated %d bytes)\n", Integer.valueOf(a10.length() - i9)).getBytes("UTF-8"));
            }
        } catch (Throwable th2) {
            th = th2;
        }
        a(outputStream);
        return i9;
    }

    public static String a(int i9) {
        try {
            String a10 = com.uc.crashsdk.a.g.a(new File(String.format(Locale.US, "/proc/%d/cmdline", Integer.valueOf(i9))), 128, false);
            return com.uc.crashsdk.a.g.b(a10) ? l(a10) : NetworkUtil.NETWORK_CLASS_UNKNOWN;
        } catch (Throwable th) {
            com.uc.crashsdk.a.g.a(th);
            return NetworkUtil.NETWORK_CLASS_UNKNOWN;
        }
    }

    public static void b(boolean z9) {
        try {
            boolean z10 = g.r() && com.uc.crashsdk.b.F() && !f11644d;
            if (!z10) {
                z10 = g.s();
            }
            if (z10) {
                if (z9) {
                    String k9 = k();
                    if (com.uc.crashsdk.a.g.a(k9)) {
                        return;
                    }
                    j();
                    a(k9, false, false);
                    return;
                }
                a(true, false);
            }
        } catch (Throwable th) {
            com.uc.crashsdk.a.g.a(th);
        }
    }

    private static String a(Throwable th, String str, long j9, boolean z9) {
        FileOutputStream fileOutputStream;
        try {
            if (!com.uc.crashsdk.b.L()) {
                g.a();
                a(true);
            }
            int i9 = (j9 > 0L ? 1 : (j9 == 0L ? 0 : -1));
            fileOutputStream = i9 == 0 ? new FileOutputStream(str) : null;
            try {
                a aVar = new a(j9, fileOutputStream);
                try {
                    if (com.uc.crashsdk.b.f11609d) {
                        JNIBridge.set((int) Constants.ERR_WATERMARK_PNG, str);
                    }
                    b(aVar, str, S());
                    if (z9) {
                        aVar.flush();
                    }
                    aVar.write(("Process Name: '" + h() + "'\n").getBytes("UTF-8"));
                    aVar.write(("Thread Name: '" + Thread.currentThread().getName() + "'\n").getBytes("UTF-8"));
                    aVar.write("Back traces starts.\n".getBytes("UTF-8"));
                    Field declaredField = Throwable.class.getDeclaredField("detailMessage");
                    declaredField.setAccessible(true);
                    Object obj = declaredField.get(th);
                    if (obj != null) {
                        declaredField.set(th, ((String) obj).replaceAll("\n\t", "\n->  "));
                    }
                    String message = th.getMessage();
                    if (message != null && !message.equals(th.getLocalizedMessage())) {
                        aVar.write(("Message: " + message + "\n").getBytes("UTF-8"));
                    }
                    th.printStackTrace(new PrintStream(aVar));
                    aVar.write("Back traces ends.\n".getBytes("UTF-8"));
                    a((OutputStream) aVar);
                    aVar.flush();
                    com.uc.crashsdk.a.a(aVar, "UTF-8", "--- --- --- --- --- --- --- --- --- --- --- --- --- --- --- ---\n");
                    if (z9) {
                        aVar.flush();
                    }
                    aVar.write("meminfo:\n".getBytes("UTF-8"));
                    b(aVar, "/proc/meminfo", 10240);
                    String format = String.format(Locale.US, "/proc/%d/status", Integer.valueOf(Process.myPid()));
                    aVar.write("status:\n".getBytes("UTF-8"));
                    b(aVar, format, 10240);
                    aVar.write(("memory info:\n" + g()).getBytes("UTF-8"));
                    a((OutputStream) aVar);
                    g(aVar);
                    com.uc.crashsdk.a.a(aVar, "UTF-8", (ArrayList<String>) null);
                    if (ag) {
                        f11647h = false;
                        aVar.write(s("JAVADUMPFILES").getBytes("UTF-8"));
                        f11647h = true;
                    }
                    aVar.flush();
                    b((OutputStream) aVar);
                    aVar.flush();
                    aVar.write("battery info:\n".getBytes("UTF-8"));
                    if (ag) {
                        f11647h = false;
                        aVar.write(s("BATTERYINFO").getBytes("UTF-8"));
                        f11647h = true;
                    } else {
                        StringBuilder Y2 = Y();
                        if (Y2 != null) {
                            aVar.write(Y2.toString().getBytes("UTF-8"));
                        }
                    }
                    a((OutputStream) aVar);
                    c(aVar);
                    aVar.write("device status:\n".getBytes("UTF-8"));
                    if (ag) {
                        try {
                            f11647h = false;
                            aVar.write(s("DEVICESTATUS").getBytes("UTF-8"));
                            f11647h = true;
                        } catch (Throwable th2) {
                            th = th2;
                            a(th, aVar);
                            a((OutputStream) aVar);
                            d(aVar);
                            e(aVar);
                            com.uc.crashsdk.a.b(aVar, "UTF-8", "--- --- --- --- --- --- --- --- --- --- --- --- --- --- --- ---\n", null);
                            if (ag) {
                            }
                            aVar.flush();
                            com.uc.crashsdk.a.a(aVar, "UTF-8", "--- --- --- --- --- --- --- --- --- --- --- --- --- --- --- ---\n", null);
                            if (ag) {
                            }
                            aVar.a();
                            a(aVar);
                            aVar.flush();
                            if (i9 != 0) {
                            }
                            com.uc.crashsdk.a.g.a(aVar);
                            com.uc.crashsdk.a.g.a(fileOutputStream);
                            if (!ag) {
                            }
                            b(ag ? a(m(str)) : str, LogType.JAVA_TYPE);
                            return str;
                        }
                    } else {
                        try {
                            Locale locale = Locale.US;
                            aVar.write(String.format(locale, "has root: %s\n", Boolean.valueOf(com.uc.crashsdk.a.g.e())).getBytes("UTF-8"));
                            String str2 = Build.TAGS;
                            String str3 = str2 != null ? str2 : "";
                            StringBuilder sb = new StringBuilder();
                            sb.append("build tags: ");
                            sb.append(str3);
                            if (com.uc.crashsdk.a.g.f()) {
                                sb.append(" (default root)");
                            }
                            sb.append("\n");
                            aVar.write(sb.toString().getBytes("UTF-8"));
                            String h9 = com.uc.crashsdk.a.g.h();
                            if (com.uc.crashsdk.a.g.b(h9)) {
                                aVar.write(String.format(locale, "su binary: %s\n", h9).getBytes("UTF-8"));
                                StringBuilder sb2 = new StringBuilder();
                                sb2.append("su permission: ");
                                sb2.append(com.uc.crashsdk.a.g.g() ? "valid (" : "invalid (");
                                sb2.append(com.uc.crashsdk.a.g.i());
                                sb2.append(")\n");
                                aVar.write(sb2.toString().getBytes("UTF-8"));
                            }
                        } catch (Throwable th3) {
                            th = th3;
                            a(th, aVar);
                            a((OutputStream) aVar);
                            d(aVar);
                            e(aVar);
                            com.uc.crashsdk.a.b(aVar, "UTF-8", "--- --- --- --- --- --- --- --- --- --- --- --- --- --- --- ---\n", null);
                            if (ag) {
                            }
                            aVar.flush();
                            com.uc.crashsdk.a.a(aVar, "UTF-8", "--- --- --- --- --- --- --- --- --- --- --- --- --- --- --- ---\n", null);
                            if (ag) {
                            }
                            aVar.a();
                            a(aVar);
                            aVar.flush();
                            if (i9 != 0) {
                            }
                            com.uc.crashsdk.a.g.a(aVar);
                            com.uc.crashsdk.a.g.a(fileOutputStream);
                            if (!ag) {
                            }
                            b(ag ? a(m(str)) : str, LogType.JAVA_TYPE);
                            return str;
                        }
                    }
                    a((OutputStream) aVar);
                    d(aVar);
                    e(aVar);
                    com.uc.crashsdk.a.b(aVar, "UTF-8", "--- --- --- --- --- --- --- --- --- --- --- --- --- --- --- ---\n", null);
                    if (ag) {
                        f11647h = false;
                        aVar.write(s("JAVACACHEDINFOS").getBytes("UTF-8"));
                        f11647h = true;
                    }
                    aVar.flush();
                    com.uc.crashsdk.a.a(aVar, "UTF-8", "--- --- --- --- --- --- --- --- --- --- --- --- --- --- --- ---\n", null);
                    if (ag) {
                        f11647h = false;
                        aVar.write(s("JAVACALLBACKINFOS").getBytes("UTF-8"));
                        f11647h = true;
                    }
                    aVar.a();
                    a(aVar);
                    aVar.flush();
                    if (i9 != 0) {
                        b(aVar);
                    }
                    com.uc.crashsdk.a.g.a(aVar);
                }
            } catch (Throwable th4) {
                th = th4;
                try {
                    a(th, (OutputStream) null);
                    if (j9 != 0) {
                        b((a) null);
                    }
                    com.uc.crashsdk.a.g.a((Closeable) null);
                    com.uc.crashsdk.a.g.a(fileOutputStream);
                    if (!ag) {
                    }
                    b(ag ? a(m(str)) : str, LogType.JAVA_TYPE);
                    return str;
                } catch (Throwable th5) {
                    if (j9 != 0) {
                        b((a) null);
                    }
                    com.uc.crashsdk.a.g.a((Closeable) null);
                    com.uc.crashsdk.a.g.a(fileOutputStream);
                    throw th5;
                }
            }
        } catch (Throwable th6) {
            th = th6;
            fileOutputStream = null;
        }
        com.uc.crashsdk.a.g.a(fileOutputStream);
        if (!ag) {
            r(str);
        }
        try {
            b(ag ? a(m(str)) : str, LogType.JAVA_TYPE);
        } catch (Throwable th7) {
            com.uc.crashsdk.a.g.a(th7);
        }
        return str;
    }

    private static boolean b(File file) {
        int indexOf;
        String name = file.getName();
        int lastIndexOf = name.lastIndexOf(95);
        if (lastIndexOf > 0 && (indexOf = name.indexOf(46, lastIndexOf)) > 0) {
            String substring = name.substring(lastIndexOf + 1, indexOf);
            return LogType.JAVA_TYPE.equals(substring) || "ucebujava".equals(substring) || LogType.NATIVE_TYPE.equals(substring) || "ucebujni".equals(substring) || LogType.UNEXP_TYPE.equals(substring) || LogType.ANR_TYPE.equals(substring);
        }
        return false;
    }

    private static String b(String str, boolean z9, boolean z10) {
        if (z9) {
            try {
                str = m(str);
            } catch (Throwable th) {
                com.uc.crashsdk.a.g.a(th);
            }
        }
        if (z10) {
            try {
                return a(str);
            } catch (Throwable th2) {
                com.uc.crashsdk.a.g.a(th2);
                return str;
            }
        }
        return str;
    }

    public static void b(String str, String str2, boolean z9) {
        h.a(str, str2, false, z9);
    }

    public static void b(String str) {
        synchronized (f11664y) {
            f11663x = str;
            com.uc.crashsdk.a.b.a(com.uc.crashsdk.b.i(), str + "\n");
        }
    }

    private static void b(String str, String str2) {
        try {
            com.uc.crashsdk.d.a(str, h(), str2);
        } catch (Throwable th) {
            com.uc.crashsdk.a.g.a(th);
        }
    }

    public static void b(Context context) {
        if (g.K()) {
            try {
                IntentFilter intentFilter = new IntentFilter();
                intentFilter.addAction("android.intent.action.BATTERY_CHANGED");
                intentFilter.addAction("android.intent.action.BATTERY_LOW");
                intentFilter.addAction("android.intent.action.BATTERY_OKAY");
                context.registerReceiver(Q, intentFilter, null, com.uc.crashsdk.a.f.a(1));
                R = true;
            } catch (Throwable th) {
                com.uc.crashsdk.a.g.a(th);
            }
        }
    }

    public static void b(int i9) {
        com.uc.crashsdk.a.f.a(0, new com.uc.crashsdk.a.e(410), i9 * 1000);
    }

    public static String a(String str) {
        int lastIndexOf;
        int indexOf;
        int i9;
        int indexOf2;
        File file;
        byte[] e9;
        if (g.x() && (lastIndexOf = str.lastIndexOf(47)) > 0 && (indexOf = str.indexOf(95, lastIndexOf)) > lastIndexOf && (indexOf2 = str.indexOf(95, (i9 = indexOf + 1))) > indexOf) {
            String c10 = com.uc.crashsdk.a.g.c("CrashSDK" + str.substring(lastIndexOf + 1, indexOf) + str.substring(i9, indexOf2));
            if (c10 == null || (e9 = com.uc.crashsdk.a.g.e((file = new File(str)))) == null || e9.length <= 0) {
                return str;
            }
            byte[] bArr = null;
            try {
                bArr = com.uc.crashsdk.a.c.b(e9, c10.substring(0, 16).getBytes());
            } catch (Throwable th) {
                com.uc.crashsdk.a.g.a(th);
            }
            if (bArr == null) {
                return str;
            }
            String str2 = str + ".ec";
            File file2 = new File(str2 + ".tmp");
            if (com.uc.crashsdk.a.g.a(file2, bArr)) {
                if (!file2.renameTo(new File(str2))) {
                    file2.delete();
                    return str;
                }
                file.delete();
                return str2;
            }
            return str;
        }
        return str;
    }

    public static void a(Throwable th, OutputStream outputStream) {
        if (outputStream != null) {
            try {
                outputStream.write("[DEBUG] CrashHandler occurred new exception:\n".getBytes("UTF-8"));
                th.printStackTrace(new PrintStream(outputStream));
                outputStream.write("\n\n".getBytes("UTF-8"));
            } catch (Throwable th2) {
                com.uc.crashsdk.a.g.a(th2);
            }
        }
        com.uc.crashsdk.a.g.a(th);
    }

    private static void a(String str, boolean z9, boolean z10) {
        int i9;
        boolean z11;
        boolean z12;
        int i10;
        String path;
        String b10;
        File a10;
        int i11;
        String str2;
        String str3;
        File file;
        boolean z13;
        com.uc.crashsdk.a.a.a("crashsdk", "crashsdk uploading logs");
        synchronized (f11653n) {
            try {
                if (com.uc.crashsdk.a.g.b(str)) {
                    String V2 = g.V();
                    File file2 = new File(V2);
                    if (file2.exists()) {
                        File[] listFiles = file2.listFiles();
                        if (listFiles == null) {
                            com.uc.crashsdk.a.a.b("List folder failed: " + V2);
                        } else {
                            int length = listFiles.length;
                            int i12 = 0;
                            int i13 = 0;
                            int i14 = 0;
                            int i15 = 0;
                            int i16 = 0;
                            int i17 = 0;
                            int i18 = 0;
                            int i19 = 0;
                            int i20 = 0;
                            boolean z14 = false;
                            boolean z15 = false;
                            boolean z16 = false;
                            while (true) {
                                if (i12 >= length) {
                                    i9 = i15;
                                    z11 = z14;
                                    z12 = z15;
                                    break;
                                }
                                File file3 = listFiles[i12];
                                File[] fileArr = listFiles;
                                if (file3.isFile()) {
                                    String name = file3.getName();
                                    if (!name.endsWith(".tmp")) {
                                        i10 = length;
                                        z11 = z14;
                                        z12 = z15;
                                        if (file3.length() == 0) {
                                            i13++;
                                            com.uc.crashsdk.a.g.a(file3);
                                        } else {
                                            if (z9) {
                                                long currentTimeMillis = (System.currentTimeMillis() - file3.lastModified()) / 1000;
                                                if (currentTimeMillis < 0 || (currentTimeMillis >= 2 && (currentTimeMillis >= 5 || !file3.getName().endsWith(".log")))) {
                                                    z13 = true;
                                                    com.uc.crashsdk.a.a.a(String.format(Locale.US, "file: %s, modify interval: %d s, safe upload: %s", file3.getName(), Long.valueOf(currentTimeMillis), Boolean.valueOf(z13)));
                                                    if (!z13) {
                                                        i15++;
                                                    }
                                                }
                                                z13 = false;
                                                com.uc.crashsdk.a.a.a(String.format(Locale.US, "file: %s, modify interval: %d s, safe upload: %s", file3.getName(), Long.valueOf(currentTimeMillis), Boolean.valueOf(z13)));
                                                if (!z13) {
                                                }
                                            }
                                            try {
                                            } catch (Throwable th) {
                                                th = th;
                                                i9 = i15;
                                            }
                                            if (g.k()) {
                                                Matcher matcher = Pattern.compile("([^_]+)_([^_]+)_([^_]+)\\.crashsdk").matcher(file3.getName());
                                                if (matcher.matches()) {
                                                    i9 = i15;
                                                    try {
                                                        file = new File(g.V() + String.format(Locale.US, "%s%s_%s_%s.%s", j(matcher.group(2)), n(), Q(), matcher.group(1), matcher.group(3)));
                                                        com.uc.crashsdk.a.a.a("crashsdk", "File " + file3.getPath() + " matches, rename to " + file.getPath());
                                                        file3.renameTo(file);
                                                        if (file != file3) {
                                                            i19++;
                                                        }
                                                        file3 = file;
                                                    } catch (Throwable th2) {
                                                        th = th2;
                                                        com.uc.crashsdk.a.g.a(th);
                                                        path = file3.getPath();
                                                        boolean[] n9 = n(path);
                                                        b10 = b(path, n9[0], n9[1]);
                                                        if (path != b10) {
                                                        }
                                                        a10 = com.uc.crashsdk.d.a(file3);
                                                        if (a10 == null) {
                                                        }
                                                        if (a10 == null) {
                                                        }
                                                        z15 = z12;
                                                        i12++;
                                                        listFiles = fileArr;
                                                        length = i10;
                                                        z14 = z11;
                                                        i15 = i9;
                                                    }
                                                    path = file3.getPath();
                                                    boolean[] n92 = n(path);
                                                    b10 = b(path, n92[0], n92[1]);
                                                    if (path != b10) {
                                                        if (n92[0]) {
                                                            i18++;
                                                        }
                                                        if (n92[1]) {
                                                            i16++;
                                                        }
                                                        file3 = new File(b10);
                                                    }
                                                    a10 = com.uc.crashsdk.d.a(file3);
                                                    if (a10 == null) {
                                                        a10 = null;
                                                    } else if (file3 != a10 && !file3.getName().equals(a10.getName()) && file3.exists()) {
                                                        file3.delete();
                                                    }
                                                    if (a10 == null) {
                                                        com.uc.crashsdk.a.a.b("onBeforeUploadLog return null, skip upload: " + file3.getAbsolutePath());
                                                    } else {
                                                        int z17 = g.z();
                                                        if (z17 <= 0 || a10.length() < z17) {
                                                            d dVar = new d((byte) 0);
                                                            dVar.f11673b = 0L;
                                                            dVar.f11672a = System.currentTimeMillis();
                                                            String U2 = U();
                                                            if (new File(U2).exists()) {
                                                                a(U2, new com.uc.crashsdk.a.e(451, new Object[]{U2, dVar}));
                                                            }
                                                            long A2 = g.A();
                                                            int B2 = g.B();
                                                            int C2 = g.C();
                                                            if (A2 >= 0) {
                                                                i11 = i16;
                                                                if (dVar.f11673b + a10.length() > A2) {
                                                                    dVar.f11676e = true;
                                                                    str2 = "Reach max upload bytes: " + A2;
                                                                    com.uc.crashsdk.a.a.b(str2);
                                                                    if (!dVar.f11676e) {
                                                                        i16 = i11;
                                                                        z15 = z12;
                                                                        z11 = true;
                                                                    } else if (dVar.f11678g) {
                                                                        i16 = i11;
                                                                        z15 = true;
                                                                    } else if (dVar.f11677f) {
                                                                        i16 = i11;
                                                                        z15 = z12;
                                                                        z16 = true;
                                                                    } else {
                                                                        String name2 = a10.getName();
                                                                        if (name2.startsWith(P())) {
                                                                            String[] split = name2.split("_", 10);
                                                                            if (split.length == 9) {
                                                                                str3 = split[1];
                                                                                boolean z18 = str3 == null && str3.equals(g.R());
                                                                                if (com.uc.crashsdk.a.c.a(a10, a10.getName(), str)) {
                                                                                    i20++;
                                                                                    if (z18) {
                                                                                        f.a(14);
                                                                                    }
                                                                                } else {
                                                                                    com.uc.crashsdk.a.a.a("crashsdk", "Uploaded log: " + a10.getName(), null);
                                                                                    if (z18) {
                                                                                        f.a(13);
                                                                                    }
                                                                                    dVar.f11673b += a10.length();
                                                                                    if (b(a10)) {
                                                                                        dVar.f11674c++;
                                                                                    } else {
                                                                                        dVar.f11675d++;
                                                                                    }
                                                                                    String U3 = U();
                                                                                    a(U3, new com.uc.crashsdk.a.e(452, new Object[]{U3, dVar}));
                                                                                    a10.delete();
                                                                                    i20 = 0;
                                                                                }
                                                                                if (i20 < 3) {
                                                                                    com.uc.crashsdk.a.a.a("crashsdk", "Upload failed 3 times continuously, abort upload!", null);
                                                                                    i16 = i11;
                                                                                    break;
                                                                                }
                                                                                i16 = i11;
                                                                                z15 = z12;
                                                                            }
                                                                        }
                                                                        str3 = null;
                                                                        if (str3 == null) {
                                                                        }
                                                                        if (com.uc.crashsdk.a.c.a(a10, a10.getName(), str)) {
                                                                        }
                                                                        if (i20 < 3) {
                                                                        }
                                                                    }
                                                                    i12++;
                                                                    listFiles = fileArr;
                                                                    length = i10;
                                                                    z14 = z11;
                                                                    i15 = i9;
                                                                }
                                                            } else {
                                                                i11 = i16;
                                                            }
                                                            if (!g.f()) {
                                                                if (b(a10)) {
                                                                    if (B2 >= 0 && dVar.f11674c >= B2) {
                                                                        dVar.f11678g = true;
                                                                        str2 = "Reach max upload builtin log count: " + B2;
                                                                        com.uc.crashsdk.a.a.b(str2);
                                                                    }
                                                                } else if (C2 >= 0 && dVar.f11675d >= C2) {
                                                                    dVar.f11677f = true;
                                                                    str2 = "Reach max upload custom log count: " + C2;
                                                                    com.uc.crashsdk.a.a.b(str2);
                                                                }
                                                            }
                                                            if (!dVar.f11676e) {
                                                            }
                                                            i12++;
                                                            listFiles = fileArr;
                                                            length = i10;
                                                            z14 = z11;
                                                            i15 = i9;
                                                        } else {
                                                            i17++;
                                                            com.uc.crashsdk.a.g.a(a10);
                                                        }
                                                    }
                                                    z15 = z12;
                                                    i12++;
                                                    listFiles = fileArr;
                                                    length = i10;
                                                    z14 = z11;
                                                    i15 = i9;
                                                }
                                            }
                                            i9 = i15;
                                            file = file3;
                                            if (file != file3) {
                                            }
                                            file3 = file;
                                            path = file3.getPath();
                                            boolean[] n922 = n(path);
                                            b10 = b(path, n922[0], n922[1]);
                                            if (path != b10) {
                                            }
                                            a10 = com.uc.crashsdk.d.a(file3);
                                            if (a10 == null) {
                                            }
                                            if (a10 == null) {
                                            }
                                            z15 = z12;
                                            i12++;
                                            listFiles = fileArr;
                                            length = i10;
                                            z14 = z11;
                                            i15 = i9;
                                        }
                                        i9 = i15;
                                        z15 = z12;
                                        i12++;
                                        listFiles = fileArr;
                                        length = i10;
                                        z14 = z11;
                                        i15 = i9;
                                    } else if ((System.currentTimeMillis() - file3.lastModified()) / 1000 > 30) {
                                        i10 = length;
                                        com.uc.crashsdk.a.a.b("delete legacy tmp file: " + name);
                                        i14++;
                                        com.uc.crashsdk.a.g.a(file3);
                                        i9 = i15;
                                        z11 = z14;
                                        i12++;
                                        listFiles = fileArr;
                                        length = i10;
                                        z14 = z11;
                                        i15 = i9;
                                    }
                                } else {
                                    com.uc.crashsdk.a.g.a(file3);
                                }
                                i10 = length;
                                i9 = i15;
                                z11 = z14;
                                i12++;
                                listFiles = fileArr;
                                length = i10;
                                z14 = z11;
                                i15 = i9;
                            }
                            if (i14 > 0) {
                                f.a(200, i14);
                            }
                            if (i13 > 0) {
                                f.a(15, i13);
                            }
                            if (i17 > 0) {
                                f.a(17, i17);
                            }
                            if (z11) {
                                f.a(19);
                            }
                            if (z12) {
                                f.a(20);
                            }
                            if (z16) {
                                f.a(21);
                            }
                            if (z11 || z12 || z16) {
                                f.a(18);
                            }
                            if (i18 > 0) {
                                f.a(24, i18);
                            }
                            if (i16 > 0) {
                                f.a((int) CrashStatKey.LOG_UPLOAD_ENCRYPT_COUNT, i16);
                            }
                            if (i19 > 0) {
                                f.a(25, i19);
                            }
                            if (i9 > 0) {
                                f.a(26, i9);
                            }
                        }
                    } else {
                        com.uc.crashsdk.a.a.a("crashsdk", "Folder not exist: " + V2);
                    }
                } else {
                    com.uc.crashsdk.a.a.a("crashsdk", "upload url is empty!");
                }
                if (z10) {
                    f11654o.open();
                }
            } catch (Throwable th3) {
                throw th3;
            }
        }
    }

    public static boolean a(boolean z9, boolean z10) {
        if (!f11644d) {
            if (com.uc.crashsdk.b.f11609d) {
                JNIBridge.set(1, true);
            }
            f11644d = true;
        }
        try {
            String k9 = k();
            if (com.uc.crashsdk.a.g.a(k9)) {
                com.uc.crashsdk.a.a.a("crashsdk", "CrashHandler url is empty!");
                return false;
            }
            if (com.uc.crashsdk.a.f.a(z9 ? 1 : 0, new com.uc.crashsdk.a.e(406, new Object[]{k9, Boolean.valueOf(z10), Boolean.valueOf(z9)})) && z9) {
                ConditionVariable conditionVariable = f11654o;
                conditionVariable.close();
                if (!conditionVariable.block(3000L)) {
                    com.uc.crashsdk.a.a.a("crashsdk", "timeout to wait for uploading");
                    return false;
                }
            }
            return true;
        } catch (Throwable th) {
            com.uc.crashsdk.a.g.a(th);
            return false;
        }
    }

    private static boolean a(String str, com.uc.crashsdk.a.e eVar) {
        boolean z9;
        FileChannel fileChannel;
        Exception e9;
        synchronized (f11655p) {
            File file = new File(str);
            if (!file.exists()) {
                try {
                    file.createNewFile();
                } catch (Exception e10) {
                    com.uc.crashsdk.a.g.a(e10);
                }
            }
            ?? r52 = 0;
            r5 = null;
            FileLock lock = null;
            z9 = false;
            try {
                try {
                    try {
                        fileChannel = new RandomAccessFile(file, "rw").getChannel();
                    } catch (Throwable th) {
                        th = th;
                        r52 = file;
                        com.uc.crashsdk.a.g.a((Closeable) r52);
                        throw th;
                    }
                } catch (Exception e11) {
                    try {
                        com.uc.crashsdk.a.g.a(e11);
                        fileChannel = null;
                    } catch (Exception e12) {
                        fileChannel = null;
                        e9 = e12;
                        com.uc.crashsdk.a.g.a(e9);
                        com.uc.crashsdk.a.g.a(fileChannel);
                        return z9;
                    }
                }
                if (fileChannel != null) {
                    try {
                        lock = fileChannel.lock();
                    } catch (Exception e13) {
                        try {
                            com.uc.crashsdk.a.g.a(e13);
                        } catch (Exception e14) {
                            e9 = e14;
                            com.uc.crashsdk.a.g.a(e9);
                            com.uc.crashsdk.a.g.a(fileChannel);
                            return z9;
                        }
                    }
                }
                try {
                    z9 = eVar.a();
                    com.uc.crashsdk.a.g.a(fileChannel);
                } finally {
                    if (lock != null) {
                        try {
                            lock.release();
                        } catch (Exception e15) {
                            com.uc.crashsdk.a.g.a(e15);
                        }
                    }
                }
            } catch (Throwable th2) {
                th = th2;
            }
        }
        return z9;
    }

    private static boolean a(String str, d dVar) {
        String a10 = com.uc.crashsdk.a.g.a(new File(str), 64, false);
        if (a10 == null) {
            return false;
        }
        try {
            Matcher matcher = Pattern.compile("(\\d+)\\s+(\\d+)\\s+(\\d+)\\s+(\\d+)").matcher(a10);
            if (matcher.find()) {
                long parseLong = Long.parseLong(matcher.group(1));
                if (System.currentTimeMillis() - parseLong < 86400000) {
                    dVar.f11673b = Long.parseLong(matcher.group(2));
                    dVar.f11674c = Integer.parseInt(matcher.group(3));
                    dVar.f11675d = Integer.parseInt(matcher.group(4));
                    dVar.f11672a = parseLong;
                }
            }
        } catch (Throwable th) {
            com.uc.crashsdk.a.g.a(th);
        }
        return true;
    }

    public static boolean a(StringBuffer stringBuffer, String str, long j9, ArrayList<String> arrayList, ArrayList<String> arrayList2, ArrayList<String> arrayList3, String str2) {
        long j10;
        boolean z9;
        boolean a10;
        if (f11643c.get()) {
            com.uc.crashsdk.a.a.b("Processing java crash, skip generate custom log: " + str);
            return false;
        }
        boolean z10 = ag || com.uc.crashsdk.b.L();
        if (!z10 && !com.uc.crashsdk.a.d.e()) {
            com.uc.crashsdk.a.a.c("DEBUG", com.uc.crashsdk.a.d.b());
            return false;
        } else if (!d(str)) {
            com.uc.crashsdk.a.a.d("DEBUG", "custom log sample miss: " + str);
            return false;
        } else if (aa()) {
            com.uc.crashsdk.a.a.b("Processing native crash, skip generate custom log: " + str);
            return false;
        } else if (stringBuffer == null || str == null) {
            return false;
        } else {
            String str3 = g.V() + k(str);
            ?? r11 = (j9 & 32) != 0 ? 1 : 0;
            if (z10) {
                long nativeClientCreateConnection = com.uc.crashsdk.b.f11609d ? JNIBridge.nativeClientCreateConnection(str3, "custom", str, r11) : 0L;
                if (nativeClientCreateConnection == 0) {
                    com.uc.crashsdk.a.a.d("DEBUG", "skip custom log: " + str);
                    return false;
                }
                j10 = nativeClientCreateConnection;
            } else if (a(h(), str, (boolean) r11)) {
                return false;
            } else {
                g.a();
                a(false);
                j10 = 0;
            }
            synchronized (f11656q) {
                z9 = r11;
                a10 = a(str3, j10, stringBuffer, str, j9, arrayList, arrayList2, arrayList3, str2);
            }
            if (a10 && !z10) {
                b(h(), str, z9);
            }
            if (j10 != 0) {
                JNIBridge.nativeClientCloseConnection(j10);
            }
            if (a10) {
                if (!z10) {
                    r(str3);
                }
                if (!z10) {
                    str3 = a(m(str3));
                }
                b(str3, str);
                if (!z9 || z10) {
                    return true;
                }
                try {
                    a(true, false);
                    return true;
                } catch (Throwable th) {
                    com.uc.crashsdk.a.g.a(th);
                    return true;
                }
            }
            return false;
        }
    }

    public static boolean a(String str, String str2, boolean z9) {
        if (o(str2)) {
            h.a(str, str2, true, z9);
            com.uc.crashsdk.a.a.b(String.format(Locale.US, "Custom log '%s' has reach max count!", str2));
            return true;
        }
        return false;
    }

    private static void a(a aVar, String str, long j9) {
        String nativeDumpThreads;
        String str2 = null;
        if (com.uc.crashsdk.b.f11609d) {
            try {
                aVar.flush();
            } catch (Throwable th) {
                com.uc.crashsdk.a.g.a(th);
            }
            nativeDumpThreads = JNIBridge.nativeDumpThreads(str, j9);
            if (ag || nativeDumpThreads == null || nativeDumpThreads.length() >= 512 || !nativeDumpThreads.startsWith("/") || nativeDumpThreads.indexOf(10) >= 0) {
                str2 = nativeDumpThreads;
            } else {
                if (!new File(nativeDumpThreads).exists()) {
                    str2 = "Can not found " + nativeDumpThreads;
                }
                String str3 = str2;
                str2 = nativeDumpThreads;
                nativeDumpThreads = str3;
            }
        } else {
            nativeDumpThreads = "Native not initialized, skip dump!";
        }
        if (nativeDumpThreads != null) {
            try {
                aVar.write(nativeDumpThreads.getBytes("UTF-8"));
                aVar.write("\n".getBytes("UTF-8"));
            } catch (Throwable th2) {
                com.uc.crashsdk.a.g.a(th2);
            }
            a((OutputStream) aVar);
        } else if (str2 != null && !ag) {
            b(aVar, str2, 1048576);
            File file = new File(str2);
            if (file.exists()) {
                file.delete();
            }
        }
        try {
            aVar.flush();
        } catch (Throwable th3) {
            com.uc.crashsdk.a.g.a(th3);
        }
    }

    private static boolean a(String str, long j9, StringBuffer stringBuffer, String str2, long j10, ArrayList<String> arrayList, ArrayList<String> arrayList2, ArrayList<String> arrayList3, String str3) {
        FileOutputStream fileOutputStream;
        a aVar;
        int i9 = (j9 > 0L ? 1 : (j9 == 0L ? 0 : -1));
        if (i9 == 0) {
            try {
                fileOutputStream = new FileOutputStream(str);
            } catch (Throwable th) {
                th = th;
                fileOutputStream = null;
                aVar = null;
                com.uc.crashsdk.a.g.a(th);
                if (aVar == null) {
                }
            }
        } else {
            fileOutputStream = null;
        }
        try {
            aVar = new a(j9, fileOutputStream);
            try {
                synchronized (f11658s) {
                    f11660u = str;
                    if (com.uc.crashsdk.b.f11609d) {
                        JNIBridge.set((int) Constants.ERR_WATERMARK_PNG, f11660u);
                    }
                }
            } catch (Throwable th2) {
                th = th2;
                com.uc.crashsdk.a.g.a(th);
                if (aVar == null) {
                }
            }
        } catch (Throwable th3) {
            th = th3;
            aVar = null;
        }
        if (aVar == null) {
            return false;
        }
        if ((j10 & 1) != 0) {
            try {
                b(aVar, str, str2);
            } catch (Throwable th4) {
                try {
                    a(th4, aVar);
                } finally {
                    com.uc.crashsdk.a.g.a(aVar);
                    com.uc.crashsdk.a.g.a(fileOutputStream);
                }
            }
        }
        aVar.write(stringBuffer.toString().getBytes());
        aVar.write("\n".getBytes("UTF-8"));
        aVar.flush();
        a((OutputStream) aVar);
        if ((j10 & 4) != 0) {
            b((OutputStream) aVar);
            aVar.flush();
        }
        if (arrayList != null && arrayList.size() > 0) {
            com.uc.crashsdk.a.a(aVar, "UTF-8", arrayList);
        }
        if (arrayList2 != null && arrayList2.size() > 0) {
            com.uc.crashsdk.a.a(aVar, "UTF-8", "--- --- --- --- --- --- --- --- --- --- --- --- --- --- --- ---\n", arrayList2);
        }
        if (arrayList3 != null && arrayList3.size() > 0) {
            com.uc.crashsdk.a.b(aVar, "UTF-8", "--- --- --- --- --- --- --- --- --- --- --- --- --- --- --- ---\n", arrayList3);
        }
        if (str3 != null) {
            aVar.flush();
            aVar.write("threads dump:\n".getBytes("UTF-8"));
            f11647h = false;
            f11662w = str3;
            a(aVar, str3, j9);
            f11662w = null;
            f11647h = true;
        }
        if ((j10 & 8) != 0 && i9 == 0) {
            aVar.flush();
            aVar.write("all threads dump:\n".getBytes("UTF-8"));
            f11661v = true;
            a(aVar, "all", 0L);
            f11661v = false;
        }
        if ((j10 & 16) != 0) {
            f(aVar);
        }
        if ((j10 & 2) != 0) {
            aVar.a();
            a(aVar);
        }
        if (i9 != 0) {
            b(aVar);
        }
        try {
            ArrayList<String> arrayList4 = f11658s;
            synchronized (arrayList4) {
                f11659t++;
                String str4 = f11660u;
                if (str4 != null) {
                    arrayList4.add(str4);
                    if (arrayList4.size() > 3) {
                        arrayList4.remove(0);
                    }
                    if (com.uc.crashsdk.b.f11609d) {
                        JNIBridge.set((int) Constants.ERR_WATERMARKR_INFO, f11660u);
                    }
                    f11660u = null;
                }
                if (com.uc.crashsdk.b.f11609d) {
                    JNIBridge.set(25, f11659t);
                }
            }
            return true;
        } catch (Throwable th5) {
            com.uc.crashsdk.a.g.a(th5);
            return true;
        }
    }

    private static String a(Date date) {
        return String.format(Locale.US, "%d%02d%02d%02d%02d%02d", Integer.valueOf(date.getYear() + 1900), Integer.valueOf(date.getMonth() + 1), Integer.valueOf(date.getDate()), Integer.valueOf(date.getHours()), Integer.valueOf(date.getMinutes()), Integer.valueOf(date.getSeconds()));
    }

    public static void a(OutputStream outputStream, String str, String str2, int i9, boolean z9, boolean z10) {
        f11647h = false;
        try {
            Locale locale = Locale.US;
            Object[] objArr = new Object[5];
            objArr[0] = str;
            objArr[1] = str2;
            objArr[2] = Integer.valueOf(i9);
            objArr[3] = Integer.valueOf(z9 ? 1 : 0);
            objArr[4] = Integer.valueOf(z10 ? 1 : 0);
            outputStream.write(String.format(locale, "$^%s`%s`%d`%d,%d^$", objArr).getBytes("UTF-8"));
        } catch (Throwable th) {
            com.uc.crashsdk.a.g.a(th);
        }
        f11647h = true;
        a(outputStream);
    }

    public static void a(OutputStream outputStream, String str, String str2) {
        f11647h = false;
        try {
            outputStream.write(String.format(Locale.US, "$^%s`%s^$", str, str2).getBytes("UTF-8"));
        } catch (Throwable th) {
            com.uc.crashsdk.a.g.a(th);
        }
        f11647h = true;
    }

    public static void a(Context context) {
        try {
            if (V()) {
                context.registerReceiver(new c((byte) 0), new IntentFilter("android.intent.action.ANR"), null, com.uc.crashsdk.a.f.a(3));
            }
        } catch (Throwable th) {
            com.uc.crashsdk.a.g.a(th);
        }
    }

    public final void a(Thread thread, Throwable th, boolean z9) {
        boolean z10;
        long j9;
        boolean z11;
        boolean i9;
        Thread.UncaughtExceptionHandler uncaughtExceptionHandler;
        Throwable th2;
        boolean z12;
        boolean i10;
        Thread.UncaughtExceptionHandler uncaughtExceptionHandler2;
        boolean z13;
        String str;
        long nativeClientCreateConnection;
        boolean z14;
        boolean i11;
        Thread.UncaughtExceptionHandler uncaughtExceptionHandler3;
        boolean z15;
        boolean i12;
        Thread.UncaughtExceptionHandler uncaughtExceptionHandler4;
        Throwable th3;
        boolean z16;
        boolean i13;
        Thread.UncaughtExceptionHandler uncaughtExceptionHandler5;
        File file;
        boolean z17;
        boolean i14;
        Thread.UncaughtExceptionHandler uncaughtExceptionHandler6;
        boolean z18;
        boolean i15;
        Thread.UncaughtExceptionHandler uncaughtExceptionHandler7;
        boolean z19;
        boolean i16;
        Thread.UncaughtExceptionHandler uncaughtExceptionHandler8;
        boolean z20;
        boolean i17;
        Thread.UncaughtExceptionHandler uncaughtExceptionHandler9;
        boolean z21 = (ag && com.uc.crashsdk.b.f11609d) || com.uc.crashsdk.b.L();
        try {
            j9 = 4;
            if (f11643c.getAndSet(true) && Process.myPid() > 0) {
                com.uc.crashsdk.a.a.d("DEBUG", "another thread is generating java report!");
                com.uc.crashsdk.a.a.d("DEBUG", "current thread exception is:");
                a(th);
                int i18 = 0;
                while (!V) {
                    Thread.sleep(1000L);
                    i18++;
                    if (i18 >= 4) {
                        break;
                    }
                }
                Process.killProcess(Process.myPid());
                if (z9) {
                    try {
                    } catch (Throwable th4) {
                        th = th4;
                        z20 = false;
                    }
                    if (g.r() && !z21) {
                        try {
                            a(true, false);
                            z20 = true;
                        } catch (Throwable th5) {
                            th = th5;
                            z20 = true;
                            com.uc.crashsdk.a.g.a(th);
                            if (!z20) {
                            }
                            f.c(false);
                            i17 = g.i();
                            if (!com.uc.crashsdk.a.d.e()) {
                            }
                            com.uc.crashsdk.a.a.a("crashsdk", "Call java default handler: " + i17);
                            if (i17) {
                            }
                            if (com.uc.crashsdk.b.B()) {
                            }
                            V = true;
                            if (Process.myPid() > 0) {
                            }
                        }
                        if (!z20 && !z21) {
                            b(false);
                        }
                        f.c(false);
                        i17 = g.i();
                        if (!com.uc.crashsdk.a.d.e()) {
                            i17 = true;
                        }
                        com.uc.crashsdk.a.a.a("crashsdk", "Call java default handler: " + i17);
                        if (i17 && (uncaughtExceptionHandler9 = T) != null) {
                            uncaughtExceptionHandler9.uncaughtException(thread, th);
                        }
                        if (com.uc.crashsdk.b.B() && !z21) {
                            com.uc.crashsdk.b.b(com.uc.crashsdk.a.g.a());
                        }
                        V = true;
                        if (Process.myPid() > 0) {
                            Process.killProcess(Process.myPid());
                            return;
                        }
                        return;
                    }
                }
                z20 = false;
                if (!z20) {
                    b(false);
                }
                f.c(false);
                i17 = g.i();
                if (!com.uc.crashsdk.a.d.e()) {
                }
                com.uc.crashsdk.a.a.a("crashsdk", "Call java default handler: " + i17);
                if (i17) {
                    uncaughtExceptionHandler9.uncaughtException(thread, th);
                }
                if (com.uc.crashsdk.b.B()) {
                    com.uc.crashsdk.b.b(com.uc.crashsdk.a.g.a());
                }
                V = true;
                if (Process.myPid() > 0) {
                }
            } else {
                U = th;
                if (!z21 && !com.uc.crashsdk.a.d.e()) {
                    com.uc.crashsdk.a.a.c("DEBUG", com.uc.crashsdk.a.d.b());
                    if (z9) {
                        try {
                        } catch (Throwable th6) {
                            th = th6;
                            z19 = false;
                        }
                        if (g.r() && !z21) {
                            try {
                                a(true, false);
                                z19 = true;
                            } catch (Throwable th7) {
                                th = th7;
                                z19 = true;
                                com.uc.crashsdk.a.g.a(th);
                                if (!z19) {
                                }
                                f.c(false);
                                i16 = g.i();
                                if (!com.uc.crashsdk.a.d.e()) {
                                }
                                com.uc.crashsdk.a.a.a("crashsdk", "Call java default handler: " + i16);
                                if (i16) {
                                }
                                if (com.uc.crashsdk.b.B()) {
                                }
                                V = true;
                                if (Process.myPid() > 0) {
                                }
                            }
                            if (!z19 && !z21) {
                                b(false);
                            }
                            f.c(false);
                            i16 = g.i();
                            if (!com.uc.crashsdk.a.d.e()) {
                                i16 = true;
                            }
                            com.uc.crashsdk.a.a.a("crashsdk", "Call java default handler: " + i16);
                            if (i16 && (uncaughtExceptionHandler8 = T) != null) {
                                uncaughtExceptionHandler8.uncaughtException(thread, th);
                            }
                            if (com.uc.crashsdk.b.B() && !z21) {
                                com.uc.crashsdk.b.b(com.uc.crashsdk.a.g.a());
                            }
                            V = true;
                            if (Process.myPid() > 0) {
                                Process.killProcess(Process.myPid());
                                return;
                            }
                            return;
                        }
                    }
                    z19 = false;
                    if (!z19) {
                        b(false);
                    }
                    f.c(false);
                    i16 = g.i();
                    if (!com.uc.crashsdk.a.d.e()) {
                    }
                    com.uc.crashsdk.a.a.a("crashsdk", "Call java default handler: " + i16);
                    if (i16) {
                        uncaughtExceptionHandler8.uncaughtException(thread, th);
                    }
                    if (com.uc.crashsdk.b.B()) {
                        com.uc.crashsdk.b.b(com.uc.crashsdk.a.g.a());
                    }
                    V = true;
                    if (Process.myPid() > 0) {
                    }
                } else {
                    com.uc.crashsdk.a.a.d("DEBUG", "encryptLog: " + g.x() + ", zipCrashLog: " + g.x());
                    if (g.f11688a != null) {
                        com.uc.crashsdk.a.a.d("DEBUG", "the set zip log to false stack is:");
                        g.f11688a.printStackTrace();
                    }
                    if (g.f11689b != null) {
                        com.uc.crashsdk.a.a.d("DEBUG", "the set encrypt to true stack is:");
                        g.f11689b.printStackTrace();
                    }
                    com.uc.crashsdk.a.a.d("DEBUG", "begin to generate java report");
                    N();
                    try {
                        z13 = g.t();
                        try {
                            String g9 = g.g();
                            if (g9 == null || g9.equals("")) {
                                g9 = k(S());
                            }
                            str = g.V() + g9;
                            z10 = false;
                        } catch (Throwable th8) {
                            th = th8;
                            com.uc.crashsdk.a.a.d("DEBUG", "get java log name failed: " + th);
                            a(th);
                            com.uc.crashsdk.a.a.d("DEBUG", "original exception is: " + th);
                            a(th);
                            z10 = true;
                            str = null;
                            try {
                                if (z21) {
                                }
                                boolean z22 = th instanceof OutOfMemoryError;
                                a(th, str, nativeClientCreateConnection, z22);
                                com.uc.crashsdk.a.a.d("DEBUG", "generate java report finished");
                                if (!com.uc.crashsdk.b.L()) {
                                    String name = new File(str).getName();
                                    String W2 = g.W();
                                    file = new File(W2);
                                    if (!file.exists()) {
                                    }
                                    String format = String.format(Locale.US, "%s%s.hprof", W2, name);
                                    com.uc.crashsdk.a.a.d("DEBUG", "begin dump hprof: " + format);
                                    long currentTimeMillis = System.currentTimeMillis();
                                    Debug.dumpHprofData(format);
                                    com.uc.crashsdk.a.a.d("DEBUG", "end dump hprof, use " + (System.currentTimeMillis() - currentTimeMillis) + " ms");
                                }
                                if (nativeClientCreateConnection != 0) {
                                    JNIBridge.nativeClientCloseConnection(nativeClientCreateConnection);
                                }
                                if (z9) {
                                }
                                z16 = false;
                                if (!z16) {
                                }
                                try {
                                    f.c(false);
                                } catch (Throwable th9) {
                                    com.uc.crashsdk.a.g.a(th9);
                                }
                                try {
                                    i13 = g.i();
                                    if (!com.uc.crashsdk.a.d.e()) {
                                    }
                                    com.uc.crashsdk.a.a.a("crashsdk", "Call java default handler: " + i13);
                                    if (i13) {
                                    }
                                    if (com.uc.crashsdk.b.B()) {
                                    }
                                } catch (Throwable th10) {
                                    com.uc.crashsdk.a.g.a(th10);
                                }
                                V = true;
                                if (Process.myPid() <= 0) {
                                }
                            }
                        }
                    } catch (Throwable th11) {
                        th = th11;
                        z13 = false;
                    }
                    try {
                        if (z21) {
                            g.a();
                            try {
                                if (com.uc.crashsdk.b.B()) {
                                    f.a(3);
                                } else {
                                    f.a(4);
                                }
                            } catch (Throwable th12) {
                                com.uc.crashsdk.a.g.a(th12);
                            }
                            new File(com.uc.crashsdk.b.b()).createNewFile();
                            if (z13) {
                                com.uc.crashsdk.a.a.d("DEBUG", "omit java crash");
                                if (z9) {
                                    try {
                                    } catch (Throwable th13) {
                                        th = th13;
                                        z18 = false;
                                    }
                                    if (g.r() && !z21) {
                                        try {
                                            a(true, false);
                                            z18 = true;
                                        } catch (Throwable th14) {
                                            th = th14;
                                            z18 = true;
                                            com.uc.crashsdk.a.g.a(th);
                                            if (!z18) {
                                            }
                                            f.c(false);
                                            i15 = g.i();
                                            if (!com.uc.crashsdk.a.d.e()) {
                                            }
                                            com.uc.crashsdk.a.a.a("crashsdk", "Call java default handler: " + i15);
                                            if (i15) {
                                            }
                                            if (com.uc.crashsdk.b.B()) {
                                            }
                                            V = true;
                                            if (Process.myPid() > 0) {
                                            }
                                        }
                                        if (!z18 && !z21) {
                                            b(false);
                                        }
                                        f.c(false);
                                        i15 = g.i();
                                        if (!com.uc.crashsdk.a.d.e()) {
                                            i15 = true;
                                        }
                                        com.uc.crashsdk.a.a.a("crashsdk", "Call java default handler: " + i15);
                                        if (i15 && (uncaughtExceptionHandler7 = T) != null) {
                                            uncaughtExceptionHandler7.uncaughtException(thread, th);
                                        }
                                        if (com.uc.crashsdk.b.B() && !z21) {
                                            com.uc.crashsdk.b.b(com.uc.crashsdk.a.g.a());
                                        }
                                        V = true;
                                        if (Process.myPid() > 0) {
                                            Process.killProcess(Process.myPid());
                                            return;
                                        }
                                        return;
                                    }
                                }
                                z18 = false;
                                if (!z18) {
                                    b(false);
                                }
                                f.c(false);
                                i15 = g.i();
                                if (!com.uc.crashsdk.a.d.e()) {
                                }
                                com.uc.crashsdk.a.a.a("crashsdk", "Call java default handler: " + i15);
                                if (i15) {
                                    uncaughtExceptionHandler7.uncaughtException(thread, th);
                                }
                                if (com.uc.crashsdk.b.B()) {
                                    com.uc.crashsdk.b.b(com.uc.crashsdk.a.g.a());
                                }
                                V = true;
                                if (Process.myPid() > 0) {
                                }
                            } else if (d(LogType.JAVA_TYPE)) {
                                nativeClientCreateConnection = 0;
                            } else {
                                com.uc.crashsdk.a.a.d("DEBUG", "java log sample miss");
                                if (z9) {
                                    try {
                                    } catch (Throwable th15) {
                                        th = th15;
                                        z17 = false;
                                    }
                                    if (g.r() && !z21) {
                                        try {
                                            a(true, false);
                                            z17 = true;
                                        } catch (Throwable th16) {
                                            th = th16;
                                            z17 = true;
                                            com.uc.crashsdk.a.g.a(th);
                                            if (!z17) {
                                            }
                                            f.c(false);
                                            i14 = g.i();
                                            if (!com.uc.crashsdk.a.d.e()) {
                                            }
                                            com.uc.crashsdk.a.a.a("crashsdk", "Call java default handler: " + i14);
                                            if (i14) {
                                            }
                                            if (com.uc.crashsdk.b.B()) {
                                            }
                                            V = true;
                                            if (Process.myPid() > 0) {
                                            }
                                        }
                                        if (!z17 && !z21) {
                                            b(false);
                                        }
                                        f.c(false);
                                        i14 = g.i();
                                        if (!com.uc.crashsdk.a.d.e()) {
                                            i14 = true;
                                        }
                                        com.uc.crashsdk.a.a.a("crashsdk", "Call java default handler: " + i14);
                                        if (i14 && (uncaughtExceptionHandler6 = T) != null) {
                                            uncaughtExceptionHandler6.uncaughtException(thread, th);
                                        }
                                        if (com.uc.crashsdk.b.B() && !z21) {
                                            com.uc.crashsdk.b.b(com.uc.crashsdk.a.g.a());
                                        }
                                        V = true;
                                        if (Process.myPid() > 0) {
                                            Process.killProcess(Process.myPid());
                                            return;
                                        }
                                        return;
                                    }
                                }
                                z17 = false;
                                if (!z17) {
                                    b(false);
                                }
                                f.c(false);
                                i14 = g.i();
                                if (!com.uc.crashsdk.a.d.e()) {
                                }
                                com.uc.crashsdk.a.a.a("crashsdk", "Call java default handler: " + i14);
                                if (i14) {
                                    uncaughtExceptionHandler6.uncaughtException(thread, th);
                                }
                                if (com.uc.crashsdk.b.B()) {
                                    com.uc.crashsdk.b.b(com.uc.crashsdk.a.g.a());
                                }
                                V = true;
                                if (Process.myPid() > 0) {
                                }
                            }
                        } else {
                            if (z13) {
                                str = "omit";
                                com.uc.crashsdk.a.a.d("DEBUG", "omit java crash");
                            }
                            nativeClientCreateConnection = com.uc.crashsdk.b.f11609d ? JNIBridge.nativeClientCreateConnection(str, LogType.JAVA_TYPE, null, 0) : 0L;
                            int i19 = (nativeClientCreateConnection > 0L ? 1 : (nativeClientCreateConnection == 0L ? 0 : -1));
                            if (i19 == 0) {
                                com.uc.crashsdk.a.a.d("DEBUG", "skip java crash:");
                                a(th);
                                if (i19 != 0 && com.uc.crashsdk.b.f11609d) {
                                    JNIBridge.nativeClientCloseConnection(nativeClientCreateConnection);
                                }
                                if (z9) {
                                    try {
                                    } catch (Throwable th17) {
                                        th = th17;
                                        z15 = false;
                                    }
                                    if (g.r() && !z21) {
                                        try {
                                            a(true, false);
                                            z15 = true;
                                        } catch (Throwable th18) {
                                            th = th18;
                                            z15 = true;
                                            com.uc.crashsdk.a.g.a(th);
                                            if (!z15) {
                                            }
                                            f.c(false);
                                            i12 = g.i();
                                            if (!com.uc.crashsdk.a.d.e()) {
                                            }
                                            com.uc.crashsdk.a.a.a("crashsdk", "Call java default handler: " + i12);
                                            if (i12) {
                                            }
                                            if (com.uc.crashsdk.b.B()) {
                                            }
                                            V = true;
                                            if (Process.myPid() > 0) {
                                            }
                                        }
                                        if (!z15 && !z21) {
                                            b(false);
                                        }
                                        f.c(false);
                                        i12 = g.i();
                                        if (!com.uc.crashsdk.a.d.e()) {
                                            i12 = true;
                                        }
                                        com.uc.crashsdk.a.a.a("crashsdk", "Call java default handler: " + i12);
                                        if (i12 && (uncaughtExceptionHandler4 = T) != null) {
                                            uncaughtExceptionHandler4.uncaughtException(thread, th);
                                        }
                                        if (com.uc.crashsdk.b.B() && !z21) {
                                            com.uc.crashsdk.b.b(com.uc.crashsdk.a.g.a());
                                        }
                                        V = true;
                                        if (Process.myPid() > 0) {
                                            Process.killProcess(Process.myPid());
                                            return;
                                        }
                                        return;
                                    }
                                }
                                z15 = false;
                                if (!z15) {
                                    b(false);
                                }
                                f.c(false);
                                i12 = g.i();
                                if (!com.uc.crashsdk.a.d.e()) {
                                }
                                com.uc.crashsdk.a.a.a("crashsdk", "Call java default handler: " + i12);
                                if (i12) {
                                    uncaughtExceptionHandler4.uncaughtException(thread, th);
                                }
                                if (com.uc.crashsdk.b.B()) {
                                    com.uc.crashsdk.b.b(com.uc.crashsdk.a.g.a());
                                }
                                V = true;
                                if (Process.myPid() > 0) {
                                }
                            } else if (z13) {
                                if (i19 != 0 && com.uc.crashsdk.b.f11609d) {
                                    JNIBridge.nativeClientCloseConnection(nativeClientCreateConnection);
                                }
                                if (z9) {
                                    try {
                                    } catch (Throwable th19) {
                                        th = th19;
                                        z14 = false;
                                    }
                                    if (g.r() && !z21) {
                                        try {
                                            a(true, false);
                                            z14 = true;
                                        } catch (Throwable th20) {
                                            th = th20;
                                            z14 = true;
                                            com.uc.crashsdk.a.g.a(th);
                                            if (!z14) {
                                            }
                                            f.c(false);
                                            i11 = g.i();
                                            if (!com.uc.crashsdk.a.d.e()) {
                                            }
                                            com.uc.crashsdk.a.a.a("crashsdk", "Call java default handler: " + i11);
                                            if (i11) {
                                            }
                                            if (com.uc.crashsdk.b.B()) {
                                            }
                                            V = true;
                                            if (Process.myPid() > 0) {
                                            }
                                        }
                                        if (!z14 && !z21) {
                                            b(false);
                                        }
                                        f.c(false);
                                        i11 = g.i();
                                        if (!com.uc.crashsdk.a.d.e()) {
                                            i11 = true;
                                        }
                                        com.uc.crashsdk.a.a.a("crashsdk", "Call java default handler: " + i11);
                                        if (i11 && (uncaughtExceptionHandler3 = T) != null) {
                                            uncaughtExceptionHandler3.uncaughtException(thread, th);
                                        }
                                        if (com.uc.crashsdk.b.B() && !z21) {
                                            com.uc.crashsdk.b.b(com.uc.crashsdk.a.g.a());
                                        }
                                        V = true;
                                        if (Process.myPid() > 0) {
                                            Process.killProcess(Process.myPid());
                                            return;
                                        }
                                        return;
                                    }
                                }
                                z14 = false;
                                if (!z14) {
                                    b(false);
                                }
                                f.c(false);
                                i11 = g.i();
                                if (!com.uc.crashsdk.a.d.e()) {
                                }
                                com.uc.crashsdk.a.a.a("crashsdk", "Call java default handler: " + i11);
                                if (i11) {
                                    uncaughtExceptionHandler3.uncaughtException(thread, th);
                                }
                                if (com.uc.crashsdk.b.B()) {
                                    com.uc.crashsdk.b.b(com.uc.crashsdk.a.g.a());
                                }
                                V = true;
                                if (Process.myPid() > 0) {
                                }
                            }
                        }
                        boolean z222 = th instanceof OutOfMemoryError;
                        a(th, str, nativeClientCreateConnection, z222);
                        com.uc.crashsdk.a.a.d("DEBUG", "generate java report finished");
                        if (!com.uc.crashsdk.b.L() && z222 && g.j()) {
                            String name2 = new File(str).getName();
                            String W22 = g.W();
                            file = new File(W22);
                            if (!file.exists()) {
                                file.mkdirs();
                            }
                            String format2 = String.format(Locale.US, "%s%s.hprof", W22, name2);
                            com.uc.crashsdk.a.a.d("DEBUG", "begin dump hprof: " + format2);
                            long currentTimeMillis2 = System.currentTimeMillis();
                            Debug.dumpHprofData(format2);
                            com.uc.crashsdk.a.a.d("DEBUG", "end dump hprof, use " + (System.currentTimeMillis() - currentTimeMillis2) + " ms");
                        }
                        if (nativeClientCreateConnection != 0 && com.uc.crashsdk.b.f11609d) {
                            JNIBridge.nativeClientCloseConnection(nativeClientCreateConnection);
                        }
                        if (z9) {
                            try {
                            } catch (Throwable th21) {
                                th3 = th21;
                                z16 = false;
                            }
                            if (g.r() && !z21) {
                                try {
                                    a(true, false);
                                    z16 = true;
                                } catch (Throwable th22) {
                                    th3 = th22;
                                    z16 = true;
                                    com.uc.crashsdk.a.g.a(th3);
                                    if (!z16) {
                                    }
                                    f.c(false);
                                    i13 = g.i();
                                    if (!com.uc.crashsdk.a.d.e()) {
                                    }
                                    com.uc.crashsdk.a.a.a("crashsdk", "Call java default handler: " + i13);
                                    if (i13) {
                                    }
                                    if (com.uc.crashsdk.b.B()) {
                                    }
                                    V = true;
                                    if (Process.myPid() <= 0) {
                                    }
                                }
                                if (!z16 && !z21) {
                                    b(false);
                                }
                                f.c(false);
                                i13 = g.i();
                                if (!com.uc.crashsdk.a.d.e()) {
                                    i13 = true;
                                }
                                com.uc.crashsdk.a.a.a("crashsdk", "Call java default handler: " + i13);
                                if (i13 && (uncaughtExceptionHandler5 = T) != null) {
                                    uncaughtExceptionHandler5.uncaughtException(thread, th);
                                }
                                if (com.uc.crashsdk.b.B() && !z21) {
                                    com.uc.crashsdk.b.b(com.uc.crashsdk.a.g.a());
                                }
                                V = true;
                                if (Process.myPid() <= 0) {
                                    Process.killProcess(Process.myPid());
                                    return;
                                }
                                return;
                            }
                        }
                        z16 = false;
                        if (!z16) {
                            b(false);
                        }
                        f.c(false);
                        i13 = g.i();
                        if (!com.uc.crashsdk.a.d.e()) {
                        }
                        com.uc.crashsdk.a.a.a("crashsdk", "Call java default handler: " + i13);
                        if (i13) {
                            uncaughtExceptionHandler5.uncaughtException(thread, th);
                        }
                        if (com.uc.crashsdk.b.B()) {
                            com.uc.crashsdk.b.b(com.uc.crashsdk.a.g.a());
                        }
                        V = true;
                        if (Process.myPid() <= 0) {
                        }
                    } catch (Throwable th23) {
                        th = th23;
                        try {
                            com.uc.crashsdk.a.a.d("DEBUG", "exception occurs while java log: " + th);
                            a(th);
                            if (!z10) {
                                com.uc.crashsdk.a.a.d("DEBUG", "original exception is: " + th);
                                a(th);
                            }
                            if (j9 != 0 && com.uc.crashsdk.b.f11609d) {
                                JNIBridge.nativeClientCloseConnection(j9);
                            }
                            if (z9) {
                                try {
                                } catch (Throwable th24) {
                                    th2 = th24;
                                    z12 = false;
                                }
                                if (g.r() && !z21) {
                                    try {
                                        a(true, false);
                                        z12 = true;
                                    } catch (Throwable th25) {
                                        th2 = th25;
                                        z12 = true;
                                        com.uc.crashsdk.a.g.a(th2);
                                        if (!z12 && !z21) {
                                            b(false);
                                        }
                                        f.c(false);
                                        i10 = g.i();
                                        if (!com.uc.crashsdk.a.d.e()) {
                                            i10 = true;
                                        }
                                        com.uc.crashsdk.a.a.a("crashsdk", "Call java default handler: " + i10);
                                        if (i10 && (uncaughtExceptionHandler2 = T) != null) {
                                            uncaughtExceptionHandler2.uncaughtException(thread, th);
                                        }
                                        if (com.uc.crashsdk.b.B() && !z21) {
                                            com.uc.crashsdk.b.b(com.uc.crashsdk.a.g.a());
                                        }
                                        V = true;
                                        if (Process.myPid() > 0) {
                                            Process.killProcess(Process.myPid());
                                            return;
                                        }
                                        return;
                                    }
                                    if (!z12) {
                                        b(false);
                                    }
                                    f.c(false);
                                    i10 = g.i();
                                    if (!com.uc.crashsdk.a.d.e()) {
                                    }
                                    com.uc.crashsdk.a.a.a("crashsdk", "Call java default handler: " + i10);
                                    if (i10) {
                                        uncaughtExceptionHandler2.uncaughtException(thread, th);
                                    }
                                    if (com.uc.crashsdk.b.B()) {
                                        com.uc.crashsdk.b.b(com.uc.crashsdk.a.g.a());
                                    }
                                    V = true;
                                    if (Process.myPid() > 0) {
                                    }
                                }
                            }
                            z12 = false;
                            if (!z12) {
                            }
                            f.c(false);
                            i10 = g.i();
                            if (!com.uc.crashsdk.a.d.e()) {
                            }
                            com.uc.crashsdk.a.a.a("crashsdk", "Call java default handler: " + i10);
                            if (i10) {
                            }
                            if (com.uc.crashsdk.b.B()) {
                            }
                            V = true;
                            if (Process.myPid() > 0) {
                            }
                        } catch (Throwable th26) {
                            if (j9 != 0 && com.uc.crashsdk.b.f11609d) {
                                JNIBridge.nativeClientCloseConnection(j9);
                            }
                            if (z9) {
                                try {
                                } catch (Throwable th27) {
                                    th = th27;
                                    z11 = false;
                                }
                                if (g.r() && !z21) {
                                    try {
                                        a(true, false);
                                        z11 = true;
                                    } catch (Throwable th28) {
                                        th = th28;
                                        z11 = true;
                                        com.uc.crashsdk.a.g.a(th);
                                        if (!z11 && !z21) {
                                            b(false);
                                        }
                                        f.c(false);
                                        i9 = g.i();
                                        if (!com.uc.crashsdk.a.d.e()) {
                                            i9 = true;
                                        }
                                        com.uc.crashsdk.a.a.a("crashsdk", "Call java default handler: " + i9);
                                        if (i9 && (uncaughtExceptionHandler = T) != null) {
                                            uncaughtExceptionHandler.uncaughtException(thread, th);
                                        }
                                        if (com.uc.crashsdk.b.B() && !z21) {
                                            com.uc.crashsdk.b.b(com.uc.crashsdk.a.g.a());
                                        }
                                        V = true;
                                        if (Process.myPid() > 0) {
                                            Process.killProcess(Process.myPid());
                                        }
                                        throw th26;
                                    }
                                    if (!z11) {
                                        b(false);
                                    }
                                    f.c(false);
                                    i9 = g.i();
                                    if (!com.uc.crashsdk.a.d.e()) {
                                    }
                                    com.uc.crashsdk.a.a.a("crashsdk", "Call java default handler: " + i9);
                                    if (i9) {
                                        uncaughtExceptionHandler.uncaughtException(thread, th);
                                    }
                                    if (com.uc.crashsdk.b.B()) {
                                        com.uc.crashsdk.b.b(com.uc.crashsdk.a.g.a());
                                    }
                                    V = true;
                                    if (Process.myPid() > 0) {
                                    }
                                    throw th26;
                                }
                            }
                            z11 = false;
                            if (!z11) {
                            }
                            f.c(false);
                            i9 = g.i();
                            if (!com.uc.crashsdk.a.d.e()) {
                            }
                            com.uc.crashsdk.a.a.a("crashsdk", "Call java default handler: " + i9);
                            if (i9) {
                            }
                            if (com.uc.crashsdk.b.B()) {
                            }
                            V = true;
                            if (Process.myPid() > 0) {
                            }
                            throw th26;
                        }
                    }
                }
            }
        } catch (Throwable th29) {
            th = th29;
            z10 = false;
            j9 = 0;
        }
    }

    private static void a(Throwable th) {
        try {
            com.uc.crashsdk.a.a.d("DEBUG", a(th.getStackTrace(), (String) null).toString());
        } catch (Throwable unused) {
        }
    }

    private static void a(Calendar calendar) {
        if (g.Q()) {
            long timeInMillis = calendar.getTimeInMillis();
            calendar.add(5, 1);
            calendar.set(11, 0);
            calendar.set(12, 0);
            calendar.set(13, 0);
            long timeInMillis2 = calendar.getTimeInMillis();
            long j9 = timeInMillis2 - timeInMillis;
            com.uc.crashsdk.a.f.a(0, new com.uc.crashsdk.a.e(415, new Object[]{Long.valueOf(timeInMillis2)}), j9 <= 3600000 ? 1000 + j9 : 3600000L);
        }
    }

    public static StringBuilder a(StackTraceElement[] stackTraceElementArr, String str) {
        StringBuilder sb = new StringBuilder();
        int i9 = 0;
        if (stackTraceElementArr != null && stackTraceElementArr.length > 0) {
            boolean z9 = str == null;
            int i10 = 0;
            for (StackTraceElement stackTraceElement : stackTraceElementArr) {
                i10++;
                sb.append("  at ");
                sb.append(stackTraceElement.toString());
                sb.append("\n");
                if (!z9 && stackTraceElement.getMethodName().contains(str)) {
                    sb.delete(0, sb.length());
                    i10 = 0;
                    z9 = true;
                }
            }
            i9 = i10;
        }
        if (i9 == 0) {
            sb.append("  (no java stack)\n");
        }
        return sb;
    }

    public static boolean a(ParcelFileDescriptor parcelFileDescriptor) {
        if (af) {
            com.uc.crashsdk.a.a.d("crashsdk", "Can not call setHostFd and getHostFd in the same process!");
            return false;
        } else if (!com.uc.crashsdk.b.f11609d) {
            com.uc.crashsdk.a.a.d("crashsdk", "Crash so is not loaded!");
            return false;
        } else {
            if (ae != null) {
                com.uc.crashsdk.a.a.c("crashsdk", "Has already set host fd!");
            }
            ae = parcelFileDescriptor;
            int fd = parcelFileDescriptor.getFd();
            int nativeCmd = (int) JNIBridge.nativeCmd(13, fd, null, null);
            ag = nativeCmd != -1;
            return fd == -1 || nativeCmd != -1;
        }
    }
}