野火视频 v2.3.5版本的 MD5 值为:102ebe58fcb84dd006410b5d2f5a93ba

以下内容为反编译后的 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 androidx.appcompat.widget.ActivityChooserModel;
import androidx.core.app.NotificationCompat;
import com.google.android.exoplayer2.C;
import com.google.android.exoplayer2.ExoPlayer;
import com.google.android.exoplayer2.extractor.ts.TsExtractor;
import com.google.android.exoplayer2.source.rtsp.SessionDescription;
import com.google.android.exoplayer2.text.ttml.TtmlNode;
import com.uc.crashsdk.a.h;
import com.uc.crashsdk.export.CrashStatKey;
import com.uc.crashsdk.export.LogType;
import com.zhy.http.okhttp.OkHttpUtils;
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 tv.danmaku.ijk.media.player.IMediaPlayer;
import tv.danmaku.ijk.media.player.IjkMediaCodecInfo;
public class e implements Thread.UncaughtExceptionHandler {
    private static long f2907b;
    private static String f2913i;
    private final List<FileInputStream> f2931e = new ArrayList();
    public static final boolean f2906a = true;
    private static final AtomicBoolean f2908c = new AtomicBoolean(false);
    private static boolean f2909d = false;
    private static long f2910f = 0;
    private static long f2911g = -1;
    private static boolean f2912h = true;
    private static String f2914j = "";
    private static String f2915k = null;
    private static String f2916l = null;
    private static String f2917m = null;
    private static final Object f2918n = new Object();
    private static final ConditionVariable f2919o = new ConditionVariable();
    private static final Object f2920p = new Object();
    private static final Object f2921q = new Object();
    private static final Object f2922r = new Object();
    private static final ArrayList<String> f2923s = new ArrayList<>();
    private static int f2924t = 0;
    private static String f2925u = null;
    private static boolean f2926v = false;
    private static String f2927w = null;
    private static String f2928x = null;
    private static final Object f2929y = new Object();
    private static final Object f2930z = 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;
        }

        public b(byte b4) {
            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(NotificationCompat.CATEGORY_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);
                }
            }
        }

        public c(byte b4) {
            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), OkHttpUtils.DEFAULT_MILLISECONDS);
        }
    }

    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 z3 = true;
        boolean z4 = false;
        if (L2 == 0 || L2 == 3 || L2 == 4) {
            if (Build.VERSION.SDK_INT <= 25) {
                boolean z5 = L2 != 0;
                if (L2 == 3) {
                    z5 = System.currentTimeMillis() % 10 == 0;
                }
                if (L2 != 4) {
                    z3 = z5;
                }
            }
        }
        if (!z3) {
            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() || !z3) {
            z4 = z3;
        } else {
            com.uc.crashsdk.a.f.a(2, new com.uc.crashsdk.a.e(413));
        }
        JNIBridge.nativeCmd(7, L3 ? 1L : 0L, null, null);
        if (z4) {
            JNIBridge.cmd(8);
        }
    }

    public static ParcelFileDescriptor E() {
        if (!com.uc.crashsdk.b.f2874d) {
            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;
                }
            }
        }
    }

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

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

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

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

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

    private void N() {
        for (FileInputStream fileInputStream : this.f2931e) {
            com.uc.crashsdk.a.g.a(fileInputStream);
        }
        this.f2931e.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 i4 = 1024;
        while (bArr == null && i4 > 0) {
            try {
                bArr = new byte[i4];
            } catch (Throwable unused) {
                i4 /= 2;
                if (i4 < 16) {
                    break;
                }
            }
        }
        return bArr;
    }

    private static String S() {
        return (!com.uc.crashsdk.b.F() || f2909d) ? 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 i4 = 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();
                        }
                        i4++;
                    } 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);
                            f2915k = str;
                            f2916l = str2;
                        } catch (Throwable th4) {
                            com.uc.crashsdk.a.g.a(fileReader);
                            com.uc.crashsdk.a.g.a(bufferedReader);
                            throw th4;
                        }
                    }
                } while (i4 < 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);
        f2915k = str;
        f2916l = 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 i4 = G;
            String str2 = i4 != 0 ? i4 != 1 ? i4 != 2 ? i4 != 4 ? " (?)" : " (Wireless)" : " (USB port)" : " (AC charger)" : " (None)";
            sb.append("pluged: ");
            sb.append(G);
            sb.append(str2);
            sb.append("\n");
            int i5 = H;
            String str3 = i5 != 1 ? i5 != 2 ? i5 != 3 ? i5 != 4 ? i5 != 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.f2873c && L && com.uc.crashsdk.a.f2793c) {
            L = false;
            if (com.uc.crashsdk.a.f.b(P)) {
                return;
            }
            com.uc.crashsdk.a.f.a(0, P, ExoPlayer.DEFAULT_DETACH_SURFACE_TIMEOUT_MS);
        }
    }

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

    private static boolean aa() {
        return com.uc.crashsdk.b.f2874d && 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;
                    int i4 = length < 0 ? 0 : length;
                    long currentTimeMillis = System.currentTimeMillis();
                    int i5 = 0;
                    int i6 = 0;
                    while (i5 < listFiles.length) {
                        File file2 = listFiles[i5];
                        boolean z3 = i5 < i4;
                        if (!z3 && currentTimeMillis - file2.lastModified() >= 432000000) {
                            z3 = true;
                        }
                        if (!z3) {
                            break;
                        }
                        file2.delete();
                        i6++;
                        if (0 >= 3) {
                            break;
                        }
                        i5++;
                    }
                    com.uc.crashsdk.a.a.a("Removed " + i6 + " logs in " + W2);
                }
            } catch (Throwable th) {
                com.uc.crashsdk.a.g.a(th);
            }
        }
    }

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

    private static String j(String str) {
        if (str == null) {
            StringBuilder a4 = android.support.v4.media.e.a(String.valueOf(System.currentTimeMillis()));
            a4.append(new Random().nextInt(65536));
            str = a4.toString();
        }
        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 a4 = com.uc.crashsdk.a.b.a(str, g.w(), g.v());
        if (!str.equals(a4)) {
            File file = new File(str);
            if (file.exists()) {
                file.delete();
            }
        }
        return a4;
    }

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

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

    private static boolean p(String str) {
        boolean z3;
        boolean z4;
        int i4;
        Integer num;
        synchronized (f2930z) {
            z3 = false;
            if (A == null) {
                A = q(com.uc.crashsdk.a.g.a(com.uc.crashsdk.b.l(), "all:1", false));
            }
            if (A.containsKey(TtmlNode.COMBINE_ALL)) {
                num = A.get(TtmlNode.COMBINE_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)) {
                    z4 = false;
                    if (!z4 && A.containsKey("crash")) {
                        num = A.get("crash");
                    } else if (z4 && A.containsKey("nocrash")) {
                        num = A.get("nocrash");
                    } else if (A.containsKey("other")) {
                        i4 = 1;
                        if (i4 != 0) {
                            long j4 = i4;
                            if (j4 < 0) {
                                long j5 = 30;
                                if (j4 == -2) {
                                    j5 = 7;
                                } else if (j4 == -3) {
                                    j5 = 15;
                                } else if (j4 == -4) {
                                    j5 = 60;
                                }
                                long b4 = com.uc.crashsdk.a.b();
                                long currentTimeMillis = b4 == 0 ? -1L : (System.currentTimeMillis() - b4) / 86400000;
                                j4 = currentTimeMillis <= j5 ? 1L : currentTimeMillis - j5;
                            }
                            if (j4 != 1) {
                                if (j4 > 0) {
                                    if (System.currentTimeMillis() % j4 == 0) {
                                    }
                                }
                            }
                            z3 = true;
                        }
                    } else {
                        num = A.get("other");
                    }
                }
                z4 = true;
                if (!z4) {
                }
                if (z4) {
                }
                if (A.containsKey("other")) {
                }
            }
            i4 = num.intValue();
            if (i4 != 0) {
            }
        }
        return z3;
    }

    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 i4 = 1;
                    try {
                        i4 = Integer.parseInt(split[1].trim(), 10);
                    } catch (Throwable th) {
                        com.uc.crashsdk.a.g.a(th);
                    }
                    hashMap.put(trim, Integer.valueOf(i4));
                }
            }
        }
        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 f2908c.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 o4 = g.o();
        if (o4 < 0) {
            return;
        }
        boolean z3 = com.uc.crashsdk.b.I() == 5;
        com.uc.crashsdk.a.f.a(0, new com.uc.crashsdk.a.e(401));
        if (z3) {
            com.uc.crashsdk.a.e eVar = new com.uc.crashsdk.a.e(402);
            X = eVar;
            com.uc.crashsdk.a.f.a(0, eVar, o4);
        }
    }

    public static void y() {
        if (com.uc.crashsdk.b.f2873c && com.uc.crashsdk.a.f2793c && !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 = f2913i;
        if (str != null) {
            return str;
        }
        String j4 = j(null);
        f2913i = j4;
        return j4;
    }

    public static String e() {
        String str;
        String str2;
        Method declaredMethod;
        String str3;
        String str4;
        boolean z3;
        if (!com.uc.crashsdk.a.g.a(f2914j)) {
            return f2914j;
        }
        String str5 = null;
        try {
            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 i4 = 0;
                boolean z4 = true;
                while (i4 < length) {
                    String str6 = strArr[i4];
                    if (!z4) {
                        sb.append(",");
                    }
                    sb.append(str6);
                    i4++;
                    z4 = false;
                }
                f2914j = sb.toString();
            }
        } catch (Throwable unused) {
        }
        if (com.uc.crashsdk.a.g.a(f2914j)) {
            try {
                str3 = Build.CPU_ABI;
            } catch (Throwable unused2) {
                str3 = null;
            }
            try {
                str4 = Build.CPU_ABI2;
            } catch (Throwable unused3) {
                str4 = null;
                z3 = !com.uc.crashsdk.a.g.a(str3);
                if (z3) {
                }
                if (!com.uc.crashsdk.a.g.a(str4)) {
                }
                declaredMethod = Class.forName("android.os.SystemProperties").getDeclaredMethod("get", String.class, String.class);
                if (declaredMethod == null) {
                }
            }
            z3 = !com.uc.crashsdk.a.g.a(str3);
            if (z3) {
                f2914j = str3;
            }
            if (!com.uc.crashsdk.a.g.a(str4)) {
                if (z3) {
                    f2914j = android.support.v4.media.d.a(new StringBuilder(), f2914j, ",");
                    f2914j = android.support.v4.media.d.a(new StringBuilder(), f2914j, str4);
                } else {
                    f2914j = 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 f2914j;
            }
            str5 = str;
            try {
                if (!com.uc.crashsdk.a.g.a(str5) && !f2914j.contains(str5)) {
                    f2914j += ",";
                    f2914j += str5;
                }
                if (!com.uc.crashsdk.a.g.a(str2) && !f2914j.contains(str2)) {
                    f2914j += ",";
                    f2914j += str2;
                }
            } catch (Throwable th3) {
                com.uc.crashsdk.a.g.a(th3);
            }
            return f2914j;
        }
        str2 = null;
        if (!com.uc.crashsdk.a.g.a(str5)) {
            f2914j += ",";
            f2914j += str5;
        }
        if (!com.uc.crashsdk.a.g.a(str2)) {
            f2914j += ",";
            f2914j += str2;
        }
        return f2914j;
    }

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

    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 "unknown";
        }
    }

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

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

    public static boolean i() {
        return f2909d;
    }

    public static boolean b(int i4, Object[] objArr) {
        if (i4 == 451) {
            if (f2906a || objArr != null) {
                return a((String) objArr[0], (d) objArr[1]);
            }
            throw new AssertionError();
        } else if (i4 != 452) {
            if (f2906a) {
                return false;
            }
            throw new AssertionError();
        } else if (f2906a || 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.f2937a), Long.valueOf(dVar.f2938b), Integer.valueOf(dVar.f2939c), Integer.valueOf(dVar.f2940d)).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(C.UTF8_NAME));
        } catch (Throwable th2) {
            a(th2, outputStream);
        }
        if (ag) {
            f2912h = false;
            try {
                outputStream.write(s("FSSTAT").getBytes(C.UTF8_NAME));
            } catch (Throwable th3) {
                a(th3, outputStream);
            }
            f2912h = 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() / 1024);
            sb.append(" kB\n");
            sb.append("JavaTotal:  ");
            sb.append(Runtime.getRuntime().totalMemory() / 1024);
            sb.append(" kB\n");
            sb.append("JavaFree:   ");
            sb.append(Runtime.getRuntime().freeMemory() / 1024);
            sb.append(" kB\n");
            sb.append("NativeHeap: ");
            sb.append(Debug.getNativeHeapSize() / 1024);
            sb.append(" kB\n");
            sb.append("NativeAllocated: ");
            sb.append(Debug.getNativeHeapAllocatedSize() / 1024);
            sb.append(" kB\n");
            sb.append("NativeFree: ");
            sb.append(Debug.getNativeHeapFreeSize() / 1024);
            sb.append(" kB\n");
            ActivityManager activityManager = (ActivityManager) com.uc.crashsdk.a.g.a().getSystemService(ActivityChooserModel.ATTRIBUTE_ACTIVITY);
            if (activityManager != null) {
                ActivityManager.MemoryInfo memoryInfo = new ActivityManager.MemoryInfo();
                activityManager.getMemoryInfo(memoryInfo);
                sb.append("availMem:   ");
                sb.append(memoryInfo.availMem / 1024);
                sb.append(" kB\n");
                sb.append("threshold:  ");
                sb.append(memoryInfo.threshold / 1024);
                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.f2874d) {
            String o4 = com.uc.crashsdk.b.o();
            f2912h = false;
            if (1 == JNIBridge.cmd(17, o4)) {
                File file = new File(o4);
                try {
                    byte[] e4 = com.uc.crashsdk.a.g.e(file);
                    if (e4 != null) {
                        outputStream.write(e4);
                    }
                } catch (Throwable th) {
                    a(th, outputStream);
                }
                try {
                    file.delete();
                } catch (Throwable th2) {
                    a(th2, outputStream);
                }
                f2912h = true;
                a(outputStream);
            }
            f2912h = true;
            return;
        }
        File[] fileArr = null;
        int i4 = IMediaPlayer.MEDIA_INFO_TIMED_TEXT_ERROR;
        try {
            i4 = 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(i4)).getBytes(C.UTF8_NAME));
            } else {
                outputStream.write("[DEBUG] listFiles failed!\n".getBytes(C.UTF8_NAME));
            }
        } catch (Throwable th3) {
            a(th3, outputStream);
        }
        if (fileArr != null) {
            try {
                if (fileArr.length >= i4) {
                    outputStream.write("opened files:\n".getBytes(C.UTF8_NAME));
                    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(C.UTF8_NAME));
                }
            } catch (Throwable th4) {
                a(th4, outputStream);
            }
        }
        a(outputStream);
    }

    private static void f(OutputStream outputStream) {
        BufferedReader bufferedReader;
        int indexOf;
        boolean z3;
        if (com.uc.crashsdk.b.f2874d) {
            try {
                outputStream.write("solib build id:\n".getBytes(C.UTF8_NAME));
            } 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.f2791a)) {
                                    z3 = false;
                                    if (z3 && !arrayList.contains(substring)) {
                                        arrayList.add(substring);
                                        if (!ag) {
                                            outputStream.write((String.format("$^%s`%s^$", "SOBUILDID", substring) + "\n").getBytes(C.UTF8_NAME));
                                        } else {
                                            outputStream.write(String.format(Locale.US, "%s: %s\n", substring, JNIBridge.nativeGet(3, 0L, substring)).getBytes(C.UTF8_NAME));
                                        }
                                    }
                                }
                                z3 = true;
                                if (z3) {
                                    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 = f2928x;
        if (com.uc.crashsdk.a.g.a(str)) {
            synchronized (f2929y) {
                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);
                f2928x = str;
            }
        }
        return str;
    }

    public static void l() {
        synchronized (f2929y) {
            f2928x = null;
        }
    }

    public static void a(int i4, Object[] objArr) {
        int i5;
        switch (i4) {
            case 401:
                JNIBridge.nativeCmd(10, com.uc.crashsdk.b.I() == 5 ? 1L : 0L, null, null);
                com.uc.crashsdk.a.f2793c = 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 & 4352) != 0) {
                                Z = 105;
                                i5 = 30;
                            } else if ((nativeGenerateUnexpLog & LogType.UNEXP_EXIT) != 0) {
                                Z = 104;
                                i5 = 31;
                            } else if ((nativeGenerateUnexpLog & LogType.UNEXP_RESTART) != 0) {
                                Z = 106;
                                i5 = 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(i5);
                            a(true);
                        }
                        synchronized (obj) {
                            X = null;
                        }
                        return;
                    }
                }
            case 403:
                ab();
                return;
            case 404:
            default:
                if (!f2906a) {
                    throw new AssertionError();
                }
                return;
            case 405:
                L = false;
                StringBuilder Y2 = Y();
                String g4 = com.uc.crashsdk.b.g();
                if (Y2 != null) {
                    com.uc.crashsdk.a.g.a(new File(g4), Y2.toString());
                    return;
                }
                return;
            case 406:
                if (!f2906a && 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.f2874d) {
                    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 i6 = N + 1;
                    N = i6;
                    if (i6 < 10) {
                        X();
                        return;
                    } else if (com.uc.crashsdk.b.f2874d) {
                        JNIBridge.set((int) TsExtractor.TS_STREAM_TYPE_HDMV_DTS, "(get failed)");
                        return;
                    } else {
                        return;
                    }
                } catch (Throwable th3) {
                    com.uc.crashsdk.a.g.a(th3);
                    return;
                }
            case 415:
                if (!f2906a && 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 f2932a;
        private final OutputStream f2933b;
        private int f2934c = 0;
        private int f2935d = 0;
        private boolean f2936e = false;

        public a(long j4, OutputStream outputStream) {
            this.f2932a = j4;
            this.f2933b = outputStream;
        }

        private int a(byte[] bArr, int i4, int i5) {
            int i6;
            this.f2935d += i5;
            if (this.f2936e) {
                return 0;
            }
            int y3 = g.y();
            if (y3 > 0) {
                int i7 = this.f2934c;
                if (i7 + i5 > y3) {
                    i6 = y3 - i7;
                    this.f2934c += i6;
                    if (this.f2932a == 0) {
                        b(new String(bArr, i4, i6));
                    } else {
                        this.f2933b.write(bArr, i4, i6);
                    }
                    if (i6 < i5) {
                        this.f2936e = true;
                    }
                    return i6;
                }
            }
            i6 = i5;
            this.f2934c += i6;
            if (this.f2932a == 0) {
            }
            if (i6 < i5) {
            }
            return i6;
        }

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

        @Override
        public final void write(int i4) {
            if (e.f2912h && e.I()) {
                com.uc.crashsdk.a.a.d("DEBUG", String.format(Locale.US, "%c", Integer.valueOf(i4)));
            }
            if (this.f2932a != 0) {
                b(String.format(Locale.US, "%c", Integer.valueOf(i4)));
            } else {
                this.f2933b.write(i4);
            }
            this.f2934c++;
            this.f2935d++;
        }

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

        public final void a() {
            try {
                if (this.f2935d - this.f2934c > 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.f2935d), Integer.valueOf(this.f2934c), Integer.valueOf(g.y()), Integer.valueOf(this.f2935d - this.f2934c)));
            } catch (Throwable th) {
                com.uc.crashsdk.a.g.a(th);
            }
        }

        @Override
        public final void write(byte[] bArr) {
            if (e.f2912h && 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);
        }

        public final void a(String str) {
            if (e.f2912h && e.I()) {
                com.uc.crashsdk.a.a.d("DEBUG", str);
            }
            if (this.f2932a != 0) {
                b(str);
            } else {
                this.f2933b.write(str.getBytes(C.UTF8_NAME));
            }
        }
    }

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

    public static class d {
        public long f2937a;
        public long f2938b;
        public int f2939c;
        public int f2940d;
        public boolean f2941e;
        public boolean f2942f;
        public boolean f2943g;

        private d() {
            this.f2937a = 0L;
            this.f2938b = 0L;
            this.f2939c = 0;
            this.f2940d = 0;
            this.f2941e = false;
            this.f2942f = false;
            this.f2943g = false;
        }

        public d(byte b4) {
            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 e4) {
                                com.uc.crashsdk.a.g.a(e4);
                            }
                        }
                        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(C.UTF8_NAME));
        } 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(C.UTF8_NAME));
            Object[] objArr = new Object[3];
            objArr[0] = e();
            if (com.uc.crashsdk.a.g.a(f2916l)) {
                T();
            }
            objArr[1] = f2916l;
            objArr[2] = f();
            outputStream.write(String.format(locale, "Cpu Information: 'abi: %s/processor: %s/hardware: %s'\n", objArr).getBytes(C.UTF8_NAME));
        } 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(C.UTF8_NAME));
            outputStream.write(("Build fingerprint: '" + Build.FINGERPRINT + "'\n").getBytes(C.UTF8_NAME));
            Object[] objArr2 = new Object[4];
            objArr2[0] = a(new Date(f2907b));
            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(C.UTF8_NAME));
        } 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(C.UTF8_NAME));
            String str5 = SessionDescription.SUPPORTED_SDP_VERSION;
            String str6 = "";
            if (com.uc.crashsdk.b.f2874d) {
                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(C.UTF8_NAME));
            if (str != null) {
                str6 = str;
            }
            outputStream.write(("Report Name: " + str6.substring(str6.lastIndexOf(47) + 1) + "\n").getBytes(C.UTF8_NAME));
        } catch (Throwable th4) {
            a(th4, outputStream);
        }
        try {
            if (ag) {
                str3 = s("UUID");
            } else {
                str3 = B;
            }
            outputStream.write(String.format("UUID: %s\n", str3).getBytes(C.UTF8_NAME));
            outputStream.write(("Log Type: " + str2 + "\n").getBytes(C.UTF8_NAME));
        } 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(C.UTF8_NAME));
        } catch (Throwable th6) {
            a(th6, outputStream);
        }
        a(outputStream);
        try {
            com.uc.crashsdk.a.a(outputStream, C.UTF8_NAME);
            if (ag) {
                f2912h = false;
                outputStream.write(s("HEADER").getBytes(C.UTF8_NAME));
                f2912h = true;
            }
        } catch (Throwable th7) {
            a(th7, outputStream);
        }
        a(outputStream);
    }

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

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

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

    public static void c(boolean z3) {
        boolean z4 = true;
        if (!R ? !z3 || !g.K() : z3 && g.K()) {
            z4 = false;
        }
        if (z4) {
            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, C.DEFAULT_MAX_SEEK_TO_PREVIOUS_POSITION_MS);
        }
    }

    public static void a(boolean z3) {
        File[] listFiles;
        try {
            if (com.uc.crashsdk.b.y() && (listFiles = new File(g.V()).listFiles()) != null) {
                int l4 = g.l();
                int m4 = g.m();
                if (listFiles.length < Math.min(l4, m4)) {
                    return;
                }
                int i4 = 0;
                int i5 = 0;
                for (File file : listFiles) {
                    if (b(file)) {
                        i4++;
                    } else {
                        i5++;
                    }
                }
                int i6 = (!z3 || i4 < l4) ? 0 : (i4 - l4) + 1;
                int i7 = (z3 || i5 < m4) ? 0 : (i5 - m4) + 1;
                if (i6 == 0 && i7 == 0) {
                    return;
                }
                Arrays.sort(listFiles, new b((byte) 0));
                int i8 = i6;
                int i9 = i7;
                for (File file2 : listFiles) {
                    boolean b4 = b(file2);
                    if (b4 && i8 > 0) {
                        com.uc.crashsdk.a.a.a("crashsdk", "Delete oldest crash log: " + file2.getPath());
                        file2.delete();
                        i8 += -1;
                    } else if (!b4 && i9 > 0) {
                        com.uc.crashsdk.a.a.a("crashsdk", "Delete oldest custom log: " + file2.getPath());
                        file2.delete();
                        i9 += -1;
                    }
                    if (i8 == 0 && i9 == 0) {
                        break;
                    }
                }
                f.a(16, i6 + i7);
                if (i6 > 0) {
                    f.a(22, i6);
                }
                if (i7 > 0) {
                    f.a(23, i7);
                }
            }
        } catch (Throwable th) {
            com.uc.crashsdk.a.g.a(th);
        }
    }

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

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

    private static void e(OutputStream outputStream) {
        int i4;
        int i5;
        File[] fileArr = null;
        try {
            i4 = g.I();
            try {
                fileArr = new File("/proc/self/task").listFiles();
            } catch (Throwable th) {
                th = th;
                com.uc.crashsdk.a.g.a(th);
                i5 = 0;
                if (fileArr != null) {
                }
            }
        } catch (Throwable th2) {
            th = th2;
            i4 = IjkMediaCodecInfo.RANK_SECURE;
        }
        if (fileArr == null) {
            return;
        }
        i5 = fileArr.length;
        if (i5 < i4) {
            return;
        }
        if (fileArr != null) {
            return;
        }
        try {
            outputStream.write("threads info:\n".getBytes(C.UTF8_NAME));
            outputStream.write(String.format(Locale.US, "threads count: %d, dump limit: %d.\n", Integer.valueOf(i5), Integer.valueOf(i4)).getBytes(C.UTF8_NAME));
            outputStream.write(" tid     name\n".getBytes(C.UTF8_NAME));
            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(C.UTF8_NAME));
            }
        } catch (Throwable th3) {
            a(th3, outputStream);
        }
        a(outputStream);
    }

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

    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(ActivityChooserModel.ATTRIBUTE_ACTIVITY);
        boolean z3 = false;
        if (activityManager == null || (processesInErrorState = activityManager.getProcessesInErrorState()) == null) {
            return false;
        }
        int myPid = Process.myPid();
        Iterator<ActivityManager.ProcessErrorStateInfo> it = processesInErrorState.iterator();
        while (true) {
            if (!it.hasNext()) {
                break;
            }
            ActivityManager.ProcessErrorStateInfo next = it.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.f2874d) {
                    JNIBridge.set((int) TsExtractor.TS_STREAM_TYPE_HDMV_DTS, next.longMsg);
                }
                z3 = true;
            }
        }
        if (!z3 && com.uc.crashsdk.b.f2874d) {
            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 b4 = com.uc.crashsdk.a.g.b(str);
            boolean b5 = com.uc.crashsdk.a.g.b(str2);
            ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
            while (true) {
                String readLine = bufferedReader.readLine();
                if (readLine != null) {
                    boolean z3 = true;
                    if ((!b4 || !readLine.contains(str)) && ((!b5 || !readLine.contains(str2)) && (readLine.indexOf(47) >= 0 || readLine.indexOf(46) <= 0))) {
                        z3 = false;
                    }
                } else {
                    return byteArrayOutputStream.toString(C.UTF8_NAME);
                }
            }
        } catch (Throwable th) {
            com.uc.crashsdk.a.g.a(th);
            return "exception exists.";
        }
    }

    public static void d(boolean z3) {
        f.d(false);
        if (z3) {
            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 z3) {
        return f.a(z3);
    }

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

    private static void a(OutputStream outputStream) {
        try {
            outputStream.write("--- --- --- --- --- --- --- --- --- --- --- --- --- --- --- ---\n".getBytes(C.UTF8_NAME));
        } 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 a4 = a(statFs, "getBlockCountLong", "getBlockCount");
            long a5 = a(statFs, "getBlockSizeLong", "getBlockSize");
            if ((a4 / 1024) * a5 < 10240) {
                return;
            }
            long a6 = a(statFs, "getAvailableBlocksLong", "getAvailableBlocks");
            long a7 = a(statFs, "getFreeBlocksLong", "getFreeBlocks");
            try {
                Locale locale = Locale.US;
                outputStream.write(String.format(locale, "%s:\n", str).getBytes(C.UTF8_NAME));
                double d4 = a5;
                outputStream.write(String.format(locale, "  total:      %d kB\n", Long.valueOf((long) (((a4 * 1.0d) * d4) / 1024.0d))).getBytes(C.UTF8_NAME));
                outputStream.write(String.format(locale, "  available:  %d kB\n", Long.valueOf((long) (((a6 * 1.0d) * d4) / 1024.0d))).getBytes(C.UTF8_NAME));
                outputStream.write(String.format(locale, "  free:       %d kB\n", Long.valueOf((long) (((a7 * 1.0d) * d4) / 1024.0d))).getBytes(C.UTF8_NAME));
                outputStream.write(String.format(locale, "  block size: %d B\n\n", Long.valueOf(a5)).getBytes(C.UTF8_NAME));
            } catch (Throwable th) {
                a(th, outputStream);
            }
        } catch (Throwable unused) {
        }
    }

    private static void b(OutputStream outputStream) {
        BufferedReader bufferedReader = null;
        try {
            outputStream.write("logcat:\n".getBytes(C.UTF8_NAME));
        } 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(C.UTF8_NAME));
            a(outputStream);
            return;
        }
        int n4 = g.n();
        bufferedReader = a(new InputStreamReader(Runtime.getRuntime().exec(new String[]{"logcat", "-d", "-b", com.umeng.analytics.pro.d.ar, "-b", "main", "-v", "threadtime", "-t", String.valueOf(n4)}).getInputStream()));
        if (bufferedReader == null) {
            outputStream.write("[DEBUG] alloc buffer failed!\n".getBytes(C.UTF8_NAME));
            a(outputStream);
            return;
        }
        f2912h = false;
        int i4 = 0;
        int i5 = 0;
        while (true) {
            String readLine = bufferedReader.readLine();
            if (readLine == null) {
                break;
            }
            i4++;
            if (i5 < n4 && !readLine.contains(" I auditd ") && !readLine.contains(" I liblog ")) {
                outputStream.write(readLine.getBytes(C.UTF8_NAME));
                outputStream.write("\n".getBytes(C.UTF8_NAME));
                i5++;
            }
        }
        outputStream.write(String.format(Locale.US, "[DEBUG] Read %d lines, wrote %d lines.\n", Integer.valueOf(i4), Integer.valueOf(i5)).getBytes(C.UTF8_NAME));
        f2912h = true;
        com.uc.crashsdk.a.g.a(bufferedReader);
        a(outputStream);
    }

    private static long a(StatFs statFs, String str, String str2) {
        try {
            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) {
        f2912h = false;
        try {
            aVar.write((s("LOG_END") + "\n").getBytes(C.UTF8_NAME));
        } catch (Throwable th) {
            com.uc.crashsdk.a.g.a(th);
        }
        f2912h = 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 i4) {
        int i5;
        DataInputStream dataInputStream;
        int i6;
        DataInputStream dataInputStream2 = null;
        int i7 = 0;
        try {
            File file = new File(str);
            if (file.exists()) {
                byte[] R2 = R();
                if (R2 == null) {
                    outputStream.write("(alloc buffer failed!)\n".getBytes(C.UTF8_NAME));
                    return 0;
                }
                dataInputStream = new DataInputStream(new FileInputStream(file));
                i6 = 0;
                i5 = 0;
                loop0: while (true) {
                    boolean z3 = false;
                    while (true) {
                        try {
                            int read = dataInputStream.read(R2);
                            if (read == -1) {
                                break loop0;
                            }
                            i6 += read;
                            int i8 = i4 - i5;
                            if (read <= i8 + 32) {
                                i8 = read;
                            }
                            if (i8 > 0 && !z3) {
                                outputStream.write(R2, 0, i8);
                                i5 += i8;
                            }
                            if (!z3) {
                                if (i8 < read || i5 >= i4) {
                                    z3 = true;
                                }
                            }
                        } catch (Throwable th) {
                            th = th;
                            i7 = i5;
                            dataInputStream2 = dataInputStream;
                            try {
                                a(th, outputStream);
                                com.uc.crashsdk.a.g.a(dataInputStream2);
                                i5 = i7;
                                a(outputStream);
                                return i5;
                            } finally {
                                com.uc.crashsdk.a.g.a(dataInputStream2);
                            }
                        }
                    }
                }
            } else {
                outputStream.write(("file: '" + str + "' not exists!\n").getBytes(C.UTF8_NAME));
                dataInputStream = null;
                i6 = 0;
                i5 = 0;
            }
            if (i5 > 0) {
                outputStream.write("\n".getBytes(C.UTF8_NAME));
            }
            if (i5 < i6) {
                outputStream.write(String.format(Locale.US, "(truncated %d bytes)\n", Integer.valueOf(i6 - i5)).getBytes(C.UTF8_NAME));
            }
        } catch (Throwable th2) {
            th = th2;
        }
        a(outputStream);
        return i5;
    }

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

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

    public static void b(boolean z3) {
        try {
            boolean z4 = g.r() && com.uc.crashsdk.b.F() && !f2909d;
            if (!z4) {
                z4 = g.s();
            }
            if (z4) {
                if (z3) {
                    String k4 = k();
                    if (com.uc.crashsdk.a.g.a(k4)) {
                        return;
                    }
                    j();
                    a(k4, 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 j4, boolean z3) {
        FileOutputStream fileOutputStream;
        try {
            if (!com.uc.crashsdk.b.L()) {
                g.a();
                a(true);
            }
            int i4 = (j4 > 0L ? 1 : (j4 == 0L ? 0 : -1));
            fileOutputStream = i4 == 0 ? new FileOutputStream(str) : null;
            try {
                a aVar = new a(j4, fileOutputStream);
                try {
                    if (com.uc.crashsdk.b.f2874d) {
                        JNIBridge.set(126, str);
                    }
                    b(aVar, str, S());
                    if (z3) {
                        aVar.flush();
                    }
                    aVar.write(("Process Name: '" + h() + "'\n").getBytes(C.UTF8_NAME));
                    aVar.write(("Thread Name: '" + Thread.currentThread().getName() + "'\n").getBytes(C.UTF8_NAME));
                    aVar.write("Back traces starts.\n".getBytes(C.UTF8_NAME));
                    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(C.UTF8_NAME));
                    }
                    th.printStackTrace(new PrintStream(aVar));
                    aVar.write("Back traces ends.\n".getBytes(C.UTF8_NAME));
                    a((OutputStream) aVar);
                    aVar.flush();
                    com.uc.crashsdk.a.a(aVar, C.UTF8_NAME, "--- --- --- --- --- --- --- --- --- --- --- --- --- --- --- ---\n");
                    if (z3) {
                        aVar.flush();
                    }
                    aVar.write("meminfo:\n".getBytes(C.UTF8_NAME));
                    b(aVar, "/proc/meminfo", 10240);
                    String format = String.format(Locale.US, "/proc/%d/status", Integer.valueOf(Process.myPid()));
                    aVar.write("status:\n".getBytes(C.UTF8_NAME));
                    b(aVar, format, 10240);
                    aVar.write(("memory info:\n" + g()).getBytes(C.UTF8_NAME));
                    a((OutputStream) aVar);
                    g(aVar);
                    com.uc.crashsdk.a.a(aVar, C.UTF8_NAME, (ArrayList<String>) null);
                    if (ag) {
                        f2912h = false;
                        aVar.write(s("JAVADUMPFILES").getBytes(C.UTF8_NAME));
                        f2912h = true;
                    }
                    aVar.flush();
                    b((OutputStream) aVar);
                    aVar.flush();
                    aVar.write("battery info:\n".getBytes(C.UTF8_NAME));
                    if (ag) {
                        f2912h = false;
                        aVar.write(s("BATTERYINFO").getBytes(C.UTF8_NAME));
                        f2912h = true;
                    } else {
                        StringBuilder Y2 = Y();
                        if (Y2 != null) {
                            aVar.write(Y2.toString().getBytes(C.UTF8_NAME));
                        }
                    }
                    a((OutputStream) aVar);
                    c(aVar);
                    aVar.write("device status:\n".getBytes(C.UTF8_NAME));
                    if (ag) {
                        try {
                            f2912h = false;
                            aVar.write(s("DEVICESTATUS").getBytes(C.UTF8_NAME));
                            f2912h = true;
                        } catch (Throwable th2) {
                            th = th2;
                            a(th, aVar);
                            a((OutputStream) aVar);
                            d(aVar);
                            e(aVar);
                            com.uc.crashsdk.a.b(aVar, C.UTF8_NAME, "--- --- --- --- --- --- --- --- --- --- --- --- --- --- --- ---\n", null);
                            if (ag) {
                            }
                            aVar.flush();
                            com.uc.crashsdk.a.a(aVar, C.UTF8_NAME, "--- --- --- --- --- --- --- --- --- --- --- --- --- --- --- ---\n", null);
                            if (ag) {
                            }
                            aVar.a();
                            a(aVar);
                            aVar.flush();
                            if (i4 != 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(C.UTF8_NAME));
                            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(C.UTF8_NAME));
                            String h4 = com.uc.crashsdk.a.g.h();
                            if (com.uc.crashsdk.a.g.b(h4)) {
                                aVar.write(String.format(locale, "su binary: %s\n", h4).getBytes(C.UTF8_NAME));
                                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(C.UTF8_NAME));
                            }
                        } catch (Throwable th3) {
                            th = th3;
                            a(th, aVar);
                            a((OutputStream) aVar);
                            d(aVar);
                            e(aVar);
                            com.uc.crashsdk.a.b(aVar, C.UTF8_NAME, "--- --- --- --- --- --- --- --- --- --- --- --- --- --- --- ---\n", null);
                            if (ag) {
                            }
                            aVar.flush();
                            com.uc.crashsdk.a.a(aVar, C.UTF8_NAME, "--- --- --- --- --- --- --- --- --- --- --- --- --- --- --- ---\n", null);
                            if (ag) {
                            }
                            aVar.a();
                            a(aVar);
                            aVar.flush();
                            if (i4 != 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, C.UTF8_NAME, "--- --- --- --- --- --- --- --- --- --- --- --- --- --- --- ---\n", null);
                    if (ag) {
                        f2912h = false;
                        aVar.write(s("JAVACACHEDINFOS").getBytes(C.UTF8_NAME));
                        f2912h = true;
                    }
                    aVar.flush();
                    com.uc.crashsdk.a.a(aVar, C.UTF8_NAME, "--- --- --- --- --- --- --- --- --- --- --- --- --- --- --- ---\n", null);
                    if (ag) {
                        f2912h = false;
                        aVar.write(s("JAVACALLBACKINFOS").getBytes(C.UTF8_NAME));
                        f2912h = true;
                    }
                    aVar.a();
                    a(aVar);
                    aVar.flush();
                    if (i4 != 0) {
                        b(aVar);
                    }
                    com.uc.crashsdk.a.g.a(aVar);
                }
            } catch (Throwable th4) {
                th = th4;
                try {
                    a(th, (OutputStream) null);
                    if (j4 != 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 (j4 != 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 z3, boolean z4) {
        if (z3) {
            try {
                str = m(str);
            } catch (Throwable th) {
                com.uc.crashsdk.a.g.a(th);
            }
        }
        if (z4) {
            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 z3) {
        h.a(str, str2, false, z3);
    }

    public static void b(String str) {
        synchronized (f2929y) {
            f2928x = 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 i4) {
        com.uc.crashsdk.a.f.a(0, new com.uc.crashsdk.a.e(410), i4 * 1000);
    }

    public static String a(String str) {
        int lastIndexOf;
        int indexOf;
        int i4;
        int indexOf2;
        File file;
        byte[] e4;
        if (g.x() && (lastIndexOf = str.lastIndexOf(47)) > 0 && (indexOf = str.indexOf(95, lastIndexOf)) > lastIndexOf && (indexOf2 = str.indexOf(95, (i4 = indexOf + 1))) > indexOf) {
            String c4 = com.uc.crashsdk.a.g.c("CrashSDK" + str.substring(lastIndexOf + 1, indexOf) + str.substring(i4, indexOf2));
            if (c4 == null || (e4 = com.uc.crashsdk.a.g.e((file = new File(str)))) == null || e4.length <= 0) {
                return str;
            }
            byte[] bArr = null;
            try {
                bArr = com.uc.crashsdk.a.c.b(e4, c4.substring(0, 16).getBytes());
            } catch (Throwable th) {
                com.uc.crashsdk.a.g.a(th);
            }
            if (bArr == null) {
                return str;
            }
            String a4 = androidx.appcompat.view.a.a(str, ".ec");
            File file2 = new File(androidx.appcompat.view.a.a(a4, ".tmp"));
            if (com.uc.crashsdk.a.g.a(file2, bArr)) {
                if (!file2.renameTo(new File(a4))) {
                    file2.delete();
                    return str;
                }
                file.delete();
                return a4;
            }
            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(C.UTF8_NAME));
                th.printStackTrace(new PrintStream(outputStream));
                outputStream.write("\n\n".getBytes(C.UTF8_NAME));
            } catch (Throwable th2) {
                com.uc.crashsdk.a.g.a(th2);
            }
        }
        com.uc.crashsdk.a.g.a(th);
    }

    private static void a(String str, boolean z3, boolean z4) {
        int i4;
        boolean z5;
        boolean z6;
        int i5;
        String path;
        String b4;
        File a4;
        int i6;
        String str2;
        String str3;
        int i7;
        File file;
        boolean z7;
        com.uc.crashsdk.a.a.a("crashsdk", "crashsdk uploading logs");
        synchronized (f2918n) {
            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 i8 = 0;
                            int i9 = 0;
                            int i10 = 0;
                            int i11 = 0;
                            int i12 = 0;
                            int i13 = 0;
                            int i14 = 0;
                            int i15 = 0;
                            int i16 = 0;
                            boolean z8 = false;
                            boolean z9 = false;
                            boolean z10 = false;
                            while (true) {
                                if (i8 >= length) {
                                    i4 = i11;
                                    z5 = z8;
                                    z6 = z9;
                                    break;
                                }
                                File file3 = listFiles[i8];
                                File[] fileArr = listFiles;
                                if (file3.isFile()) {
                                    String name = file3.getName();
                                    if (!name.endsWith(".tmp")) {
                                        i5 = length;
                                        z5 = z8;
                                        z6 = z9;
                                        if (file3.length() == 0) {
                                            i9++;
                                            com.uc.crashsdk.a.g.a(file3);
                                        } else {
                                            if (z3) {
                                                long currentTimeMillis = (System.currentTimeMillis() - file3.lastModified()) / 1000;
                                                if (currentTimeMillis < 0 || (currentTimeMillis >= 2 && (currentTimeMillis >= 5 || !file3.getName().endsWith(".log")))) {
                                                    z7 = 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(z7)));
                                                    if (!z7) {
                                                        i11++;
                                                    }
                                                }
                                                z7 = 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(z7)));
                                                if (!z7) {
                                                }
                                            }
                                            try {
                                            } catch (Throwable th) {
                                                th = th;
                                                i4 = i11;
                                            }
                                            if (g.k()) {
                                                Matcher matcher = Pattern.compile("([^_]+)_([^_]+)_([^_]+)\\.crashsdk").matcher(file3.getName());
                                                if (matcher.matches()) {
                                                    i4 = i11;
                                                    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) {
                                                            i15++;
                                                        }
                                                        file3 = file;
                                                    } catch (Throwable th2) {
                                                        th = th2;
                                                        com.uc.crashsdk.a.g.a(th);
                                                        path = file3.getPath();
                                                        boolean[] n4 = n(path);
                                                        b4 = b(path, n4[0], n4[1]);
                                                        if (path != b4) {
                                                        }
                                                        a4 = com.uc.crashsdk.d.a(file3);
                                                        if (a4 == null) {
                                                        }
                                                        if (a4 == null) {
                                                        }
                                                        z9 = z6;
                                                        i8++;
                                                        listFiles = fileArr;
                                                        length = i5;
                                                        z8 = z5;
                                                        i11 = i4;
                                                    }
                                                    path = file3.getPath();
                                                    boolean[] n42 = n(path);
                                                    b4 = b(path, n42[0], n42[1]);
                                                    if (path != b4) {
                                                        if (n42[0]) {
                                                            i14++;
                                                        }
                                                        if (n42[1]) {
                                                            i12++;
                                                        }
                                                        file3 = new File(b4);
                                                    }
                                                    a4 = com.uc.crashsdk.d.a(file3);
                                                    if (a4 == null) {
                                                        a4 = null;
                                                    } else if (file3 != a4 && !file3.getName().equals(a4.getName()) && file3.exists()) {
                                                        file3.delete();
                                                    }
                                                    if (a4 == null) {
                                                        com.uc.crashsdk.a.a.b("onBeforeUploadLog return null, skip upload: " + file3.getAbsolutePath());
                                                    } else {
                                                        int z11 = g.z();
                                                        if (z11 <= 0 || a4.length() < z11) {
                                                            d dVar = new d((byte) 0);
                                                            dVar.f2938b = 0L;
                                                            dVar.f2937a = 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) {
                                                                i6 = i12;
                                                                if (dVar.f2938b + a4.length() > A2) {
                                                                    dVar.f2941e = true;
                                                                    str2 = "Reach max upload bytes: " + A2;
                                                                    com.uc.crashsdk.a.a.b(str2);
                                                                    if (!dVar.f2941e) {
                                                                        i12 = i6;
                                                                        z9 = z6;
                                                                        z5 = true;
                                                                    } else if (dVar.f2943g) {
                                                                        i12 = i6;
                                                                        z9 = true;
                                                                    } else if (dVar.f2942f) {
                                                                        i12 = i6;
                                                                        z9 = z6;
                                                                        z10 = true;
                                                                    } else {
                                                                        String name2 = a4.getName();
                                                                        if (name2.startsWith(P())) {
                                                                            String[] split = name2.split("_", 10);
                                                                            if (split.length == 9) {
                                                                                str3 = split[1];
                                                                                boolean z12 = str3 == null && str3.equals(g.R());
                                                                                if (com.uc.crashsdk.a.c.a(a4, a4.getName(), str)) {
                                                                                    i16++;
                                                                                    if (z12) {
                                                                                        f.a(14);
                                                                                    }
                                                                                    i7 = 3;
                                                                                } else {
                                                                                    com.uc.crashsdk.a.a.a("crashsdk", "Uploaded log: " + a4.getName(), null);
                                                                                    if (z12) {
                                                                                        f.a(13);
                                                                                    }
                                                                                    dVar.f2938b += a4.length();
                                                                                    if (b(a4)) {
                                                                                        dVar.f2939c++;
                                                                                    } else {
                                                                                        dVar.f2940d++;
                                                                                    }
                                                                                    String U3 = U();
                                                                                    a(U3, new com.uc.crashsdk.a.e(452, new Object[]{U3, dVar}));
                                                                                    a4.delete();
                                                                                    i7 = 3;
                                                                                    i16 = 0;
                                                                                }
                                                                                if (i16 < i7) {
                                                                                    com.uc.crashsdk.a.a.a("crashsdk", "Upload failed 3 times continuously, abort upload!", null);
                                                                                    i12 = i6;
                                                                                    break;
                                                                                }
                                                                                i12 = i6;
                                                                                z9 = z6;
                                                                            }
                                                                        }
                                                                        str3 = null;
                                                                        if (str3 == null) {
                                                                        }
                                                                        if (com.uc.crashsdk.a.c.a(a4, a4.getName(), str)) {
                                                                        }
                                                                        if (i16 < i7) {
                                                                        }
                                                                    }
                                                                    i8++;
                                                                    listFiles = fileArr;
                                                                    length = i5;
                                                                    z8 = z5;
                                                                    i11 = i4;
                                                                }
                                                            } else {
                                                                i6 = i12;
                                                            }
                                                            if (!g.f()) {
                                                                if (b(a4)) {
                                                                    if (B2 >= 0 && dVar.f2939c >= B2) {
                                                                        dVar.f2943g = true;
                                                                        str2 = "Reach max upload builtin log count: " + B2;
                                                                        com.uc.crashsdk.a.a.b(str2);
                                                                    }
                                                                } else if (C2 >= 0 && dVar.f2940d >= C2) {
                                                                    dVar.f2942f = true;
                                                                    str2 = "Reach max upload custom log count: " + C2;
                                                                    com.uc.crashsdk.a.a.b(str2);
                                                                }
                                                            }
                                                            if (!dVar.f2941e) {
                                                            }
                                                            i8++;
                                                            listFiles = fileArr;
                                                            length = i5;
                                                            z8 = z5;
                                                            i11 = i4;
                                                        } else {
                                                            i13++;
                                                            com.uc.crashsdk.a.g.a(a4);
                                                        }
                                                    }
                                                    z9 = z6;
                                                    i8++;
                                                    listFiles = fileArr;
                                                    length = i5;
                                                    z8 = z5;
                                                    i11 = i4;
                                                }
                                            }
                                            i4 = i11;
                                            file = file3;
                                            if (file != file3) {
                                            }
                                            file3 = file;
                                            path = file3.getPath();
                                            boolean[] n422 = n(path);
                                            b4 = b(path, n422[0], n422[1]);
                                            if (path != b4) {
                                            }
                                            a4 = com.uc.crashsdk.d.a(file3);
                                            if (a4 == null) {
                                            }
                                            if (a4 == null) {
                                            }
                                            z9 = z6;
                                            i8++;
                                            listFiles = fileArr;
                                            length = i5;
                                            z8 = z5;
                                            i11 = i4;
                                        }
                                        i4 = i11;
                                        z9 = z6;
                                        i8++;
                                        listFiles = fileArr;
                                        length = i5;
                                        z8 = z5;
                                        i11 = i4;
                                    } else if ((System.currentTimeMillis() - file3.lastModified()) / 1000 > 30) {
                                        i5 = length;
                                        com.uc.crashsdk.a.a.b("delete legacy tmp file: " + name);
                                        i10++;
                                        com.uc.crashsdk.a.g.a(file3);
                                        i4 = i11;
                                        z5 = z8;
                                        i8++;
                                        listFiles = fileArr;
                                        length = i5;
                                        z8 = z5;
                                        i11 = i4;
                                    }
                                } else {
                                    com.uc.crashsdk.a.g.a(file3);
                                }
                                i5 = length;
                                i4 = i11;
                                z5 = z8;
                                i8++;
                                listFiles = fileArr;
                                length = i5;
                                z8 = z5;
                                i11 = i4;
                            }
                            if (i10 > 0) {
                                f.a(200, i10);
                            }
                            if (i9 > 0) {
                                f.a(15, i9);
                            }
                            if (i13 > 0) {
                                f.a(17, i13);
                            }
                            if (z5) {
                                f.a(19);
                            }
                            if (z6) {
                                f.a(20);
                            }
                            if (z10) {
                                f.a(21);
                            }
                            if (z5 || z6 || z10) {
                                f.a(18);
                            }
                            if (i14 > 0) {
                                f.a(24, i14);
                            }
                            if (i12 > 0) {
                                f.a((int) CrashStatKey.LOG_UPLOAD_ENCRYPT_COUNT, i12);
                            }
                            if (i15 > 0) {
                                f.a(25, i15);
                            }
                            if (i4 > 0) {
                                f.a(26, i4);
                            }
                        }
                    } 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 (z4) {
                    f2919o.open();
                }
            } catch (Throwable th3) {
                throw th3;
            }
        }
    }

    public static boolean a(boolean z3, boolean z4) {
        if (!f2909d) {
            if (com.uc.crashsdk.b.f2874d) {
                JNIBridge.set(1, true);
            }
            f2909d = true;
        }
        try {
            String k4 = k();
            if (com.uc.crashsdk.a.g.a(k4)) {
                com.uc.crashsdk.a.a.a("crashsdk", "CrashHandler url is empty!");
                return false;
            }
            if (com.uc.crashsdk.a.f.a(z3 ? 1 : 0, new com.uc.crashsdk.a.e(406, new Object[]{k4, Boolean.valueOf(z4), Boolean.valueOf(z3)})) && z3) {
                ConditionVariable conditionVariable = f2919o;
                conditionVariable.close();
                if (!conditionVariable.block(C.DEFAULT_MAX_SEEK_TO_PREVIOUS_POSITION_MS)) {
                    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 z3;
        FileChannel fileChannel;
        Exception e4;
        synchronized (f2920p) {
            File file = new File(str);
            if (!file.exists()) {
                try {
                    file.createNewFile();
                } catch (Exception e5) {
                    com.uc.crashsdk.a.g.a(e5);
                }
            }
            ?? r5 = 0;
            r5 = null;
            FileLock lock = null;
            z3 = false;
            try {
                try {
                    try {
                        fileChannel = new RandomAccessFile(file, "rw").getChannel();
                    } catch (Throwable th) {
                        th = th;
                        r5 = file;
                        com.uc.crashsdk.a.g.a((Closeable) r5);
                        throw th;
                    }
                } catch (Exception e6) {
                    try {
                        com.uc.crashsdk.a.g.a(e6);
                        fileChannel = null;
                    } catch (Exception e7) {
                        fileChannel = null;
                        e4 = e7;
                        com.uc.crashsdk.a.g.a(e4);
                        com.uc.crashsdk.a.g.a(fileChannel);
                        return z3;
                    }
                }
                if (fileChannel != null) {
                    try {
                        lock = fileChannel.lock();
                    } catch (Exception e8) {
                        try {
                            com.uc.crashsdk.a.g.a(e8);
                        } catch (Exception e9) {
                            e4 = e9;
                            com.uc.crashsdk.a.g.a(e4);
                            com.uc.crashsdk.a.g.a(fileChannel);
                            return z3;
                        }
                    }
                }
                try {
                    z3 = eVar.a();
                    com.uc.crashsdk.a.g.a(fileChannel);
                } finally {
                    if (lock != null) {
                        try {
                            lock.release();
                        } catch (Exception e10) {
                            com.uc.crashsdk.a.g.a(e10);
                        }
                    }
                }
            } catch (Throwable th2) {
                th = th2;
            }
        }
        return z3;
    }

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

    public static boolean a(StringBuffer stringBuffer, String str, long j4, ArrayList<String> arrayList, ArrayList<String> arrayList2, ArrayList<String> arrayList3, String str2) {
        long j5;
        boolean z3;
        boolean a4;
        if (f2908c.get()) {
            com.uc.crashsdk.a.a.b("Processing java crash, skip generate custom log: " + str);
            return false;
        }
        boolean z4 = ag || com.uc.crashsdk.b.L();
        if (!z4 && !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 = (j4 & 32) != 0 ? 1 : 0;
            if (z4) {
                long nativeClientCreateConnection = com.uc.crashsdk.b.f2874d ? JNIBridge.nativeClientCreateConnection(str3, "custom", str, r11) : 0L;
                if (nativeClientCreateConnection == 0) {
                    com.uc.crashsdk.a.a.d("DEBUG", "skip custom log: " + str);
                    return false;
                }
                j5 = nativeClientCreateConnection;
            } else if (a(h(), str, (boolean) r11)) {
                return false;
            } else {
                g.a();
                a(false);
                j5 = 0;
            }
            synchronized (f2921q) {
                z3 = r11;
                a4 = a(str3, j5, stringBuffer, str, j4, arrayList, arrayList2, arrayList3, str2);
            }
            if (a4 && !z4) {
                b(h(), str, z3);
            }
            if (j5 != 0) {
                JNIBridge.nativeClientCloseConnection(j5);
            }
            if (a4) {
                if (!z4) {
                    r(str3);
                }
                if (!z4) {
                    str3 = a(m(str3));
                }
                b(str3, str);
                if (!z3 || z4) {
                    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 z3) {
        if (o(str2)) {
            h.a(str, str2, true, z3);
            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 j4) {
        String nativeDumpThreads;
        String str2 = null;
        if (com.uc.crashsdk.b.f2874d) {
            try {
                aVar.flush();
            } catch (Throwable th) {
                com.uc.crashsdk.a.g.a(th);
            }
            nativeDumpThreads = JNIBridge.nativeDumpThreads(str, j4);
            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(C.UTF8_NAME));
                aVar.write("\n".getBytes(C.UTF8_NAME));
            } 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 j4, StringBuffer stringBuffer, String str2, long j5, ArrayList<String> arrayList, ArrayList<String> arrayList2, ArrayList<String> arrayList3, String str3) {
        FileOutputStream fileOutputStream;
        a aVar;
        int i4 = (j4 > 0L ? 1 : (j4 == 0L ? 0 : -1));
        if (i4 == 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(j4, fileOutputStream);
            try {
                synchronized (f2923s) {
                    f2925u = str;
                    if (com.uc.crashsdk.b.f2874d) {
                        JNIBridge.set(126, f2925u);
                    }
                }
            } 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 ((j5 & 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(C.UTF8_NAME));
        aVar.flush();
        a((OutputStream) aVar);
        if ((j5 & 4) != 0) {
            b((OutputStream) aVar);
            aVar.flush();
        }
        if (arrayList != null && arrayList.size() > 0) {
            com.uc.crashsdk.a.a(aVar, C.UTF8_NAME, arrayList);
        }
        if (arrayList2 != null && arrayList2.size() > 0) {
            com.uc.crashsdk.a.a(aVar, C.UTF8_NAME, "--- --- --- --- --- --- --- --- --- --- --- --- --- --- --- ---\n", arrayList2);
        }
        if (arrayList3 != null && arrayList3.size() > 0) {
            com.uc.crashsdk.a.b(aVar, C.UTF8_NAME, "--- --- --- --- --- --- --- --- --- --- --- --- --- --- --- ---\n", arrayList3);
        }
        if (str3 != null) {
            aVar.flush();
            aVar.write("threads dump:\n".getBytes(C.UTF8_NAME));
            f2912h = false;
            f2927w = str3;
            a(aVar, str3, j4);
            f2927w = null;
            f2912h = true;
        }
        if ((j5 & 8) != 0 && i4 == 0) {
            aVar.flush();
            aVar.write("all threads dump:\n".getBytes(C.UTF8_NAME));
            f2926v = true;
            a(aVar, TtmlNode.COMBINE_ALL, 0L);
            f2926v = false;
        }
        if ((j5 & 16) != 0) {
            f(aVar);
        }
        if ((j5 & 2) != 0) {
            aVar.a();
            a(aVar);
        }
        if (i4 != 0) {
            b(aVar);
        }
        try {
            ArrayList<String> arrayList4 = f2923s;
            synchronized (arrayList4) {
                f2924t++;
                String str4 = f2925u;
                if (str4 != null) {
                    arrayList4.add(str4);
                    if (arrayList4.size() > 3) {
                        arrayList4.remove(0);
                    }
                    if (com.uc.crashsdk.b.f2874d) {
                        JNIBridge.set(127, f2925u);
                    }
                    f2925u = null;
                }
                if (com.uc.crashsdk.b.f2874d) {
                    JNIBridge.set(25, f2924t);
                }
            }
        } 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 i4, boolean z3, boolean z4) {
        f2912h = false;
        try {
            Locale locale = Locale.US;
            Object[] objArr = new Object[5];
            objArr[0] = str;
            objArr[1] = str2;
            objArr[2] = Integer.valueOf(i4);
            objArr[3] = Integer.valueOf(z3 ? 1 : 0);
            objArr[4] = Integer.valueOf(z4 ? 1 : 0);
            outputStream.write(String.format(locale, "$^%s`%s`%d`%d,%d^$", objArr).getBytes(C.UTF8_NAME));
        } catch (Throwable th) {
            com.uc.crashsdk.a.g.a(th);
        }
        f2912h = true;
        a(outputStream);
    }

    public static void a(OutputStream outputStream, String str, String str2) {
        f2912h = false;
        try {
            outputStream.write(String.format(Locale.US, "$^%s`%s^$", str, str2).getBytes(C.UTF8_NAME));
        } catch (Throwable th) {
            com.uc.crashsdk.a.g.a(th);
        }
        f2912h = 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 z3) {
        boolean z4;
        long j4;
        boolean z5;
        boolean i4;
        Thread.UncaughtExceptionHandler uncaughtExceptionHandler;
        Throwable th2;
        boolean z6;
        boolean i5;
        Thread.UncaughtExceptionHandler uncaughtExceptionHandler2;
        boolean z7;
        String str;
        long nativeClientCreateConnection;
        boolean z8;
        boolean i6;
        Thread.UncaughtExceptionHandler uncaughtExceptionHandler3;
        boolean z9;
        boolean i7;
        Thread.UncaughtExceptionHandler uncaughtExceptionHandler4;
        Throwable th3;
        boolean z10;
        boolean i8;
        Thread.UncaughtExceptionHandler uncaughtExceptionHandler5;
        File file;
        boolean z11;
        boolean i9;
        Thread.UncaughtExceptionHandler uncaughtExceptionHandler6;
        boolean z12;
        boolean i10;
        Thread.UncaughtExceptionHandler uncaughtExceptionHandler7;
        boolean z13;
        boolean i11;
        Thread.UncaughtExceptionHandler uncaughtExceptionHandler8;
        boolean z14;
        boolean i12;
        Thread.UncaughtExceptionHandler uncaughtExceptionHandler9;
        boolean z15 = (ag && com.uc.crashsdk.b.f2874d) || com.uc.crashsdk.b.L();
        try {
            j4 = 4;
            if (f2908c.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 i13 = 0;
                while (!V) {
                    Thread.sleep(1000L);
                    i13++;
                    if (i13 >= 4) {
                        break;
                    }
                }
                Process.killProcess(Process.myPid());
                if (z3) {
                    try {
                    } catch (Throwable th4) {
                        th = th4;
                        z14 = false;
                    }
                    if (g.r() && !z15) {
                        try {
                            a(true, false);
                            z14 = true;
                        } catch (Throwable th5) {
                            th = th5;
                            z14 = true;
                            com.uc.crashsdk.a.g.a(th);
                            if (!z14) {
                            }
                            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 (!z14 && !z15) {
                            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 && (uncaughtExceptionHandler9 = T) != null) {
                            uncaughtExceptionHandler9.uncaughtException(thread, th);
                        }
                        if (com.uc.crashsdk.b.B() && !z15) {
                            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);
                i12 = g.i();
                if (!com.uc.crashsdk.a.d.e()) {
                }
                com.uc.crashsdk.a.a.a("crashsdk", "Call java default handler: " + i12);
                if (i12) {
                    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 (!z15 && !com.uc.crashsdk.a.d.e()) {
                    com.uc.crashsdk.a.a.c("DEBUG", com.uc.crashsdk.a.d.b());
                    if (z3) {
                        try {
                        } catch (Throwable th6) {
                            th = th6;
                            z13 = false;
                        }
                        if (g.r() && !z15) {
                            try {
                                a(true, false);
                                z13 = true;
                            } catch (Throwable th7) {
                                th = th7;
                                z13 = true;
                                com.uc.crashsdk.a.g.a(th);
                                if (!z13) {
                                }
                                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 (!z13 && !z15) {
                                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 && (uncaughtExceptionHandler8 = T) != null) {
                                uncaughtExceptionHandler8.uncaughtException(thread, th);
                            }
                            if (com.uc.crashsdk.b.B() && !z15) {
                                com.uc.crashsdk.b.b(com.uc.crashsdk.a.g.a());
                            }
                            V = true;
                            if (Process.myPid() > 0) {
                                Process.killProcess(Process.myPid());
                                return;
                            }
                            return;
                        }
                    }
                    z13 = false;
                    if (!z13) {
                        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) {
                        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.f2953a != null) {
                        com.uc.crashsdk.a.a.d("DEBUG", "the set zip log to false stack is:");
                        g.f2953a.printStackTrace();
                    }
                    if (g.f2954b != null) {
                        com.uc.crashsdk.a.a.d("DEBUG", "the set encrypt to true stack is:");
                        g.f2954b.printStackTrace();
                    }
                    com.uc.crashsdk.a.a.d("DEBUG", "begin to generate java report");
                    N();
                    try {
                        z7 = g.t();
                        try {
                            String g4 = g.g();
                            if (g4 == null || g4.equals("")) {
                                g4 = k(S());
                            }
                            str = g.V() + g4;
                            z4 = 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);
                            str = null;
                            z4 = true;
                            try {
                                if (z15) {
                                }
                                boolean z16 = th instanceof OutOfMemoryError;
                                a(th, str, nativeClientCreateConnection, z16);
                                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 (z3) {
                                }
                                z10 = false;
                                if (!z10) {
                                }
                                try {
                                    f.c(false);
                                } catch (Throwable th9) {
                                    com.uc.crashsdk.a.g.a(th9);
                                }
                                try {
                                    i8 = g.i();
                                    if (!com.uc.crashsdk.a.d.e()) {
                                    }
                                    com.uc.crashsdk.a.a.a("crashsdk", "Call java default handler: " + i8);
                                    if (i8) {
                                    }
                                    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;
                        z7 = false;
                    }
                    try {
                        if (z15) {
                            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 (z7) {
                                com.uc.crashsdk.a.a.d("DEBUG", "omit java crash");
                                if (z3) {
                                    try {
                                    } catch (Throwable th13) {
                                        th = th13;
                                        z12 = false;
                                    }
                                    if (g.r() && !z15) {
                                        try {
                                            a(true, false);
                                            z12 = true;
                                        } catch (Throwable th14) {
                                            th = th14;
                                            z12 = true;
                                            com.uc.crashsdk.a.g.a(th);
                                            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) {
                                            }
                                        }
                                        if (!z12 && !z15) {
                                            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 && (uncaughtExceptionHandler7 = T) != null) {
                                            uncaughtExceptionHandler7.uncaughtException(thread, th);
                                        }
                                        if (com.uc.crashsdk.b.B() && !z15) {
                                            com.uc.crashsdk.b.b(com.uc.crashsdk.a.g.a());
                                        }
                                        V = true;
                                        if (Process.myPid() > 0) {
                                            Process.killProcess(Process.myPid());
                                            return;
                                        }
                                        return;
                                    }
                                }
                                z12 = false;
                                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) {
                                    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 (z3) {
                                    try {
                                    } catch (Throwable th15) {
                                        th = th15;
                                        z11 = false;
                                    }
                                    if (g.r() && !z15) {
                                        try {
                                            a(true, false);
                                            z11 = true;
                                        } catch (Throwable th16) {
                                            th = th16;
                                            z11 = true;
                                            com.uc.crashsdk.a.g.a(th);
                                            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) {
                                            }
                                        }
                                        if (!z11 && !z15) {
                                            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 && (uncaughtExceptionHandler6 = T) != null) {
                                            uncaughtExceptionHandler6.uncaughtException(thread, th);
                                        }
                                        if (com.uc.crashsdk.b.B() && !z15) {
                                            com.uc.crashsdk.b.b(com.uc.crashsdk.a.g.a());
                                        }
                                        V = true;
                                        if (Process.myPid() > 0) {
                                            Process.killProcess(Process.myPid());
                                            return;
                                        }
                                        return;
                                    }
                                }
                                z11 = false;
                                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) {
                                    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 (z7) {
                                str = "omit";
                                com.uc.crashsdk.a.a.d("DEBUG", "omit java crash");
                            }
                            nativeClientCreateConnection = com.uc.crashsdk.b.f2874d ? JNIBridge.nativeClientCreateConnection(str, LogType.JAVA_TYPE, null, 0) : 0L;
                            int i14 = (nativeClientCreateConnection > 0L ? 1 : (nativeClientCreateConnection == 0L ? 0 : -1));
                            if (i14 == 0) {
                                com.uc.crashsdk.a.a.d("DEBUG", "skip java crash:");
                                a(th);
                                if (i14 != 0 && com.uc.crashsdk.b.f2874d) {
                                    JNIBridge.nativeClientCloseConnection(nativeClientCreateConnection);
                                }
                                if (z3) {
                                    try {
                                    } catch (Throwable th17) {
                                        th = th17;
                                        z9 = false;
                                    }
                                    if (g.r() && !z15) {
                                        try {
                                            a(true, false);
                                            z9 = true;
                                        } catch (Throwable th18) {
                                            th = th18;
                                            z9 = true;
                                            com.uc.crashsdk.a.g.a(th);
                                            if (!z9) {
                                            }
                                            f.c(false);
                                            i7 = g.i();
                                            if (!com.uc.crashsdk.a.d.e()) {
                                            }
                                            com.uc.crashsdk.a.a.a("crashsdk", "Call java default handler: " + i7);
                                            if (i7) {
                                            }
                                            if (com.uc.crashsdk.b.B()) {
                                            }
                                            V = true;
                                            if (Process.myPid() > 0) {
                                            }
                                        }
                                        if (!z9 && !z15) {
                                            b(false);
                                        }
                                        f.c(false);
                                        i7 = g.i();
                                        if (!com.uc.crashsdk.a.d.e()) {
                                            i7 = true;
                                        }
                                        com.uc.crashsdk.a.a.a("crashsdk", "Call java default handler: " + i7);
                                        if (i7 && (uncaughtExceptionHandler4 = T) != null) {
                                            uncaughtExceptionHandler4.uncaughtException(thread, th);
                                        }
                                        if (com.uc.crashsdk.b.B() && !z15) {
                                            com.uc.crashsdk.b.b(com.uc.crashsdk.a.g.a());
                                        }
                                        V = true;
                                        if (Process.myPid() > 0) {
                                            Process.killProcess(Process.myPid());
                                            return;
                                        }
                                        return;
                                    }
                                }
                                z9 = false;
                                if (!z9) {
                                    b(false);
                                }
                                f.c(false);
                                i7 = g.i();
                                if (!com.uc.crashsdk.a.d.e()) {
                                }
                                com.uc.crashsdk.a.a.a("crashsdk", "Call java default handler: " + i7);
                                if (i7) {
                                    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 (z7) {
                                if (i14 != 0 && com.uc.crashsdk.b.f2874d) {
                                    JNIBridge.nativeClientCloseConnection(nativeClientCreateConnection);
                                }
                                if (z3) {
                                    try {
                                    } catch (Throwable th19) {
                                        th = th19;
                                        z8 = false;
                                    }
                                    if (g.r() && !z15) {
                                        try {
                                            a(true, false);
                                            z8 = true;
                                        } catch (Throwable th20) {
                                            th = th20;
                                            z8 = true;
                                            com.uc.crashsdk.a.g.a(th);
                                            if (!z8) {
                                            }
                                            f.c(false);
                                            i6 = g.i();
                                            if (!com.uc.crashsdk.a.d.e()) {
                                            }
                                            com.uc.crashsdk.a.a.a("crashsdk", "Call java default handler: " + i6);
                                            if (i6) {
                                            }
                                            if (com.uc.crashsdk.b.B()) {
                                            }
                                            V = true;
                                            if (Process.myPid() > 0) {
                                            }
                                        }
                                        if (!z8 && !z15) {
                                            b(false);
                                        }
                                        f.c(false);
                                        i6 = g.i();
                                        if (!com.uc.crashsdk.a.d.e()) {
                                            i6 = true;
                                        }
                                        com.uc.crashsdk.a.a.a("crashsdk", "Call java default handler: " + i6);
                                        if (i6 && (uncaughtExceptionHandler3 = T) != null) {
                                            uncaughtExceptionHandler3.uncaughtException(thread, th);
                                        }
                                        if (com.uc.crashsdk.b.B() && !z15) {
                                            com.uc.crashsdk.b.b(com.uc.crashsdk.a.g.a());
                                        }
                                        V = true;
                                        if (Process.myPid() > 0) {
                                            Process.killProcess(Process.myPid());
                                            return;
                                        }
                                        return;
                                    }
                                }
                                z8 = false;
                                if (!z8) {
                                    b(false);
                                }
                                f.c(false);
                                i6 = g.i();
                                if (!com.uc.crashsdk.a.d.e()) {
                                }
                                com.uc.crashsdk.a.a.a("crashsdk", "Call java default handler: " + i6);
                                if (i6) {
                                    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 z162 = th instanceof OutOfMemoryError;
                        a(th, str, nativeClientCreateConnection, z162);
                        com.uc.crashsdk.a.a.d("DEBUG", "generate java report finished");
                        if (!com.uc.crashsdk.b.L() && z162 && 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.f2874d) {
                            JNIBridge.nativeClientCloseConnection(nativeClientCreateConnection);
                        }
                        if (z3) {
                            try {
                            } catch (Throwable th21) {
                                th3 = th21;
                                z10 = false;
                            }
                            if (g.r() && !z15) {
                                try {
                                    a(true, false);
                                    z10 = true;
                                } catch (Throwable th22) {
                                    th3 = th22;
                                    z10 = true;
                                    com.uc.crashsdk.a.g.a(th3);
                                    if (!z10) {
                                    }
                                    f.c(false);
                                    i8 = g.i();
                                    if (!com.uc.crashsdk.a.d.e()) {
                                    }
                                    com.uc.crashsdk.a.a.a("crashsdk", "Call java default handler: " + i8);
                                    if (i8) {
                                    }
                                    if (com.uc.crashsdk.b.B()) {
                                    }
                                    V = true;
                                    if (Process.myPid() <= 0) {
                                    }
                                }
                                if (!z10 && !z15) {
                                    b(false);
                                }
                                f.c(false);
                                i8 = g.i();
                                if (!com.uc.crashsdk.a.d.e()) {
                                    i8 = true;
                                }
                                com.uc.crashsdk.a.a.a("crashsdk", "Call java default handler: " + i8);
                                if (i8 && (uncaughtExceptionHandler5 = T) != null) {
                                    uncaughtExceptionHandler5.uncaughtException(thread, th);
                                }
                                if (com.uc.crashsdk.b.B() && !z15) {
                                    com.uc.crashsdk.b.b(com.uc.crashsdk.a.g.a());
                                }
                                V = true;
                                if (Process.myPid() <= 0) {
                                    Process.killProcess(Process.myPid());
                                    return;
                                }
                                return;
                            }
                        }
                        z10 = false;
                        if (!z10) {
                            b(false);
                        }
                        f.c(false);
                        i8 = g.i();
                        if (!com.uc.crashsdk.a.d.e()) {
                        }
                        com.uc.crashsdk.a.a.a("crashsdk", "Call java default handler: " + i8);
                        if (i8) {
                            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 (!z4) {
                                com.uc.crashsdk.a.a.d("DEBUG", "original exception is: " + th);
                                a(th);
                            }
                            if (j4 != 0 && com.uc.crashsdk.b.f2874d) {
                                JNIBridge.nativeClientCloseConnection(j4);
                            }
                            if (z3) {
                                try {
                                } catch (Throwable th24) {
                                    th2 = th24;
                                    z6 = false;
                                }
                                if (g.r() && !z15) {
                                    try {
                                        a(true, false);
                                        z6 = true;
                                    } catch (Throwable th25) {
                                        th2 = th25;
                                        z6 = true;
                                        com.uc.crashsdk.a.g.a(th2);
                                        if (!z6 && !z15) {
                                            b(false);
                                        }
                                        f.c(false);
                                        i5 = g.i();
                                        if (!com.uc.crashsdk.a.d.e()) {
                                            i5 = true;
                                        }
                                        com.uc.crashsdk.a.a.a("crashsdk", "Call java default handler: " + i5);
                                        if (i5 && (uncaughtExceptionHandler2 = T) != null) {
                                            uncaughtExceptionHandler2.uncaughtException(thread, th);
                                        }
                                        if (com.uc.crashsdk.b.B() && !z15) {
                                            com.uc.crashsdk.b.b(com.uc.crashsdk.a.g.a());
                                        }
                                        V = true;
                                        if (Process.myPid() > 0) {
                                            Process.killProcess(Process.myPid());
                                            return;
                                        }
                                        return;
                                    }
                                    if (!z6) {
                                        b(false);
                                    }
                                    f.c(false);
                                    i5 = g.i();
                                    if (!com.uc.crashsdk.a.d.e()) {
                                    }
                                    com.uc.crashsdk.a.a.a("crashsdk", "Call java default handler: " + i5);
                                    if (i5) {
                                        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) {
                                    }
                                }
                            }
                            z6 = false;
                            if (!z6) {
                            }
                            f.c(false);
                            i5 = g.i();
                            if (!com.uc.crashsdk.a.d.e()) {
                            }
                            com.uc.crashsdk.a.a.a("crashsdk", "Call java default handler: " + i5);
                            if (i5) {
                            }
                            if (com.uc.crashsdk.b.B()) {
                            }
                            V = true;
                            if (Process.myPid() > 0) {
                            }
                        } catch (Throwable th26) {
                            if (j4 != 0 && com.uc.crashsdk.b.f2874d) {
                                JNIBridge.nativeClientCloseConnection(j4);
                            }
                            if (z3) {
                                try {
                                } catch (Throwable th27) {
                                    th = th27;
                                    z5 = false;
                                }
                                if (g.r() && !z15) {
                                    try {
                                        a(true, false);
                                        z5 = true;
                                    } catch (Throwable th28) {
                                        th = th28;
                                        z5 = true;
                                        com.uc.crashsdk.a.g.a(th);
                                        if (!z5 && !z15) {
                                            b(false);
                                        }
                                        f.c(false);
                                        i4 = g.i();
                                        if (!com.uc.crashsdk.a.d.e()) {
                                            i4 = true;
                                        }
                                        com.uc.crashsdk.a.a.a("crashsdk", "Call java default handler: " + i4);
                                        if (i4 && (uncaughtExceptionHandler = T) != null) {
                                            uncaughtExceptionHandler.uncaughtException(thread, th);
                                        }
                                        if (com.uc.crashsdk.b.B() && !z15) {
                                            com.uc.crashsdk.b.b(com.uc.crashsdk.a.g.a());
                                        }
                                        V = true;
                                        if (Process.myPid() > 0) {
                                            Process.killProcess(Process.myPid());
                                        }
                                        throw th26;
                                    }
                                    if (!z5) {
                                        b(false);
                                    }
                                    f.c(false);
                                    i4 = g.i();
                                    if (!com.uc.crashsdk.a.d.e()) {
                                    }
                                    com.uc.crashsdk.a.a.a("crashsdk", "Call java default handler: " + i4);
                                    if (i4) {
                                        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;
                                }
                            }
                            z5 = false;
                            if (!z5) {
                            }
                            f.c(false);
                            i4 = g.i();
                            if (!com.uc.crashsdk.a.d.e()) {
                            }
                            com.uc.crashsdk.a.a.a("crashsdk", "Call java default handler: " + i4);
                            if (i4) {
                            }
                            if (com.uc.crashsdk.b.B()) {
                            }
                            V = true;
                            if (Process.myPid() > 0) {
                            }
                            throw th26;
                        }
                    }
                }
            }
        } catch (Throwable th29) {
            th = th29;
            z4 = false;
            j4 = 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 j4 = timeInMillis2 - timeInMillis;
            com.uc.crashsdk.a.f.a(0, new com.uc.crashsdk.a.e(415, new Object[]{Long.valueOf(timeInMillis2)}), j4 <= 3600000 ? 1000 + j4 : 3600000L);
        }
    }

    public static StringBuilder a(StackTraceElement[] stackTraceElementArr, String str) {
        StringBuilder sb = new StringBuilder();
        int i4 = 0;
        if (stackTraceElementArr != null && stackTraceElementArr.length > 0) {
            boolean z3 = str == null;
            int i5 = 0;
            for (StackTraceElement stackTraceElement : stackTraceElementArr) {
                i5++;
                sb.append("  at ");
                sb.append(stackTraceElement.toString());
                sb.append("\n");
                if (!z3 && stackTraceElement.getMethodName().contains(str)) {
                    sb.delete(0, sb.length());
                    z3 = true;
                    i5 = 0;
                }
            }
            i4 = i5;
        }
        if (i4 == 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.f2874d) {
            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;
        }
    }
}