嘿嘿连载.apk(点击下载) / 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.Debug;
import android.os.Environment;
import android.os.Looper;
import android.os.ParcelFileDescriptor;
import android.os.Process;
import android.os.StatFs;
import android.os.StrictMode;
import com.bigkoo.pickerview.utils.LunarCalendar;
import com.google.android.exoplayer2.trackselection.AdaptiveTrackSelection;
import com.google.android.gms.common.internal.ImagesContract;
import com.heiheilianzai.app.utils.ZToast;
import com.meizu.cloud.pushsdk.constants.PushConstants;
import com.uc.crashsdk.a.f;
import com.uc.crashsdk.a.g;
import com.uc.crashsdk.a.h;
import com.uc.crashsdk.export.LogType;
import com.umeng.umcrash.UMCustomLogInfoBuilder;
import com.xiaomi.mipush.sdk.Constants;
import io.reactivex.annotations.SchedulerSupport;
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 kotlinx.coroutines.scheduling.WorkQueueKt;
import org.mozilla.universalchardet.prober.distributionanalysis.Big5DistributionAnalysis;
import tv.danmaku.ijk.media.player.IMediaPlayer;

/* compiled from: ProGuard */
public class e implements Thread.UncaughtExceptionHandler {
    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;

    /* renamed from: a  reason: collision with root package name */
    static final /* synthetic */ boolean f6214a = (!e.class.desiredAssertionStatus());
    private static Runnable aa = new com.uc.crashsdk.a.e(407);
    private static final Object ab = new Object();
    private static boolean ac = false;
    private static ParcelFileDescriptor ad = null;
    private static boolean ae = false;
    private static boolean af = false;
    private static long b;
    private static final AtomicBoolean c = new AtomicBoolean(false);
    private static boolean d = false;
    private static long f = 0;
    private static long g = -1;
    private static boolean h = true;
    private static String i;
    private static String j = "";
    private static String k = null;
    private static String l = null;
    private static String m = null;
    private static final Object n = new Object();
    private static final Object o = new Object();
    private static final Object p = new Object();
    private static final Object q = new Object();
    private static final ArrayList<String> r = new ArrayList<>();
    private static int s = 0;
    private static String t = null;
    private static boolean u = false;
    private static String v = null;
    private static String w = null;
    private static String x = null;
    private static final Object y = new Object();
    private static final Object z = new Object();
    private final List<FileInputStream> e = new ArrayList();

    /* access modifiers changed from: private */
    /* compiled from: ProGuard */
    public static class a extends OutputStream {

        /* renamed from: a  reason: collision with root package name */
        private final long f6215a;
        private final OutputStream b;
        private int c = 0;
        private int d = 0;
        private boolean e = false;

        a(long j, OutputStream outputStream) {
            this.f6215a = j;
            this.b = outputStream;
        }

        /* JADX WARNING: Removed duplicated region for block: B:11:0x0027  */
        /* JADX WARNING: Removed duplicated region for block: B:12:0x0030  */
        /* JADX WARNING: Removed duplicated region for block: B:14:0x0037  */
        private int a(byte[] bArr, int i, int i2) {
            int i3;
            this.d += i2;
            if (this.e) {
                return 0;
            }
            int V = g.V();
            if (V > 0) {
                int i4 = this.c;
                if (i4 + i2 > V) {
                    i3 = V - i4;
                    this.c += i3;
                    if (this.f6215a == 0) {
                        b(new String(bArr, i, i3));
                    } else {
                        this.b.write(bArr, i, i3);
                    }
                    if (i3 < i2) {
                        this.e = true;
                    }
                    return i3;
                }
            }
            i3 = i2;
            this.c += i3;
            if (this.f6215a == 0) {
            }
            if (i3 < i2) {
            }
            return i3;
        }

        private void b(String str) {
            if (b.d) {
                JNIBridge.nativeClientWriteData(this.f6215a, str);
            }
        }

        /* access modifiers changed from: package-private */
        public final void a() {
            try {
                if (this.d - this.c > 0) {
                    a(UMCustomLogInfoBuilder.LINE_SEP);
                    a("--- --- --- --- --- --- --- --- --- --- --- --- --- --- --- ---\n");
                }
                int V = g.V();
                a(String.format(Locale.US, "Full: %d bytes, write: %d bytes, limit: %d bytes, reject: %d bytes.\n", Integer.valueOf(this.d), Integer.valueOf(this.c), Integer.valueOf(V), Integer.valueOf(this.d - this.c)));
            } catch (Throwable th) {
                g.a(th);
            }
        }

        /* access modifiers changed from: package-private */
        public final void a(String str) {
            if (e.h && e.N()) {
                com.uc.crashsdk.a.a.d("DEBUG", str);
            }
            if (this.f6215a != 0) {
                b(str);
            } else {
                this.b.write(str.getBytes("UTF-8"));
            }
        }

        @Override // java.io.OutputStream
        public final void write(int i) {
            if (e.h && e.N()) {
                com.uc.crashsdk.a.a.d("DEBUG", String.format(Locale.US, "%c", Integer.valueOf(i)));
            }
            if (this.f6215a != 0) {
                b(String.format(Locale.US, "%c", Integer.valueOf(i)));
            } else {
                this.b.write(i);
            }
            this.c++;
            this.d++;
        }

        @Override // java.io.OutputStream
        public final void write(byte[] bArr) {
            if (e.h && e.N() && !(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);
        }

        @Override // java.io.OutputStream
        public final void write(byte[] bArr, int i, int i2) {
            if (e.h && e.N()) {
                byte[] bArr2 = new byte[i2];
                System.arraycopy(bArr, i, bArr2, 0, i2);
                if (!(i2 == 1 && bArr2[0] == 10)) {
                    try {
                        com.uc.crashsdk.a.a.d("DEBUG", new String(bArr2));
                    } catch (Throwable unused) {
                    }
                }
            }
            a(bArr, i, i2);
        }
    }

    /* access modifiers changed from: private */
    /* compiled from: ProGuard */
    public static class b implements Comparator<File> {
        private b() {
        }

        /* synthetic */ b(byte b) {
            this();
        }

        /* JADX DEBUG: Method arguments types fixed to match base method, original types: [java.lang.Object, java.lang.Object] */
        @Override // java.util.Comparator
        public final /* synthetic */ 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;
        }
    }

    /* access modifiers changed from: private */
    /* compiled from: ProGuard */
    public static class c extends BroadcastReceiver {
        private c() {
        }

        /* synthetic */ c(byte b) {
            this();
        }

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

    /* access modifiers changed from: private */
    /* compiled from: ProGuard */
    public static class d {

        /* renamed from: a  reason: collision with root package name */
        long f6216a;
        long b;
        int c;
        int d;
        boolean e;
        boolean f;
        boolean g;

        private d() {
            this.f6216a = 0;
            this.b = 0;
            this.c = 0;
            this.d = 0;
            this.e = false;
            this.f = false;
            this.g = false;
        }

        /* synthetic */ d(byte b2) {
            this();
        }
    }

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

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

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

    static String C() {
        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");
            try {
                ActivityManager activityManager = (ActivityManager) g.a().getSystemService(PushConstants.INTENT_ACTIVITY_NAME);
                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(UMCustomLogInfoBuilder.LINE_SEP);
                }
            } catch (Throwable th) {
                g.a(th);
            }
            return sb.toString();
        } catch (Throwable th2) {
            g.a(th2);
            return "";
        }
    }

    /* JADX WARNING: Code restructure failed: missing block: B:22:0x0041, code lost:
        if ((java.lang.System.currentTimeMillis() % 3) == 0) goto L_0x0045;
     */
    /* JADX WARNING: Code restructure failed: missing block: B:4:0x000f, code lost:
        if (r0 == 1) goto L_0x0011;
     */
    /* JADX WARNING: Removed duplicated region for block: B:25:0x0047  */
    /* JADX WARNING: Removed duplicated region for block: B:32:0x0072  */
    /* JADX WARNING: Removed duplicated region for block: B:34:? A[RETURN, SYNTHETIC] */
    public static void D() {
        int p2 = g.p();
        boolean z2 = true;
        if (p2 == 0 || p2 == 3 || p2 == 4) {
            int i2 = Build.VERSION.SDK_INT;
            if (i2 >= 21 && i2 <= 25) {
                boolean z3 = p2 == 3 ? System.currentTimeMillis() % 10 == 0 : p2 != 0;
                if (p2 != 4) {
                    z2 = z3;
                }
            }
            if (!z2) {
                com.uc.crashsdk.a.a.a("crashsdk", "SIG 3 is disabled by settings");
            }
            boolean I2 = b.I();
            if (Looper.getMainLooper() != Looper.myLooper() && z2) {
                f.a(2, new com.uc.crashsdk.a.e(413));
                z2 = false;
            }
            JNIBridge.nativeCmd(7, I2 ? 1 : 0, null, null);
            if (!z2) {
                JNIBridge.cmd(8);
                return;
            }
            return;
        }
        z2 = false;
        if (!z2) {
        }
        boolean I22 = b.I();
        f.a(2, new com.uc.crashsdk.a.e(413));
        z2 = false;
        JNIBridge.nativeCmd(7, I22 ? 1 : 0, null, null);
        if (!z2) {
        }
    }

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

    public static boolean F() {
        return af;
    }

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

    static boolean H() {
        return d;
    }

    static String I() {
        return a(new Date());
    }

    static void J() {
        O = false;
        if (!b.L()) {
            f.a(3, new com.uc.crashsdk.a.e(416), 11000);
        }
        if (!U()) {
            N = 0;
            W();
        }
    }

    static boolean K() {
        return c.get() || Z();
    }

    static void L() {
        if (b.c && a.c && !f.b(aa)) {
            f.a(0, aa, 1000);
        }
    }

    private void M() {
        int k2 = g.k();
        for (int i2 = 0; i2 < k2; i2++) {
            try {
                this.e.add(new FileInputStream("/dev/null"));
            } catch (Exception e2) {
                g.a(e2);
                return;
            }
        }
    }

    /* access modifiers changed from: private */
    public static boolean N() {
        if (g.q()) {
            return true;
        }
        return a();
    }

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

    private static String P() {
        return b.L() ? "fg" : "bg";
    }

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

    private static String R() {
        return (!b.C() || d) ? LogType.JAVA_TYPE : "ucebujava";
    }

    private static void S() {
        String str;
        BufferedReader bufferedReader;
        FileReader fileReader;
        Throwable th;
        String str2 = Constants.ACCEPT_TIME_SEPARATOR_SERVER;
        try {
            str = Build.HARDWARE;
        } catch (Throwable th2) {
            g.a(th2);
            str = str2;
        }
        try {
            fileReader = new FileReader(new File("/proc/cpuinfo"));
            try {
                bufferedReader = new BufferedReader(fileReader, 512);
                int i2 = 0;
                do {
                    try {
                        String readLine = bufferedReader.readLine();
                        if (readLine == null) {
                            break;
                        }
                        if (readLine.startsWith("Hardware")) {
                            str = readLine.substring(readLine.indexOf(Constants.COLON_SEPARATOR) + 1).trim();
                        } else if (readLine.startsWith("Processor")) {
                            str2 = readLine.substring(readLine.indexOf(Constants.COLON_SEPARATOR) + 1).trim();
                        }
                        i2++;
                    } catch (Throwable th3) {
                        th = th3;
                        try {
                            g.a(th);
                            g.a(fileReader);
                            g.a(bufferedReader);
                            k = str;
                            l = str2;
                        } catch (Throwable th4) {
                            g.a(fileReader);
                            g.a(bufferedReader);
                            throw th4;
                        }
                    }
                } while (i2 < 2);
                g.a(fileReader);
            } catch (Throwable th5) {
                bufferedReader = null;
                th = th5;
                g.a(th);
                g.a(fileReader);
                g.a(bufferedReader);
                k = str;
                l = str2;
            }
        } catch (Throwable th6) {
            bufferedReader = null;
            th = th6;
            fileReader = null;
            g.a(th);
            g.a(fileReader);
            g.a(bufferedReader);
            k = str;
            l = str2;
        }
        g.a(bufferedReader);
        k = str;
        l = str2;
    }

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

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

    private static void V() {
        if (!O && !b.C() && !b.I()) {
            JNIBridge.cmd(18);
        }
    }

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

    private static StringBuilder X() {
        String str;
        try {
            StringBuilder sb = new StringBuilder();
            sb.append("level: ");
            sb.append(C);
            sb.append(UMCustomLogInfoBuilder.LINE_SEP);
            sb.append("scale: ");
            sb.append(D);
            sb.append(UMCustomLogInfoBuilder.LINE_SEP);
            String str2 = " (Unknown)";
            switch (F) {
                case 1:
                    str = str2;
                    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(UMCustomLogInfoBuilder.LINE_SEP);
            int i2 = G;
            String str3 = i2 != 0 ? i2 != 1 ? i2 != 2 ? i2 != 4 ? " (?)" : " (Wireless)" : " (USB port)" : " (AC charger)" : " (None)";
            sb.append("pluged: ");
            sb.append(G);
            sb.append(str3);
            sb.append(UMCustomLogInfoBuilder.LINE_SEP);
            int i3 = H;
            if (i3 != 1) {
                str2 = i3 != 2 ? i3 != 3 ? i3 != 4 ? i3 != 5 ? " (?)" : " (Full)" : " (Not charging)" : " (Discharging)" : " (Charging)";
            }
            sb.append("status: ");
            sb.append(H);
            sb.append(str2);
            sb.append(UMCustomLogInfoBuilder.LINE_SEP);
            sb.append("voltage: ");
            sb.append(E);
            sb.append(UMCustomLogInfoBuilder.LINE_SEP);
            sb.append("temperature: ");
            sb.append(I);
            sb.append(UMCustomLogInfoBuilder.LINE_SEP);
            sb.append("technology: ");
            sb.append(J);
            sb.append(UMCustomLogInfoBuilder.LINE_SEP);
            sb.append("battery low: ");
            sb.append(K);
            sb.append(UMCustomLogInfoBuilder.LINE_SEP);
            return sb;
        } catch (Throwable th) {
            g.a(th);
            return null;
        }
    }

    private static void Y() {
        if (b.c && L && a.c) {
            L = false;
            if (!f.b(P)) {
                f.a(0, P, AdaptiveTrackSelection.DEFAULT_MIN_TIME_BETWEEN_BUFFER_REEVALUTATION_MS);
            }
        }
    }

    private static boolean Z() {
        return b.d && JNIBridge.nativeIsCrashing();
    }

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

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

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

    static String a(int i2) {
        try {
            String a2 = g.a(new File(String.format(Locale.US, "/proc/%d/cmdline", Integer.valueOf(i2))), 128, false);
            return g.b(a2) ? k(a2) : "unknown";
        } catch (Throwable th) {
            g.a(th);
            return "unknown";
        }
    }

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

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

    static String a(String str, String str2) {
        try {
            BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(Runtime.getRuntime().exec(Build.VERSION.SDK_INT >= 26 ? new String[]{"ps", "-ef"} : new String[]{"ps"}).getInputStream()));
            boolean b2 = g.b(str);
            boolean b3 = g.b(str2);
            ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
            while (true) {
                String readLine = bufferedReader.readLine();
                if (readLine == null) {
                    return byteArrayOutputStream.toString("UTF-8");
                }
                boolean z2 = true;
                if ((!b2 || !readLine.contains(str)) && ((!b3 || !readLine.contains(str2)) && (readLine.indexOf(47) >= 0 || readLine.indexOf(46) <= 0))) {
                    z2 = false;
                }
                if (z2) {
                    byteArrayOutputStream.write(readLine.getBytes("UTF-8"));
                    byteArrayOutputStream.write(UMCustomLogInfoBuilder.LINE_SEP.getBytes("UTF-8"));
                }
            }
        } catch (Throwable th) {
            g.a(th);
            return "exception exists.";
        }
    }

    /* JADX INFO: finally extract failed */
    /* JADX WARNING: Code restructure failed: missing block: B:179:0x0329, code lost:
        if (r13 != 0) goto L_0x0339;
     */
    /* JADX WARNING: Code restructure failed: missing block: B:186:0x0337, code lost:
        if (r18 != 0) goto L_0x0339;
     */
    /* JADX WARNING: Code restructure failed: missing block: B:187:0x0339, code lost:
        b(r14);
     */
    /* JADX WARNING: Code restructure failed: missing block: B:188:0x033c, code lost:
        com.uc.crashsdk.a.g.a(r14);
     */
    /* JADX WARNING: Code restructure failed: missing block: B:189:0x0341, code lost:
        if (com.uc.crashsdk.e.af != false) goto L_0x0346;
     */
    /* JADX WARNING: Code restructure failed: missing block: B:190:0x0343, code lost:
        q(r17);
     */
    /* JADX WARNING: Code restructure failed: missing block: B:193:0x0348, code lost:
        if (com.uc.crashsdk.e.af != false) goto L_0x0353;
     */
    /* JADX WARNING: Code restructure failed: missing block: B:194:0x034a, code lost:
        r0 = a(l(r17));
     */
    /* JADX WARNING: Code restructure failed: missing block: B:195:0x0353, code lost:
        r0 = r17;
     */
    /* JADX WARNING: Code restructure failed: missing block: B:196:0x0354, code lost:
        b(r0, com.uc.crashsdk.export.LogType.JAVA_TYPE);
     */
    /* JADX WARNING: Code restructure failed: missing block: B:197:0x035a, code lost:
        r0 = move-exception;
     */
    /* JADX WARNING: Code restructure failed: missing block: B:198:0x035b, code lost:
        com.uc.crashsdk.a.g.a(r0);
     */
    /* JADX WARNING: Removed duplicated region for block: B:152:0x02d8  */
    /* JADX WARNING: Removed duplicated region for block: B:168:0x0304  */
    private static String a(Throwable th, String str, long j2, boolean z2) {
        a aVar;
        Throwable th2;
        try {
            if (!b.I()) {
                g.u();
                a(true);
            }
            int i2 = (j2 > 0 ? 1 : (j2 == 0 ? 0 : -1));
            aVar = new a(j2, i2 == 0 ? new FileOutputStream(str) : null);
            try {
                if (b.d) {
                    JNIBridge.set((int) Big5DistributionAnalysis.LOWBYTE_END_1, str);
                }
            } catch (Throwable th3) {
                th2 = th3;
                try {
                    a(th2, aVar);
                } catch (Throwable th4) {
                    if (j2 != 0) {
                        b(aVar);
                    }
                    g.a(aVar);
                    throw th4;
                }
            }
            b(aVar, str, R());
            if (z2) {
                try {
                    aVar.flush();
                } catch (Throwable th5) {
                    g.a(th5);
                }
            }
            try {
                aVar.write(("Process Name: '" + h() + "'\n").getBytes("UTF-8"));
                aVar.write(("Thread Name: '" + Thread.currentThread().getName() + "'\n").getBytes("UTF-8"));
            } catch (Throwable th6) {
                g.a(th6);
            }
            try {
                aVar.write("Back traces starts.\n".getBytes("UTF-8"));
                try {
                    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->  "));
                    }
                } catch (Throwable th7) {
                    g.a(th7);
                }
                String message = th.getMessage();
                if (message != null && !message.equals(th.getLocalizedMessage())) {
                    aVar.write(("Message: " + message + UMCustomLogInfoBuilder.LINE_SEP).getBytes("UTF-8"));
                }
            } catch (Throwable th8) {
                g.a(th8);
            }
            try {
                th.printStackTrace(new PrintStream(aVar));
            } catch (Throwable th9) {
                g.a(th9);
            }
            try {
                aVar.write("Back traces ends.\n".getBytes("UTF-8"));
            } catch (Throwable th10) {
                g.a(th10);
            }
            a((OutputStream) aVar);
            try {
                aVar.flush();
            } catch (Throwable th11) {
                g.a(th11);
            }
            try {
                a.a(aVar, "UTF-8", "--- --- --- --- --- --- --- --- --- --- --- --- --- --- --- ---\n");
            } catch (Throwable th12) {
                g.a(th12);
            }
            if (z2) {
                try {
                    aVar.flush();
                } catch (Throwable th13) {
                    g.a(th13);
                }
            }
            try {
                aVar.write("meminfo:\n".getBytes("UTF-8"));
                b(aVar, "/proc/meminfo", 10240);
            } catch (Throwable th14) {
                a(th14, aVar);
            }
            try {
                String format = String.format(Locale.US, "/proc/%d/status", Integer.valueOf(Process.myPid()));
                aVar.write("status:\n".getBytes("UTF-8"));
                b(aVar, format, 10240);
            } catch (Throwable th15) {
                a(th15, aVar);
            }
            try {
                aVar.write(("memory info:\n" + C()).getBytes("UTF-8"));
            } catch (Throwable th16) {
                a(th16, aVar);
            }
            a((OutputStream) aVar);
            g(aVar);
            try {
                a.a(aVar, "UTF-8", (ArrayList<String>) null);
            } catch (Throwable th17) {
                a(th17, aVar);
            }
            if (af) {
                h = false;
                try {
                    aVar.write(r("JAVADUMPFILES").getBytes("UTF-8"));
                } catch (Throwable th18) {
                    a(th18, aVar);
                }
                h = true;
            }
            try {
                aVar.flush();
            } catch (Throwable th19) {
                g.a(th19);
            }
            b((OutputStream) aVar);
            try {
                aVar.flush();
            } catch (Throwable th20) {
                g.a(th20);
            }
            try {
                aVar.write("battery info:\n".getBytes("UTF-8"));
            } catch (Throwable th21) {
                a(th21, aVar);
            }
            try {
                if (af) {
                    h = false;
                    aVar.write(r("BATTERYINFO").getBytes("UTF-8"));
                    h = true;
                } else {
                    StringBuilder X2 = X();
                    if (X2 != null) {
                        aVar.write(X2.toString().getBytes("UTF-8"));
                    }
                }
            } catch (Throwable th22) {
                a(th22, aVar);
            }
            a((OutputStream) aVar);
            c(aVar);
            try {
                aVar.write("device status:\n".getBytes("UTF-8"));
            } catch (Throwable th23) {
                a(th23, aVar);
            }
            if (af) {
                try {
                    h = false;
                    aVar.write(r("DEVICESTATUS").getBytes("UTF-8"));
                    h = true;
                } catch (Throwable th24) {
                    th = th24;
                }
            } else {
                try {
                    aVar.write(String.format(Locale.US, "has root: %s\n", Boolean.valueOf(g.e())).getBytes("UTF-8"));
                    String str2 = "";
                    if (Build.TAGS != null) {
                        str2 = Build.TAGS;
                    }
                    StringBuilder sb = new StringBuilder();
                    sb.append("build tags: ");
                    sb.append(str2);
                    if (g.f()) {
                        sb.append(" (default root)");
                    }
                    sb.append(UMCustomLogInfoBuilder.LINE_SEP);
                    aVar.write(sb.toString().getBytes("UTF-8"));
                    String h2 = g.h();
                    if (g.b(h2)) {
                        aVar.write(String.format(Locale.US, "su binary: %s\n", h2).getBytes("UTF-8"));
                        StringBuilder sb2 = new StringBuilder();
                        sb2.append("su permission: ");
                        sb2.append(g.g() ? "valid (" : "invalid (");
                        sb2.append(g.i());
                        sb2.append(")\n");
                        aVar.write(sb2.toString().getBytes("UTF-8"));
                    }
                } catch (Throwable th25) {
                    th = th25;
                    a(th, aVar);
                    a((OutputStream) aVar);
                    d(aVar);
                    e(aVar);
                    a.b(aVar, "UTF-8", "--- --- --- --- --- --- --- --- --- --- --- --- --- --- --- ---\n", null);
                    if (af) {
                    }
                    aVar.flush();
                    a.a(aVar, "UTF-8", "--- --- --- --- --- --- --- --- --- --- --- --- --- --- --- ---\n", null);
                    if (af) {
                    }
                    aVar.a();
                    a(aVar);
                    aVar.flush();
                }
            }
            a((OutputStream) aVar);
            d(aVar);
            e(aVar);
            try {
                a.b(aVar, "UTF-8", "--- --- --- --- --- --- --- --- --- --- --- --- --- --- --- ---\n", null);
            } catch (Throwable th26) {
                a(th26, aVar);
            }
            if (af) {
                h = false;
                try {
                    aVar.write(r("JAVACACHEDINFOS").getBytes("UTF-8"));
                } catch (Throwable th27) {
                    a(th27, aVar);
                }
                h = true;
            }
            try {
                aVar.flush();
            } catch (Throwable th28) {
                g.a(th28);
            }
            try {
                a.a(aVar, "UTF-8", "--- --- --- --- --- --- --- --- --- --- --- --- --- --- --- ---\n", null);
            } catch (Throwable th29) {
                a(th29, aVar);
            }
            if (af) {
                h = false;
                try {
                    aVar.write(r("JAVACALLBACKINFOS").getBytes("UTF-8"));
                } catch (Throwable th30) {
                    a(th30, aVar);
                }
                h = true;
            }
            aVar.a();
            a(aVar);
            try {
                aVar.flush();
            } catch (Throwable th31) {
                g.a(th31);
            }
        } catch (Throwable th32) {
            th2 = th32;
            aVar = null;
            a(th2, aVar);
        }
        return str;
    }

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

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

    /* JADX INFO: Can't fix incorrect switch cases order, some code will duplicate */
    /* JADX WARNING: Code restructure failed: missing block: B:112:0x016e, code lost:
        if (com.uc.crashsdk.b.w() != false) goto L_0x01f1;
     */
    /* JADX WARNING: Code restructure failed: missing block: B:114:0x0174, code lost:
        if (com.uc.crashsdk.a.d.d() != false) goto L_0x0180;
     */
    /* JADX WARNING: Code restructure failed: missing block: B:115:0x0176, code lost:
        com.uc.crashsdk.a.a.c("DEBUG", com.uc.crashsdk.a.d.b());
     */
    /* JADX WARNING: Code restructure failed: missing block: B:116:0x017f, code lost:
        return;
     */
    /* JADX WARNING: Code restructure failed: missing block: B:118:0x0186, code lost:
        if (c(com.uc.crashsdk.export.LogType.UNEXP_TYPE) != false) goto L_0x0190;
     */
    /* JADX WARNING: Code restructure failed: missing block: B:119:0x0188, code lost:
        com.uc.crashsdk.a.a.d("DEBUG", "unexp sample miss");
     */
    /* JADX WARNING: Code restructure failed: missing block: B:120:0x018f, code lost:
        return;
     */
    /* JADX WARNING: Code restructure failed: missing block: B:121:0x0190, code lost:
        r5 = com.uc.crashsdk.JNIBridge.nativeGenerateUnexpLog((long) com.uc.crashsdk.g.E(), com.uc.crashsdk.g.F());
     */
    /* JADX WARNING: Code restructure failed: missing block: B:122:0x019d, code lost:
        if (r5 == 0) goto L_0x01e7;
     */
    /* JADX WARNING: Code restructure failed: missing block: B:123:0x019f, code lost:
        com.uc.crashsdk.f.a(11);
     */
    /* JADX WARNING: Code restructure failed: missing block: B:124:0x01a6, code lost:
        if ((r5 & 4352) == 0) goto L_0x01b2;
     */
    /* JADX WARNING: Code restructure failed: missing block: B:125:0x01a8, code lost:
        com.uc.crashsdk.e.Z = 105;
        r5 = 30;
     */
    /* JADX WARNING: Code restructure failed: missing block: B:126:0x01ae, code lost:
        com.uc.crashsdk.f.a(r5);
     */
    /* JADX WARNING: Code restructure failed: missing block: B:128:0x01b4, code lost:
        if ((r5 & com.uc.crashsdk.export.LogType.UNEXP_EXIT) == 0) goto L_0x01bd;
     */
    /* JADX WARNING: Code restructure failed: missing block: B:129:0x01b6, code lost:
        com.uc.crashsdk.e.Z = 104;
        r5 = 31;
     */
    /* JADX WARNING: Code restructure failed: missing block: B:131:0x01bf, code lost:
        if ((r5 & com.uc.crashsdk.export.LogType.UNEXP_RESTART) == 0) goto L_0x01c8;
     */
    /* JADX WARNING: Code restructure failed: missing block: B:132:0x01c1, code lost:
        com.uc.crashsdk.e.Z = 106;
        r5 = 32;
     */
    /* JADX WARNING: Code restructure failed: missing block: B:134:0x01ca, code lost:
        if ((r5 & com.uc.crashsdk.export.LogType.UNEXP_ANR) == 0) goto L_0x01d4;
     */
    /* JADX WARNING: Code restructure failed: missing block: B:135:0x01cc, code lost:
        com.uc.crashsdk.e.Z = 103;
        com.uc.crashsdk.f.a(10);
     */
    /* JADX WARNING: Code restructure failed: missing block: B:137:0x01d6, code lost:
        if ((r5 & com.uc.crashsdk.export.LogType.UNEXP_LOW_MEMORY) == 0) goto L_0x01e0;
     */
    /* JADX WARNING: Code restructure failed: missing block: B:138:0x01d8, code lost:
        com.uc.crashsdk.e.Z = 107;
        com.uc.crashsdk.f.a(29);
     */
    /* JADX WARNING: Code restructure failed: missing block: B:139:0x01e0, code lost:
        com.uc.crashsdk.e.Z = 102;
     */
    /* JADX WARNING: Code restructure failed: missing block: B:140:0x01e4, code lost:
        a(true);
     */
    /* JADX WARNING: Code restructure failed: missing block: B:141:0x01e7, code lost:
        r5 = com.uc.crashsdk.e.Y;
     */
    /* JADX WARNING: Code restructure failed: missing block: B:142:0x01e9, code lost:
        monitor-enter(r5);
     */
    /* JADX WARNING: Code restructure failed: missing block: B:144:?, code lost:
        com.uc.crashsdk.e.X = null;
     */
    /* JADX WARNING: Code restructure failed: missing block: B:145:0x01ec, code lost:
        monitor-exit(r5);
     */
    /* JADX WARNING: Code restructure failed: missing block: B:146:0x01ed, code lost:
        return;
     */
    /* JADX WARNING: Code restructure failed: missing block: B:150:0x01f1, code lost:
        return;
     */
    public static void a(int i2, Object[] objArr) {
        switch (i2) {
            case 401:
                JNIBridge.nativeCmd(10, b.F() == 5 ? 1 : 0, null, null);
                a.c = true;
                a.a(false);
                L = true;
                Y();
                L();
                return;
            case 402:
                synchronized (Y) {
                    if (X != null) {
                        W = true;
                        break;
                    } else {
                        return;
                    }
                }
            case 403:
                aa();
                return;
            case 404:
            default:
                if (!f6214a) {
                    throw new AssertionError();
                }
                return;
            case 405:
                L = false;
                StringBuilder X2 = X();
                String n2 = b.n();
                if (X2 != null) {
                    g.a(new File(n2), X2.toString());
                    return;
                }
                return;
            case 406:
                if (f6214a || objArr != null) {
                    a((String) objArr[0], ((Boolean) objArr[1]).booleanValue(), ((Boolean) objArr[2]).booleanValue());
                    return;
                }
                throw new AssertionError();
            case 407:
                try {
                    a.d();
                    return;
                } catch (Throwable th) {
                    g.a(th);
                    return;
                }
            case 408:
                synchronized (ab) {
                    if (!ac && g.O()) {
                        if (b.K()) {
                            b.z();
                            h.f();
                            f.c();
                            if (b.C()) {
                                b();
                            }
                            if (g.O()) {
                                a(Calendar.getInstance());
                            }
                            ac = true;
                            return;
                        }
                    }
                    return;
                }
            case 409:
                b(false, false);
                return;
            case 410:
                a(false, true);
                return;
            case 411:
                if (b.d) {
                    JNIBridge.set(28, c(LogType.NATIVE_TYPE));
                    JNIBridge.set(29, c(LogType.ANR_TYPE));
                    return;
                }
                return;
            case 412:
                if (!R && b.L() && g.o()) {
                    b(g.a());
                    return;
                } else if (!R) {
                    return;
                } else {
                    if (!b.L() || !g.o()) {
                        try {
                            g.a().unregisterReceiver(Q);
                            R = false;
                            return;
                        } catch (Throwable th2) {
                            g.a(th2);
                            return;
                        }
                    } else {
                        return;
                    }
                }
            case 413:
                JNIBridge.cmd(8);
                return;
            case 414:
                try {
                    if (!d(g.a())) {
                        int i3 = N + 1;
                        N = i3;
                        if (i3 < 10) {
                            W();
                            return;
                        } else if (b.d) {
                            JNIBridge.set(130, "(get failed)");
                            return;
                        } else {
                            return;
                        }
                    } else {
                        return;
                    }
                } catch (Throwable th3) {
                    g.a(th3);
                    return;
                }
            case 415:
                if (f6214a || objArr != null) {
                    long longValue = ((Long) objArr[0]).longValue();
                    Calendar instance = Calendar.getInstance();
                    if (instance.getTimeInMillis() >= longValue) {
                        h.g();
                        f.a(100);
                        b(true, true);
                        h.b();
                    } else {
                        h.h();
                        h.i();
                        h.c();
                    }
                    a(instance);
                    break;
                } else {
                    throw new AssertionError();
                }
            case 416:
                break;
        }
        V();
    }

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

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

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

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

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

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

    private static void a(OutputStream outputStream, String str, Set<String> set) {
        if (!g.a(str) && !set.contains(str) && !str.equals("/storage/emulated")) {
            set.add(str);
            try {
                StatFs statFs = new StatFs(str);
                long a2 = a(statFs, "getBlockCountLong", "getBlockCount");
                long a3 = a(statFs, "getBlockSizeLong", "getBlockSize");
                if ((a2 / 1024) * a3 >= 10240) {
                    long a4 = a(statFs, "getAvailableBlocksLong", "getAvailableBlocks");
                    long a5 = a(statFs, "getFreeBlocksLong", "getFreeBlocks");
                    try {
                        outputStream.write(String.format(Locale.US, "%s:\n", str).getBytes("UTF-8"));
                        double d2 = (double) a3;
                        outputStream.write(String.format(Locale.US, "  total:      %d kB\n", Long.valueOf((long) (((((double) a2) * 1.0d) * d2) / 1024.0d))).getBytes("UTF-8"));
                        outputStream.write(String.format(Locale.US, "  available:  %d kB\n", Long.valueOf((long) (((((double) a4) * 1.0d) * d2) / 1024.0d))).getBytes("UTF-8"));
                        outputStream.write(String.format(Locale.US, "  free:       %d kB\n", Long.valueOf((long) (((((double) a5) * 1.0d) * d2) / 1024.0d))).getBytes("UTF-8"));
                        outputStream.write(String.format(Locale.US, "  block size: %d B\n\n", Long.valueOf(a3)).getBytes("UTF-8"));
                    } catch (Throwable th) {
                        a(th, outputStream);
                    }
                }
            } catch (Throwable unused) {
            }
        }
    }

    public static void a(String str, boolean z2) {
        if (z2) {
            x = str;
            return;
        }
        synchronized (y) {
            w = str;
            com.uc.crashsdk.a.b.a(b.p(), str + UMCustomLogInfoBuilder.LINE_SEP);
        }
    }

    /* JADX WARNING: Removed duplicated region for block: B:110:0x02f1  */
    /* JADX WARNING: Removed duplicated region for block: B:112:0x02fd  */
    /* JADX WARNING: Removed duplicated region for block: B:132:0x0356  */
    /* JADX WARNING: Removed duplicated region for block: B:140:0x03af  */
    /* JADX WARNING: Removed duplicated region for block: B:146:0x03c8  */
    /* JADX WARNING: Removed duplicated region for block: B:194:0x03bd A[SYNTHETIC] */
    /* JADX WARNING: Removed duplicated region for block: B:43:0x0121  */
    /* JADX WARNING: Removed duplicated region for block: B:56:0x01bd  */
    /* JADX WARNING: Removed duplicated region for block: B:62:0x01db  */
    /* JADX WARNING: Removed duplicated region for block: B:71:0x01f3  */
    /* JADX WARNING: Removed duplicated region for block: B:72:0x01f5 A[ADDED_TO_REGION] */
    /* JADX WARNING: Removed duplicated region for block: B:79:0x0210  */
    /* JADX WARNING: Removed duplicated region for block: B:80:0x0226  */
    /* JADX WARNING: Removed duplicated region for block: B:98:0x02b7  */
    private static void a(String str, boolean z2, boolean z3) {
        Object obj;
        int i2;
        boolean z4;
        boolean z5;
        int i3;
        int i4;
        int i5;
        File file;
        String path;
        String b2;
        File a2;
        String str2;
        int i6;
        int i7;
        String str3;
        Throwable th;
        boolean z6;
        com.uc.crashsdk.a.a.a("crashsdk", "crashsdk uploading logs");
        synchronized (n) {
            try {
                if (g.b(str)) {
                    String s2 = g.s();
                    File file2 = new File(s2);
                    if (!file2.exists()) {
                        com.uc.crashsdk.a.a.a("crashsdk", "Folder not exist: " + s2);
                    } else {
                        File[] listFiles = file2.listFiles();
                        if (listFiles == null) {
                            com.uc.crashsdk.a.a.b("List folder failed: " + s2);
                        } 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 z7 = false;
                            boolean z8 = false;
                            boolean z9 = false;
                            while (true) {
                                if (i8 >= length) {
                                    i2 = i11;
                                    z4 = z7;
                                    z5 = z8;
                                    i3 = i15;
                                    break;
                                }
                                File file3 = listFiles[i8];
                                if (!file3.isFile()) {
                                    g.a(file3);
                                } else {
                                    String name = file3.getName();
                                    if (!name.endsWith(".tmp")) {
                                        i4 = length;
                                        z4 = z7;
                                        z5 = z8;
                                        if (file3.length() == 0) {
                                            i9++;
                                            g.a(file3);
                                        } else {
                                            if (z2) {
                                                long currentTimeMillis = (System.currentTimeMillis() - file3.lastModified()) / 1000;
                                                if (currentTimeMillis >= 0) {
                                                    if (currentTimeMillis >= 2) {
                                                        if (currentTimeMillis < 5 && file3.getName().endsWith(".log")) {
                                                        }
                                                    }
                                                    z6 = 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(z6)));
                                                    if (!z6) {
                                                        i11++;
                                                    }
                                                }
                                                z6 = 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(z6)));
                                                if (!z6) {
                                                }
                                            }
                                            try {
                                                if (g.A()) {
                                                    Matcher matcher = Pattern.compile("([^_]+)_([^_]+)_([^_]+)\\.crashsdk").matcher(file3.getName());
                                                    if (matcher.matches()) {
                                                        String group = matcher.group(1);
                                                        String group2 = matcher.group(2);
                                                        i2 = i11;
                                                        try {
                                                            file = new File(g.s() + String.format(Locale.US, "%s%s_%s_%s.%s", i(group2), I(), P(), group, 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++;
                                                            }
                                                        } catch (Throwable th2) {
                                                            th = th2;
                                                        }
                                                        path = file.getPath();
                                                        boolean[] m2 = m(path);
                                                        b2 = b(path, m2[0], m2[1]);
                                                        if (path != b2) {
                                                            if (m2[0]) {
                                                                i14++;
                                                            }
                                                            if (m2[1]) {
                                                                i12++;
                                                            }
                                                            file = new File(b2);
                                                        }
                                                        a2 = d.a(file);
                                                        if (a2 == null) {
                                                            a2 = null;
                                                        } else if (file != a2 && !file.getName().equals(a2.getName()) && file.exists()) {
                                                            file.delete();
                                                        }
                                                        if (a2 == null) {
                                                            com.uc.crashsdk.a.a.b("onBeforeUploadLog return null, skip upload: " + file.getAbsolutePath());
                                                        } else {
                                                            int W2 = g.W();
                                                            if (W2 <= 0 || a2.length() < ((long) W2)) {
                                                                d dVar = new d((byte) 0);
                                                                dVar.b = 0;
                                                                dVar.f6216a = System.currentTimeMillis();
                                                                String T2 = T();
                                                                if (new File(T2).exists()) {
                                                                    a(T2, new com.uc.crashsdk.a.e(451, new Object[]{T2, dVar}));
                                                                }
                                                                long a3 = g.a();
                                                                int f2 = g.f();
                                                                int g2 = g.g();
                                                                if (a3 >= 0) {
                                                                    i5 = i14;
                                                                    i3 = i15;
                                                                    if (dVar.b + a2.length() > a3) {
                                                                        dVar.e = true;
                                                                        str3 = "Reach max upload bytes: " + a3;
                                                                    }
                                                                    if (!g.v()) {
                                                                        if (b(a2)) {
                                                                            if (f2 >= 0 && dVar.c >= f2) {
                                                                                dVar.g = true;
                                                                                str3 = "Reach max upload builtin log count: " + f2;
                                                                            }
                                                                        } else if (g2 >= 0 && dVar.d >= g2) {
                                                                            dVar.f = true;
                                                                            str3 = "Reach max upload custom log count: " + g2;
                                                                        }
                                                                    }
                                                                    if (dVar.e) {
                                                                        z7 = true;
                                                                        i15 = i3;
                                                                    } else if (dVar.g) {
                                                                        i15 = i3;
                                                                        z7 = z4;
                                                                        i11 = i2;
                                                                        z8 = true;
                                                                        i8++;
                                                                        listFiles = listFiles;
                                                                        i14 = i5;
                                                                        length = i4;
                                                                    } else {
                                                                        if (dVar.f) {
                                                                            z9 = true;
                                                                        } else {
                                                                            String name2 = a2.getName();
                                                                            if (name2.startsWith(O())) {
                                                                                String[] split = name2.split("_", 10);
                                                                                if (split.length == 9) {
                                                                                    str2 = split[1];
                                                                                    boolean z10 = str2 == null && str2.equals(g.R());
                                                                                    if (!com.uc.crashsdk.a.c.a(a2, a2.getName(), str)) {
                                                                                        com.uc.crashsdk.a.a.a("crashsdk", "Uploaded log: " + a2.getName(), null);
                                                                                        if (z10) {
                                                                                            f.a(13);
                                                                                        }
                                                                                        dVar.b += a2.length();
                                                                                        if (b(a2)) {
                                                                                            dVar.c++;
                                                                                        } else {
                                                                                            dVar.d++;
                                                                                        }
                                                                                        String T3 = T();
                                                                                        a(T3, new com.uc.crashsdk.a.e(452, new Object[]{T3, dVar}));
                                                                                        a2.delete();
                                                                                        i7 = 3;
                                                                                        i6 = 0;
                                                                                    } else {
                                                                                        i6 = i16 + 1;
                                                                                        if (z10) {
                                                                                            f.a(14);
                                                                                        }
                                                                                        i7 = 3;
                                                                                    }
                                                                                    if (i6 < i7) {
                                                                                        com.uc.crashsdk.a.a.a("crashsdk", "Upload failed 3 times continuously, abort upload!", null);
                                                                                        i14 = i5;
                                                                                        break;
                                                                                    }
                                                                                    i16 = i6;
                                                                                }
                                                                            }
                                                                            str2 = null;
                                                                            if (str2 == null) {
                                                                            }
                                                                            if (!com.uc.crashsdk.a.c.a(a2, a2.getName(), str)) {
                                                                            }
                                                                            if (i6 < i7) {
                                                                            }
                                                                        }
                                                                        i15 = i3;
                                                                        z7 = z4;
                                                                    }
                                                                    z8 = z5;
                                                                    i11 = i2;
                                                                    i8++;
                                                                    listFiles = listFiles;
                                                                    i14 = i5;
                                                                    length = i4;
                                                                } else {
                                                                    i5 = i14;
                                                                    i3 = i15;
                                                                    if (!g.v()) {
                                                                    }
                                                                    if (dVar.e) {
                                                                    }
                                                                    z8 = z5;
                                                                    i11 = i2;
                                                                    i8++;
                                                                    listFiles = listFiles;
                                                                    i14 = i5;
                                                                    length = i4;
                                                                }
                                                                com.uc.crashsdk.a.a.b(str3);
                                                                if (dVar.e) {
                                                                }
                                                                z8 = z5;
                                                                i11 = i2;
                                                                i8++;
                                                                listFiles = listFiles;
                                                                i14 = i5;
                                                                length = i4;
                                                            } else {
                                                                i13++;
                                                                g.a(a2);
                                                            }
                                                        }
                                                        i5 = i14;
                                                        z7 = z4;
                                                        z8 = z5;
                                                        i11 = i2;
                                                        i8++;
                                                        listFiles = listFiles;
                                                        i14 = i5;
                                                        length = i4;
                                                    }
                                                }
                                                i2 = i11;
                                                file = file3;
                                                if (file != file3) {
                                                }
                                            } catch (Throwable th3) {
                                                th = th3;
                                                i2 = i11;
                                                g.a(th);
                                                file = file3;
                                                path = file.getPath();
                                                boolean[] m22 = m(path);
                                                b2 = b(path, m22[0], m22[1]);
                                                if (path != b2) {
                                                }
                                                a2 = d.a(file);
                                                if (a2 == null) {
                                                }
                                                if (a2 == null) {
                                                }
                                                i5 = i14;
                                                z7 = z4;
                                                z8 = z5;
                                                i11 = i2;
                                                i8++;
                                                listFiles = listFiles;
                                                i14 = i5;
                                                length = i4;
                                            }
                                            path = file.getPath();
                                            boolean[] m222 = m(path);
                                            b2 = b(path, m222[0], m222[1]);
                                            if (path != b2) {
                                            }
                                            a2 = d.a(file);
                                            if (a2 == null) {
                                            }
                                            if (a2 == null) {
                                            }
                                            i5 = i14;
                                            z7 = z4;
                                            z8 = z5;
                                            i11 = i2;
                                            i8++;
                                            listFiles = listFiles;
                                            i14 = i5;
                                            length = i4;
                                        }
                                        i5 = i14;
                                        z7 = z4;
                                        z8 = z5;
                                        i8++;
                                        listFiles = listFiles;
                                        i14 = i5;
                                        length = i4;
                                    } else if ((System.currentTimeMillis() - file3.lastModified()) / 1000 > 30) {
                                        i4 = length;
                                        com.uc.crashsdk.a.a.b("delete legacy tmp file: " + name);
                                        i10++;
                                        g.a(file3);
                                        i5 = i14;
                                        i8++;
                                        listFiles = listFiles;
                                        i14 = i5;
                                        length = i4;
                                    }
                                }
                                i4 = length;
                                i5 = i14;
                                i8++;
                                listFiles = listFiles;
                                i14 = i5;
                                length = i4;
                            }
                            if (i10 > 0) {
                                f.a(200, i10);
                            }
                            if (i9 > 0) {
                                f.a(15, i9);
                            }
                            if (i13 > 0) {
                                f.a(17, i13);
                            }
                            if (z4) {
                                f.a(19);
                            }
                            if (z5) {
                                f.a(20);
                            }
                            if (z9) {
                                f.a(21);
                            }
                            if (z4 || z5 || z9) {
                                f.a(18);
                            }
                            if (i14 > 0) {
                                f.a(24, i14);
                            }
                            if (i12 > 0) {
                                f.a(201, i12);
                            }
                            if (i3 > 0) {
                                f.a(25, i3);
                            }
                            if (i2 > 0) {
                                f.a(26, i2);
                            }
                        }
                    }
                } else {
                    com.uc.crashsdk.a.a.a("crashsdk", "upload url is empty!");
                }
                if (z3) {
                    obj = n;
                    obj.notify();
                }
            } catch (Throwable th4) {
                if (z3) {
                    n.notify();
                }
                throw th4;
            }
        }
    }

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

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

    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 j2 = timeInMillis2 - timeInMillis;
            long j3 = 3600000;
            if (j2 <= 3600000) {
                j3 = 1000 + j2;
            }
            f.a(0, new com.uc.crashsdk.a.e(415, new Object[]{Long.valueOf(timeInMillis2)}), j3);
        }
    }

    static void a(boolean z2) {
        File[] listFiles;
        try {
            if (b.H() && (listFiles = new File(g.s()).listFiles()) != null) {
                int B2 = g.B();
                int C2 = g.C();
                if (listFiles.length >= Math.min(B2, C2)) {
                    int i2 = 0;
                    int i3 = 0;
                    for (File file : listFiles) {
                        if (b(file)) {
                            i2++;
                        } else {
                            i3++;
                        }
                    }
                    int i4 = (!z2 || i2 < B2) ? 0 : (i2 - B2) + 1;
                    int i5 = (z2 || i3 < C2) ? 0 : (i3 - C2) + 1;
                    if (!(i4 == 0 && i5 == 0)) {
                        Arrays.sort(listFiles, new b((byte) 0));
                        int i6 = i5;
                        int i7 = i4;
                        for (File file2 : listFiles) {
                            boolean b2 = b(file2);
                            if (b2 && i7 > 0) {
                                com.uc.crashsdk.a.a.a("crashsdk", "Delete oldest crash log: " + file2.getPath());
                                file2.delete();
                                i7 += -1;
                            } else if (!b2 && i6 > 0) {
                                com.uc.crashsdk.a.a.a("crashsdk", "Delete oldest custom log: " + file2.getPath());
                                file2.delete();
                                i6 += -1;
                            }
                            if (i7 == 0 && i6 == 0) {
                                break;
                            }
                        }
                        f.a(16, i4 + i5);
                        if (i4 > 0) {
                            f.a(22, i4);
                        }
                        if (i5 > 0) {
                            f.a(23, i5);
                        }
                    }
                }
            }
        } catch (Throwable th) {
            g.a(th);
        }
    }

    public static boolean a() {
        if (f == 0) {
            f = 2;
            if (g(b.a("logs")) == 1) {
                f = 1;
            }
        }
        return f == 1;
    }

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

    /* JADX WARNING: Removed duplicated region for block: B:28:0x0043 A[RETURN] */
    /* JADX WARNING: Removed duplicated region for block: B:29:0x0044  */
    private static boolean a(String str, long j2, StringBuffer stringBuffer, String str2, long j3, ArrayList<String> arrayList, ArrayList<String> arrayList2, ArrayList<String> arrayList3, String str3) {
        a aVar;
        FileOutputStream fileOutputStream;
        Throwable th;
        int i2 = (j2 > 0 ? 1 : (j2 == 0 ? 0 : -1));
        if (i2 == 0) {
            try {
                fileOutputStream = new FileOutputStream(str);
            } catch (Throwable th2) {
                th = th2;
                fileOutputStream = null;
                aVar = null;
                g.a(th);
                if (aVar != null) {
                }
            }
        } else {
            fileOutputStream = null;
        }
        try {
            aVar = new a(j2, fileOutputStream);
        } catch (Throwable th3) {
            th = th3;
            aVar = null;
            g.a(th);
            if (aVar != null) {
            }
        }
        try {
            synchronized (r) {
                t = str;
                if (b.d) {
                    JNIBridge.set((int) Big5DistributionAnalysis.LOWBYTE_END_1, t);
                }
            }
        } catch (Throwable th4) {
            th = th4;
            g.a(th);
            if (aVar != null) {
            }
        }
        if (aVar != null) {
            return false;
        }
        if ((j3 & 1) != 0) {
            try {
                b(aVar, str, str2);
            } catch (Throwable th5) {
                g.a(aVar);
                g.a(fileOutputStream);
                throw th5;
            }
        }
        try {
            aVar.write(stringBuffer.toString().getBytes());
            aVar.write(UMCustomLogInfoBuilder.LINE_SEP.getBytes("UTF-8"));
            aVar.flush();
        } catch (Throwable th6) {
            a(th6, aVar);
        }
        a((OutputStream) aVar);
        if ((j3 & 4) != 0) {
            b((OutputStream) aVar);
            try {
                aVar.flush();
            } catch (Throwable th7) {
                g.a(th7);
            }
        }
        if (arrayList != null && arrayList.size() > 0) {
            a.a(aVar, "UTF-8", arrayList);
        }
        if (arrayList2 != null && arrayList2.size() > 0) {
            a.a(aVar, "UTF-8", "--- --- --- --- --- --- --- --- --- --- --- --- --- --- --- ---\n", arrayList2);
        }
        if (arrayList3 != null && arrayList3.size() > 0) {
            a.b(aVar, "UTF-8", "--- --- --- --- --- --- --- --- --- --- --- --- --- --- --- ---\n", arrayList3);
        }
        if (str3 != null) {
            try {
                aVar.flush();
            } catch (Throwable th8) {
                a(th8, aVar);
            }
            try {
                aVar.write("threads dump:\n".getBytes("UTF-8"));
            } catch (Throwable th9) {
                a(th9, aVar);
            }
            h = false;
            v = str3;
            try {
                a(aVar, str3, j2);
            } catch (Throwable th10) {
                a(th10, aVar);
            }
            v = null;
            h = true;
        }
        if ((j3 & 8) != 0 && i2 == 0) {
            try {
                aVar.flush();
            } catch (Throwable th11) {
                a(th11, aVar);
            }
            try {
                aVar.write("all threads dump:\n".getBytes("UTF-8"));
            } catch (Throwable th12) {
                a(th12, aVar);
            }
            u = true;
            try {
                a(aVar, "all", 0L);
            } catch (Throwable th13) {
                a(th13, aVar);
            }
            u = false;
        }
        if ((j3 & 16) != 0) {
            f(aVar);
        }
        if ((j3 & 2) != 0) {
            aVar.a();
            a(aVar);
        }
        if (i2 != 0) {
            b(aVar);
        }
        g.a(aVar);
        g.a(fileOutputStream);
        try {
            synchronized (r) {
                s++;
                if (t != null) {
                    r.add(t);
                    if (r.size() > 3) {
                        r.remove(0);
                    }
                    if (b.d) {
                        JNIBridge.set((int) WorkQueueKt.MASK, t);
                    }
                    t = null;
                }
                if (b.d) {
                    JNIBridge.set(25, (long) s);
                }
            }
        } catch (Throwable th14) {
            g.a(th14);
        }
        return true;
    }

    /* JADX WARN: Multi-variable type inference failed */
    /* JADX WARN: Type inference failed for: r1v1, types: [java.io.Closeable] */
    /* JADX WARN: Type inference failed for: r1v3, types: [java.io.Closeable] */
    /* JADX WARN: Type inference failed for: r1v4, types: [java.nio.channels.FileChannel] */
    /* JADX WARN: Type inference failed for: r1v7 */
    /* JADX WARN: Type inference failed for: r1v8 */
    /* JADX WARN: Type inference failed for: r1v11 */
    /* JADX WARN: Type inference failed for: r1v12 */
    /* JADX WARN: Type inference failed for: r1v13 */
    /* JADX WARN: Type inference failed for: r1v14 */
    /* JADX WARN: Type inference failed for: r1v16 */
    /* JADX WARNING: Code restructure failed: missing block: B:12:0x0024, code lost:
        r6 = th;
     */
    /* JADX WARNING: Code restructure failed: missing block: B:13:0x0025, code lost:
        r1 = r5;
     */
    /* JADX WARNING: Code restructure failed: missing block: B:14:0x0027, code lost:
        r1 = move-exception;
     */
    /* JADX WARNING: Code restructure failed: missing block: B:16:?, code lost:
        com.uc.crashsdk.a.g.a(r1);
     */
    /* JADX WARNING: Code restructure failed: missing block: B:17:0x002b, code lost:
        r1 = r5;
     */
    /* JADX WARNING: Failed to process nested try/catch */
    /* JADX WARNING: Removed duplicated region for block: B:12:0x0024 A[ExcHandler: all (th java.lang.Throwable), Splitter:B:10:0x0018] */
    /* JADX WARNING: Unknown variable types count: 2 */
    private static boolean a(String str, com.uc.crashsdk.a.e eVar) {
        boolean z2;
        Throwable th;
        ?? r1;
        Exception e2;
        FileLock fileLock;
        ?? r12;
        synchronized (o) {
            File file = new File(str);
            if (!file.exists()) {
                try {
                    file.createNewFile();
                } catch (Exception e3) {
                    g.a(e3);
                }
            }
            FileLock fileLock2 = null;
            z2 = false;
            try {
                FileChannel fileChannel = new RandomAccessFile(file, "rw").getChannel();
                if (fileChannel != 0) {
                    try {
                        fileLock2 = fileChannel.lock();
                    } catch (Exception e4) {
                        try {
                            g.a(e4);
                        } catch (Exception e5) {
                            e2 = e5;
                            fileLock = fileChannel;
                        }
                    }
                }
                try {
                    z2 = eVar.a();
                    r12 = fileChannel;
                } finally {
                    if (fileLock2 != null) {
                        try {
                            fileLock2.release();
                        } catch (Exception e6) {
                            g.a(e6);
                        }
                    }
                }
            } catch (Exception e7) {
                fileLock = fileLock2;
                e2 = e7;
                try {
                    g.a(e2);
                    r12 = fileLock;
                    g.a((Closeable) r12);
                    return z2;
                } catch (Throwable th2) {
                    th = th2;
                    r1 = fileLock;
                }
            } catch (Throwable th3) {
            }
            g.a((Closeable) r12);
        }
        return z2;
        g.a((Closeable) r1);
        throw th;
    }

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

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

    public static boolean a(StringBuffer stringBuffer, String str, long j2, ArrayList<String> arrayList, ArrayList<String> arrayList2, ArrayList<String> arrayList3, String str2) {
        long j3;
        boolean a2;
        long j4;
        if (c.get()) {
            com.uc.crashsdk.a.a.b("Processing java crash, skip generate custom log: " + str);
            return false;
        }
        boolean z2 = af || b.I();
        if (!z2 && !com.uc.crashsdk.a.d.d()) {
            com.uc.crashsdk.a.a.c("DEBUG", com.uc.crashsdk.a.d.b());
            return false;
        } else if (!c(str)) {
            com.uc.crashsdk.a.a.d("DEBUG", "custom log sample miss: " + str);
            return false;
        } else if (Z()) {
            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.s() + j(str);
            boolean z3 = (j2 & 32) != 0;
            if (z2) {
                if (b.d) {
                    int i2 = z3 ? 1 : 0;
                    int i3 = z3 ? 1 : 0;
                    int i4 = z3 ? 1 : 0;
                    j4 = JNIBridge.nativeClientCreateConnection(str3, SchedulerSupport.CUSTOM, str, i2);
                } else {
                    j4 = 0;
                }
                if (j4 == 0) {
                    com.uc.crashsdk.a.a.d("DEBUG", "skip custom log: " + str);
                    return false;
                }
                j3 = j4;
            } else if (a(h(), str, z3)) {
                return false;
            } else {
                g.u();
                a(false);
                j3 = 0;
            }
            synchronized (p) {
                a2 = a(str3, j3, stringBuffer, str, j2, arrayList, arrayList2, arrayList3, str2);
            }
            if (a2 && !z2) {
                b(h(), str, z3);
            }
            if (j3 != 0) {
                JNIBridge.nativeClientCloseConnection(j3);
            }
            if (!a2) {
                return false;
            }
            if (!z2) {
                q(str3);
            }
            if (!z2) {
                str3 = a(l(str3));
            }
            b(str3, str);
            if (!z3 || z2) {
                return true;
            }
            try {
                a(true, false);
                return true;
            } catch (Throwable th) {
                g.a(th);
                return true;
            }
        }
    }

    public static boolean a(boolean z2, boolean z3) {
        if (!d) {
            if (b.d) {
                JNIBridge.set(1, true);
            }
            d = true;
        }
        try {
            String k2 = k();
            if (g.a(k2)) {
                com.uc.crashsdk.a.a.a("crashsdk", "CrashHandler url is empty!");
                return false;
            }
            synchronized (n) {
                if (f.a(z2 ? 1 : 0, new com.uc.crashsdk.a.e(406, new Object[]{k2, Boolean.valueOf(z3), Boolean.valueOf(z2)})) && z2) {
                    try {
                        n.wait();
                    } catch (InterruptedException e2) {
                        g.a(e2);
                    }
                }
            }
            return true;
        } catch (Throwable th) {
            g.a(th);
            return false;
        }
    }

    private static void aa() {
        String t2 = g.t();
        File file = new File(t2);
        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 i2 = length < 0 ? 0 : length;
                    long currentTimeMillis = System.currentTimeMillis();
                    int i3 = 0;
                    int i4 = 0;
                    int i5 = 0;
                    while (i3 < listFiles.length) {
                        File file2 = listFiles[i3];
                        boolean z2 = i3 < i2;
                        if (!z2 && currentTimeMillis - file2.lastModified() >= 432000000) {
                            z2 = true;
                        }
                        if (!z2) {
                            break;
                        }
                        try {
                            file2.delete();
                            i4++;
                            i5 = 0;
                        } catch (Throwable th) {
                            i5++;
                            g.a(th);
                        }
                        if (i5 >= 3) {
                            break;
                        }
                        i3++;
                    }
                    com.uc.crashsdk.a.a.a("Removed " + i4 + " logs in " + t2);
                }
            } catch (Throwable th2) {
                g.a(th2);
            }
        }
    }

    static int b(OutputStream outputStream, String str, int i2) {
        int i3;
        Throwable th;
        DataInputStream dataInputStream;
        int i4;
        DataInputStream dataInputStream2 = null;
        try {
            File file = new File(str);
            if (file.exists()) {
                byte[] Q2 = Q();
                if (Q2 == null) {
                    outputStream.write("(alloc buffer failed!)\n".getBytes("UTF-8"));
                    g.a(dataInputStream2);
                    return 0;
                }
                dataInputStream = new DataInputStream(new FileInputStream(file));
                i4 = 0;
                i3 = 0;
                loop0:
                while (true) {
                    boolean z2 = false;
                    while (true) {
                        try {
                            int read = dataInputStream.read(Q2);
                            if (read == -1) {
                                break loop0;
                            }
                            i4 += read;
                            int i5 = i2 - i3;
                            if (read <= i5 + 32) {
                                i5 = read;
                            }
                            if (i5 > 0 && !z2) {
                                outputStream.write(Q2, 0, i5);
                                i3 += i5;
                            }
                            if (!z2) {
                                if (i5 < read || i3 >= i2) {
                                    z2 = true;
                                }
                            }
                        } catch (Throwable th2) {
                            th = th2;
                            dataInputStream2 = dataInputStream;
                            try {
                                a(th, outputStream);
                                a(outputStream);
                                return i3;
                            } finally {
                                g.a(dataInputStream2);
                            }
                        }
                    }
                }
            } else {
                outputStream.write(("file: '" + str + "' not exists!\n").getBytes("UTF-8"));
                dataInputStream = dataInputStream2;
                i4 = 0;
                i3 = 0;
            }
            if (i3 > 0) {
                outputStream.write(UMCustomLogInfoBuilder.LINE_SEP.getBytes("UTF-8"));
            }
            if (i3 < i4) {
                outputStream.write(String.format(Locale.US, "(truncated %d bytes)\n", Integer.valueOf(i4 - i3)).getBytes("UTF-8"));
            }
            g.a(dataInputStream);
        } catch (Throwable th3) {
            th = th3;
            i3 = 0;
            a(th, outputStream);
            a(outputStream);
            return i3;
        }
        a(outputStream);
        return i3;
    }

    /* JADX DEBUG: Multi-variable search result rejected for r0v3, resolved type: boolean */
    /* JADX WARN: Multi-variable type inference failed */
    public static int b(boolean z2, boolean z3) {
        int i2;
        if (z3 && !ac) {
            f.d(false);
        }
        if (z2) {
            boolean a2 = f.a(b.m(), false);
            h.i();
            i2 = a2;
        } else {
            int a3 = f.a();
            h.i();
            i2 = a3;
        }
        return z3 ? f.a(z2) : i2 == 1 ? 1 : 0;
    }

    private static String b(String str, boolean z2, boolean z3) {
        if (z2) {
            try {
                str = l(str);
            } catch (Throwable th) {
                g.a(th);
            }
        }
        if (!z3) {
            return str;
        }
        try {
            return a(str);
        } catch (Throwable th2) {
            g.a(th2);
            return str;
        }
    }

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

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

    public static void b(Context context) {
        if (g.o()) {
            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, f.a(1));
                R = true;
            } catch (Throwable th) {
                g.a(th);
            }
        }
    }

    private static void b(a aVar) {
        h = false;
        try {
            aVar.write((r("LOG_END") + UMCustomLogInfoBuilder.LINE_SEP).getBytes("UTF-8"));
        } catch (Throwable th) {
            g.a(th);
        }
        h = true;
    }

    private static void b(OutputStream outputStream) {
        BufferedReader bufferedReader = null;
        try {
            outputStream.write("logcat:\n".getBytes("UTF-8"));
            if (g.D() <= 0) {
                try {
                    outputStream.write("[DEBUG] custom java logcat lines count is 0!\n".getBytes("UTF-8"));
                } catch (Throwable th) {
                    a(th, outputStream);
                }
                a(outputStream);
                g.a((Closeable) null);
                return;
            }
            int D2 = g.D();
            bufferedReader = a(new InputStreamReader(Runtime.getRuntime().exec(new String[]{"logcat", "-d", "-b", "events", "-b", "main", "-v", "threadtime", "-t", String.valueOf(D2)}).getInputStream()));
            if (bufferedReader == null) {
                try {
                    outputStream.write("[DEBUG] alloc buffer failed!\n".getBytes("UTF-8"));
                } catch (Throwable th2) {
                    a(th2, outputStream);
                }
                a(outputStream);
                g.a(bufferedReader);
                return;
            }
            h = false;
            int i2 = 0;
            int i3 = 0;
            while (true) {
                String readLine = bufferedReader.readLine();
                if (readLine != null) {
                    i2++;
                    if (i3 < D2 && !readLine.contains(" I auditd ") && !readLine.contains(" I liblog ")) {
                        outputStream.write(readLine.getBytes("UTF-8"));
                        outputStream.write(UMCustomLogInfoBuilder.LINE_SEP.getBytes("UTF-8"));
                        i3++;
                    }
                } else {
                    try {
                        break;
                    } catch (Throwable th3) {
                        a(th3, outputStream);
                    }
                }
            }
            outputStream.write(String.format(Locale.US, "[DEBUG] Read %d lines, wrote %d lines.\n", Integer.valueOf(i2), Integer.valueOf(i3)).getBytes("UTF-8"));
            h = true;
            g.a(bufferedReader);
            a(outputStream);
        } catch (Throwable th4) {
            g.a((Closeable) null);
            throw th4;
        }
    }

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

    public static void b(String str) {
        synchronized (z) {
            String q2 = b.q();
            com.uc.crashsdk.a.b.a(q2, str + UMCustomLogInfoBuilder.LINE_SEP);
        }
    }

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

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

    static void b(boolean z2) {
        try {
            boolean z3 = g.r() && b.C() && !d;
            if (!z3) {
                z3 = g.H();
            }
            if (z3) {
                if (z2) {
                    String k2 = k();
                    if (!g.a(k2)) {
                        j();
                        a(k2, false, false);
                        return;
                    }
                    return;
                }
                a(true, false);
            }
        } catch (Throwable th) {
            g.a(th);
        }
    }

    public static boolean b(int i2, Object[] objArr) {
        if (i2 != 451) {
            if (i2 != 452) {
                if (f6214a) {
                    return false;
                }
                throw new AssertionError();
            } else if (f6214a || objArr != null) {
                d dVar = (d) objArr[1];
                return g.a(new File((String) objArr[0]), String.format(Locale.US, "%d %d %d %d", Long.valueOf(dVar.f6216a), Long.valueOf(dVar.b), Integer.valueOf(dVar.c), Integer.valueOf(dVar.d)).getBytes());
            } else {
                throw new AssertionError();
            }
        } else if (f6214a || objArr != null) {
            return a((String) objArr[0], (d) objArr[1]);
        } else {
            throw new AssertionError();
        }
    }

    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) {
            return false;
        }
        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);
    }

    /* JADX WARNING: Removed duplicated region for block: B:29:0x006e A[Catch:{ all -> 0x0080 }] */
    private static void c(OutputStream outputStream) {
        HashSet hashSet;
        File[] listFiles;
        Throwable th;
        try {
            outputStream.write("disk info:\n".getBytes("UTF-8"));
        } catch (Throwable th2) {
            a(th2, outputStream);
        }
        if (af) {
            h = false;
            try {
                outputStream.write(r("FSSTAT").getBytes("UTF-8"));
            } catch (Throwable th3) {
                a(th3, outputStream);
            }
            h = true;
        } else {
            try {
                hashSet = new HashSet();
                try {
                    a(outputStream, a(new File(g.b())), hashSet);
                } catch (Throwable th4) {
                    th = th4;
                }
            } catch (Throwable th5) {
                hashSet = null;
                th = th5;
                a(th, outputStream);
                a(outputStream, a(Environment.getExternalStorageDirectory()), hashSet);
                File file = new File("/storage");
                while (r2 < r3) {
                }
                a(outputStream);
            }
            try {
                a(outputStream, a(Environment.getExternalStorageDirectory()), hashSet);
                File file2 = new File("/storage");
                if (file2.exists() && (listFiles = file2.listFiles()) != null) {
                    for (File file3 : listFiles) {
                        if (file3.isDirectory()) {
                            a(outputStream, a(file3), hashSet);
                        }
                    }
                }
            } catch (Throwable th6) {
                a(th6, outputStream);
            }
        }
        a(outputStream);
    }

    static void c(boolean z2) {
        boolean z3 = true;
        if (!R ? !z2 || !g.o() : z2 && g.o()) {
            z3 = false;
        }
        if (z3) {
            if (f.b(S)) {
                f.a(S);
            }
            f.a(0, S, ZToast.LENGTH_LONG);
        }
    }

    static boolean c(String str) {
        if (af) {
            return true;
        }
        try {
            return o(str);
        } catch (Throwable th) {
            g.a(th);
            return true;
        }
    }

    public static int d(boolean z2) {
        int b2 = z2 ? f.a(b.m()) ? 1 : 0 : f.b();
        int b3 = f.b(z2);
        return b3 > b2 ? b3 : b2;
    }

    private static void d(OutputStream outputStream) {
        if (b.d) {
            String u2 = b.u();
            h = false;
            if (1 == JNIBridge.cmd(17, u2)) {
                File file = new File(u2);
                try {
                    byte[] e2 = g.e(file);
                    if (e2 != null) {
                        outputStream.write(e2);
                    }
                } catch (Throwable th) {
                    a(th, outputStream);
                }
                try {
                    file.delete();
                } catch (Throwable th2) {
                    a(th2, outputStream);
                }
                h = true;
                a(outputStream);
            }
            h = true;
            return;
        }
        File[] fileArr = null;
        int i2 = IMediaPlayer.MEDIA_INFO_TIMED_TEXT_ERROR;
        try {
            i2 = g.l();
            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(i2)).getBytes("UTF-8"));
            } else {
                outputStream.write("[DEBUG] listFiles failed!\n".getBytes("UTF-8"));
            }
        } catch (Throwable th3) {
            a(th3, outputStream);
        }
        if (fileArr != null) {
            try {
                if (fileArr.length >= i2) {
                    outputStream.write("opened files:\n".getBytes("UTF-8"));
                    StringBuilder sb = new StringBuilder();
                    try {
                        for (File file2 : fileArr) {
                            sb.append(file2.getName());
                            sb.append(" -> ");
                            sb.append(file2.getCanonicalPath());
                            sb.append(UMCustomLogInfoBuilder.LINE_SEP);
                        }
                    } catch (Throwable th4) {
                        a(th4, outputStream);
                    }
                    outputStream.write(sb.toString().getBytes("UTF-8"));
                }
            } catch (Throwable th5) {
                a(th5, outputStream);
            }
        }
        a(outputStream);
    }

    /* access modifiers changed from: private */
    public static boolean d(Context context) {
        List<ActivityManager.ProcessErrorStateInfo> processesInErrorState;
        ActivityManager activityManager = (ActivityManager) context.getSystemService(PushConstants.INTENT_ACTIVITY_NAME);
        boolean z2 = false;
        if (activityManager == null || (processesInErrorState = activityManager.getProcessesInErrorState()) == null) {
            return false;
        }
        int myPid = Process.myPid();
        Iterator<ActivityManager.ProcessErrorStateInfo> it2 = processesInErrorState.iterator();
        while (true) {
            if (!it2.hasNext()) {
                break;
            }
            ActivityManager.ProcessErrorStateInfo next = it2.next();
            if (next.pid == myPid) {
                O = true;
                if (N()) {
                    com.uc.crashsdk.a.a.d("crashsdk", "ANR occurred in process: " + next.processName);
                }
                if (b.d) {
                    JNIBridge.set(130, next.longMsg);
                }
                z2 = true;
            }
        }
        if (!z2 && b.d) {
            V();
        }
        return true;
    }

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

    /* JADX WARNING: Removed duplicated region for block: B:32:0x0063  */
    /* JADX WARNING: Removed duplicated region for block: B:35:0x006b  */
    /* JADX WARNING: Removed duplicated region for block: B:42:0x00af A[Catch:{ all -> 0x00d3 }] */
    /* JADX WARNING: Removed duplicated region for block: B:46:0x00d1  */
    public static String e() {
        String str;
        String str2;
        Throwable th;
        Method declaredMethod;
        String str3;
        String str4;
        boolean z2;
        if (!g.a(j)) {
            return j;
        }
        String str5 = null;
        try {
            if (Build.VERSION.SDK_INT >= 21) {
                Field declaredField = Build.class.getDeclaredField("SUPPORTED_ABIS");
                declaredField.setAccessible(true);
                Object obj = declaredField.get(null);
                if (obj != null && (obj instanceof String[])) {
                    String[] strArr = (String[]) obj;
                    StringBuilder sb = new StringBuilder();
                    int length = strArr.length;
                    int i2 = 0;
                    boolean z3 = true;
                    while (i2 < length) {
                        String str6 = strArr[i2];
                        if (!z3) {
                            sb.append(Constants.ACCEPT_TIME_SEPARATOR_SP);
                        }
                        sb.append(str6);
                        i2++;
                        z3 = false;
                    }
                    j = sb.toString();
                }
            }
        } catch (Throwable unused) {
        }
        if (g.a(j)) {
            try {
                str4 = Build.CPU_ABI;
                try {
                    str3 = Build.CPU_ABI2;
                } catch (Throwable unused2) {
                }
            } catch (Throwable unused3) {
                str4 = null;
                str3 = null;
                z2 = !g.a(str4);
                if (z2) {
                }
                if (!g.a(str3)) {
                }
                declaredMethod = Class.forName("android.os.SystemProperties").getDeclaredMethod("get", String.class, String.class);
                if (declaredMethod == null) {
                }
            }
            z2 = !g.a(str4);
            if (z2) {
                j = str4;
            }
            if (!g.a(str3)) {
                if (z2) {
                    j += Constants.ACCEPT_TIME_SEPARATOR_SP;
                    j += str3;
                } else {
                    j = str3;
                }
            }
        }
        try {
            declaredMethod = Class.forName("android.os.SystemProperties").getDeclaredMethod("get", String.class, String.class);
            if (declaredMethod == null) {
                declaredMethod.setAccessible(true);
                str2 = (String) declaredMethod.invoke(null, "ro.product.cpu.abi", null);
                try {
                    str = (String) declaredMethod.invoke(null, "ro.product.cpu.abi2", null);
                } catch (Throwable th2) {
                    th = th2;
                }
                str5 = str2;
                try {
                    if (!g.a(str5) && !j.contains(str5)) {
                        j += Constants.ACCEPT_TIME_SEPARATOR_SP;
                        j += str5;
                    }
                    if (!g.a(str) && !j.contains(str)) {
                        j += Constants.ACCEPT_TIME_SEPARATOR_SP;
                        j += str;
                    }
                } catch (Throwable th3) {
                    g.a(th3);
                }
                return j;
            }
            str = null;
            j += Constants.ACCEPT_TIME_SEPARATOR_SP;
            j += str5;
            j += Constants.ACCEPT_TIME_SEPARATOR_SP;
            j += str;
            return j;
        } catch (Throwable th4) {
            th = th4;
            str2 = null;
            g.a(th);
            str = null;
            str5 = str2;
            j += Constants.ACCEPT_TIME_SEPARATOR_SP;
            j += str5;
            j += Constants.ACCEPT_TIME_SEPARATOR_SP;
            j += str;
            return j;
        }
    }

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

    /* JADX WARNING: Removed duplicated region for block: B:15:0x0025 A[RETURN] */
    /* JADX WARNING: Removed duplicated region for block: B:16:0x0026  */
    private static void e(OutputStream outputStream) {
        int i2;
        int i3;
        Throwable th;
        File[] fileArr = null;
        try {
            i3 = g.m();
            try {
                fileArr = new File("/proc/self/task").listFiles();
                if (fileArr == null || (i2 = fileArr.length) < i3) {
                    return;
                }
            } catch (Throwable th2) {
                th = th2;
                g.a(th);
                i2 = 0;
                if (fileArr != null) {
                }
            }
        } catch (Throwable th3) {
            th = th3;
            i3 = 300;
            g.a(th);
            i2 = 0;
            if (fileArr != null) {
            }
        }
        if (fileArr != null) {
            try {
                outputStream.write("threads info:\n".getBytes("UTF-8"));
                outputStream.write(String.format(Locale.US, "threads count: %d, dump limit: %d.\n", Integer.valueOf(i2), Integer.valueOf(i3)).getBytes("UTF-8"));
                outputStream.write(" tid     name\n".getBytes("UTF-8"));
                for (File file : fileArr) {
                    outputStream.write(String.format(Locale.US, "%5s %s\n", file.getName(), k(g.a(new File(file.getPath(), "comm"), 128, false))).getBytes("UTF-8"));
                }
            } catch (Throwable th4) {
                a(th4, outputStream);
            }
            a(outputStream);
        }
    }

    public static String f() {
        if (g.a(k)) {
            S();
        }
        return k;
    }

    /* JADX WARNING: Removed duplicated region for block: B:33:0x006f A[SYNTHETIC, Splitter:B:33:0x006f] */
    /* JADX WARNING: Removed duplicated region for block: B:37:0x009b  */
    private static void f(OutputStream outputStream) {
        BufferedReader bufferedReader;
        FileReader fileReader;
        Throwable th;
        int indexOf;
        boolean z2;
        if (b.d) {
            try {
                outputStream.write("solib build id:\n".getBytes("UTF-8"));
            } catch (Throwable th2) {
                a(th2, outputStream);
            }
            try {
                ArrayList arrayList = new ArrayList();
                fileReader = new FileReader(new File("/proc/self/maps"));
                try {
                    bufferedReader = new BufferedReader(fileReader, 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/")) {
                                    if (!substring.contains(a.f6202a)) {
                                        z2 = false;
                                        if (z2 && !arrayList.contains(substring)) {
                                            arrayList.add(substring);
                                            if (!af) {
                                                try {
                                                    outputStream.write((String.format("$^%s`%s^$", "SOBUILDID", substring) + UMCustomLogInfoBuilder.LINE_SEP).getBytes("UTF-8"));
                                                } catch (Throwable th3) {
                                                    a(th3, outputStream);
                                                }
                                            } else {
                                                outputStream.write(String.format(Locale.US, "%s: %s\n", substring, JNIBridge.nativeGet(3, 0, substring)).getBytes("UTF-8"));
                                            }
                                        }
                                    }
                                }
                                z2 = true;
                                arrayList.add(substring);
                                if (!af) {
                                }
                            }
                        } catch (Throwable th4) {
                            th = th4;
                            try {
                                a(th, outputStream);
                                g.a(fileReader);
                                g.a(bufferedReader);
                                a(outputStream);
                            } catch (Throwable th5) {
                                g.a(fileReader);
                                g.a(bufferedReader);
                                throw th5;
                            }
                        }
                    }
                } catch (Throwable th6) {
                    th = th6;
                    bufferedReader = null;
                    a(th, outputStream);
                    g.a(fileReader);
                    g.a(bufferedReader);
                    a(outputStream);
                }
            } catch (Throwable th7) {
                th = th7;
                fileReader = null;
                bufferedReader = null;
                a(th, outputStream);
                g.a(fileReader);
                g.a(bufferedReader);
                a(outputStream);
            }
            g.a(fileReader);
            g.a(bufferedReader);
            a(outputStream);
        }
    }

    static /* synthetic */ int g() {
        int i2 = M + 1;
        M = i2;
        return i2;
    }

    private static long g(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) {
            g.a(th);
        }
        return 0;
    }

    private static void g(OutputStream outputStream) {
        try {
            outputStream.write("recent status:\n".getBytes("UTF-8"));
        } catch (Throwable th) {
            a(th, outputStream);
        }
        try {
            outputStream.write(String.format(Locale.US, "last version: '%s'\n", af ? r("LASTVER") : a.m()).getBytes("UTF-8"));
        } catch (Throwable th2) {
            a(th2, outputStream);
        }
        try {
            synchronized (r) {
                if (t != null) {
                    outputStream.write(String.format(Locale.US, "generating log: %s\n", t).getBytes("UTF-8"));
                }
                if (s > 0 || r.size() > 0) {
                    outputStream.write(String.format(Locale.US, "generated %d logs, recent are:\n", Integer.valueOf(s)).getBytes("UTF-8"));
                    Iterator<String> it2 = r.iterator();
                    while (it2.hasNext()) {
                        outputStream.write(String.format(Locale.US, "* %s\n", it2.next()).getBytes("UTF-8"));
                    }
                }
            }
            outputStream.write(String.format(Locale.US, "dumping all threads: %s\n", Boolean.valueOf(u)).getBytes("UTF-8"));
            if (v != null) {
                outputStream.write(String.format(Locale.US, "dumping threads: %s\n", v).getBytes("UTF-8"));
            }
        } catch (Throwable th3) {
            a(th3, outputStream);
        }
        a(outputStream);
    }

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

    private static String h(String str) {
        try {
            return str.replaceAll("[^0-9a-zA-Z-.]", Constants.ACCEPT_TIME_SEPARATOR_SERVER);
        } catch (Throwable unused) {
            return "unknown";
        }
    }

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

    static /* synthetic */ void i() {
        StringBuilder X2;
        if (b.d && (X2 = X()) != null) {
            JNIBridge.set(125, X2.toString());
        }
        L = true;
        Y();
    }

    private static String j(String str) {
        return String.format(Locale.US, "%s%s_%s_%s.log", x(), I(), P(), str);
    }

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

    public static String k() {
        if (g.a(w)) {
            synchronized (y) {
                w = g.a(b.p(), x, true);
            }
        }
        return w;
    }

    private static String k(String str) {
        if (!g.b(str)) {
            return "";
        }
        int indexOf = str.indexOf(0);
        if (indexOf >= 0) {
            str = str.substring(0, indexOf);
        }
        return str.trim();
    }

    private static String l(String str) {
        String a2 = com.uc.crashsdk.a.b.a(str, g.L(), g.K());
        if (!str.equals(a2)) {
            File file = new File(str);
            if (file.exists()) {
                file.delete();
            }
        }
        return a2;
    }

    public static void l() {
        if (!af) {
            f.a(1, new com.uc.crashsdk.a.e(411), 1000);
        }
    }

    /* JADX WARNING: Code restructure failed: missing block: B:22:0x0051, code lost:
        if (r7.endsWith(r3) != false) goto L_0x005a;
     */
    /* JADX WARNING: Code restructure failed: missing block: B:27:0x0068, code lost:
        if (r7.indexOf(".log", r7.lastIndexOf(95)) != r7.lastIndexOf(".log")) goto L_0x005a;
     */
    private static boolean[] m(String str) {
        boolean K2 = g.K();
        boolean N2 = g.N();
        if (K2 || N2) {
            if (!str.endsWith(".tmp") && !str.contains(".ec")) {
                int lastIndexOf = str.lastIndexOf(File.separatorChar);
                if (lastIndexOf < 0) {
                    lastIndexOf = 0;
                }
                int i2 = 0;
                do {
                    lastIndexOf = str.indexOf(95, lastIndexOf);
                    if (lastIndexOf >= 0) {
                        i2++;
                        lastIndexOf++;
                        continue;
                    }
                } while (lastIndexOf >= 0);
                if (i2 == 8) {
                    String L2 = g.L();
                    if (!str.endsWith(".log")) {
                        if (!g.a(L2)) {
                        }
                    } else if (!g.a(L2)) {
                    }
                    K2 = false;
                }
            }
            K2 = false;
            N2 = false;
        }
        return new boolean[]{K2, N2};
    }

    public static void n() {
        b = System.currentTimeMillis();
    }

    /* JADX WARNING: Removed duplicated region for block: B:28:0x00ae  */
    private static boolean n(String str) {
        boolean z2;
        boolean z3;
        Throwable th;
        Exception e2;
        FileWriter fileWriter;
        int i2;
        synchronized (q) {
            File file = new File(g.U() + "customlog");
            String a2 = g.a(file, 1024, false);
            long currentTimeMillis = System.currentTimeMillis();
            StringBuffer stringBuffer = new StringBuffer();
            if (a2 != null) {
                stringBuffer.append(a2);
                Matcher matcher = Pattern.compile("([^\\n\\r\\t\\s]+) (\\d+) (\\d+)").matcher(stringBuffer);
                int i3 = 0;
                while (true) {
                    if (!matcher.find(i3)) {
                        break;
                    } else if (!str.equals(matcher.group(1))) {
                        i3 = matcher.end();
                    } else {
                        long parseLong = Long.parseLong(matcher.group(2));
                        if (currentTimeMillis - parseLong < 86400000) {
                            try {
                                i2 = Integer.parseInt(matcher.group(3));
                            } catch (Exception e3) {
                                g.a(e3);
                            }
                        } else {
                            parseLong = currentTimeMillis;
                            i2 = 0;
                        }
                        int h2 = g.h();
                        z2 = h2 >= 0 && i2 >= h2;
                        stringBuffer.replace(matcher.start(), matcher.end(), String.format(Locale.US, "%s %d %d", str, Long.valueOf(parseLong), Integer.valueOf(i2 + 1)));
                        z3 = true;
                    }
                }
                if (!z3) {
                    stringBuffer.append(String.format(Locale.US, "%s %d 1\n", str, Long.valueOf(currentTimeMillis)));
                }
                FileWriter fileWriter2 = null;
                fileWriter = new FileWriter(file);
                String stringBuffer2 = stringBuffer.toString();
                fileWriter.write(stringBuffer2, 0, stringBuffer2.length());
                g.a(fileWriter);
            }
            z3 = false;
            z2 = false;
            if (!z3) {
            }
            FileWriter fileWriter22 = null;
            try {
                fileWriter = new FileWriter(file);
                try {
                    String stringBuffer22 = stringBuffer.toString();
                    fileWriter.write(stringBuffer22, 0, stringBuffer22.length());
                    g.a(fileWriter);
                } catch (Exception e4) {
                    e2 = e4;
                    fileWriter22 = fileWriter;
                    try {
                        g.a(e2);
                        g.a(fileWriter22);
                        return z2;
                    } catch (Throwable th2) {
                        th = th2;
                        g.a(fileWriter22);
                        throw th;
                    }
                } catch (Throwable th3) {
                    th = th3;
                    fileWriter22 = fileWriter;
                    g.a(fileWriter22);
                    throw th;
                }
            } catch (Exception e5) {
                e2 = e5;
                g.a(e2);
                g.a(fileWriter22);
                return z2;
            }
        }
        return z2;
    }

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

    /* JADX WARNING: Removed duplicated region for block: B:34:0x00a0  */
    /* JADX WARNING: Removed duplicated region for block: B:35:0x00ab  */
    /* JADX WARNING: Removed duplicated region for block: B:37:0x00ae  */
    private static boolean o(String str) {
        boolean z2;
        int i2;
        boolean z3;
        Integer num;
        synchronized (z) {
            if (A == null) {
                A = p(g.a(b.q(), "all:1", false));
            }
            z2 = true;
            if (A.containsKey("all")) {
                num = A.get("all");
            } else if (A.containsKey(str)) {
                num = A.get(str);
            } else {
                if (!LogType.JAVA_TYPE.equals(str) && !LogType.NATIVE_TYPE.equals(str) && !LogType.ANR_TYPE.equals(str)) {
                    if (!LogType.UNEXP_TYPE.equals(str)) {
                        z3 = false;
                        if (!z3 && A.containsKey("crash")) {
                            num = A.get("crash");
                        } else if (z3 && A.containsKey("nocrash")) {
                            num = A.get("nocrash");
                        } else if (!A.containsKey("other")) {
                            num = A.get("other");
                        } else {
                            i2 = 1;
                            if (i2 != 0) {
                                long j2 = (long) i2;
                                if (j2 < 0) {
                                    long j3 = 30;
                                    if (j2 == -2) {
                                        j3 = 7;
                                    } else if (j2 == -3) {
                                        j3 = 15;
                                    } else if (j2 == -4) {
                                        j3 = 60;
                                    }
                                    long b2 = a.b();
                                    long currentTimeMillis = b2 == 0 ? -1 : (System.currentTimeMillis() - b2) / 86400000;
                                    j2 = currentTimeMillis <= j3 ? 1 : currentTimeMillis - j3;
                                }
                                if (j2 != 1) {
                                    if (j2 > 0) {
                                        if (System.currentTimeMillis() % j2 == 0) {
                                        }
                                    }
                                }
                            }
                            z2 = false;
                        }
                    }
                }
                z3 = true;
                if (!z3) {
                }
                if (z3) {
                }
                if (!A.containsKey("other")) {
                }
            }
            i2 = num.intValue();
            if (i2 != 0) {
            }
            z2 = false;
        }
        return z2;
    }

    public static String p() {
        return B;
    }

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

    static long q() {
        if (g == -1) {
            g = g(b.a(ImagesContract.LOCAL));
        }
        return g;
    }

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

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

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

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

    static void t() {
        i = null;
    }

    public static Throwable u() {
        return U;
    }

    public static int v() {
        if (b.F() == 5) {
            return Z;
        }
        return 100;
    }

    public static void w() {
        long E2 = (long) g.E();
        if (E2 >= 0) {
            boolean z2 = b.F() == 5;
            f.a(0, new com.uc.crashsdk.a.e(401));
            if (z2) {
                X = new com.uc.crashsdk.a.e(402);
                f.a(0, X, E2);
            }
        }
    }

    static String x() {
        String str = i;
        if (str != null) {
            return str;
        }
        String i2 = i((String) null);
        i = i2;
        return i2;
    }

    public static boolean y() {
        synchronized (Y) {
            if (X == null || W) {
                return false;
            }
            f.a(X);
            X = null;
            return true;
        }
    }

    public static String z() {
        return "https://errlog.umeng.com/upload";
    }

    /* JADX WARNING: Removed duplicated region for block: B:106:0x0144  */
    /* JADX WARNING: Removed duplicated region for block: B:132:0x01d3 A[SYNTHETIC, Splitter:B:132:0x01d3] */
    /* JADX WARNING: Removed duplicated region for block: B:175:0x0238 A[Catch:{ all -> 0x0263 }] */
    /* JADX WARNING: Removed duplicated region for block: B:189:0x0270  */
    /* JADX WARNING: Removed duplicated region for block: B:218:0x02b7 A[Catch:{ all -> 0x02e2 }] */
    /* JADX WARNING: Removed duplicated region for block: B:232:0x02ef  */
    /* JADX WARNING: Removed duplicated region for block: B:234:0x02fb  */
    /* JADX WARNING: Removed duplicated region for block: B:274:0x0359 A[Catch:{ all -> 0x0384 }] */
    /* JADX WARNING: Removed duplicated region for block: B:288:0x0391  */
    /* JADX WARNING: Removed duplicated region for block: B:319:0x03d8 A[Catch:{ all -> 0x0403 }] */
    /* JADX WARNING: Removed duplicated region for block: B:333:0x0410  */
    /* JADX WARNING: Removed duplicated region for block: B:341:0x0448  */
    /* JADX WARNING: Removed duplicated region for block: B:354:0x04a6 A[SYNTHETIC, Splitter:B:354:0x04a6] */
    /* JADX WARNING: Removed duplicated region for block: B:369:0x04c1 A[ADDED_TO_REGION] */
    /* JADX WARNING: Removed duplicated region for block: B:379:0x04dc A[Catch:{ all -> 0x0507 }] */
    /* JADX WARNING: Removed duplicated region for block: B:393:0x0514  */
    /* JADX WARNING: Removed duplicated region for block: B:402:0x053a A[Catch:{ all -> 0x05d1, all -> 0x05f4, all -> 0x05f1, all -> 0x0609, all -> 0x0643 }] */
    /* JADX WARNING: Removed duplicated region for block: B:409:0x055b A[SYNTHETIC, Splitter:B:409:0x055b] */
    /* JADX WARNING: Removed duplicated region for block: B:424:0x0576 A[ADDED_TO_REGION] */
    /* JADX WARNING: Removed duplicated region for block: B:434:0x0591 A[Catch:{ all -> 0x05bc }] */
    /* JADX WARNING: Removed duplicated region for block: B:448:0x05c9  */
    /* JADX WARNING: Removed duplicated region for block: B:471:0x05fd A[ADDED_TO_REGION] */
    /* JADX WARNING: Removed duplicated region for block: B:48:0x008a A[Catch:{ all -> 0x00b5 }] */
    /* JADX WARNING: Removed duplicated region for block: B:495:0x0650  */
    /* JADX WARNING: Removed duplicated region for block: B:501:? A[RETURN, SYNTHETIC] */
    /* JADX WARNING: Removed duplicated region for block: B:503:? A[RETURN, SYNTHETIC] */
    /* JADX WARNING: Removed duplicated region for block: B:505:? A[RETURN, SYNTHETIC] */
    /* JADX WARNING: Removed duplicated region for block: B:507:? A[RETURN, SYNTHETIC] */
    /* JADX WARNING: Removed duplicated region for block: B:509:? A[RETURN, SYNTHETIC] */
    /* JADX WARNING: Removed duplicated region for block: B:511:? A[RETURN, SYNTHETIC] */
    /* JADX WARNING: Removed duplicated region for block: B:513:? A[RETURN, SYNTHETIC] */
    /* JADX WARNING: Removed duplicated region for block: B:515:? A[RETURN, SYNTHETIC] */
    /* JADX WARNING: Removed duplicated region for block: B:62:0x00c1  */
    /* JADX WARNING: Removed duplicated region for block: B:92:0x010d A[Catch:{ all -> 0x0138 }] */
    public final void a(Thread thread, Throwable th, boolean z2) {
        long j2;
        boolean z3;
        Throwable th2;
        boolean z4;
        boolean z5;
        Throwable th3;
        boolean z6;
        boolean z7;
        Throwable th4;
        boolean z8;
        String str;
        boolean z9;
        boolean z10;
        Throwable th5;
        File file;
        boolean z11;
        Throwable th6;
        boolean z12;
        Throwable th7;
        boolean z13;
        Throwable th8;
        boolean z14;
        Throwable th9;
        Throwable th10;
        boolean z15;
        Throwable th11;
        boolean z16;
        Throwable th12;
        boolean z17 = (af && b.d) || b.I();
        try {
            if (!c.getAndSet(true) || Process.myPid() <= 0) {
                U = th;
                if (z17 || com.uc.crashsdk.a.d.d()) {
                    com.uc.crashsdk.a.a.d("DEBUG", "begin to generate java report");
                    try {
                        for (FileInputStream fileInputStream : this.e) {
                            g.a(fileInputStream);
                        }
                        this.e.clear();
                    } catch (Throwable th13) {
                        g.a(th13);
                    }
                    try {
                        z8 = g.I();
                        try {
                            String w2 = g.w();
                            if (w2 == null || w2.equals("")) {
                                w2 = j(R());
                            }
                            str = g.s() + w2;
                            z3 = false;
                        } catch (Throwable th14) {
                            th10 = th14;
                            com.uc.crashsdk.a.a.d("DEBUG", "get java log name failed: " + th10);
                            a(th10);
                            com.uc.crashsdk.a.a.d("DEBUG", "original exception is: " + th);
                            a(th);
                            str = null;
                            z3 = true;
                            if (!z17) {
                            }
                            boolean z18 = th instanceof OutOfMemoryError;
                            a(th, str, j2, z18);
                            com.uc.crashsdk.a.a.d("DEBUG", "generate java report finished");
                            String name = new File(str).getName();
                            String t2 = g.t();
                            file = new File(t2);
                            if (!file.exists()) {
                            }
                            String format = String.format(Locale.US, "%s%s.hprof", t2, name);
                            com.uc.crashsdk.a.a.d("DEBUG", "begin dump hprof: " + format);
                            long currentTimeMillis = System.currentTimeMillis();
                            try {
                                Debug.dumpHprofData(format);
                            } catch (Throwable th15) {
                                g.a(th15);
                            }
                            com.uc.crashsdk.a.a.d("DEBUG", "end dump hprof, use " + (System.currentTimeMillis() - currentTimeMillis) + " ms");
                            JNIBridge.nativeClientCloseConnection(j2);
                            if (z2) {
                            }
                            z9 = false;
                            if (!z9) {
                            }
                            z10 = false;
                            f.c(z10);
                            boolean y2 = g.y();
                            if (!com.uc.crashsdk.a.d.d()) {
                            }
                            com.uc.crashsdk.a.a.a("crashsdk", "Call java default handler: " + y2);
                            T.uncaughtException(thread, th);
                            b.b(g.a());
                            V = true;
                            if (Process.myPid() <= 0) {
                            }
                        }
                    } catch (Throwable th16) {
                        th10 = th16;
                        z8 = false;
                        com.uc.crashsdk.a.a.d("DEBUG", "get java log name failed: " + th10);
                        a(th10);
                        com.uc.crashsdk.a.a.d("DEBUG", "original exception is: " + th);
                        a(th);
                        str = null;
                        z3 = true;
                        if (!z17) {
                        }
                        boolean z182 = th instanceof OutOfMemoryError;
                        a(th, str, j2, z182);
                        com.uc.crashsdk.a.a.d("DEBUG", "generate java report finished");
                        String name2 = new File(str).getName();
                        String t22 = g.t();
                        file = new File(t22);
                        if (!file.exists()) {
                        }
                        String format2 = String.format(Locale.US, "%s%s.hprof", t22, 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");
                        JNIBridge.nativeClientCloseConnection(j2);
                        if (z2) {
                        }
                        z9 = false;
                        if (!z9) {
                        }
                        z10 = false;
                        f.c(z10);
                        boolean y22 = g.y();
                        if (!com.uc.crashsdk.a.d.d()) {
                        }
                        com.uc.crashsdk.a.a.a("crashsdk", "Call java default handler: " + y22);
                        T.uncaughtException(thread, th);
                        b.b(g.a());
                        V = true;
                        if (Process.myPid() <= 0) {
                        }
                    }
                    if (!z17) {
                        try {
                            g.u();
                            try {
                                if (b.L()) {
                                    f.a(3);
                                } else {
                                    f.a(4);
                                }
                            } catch (Throwable th17) {
                                g.a(th17);
                            }
                        } catch (Throwable th18) {
                            th2 = th18;
                            j2 = 0;
                            try {
                                com.uc.crashsdk.a.a.d("DEBUG", "exception occurs while java log: " + th2);
                                a(th2);
                                if (!z3) {
                                }
                                JNIBridge.nativeClientCloseConnection(j2);
                                if (z2) {
                                }
                                z6 = false;
                                if (!z6) {
                                }
                                z7 = false;
                                try {
                                    f.c(z7);
                                } catch (Throwable th19) {
                                    g.a(th19);
                                }
                                try {
                                    boolean y3 = g.y();
                                    if (!com.uc.crashsdk.a.d.d()) {
                                    }
                                    com.uc.crashsdk.a.a.a("crashsdk", "Call java default handler: " + y3);
                                    T.uncaughtException(thread, th);
                                    b.b(g.a());
                                } catch (Throwable th20) {
                                    g.a(th20);
                                }
                                V = true;
                                if (Process.myPid() <= 0) {
                                }
                            } catch (Throwable th21) {
                                g.a(th21);
                            }
                        }
                        try {
                            new File(b.l()).createNewFile();
                        } catch (Throwable th22) {
                            g.a(th22);
                        }
                        if (z8) {
                            com.uc.crashsdk.a.a.d("DEBUG", "omit java crash");
                            if (z2) {
                                try {
                                    if (g.r() && !z17) {
                                        try {
                                            a(true, false);
                                            z14 = true;
                                        } catch (Throwable th23) {
                                            th9 = th23;
                                            z14 = true;
                                            g.a(th9);
                                            b(false);
                                            f.c(false);
                                            boolean y4 = g.y();
                                            if (!com.uc.crashsdk.a.d.d()) {
                                            }
                                            com.uc.crashsdk.a.a.a("crashsdk", "Call java default handler: " + y4);
                                            T.uncaughtException(thread, th);
                                            b.b(g.a());
                                            V = true;
                                            if (Process.myPid() <= 0) {
                                            }
                                        }
                                        if (!z14 && !z17) {
                                            b(false);
                                        }
                                        f.c(false);
                                        boolean y42 = g.y();
                                        if (!com.uc.crashsdk.a.d.d()) {
                                            y42 = true;
                                        }
                                        com.uc.crashsdk.a.a.a("crashsdk", "Call java default handler: " + y42);
                                        if (y42 && T != null) {
                                            T.uncaughtException(thread, th);
                                        }
                                        if (b.L() && !z17) {
                                            b.b(g.a());
                                        }
                                        V = true;
                                        if (Process.myPid() <= 0) {
                                            Process.killProcess(Process.myPid());
                                            return;
                                        }
                                        return;
                                    }
                                } catch (Throwable th24) {
                                    th9 = th24;
                                    z14 = false;
                                    g.a(th9);
                                    b(false);
                                    f.c(false);
                                    boolean y422 = g.y();
                                    if (!com.uc.crashsdk.a.d.d()) {
                                    }
                                    com.uc.crashsdk.a.a.a("crashsdk", "Call java default handler: " + y422);
                                    T.uncaughtException(thread, th);
                                    b.b(g.a());
                                    V = true;
                                    if (Process.myPid() <= 0) {
                                    }
                                }
                            }
                            z14 = false;
                            b(false);
                            try {
                                f.c(false);
                            } catch (Throwable th25) {
                                g.a(th25);
                            }
                            try {
                                boolean y4222 = g.y();
                                if (!com.uc.crashsdk.a.d.d()) {
                                }
                                com.uc.crashsdk.a.a.a("crashsdk", "Call java default handler: " + y4222);
                                T.uncaughtException(thread, th);
                                b.b(g.a());
                            } catch (Throwable th26) {
                                g.a(th26);
                            }
                            V = true;
                            if (Process.myPid() <= 0) {
                            }
                        } else if (!c(LogType.JAVA_TYPE)) {
                            com.uc.crashsdk.a.a.d("DEBUG", "java log sample miss");
                            if (z2) {
                                try {
                                    if (g.r() && !z17) {
                                        try {
                                            a(true, false);
                                            z13 = true;
                                        } catch (Throwable th27) {
                                            th8 = th27;
                                            z13 = true;
                                            g.a(th8);
                                            b(false);
                                            f.c(false);
                                            boolean y5 = g.y();
                                            if (!com.uc.crashsdk.a.d.d()) {
                                            }
                                            com.uc.crashsdk.a.a.a("crashsdk", "Call java default handler: " + y5);
                                            T.uncaughtException(thread, th);
                                            b.b(g.a());
                                            V = true;
                                            if (Process.myPid() <= 0) {
                                            }
                                        }
                                        if (!z13 && !z17) {
                                            b(false);
                                        }
                                        f.c(false);
                                        boolean y52 = g.y();
                                        if (!com.uc.crashsdk.a.d.d()) {
                                            y52 = true;
                                        }
                                        com.uc.crashsdk.a.a.a("crashsdk", "Call java default handler: " + y52);
                                        if (y52 && T != null) {
                                            T.uncaughtException(thread, th);
                                        }
                                        if (b.L() && !z17) {
                                            b.b(g.a());
                                        }
                                        V = true;
                                        if (Process.myPid() <= 0) {
                                            Process.killProcess(Process.myPid());
                                            return;
                                        }
                                        return;
                                    }
                                } catch (Throwable th28) {
                                    th8 = th28;
                                    z13 = false;
                                    g.a(th8);
                                    b(false);
                                    f.c(false);
                                    boolean y522 = g.y();
                                    if (!com.uc.crashsdk.a.d.d()) {
                                    }
                                    com.uc.crashsdk.a.a.a("crashsdk", "Call java default handler: " + y522);
                                    T.uncaughtException(thread, th);
                                    b.b(g.a());
                                    V = true;
                                    if (Process.myPid() <= 0) {
                                    }
                                }
                            }
                            z13 = false;
                            b(false);
                            try {
                                f.c(false);
                            } catch (Throwable th29) {
                                g.a(th29);
                            }
                            try {
                                boolean y5222 = g.y();
                                if (!com.uc.crashsdk.a.d.d()) {
                                }
                                com.uc.crashsdk.a.a.a("crashsdk", "Call java default handler: " + y5222);
                                T.uncaughtException(thread, th);
                                b.b(g.a());
                            } catch (Throwable th30) {
                                g.a(th30);
                            }
                            V = true;
                            if (Process.myPid() <= 0) {
                            }
                        } else {
                            j2 = 0;
                        }
                    } else {
                        if (z8) {
                            str = "omit";
                            com.uc.crashsdk.a.a.d("DEBUG", "omit java crash");
                        }
                        j2 = b.d ? JNIBridge.nativeClientCreateConnection(str, LogType.JAVA_TYPE, null, 0) : 0;
                        int i2 = (j2 > 0 ? 1 : (j2 == 0 ? 0 : -1));
                        if (i2 == 0) {
                            try {
                                com.uc.crashsdk.a.a.d("DEBUG", "skip java crash:");
                                a(th);
                                if (i2 != 0 && b.d) {
                                    JNIBridge.nativeClientCloseConnection(j2);
                                }
                                if (z2) {
                                    try {
                                        if (g.r() && !z17) {
                                            try {
                                                a(true, false);
                                                z12 = true;
                                            } catch (Throwable th31) {
                                                th7 = th31;
                                                z12 = true;
                                                g.a(th7);
                                                b(false);
                                                f.c(false);
                                                boolean y6 = g.y();
                                                if (!com.uc.crashsdk.a.d.d()) {
                                                }
                                                com.uc.crashsdk.a.a.a("crashsdk", "Call java default handler: " + y6);
                                                T.uncaughtException(thread, th);
                                                b.b(g.a());
                                                V = true;
                                                if (Process.myPid() <= 0) {
                                                }
                                            }
                                            if (!z12 && !z17) {
                                                b(false);
                                            }
                                            f.c(false);
                                            boolean y62 = g.y();
                                            if (!com.uc.crashsdk.a.d.d()) {
                                                y62 = true;
                                            }
                                            com.uc.crashsdk.a.a.a("crashsdk", "Call java default handler: " + y62);
                                            if (y62 && T != null) {
                                                T.uncaughtException(thread, th);
                                            }
                                            if (b.L() && !z17) {
                                                b.b(g.a());
                                            }
                                            V = true;
                                            if (Process.myPid() <= 0) {
                                                Process.killProcess(Process.myPid());
                                                return;
                                            }
                                            return;
                                        }
                                    } catch (Throwable th32) {
                                        th7 = th32;
                                        z12 = false;
                                        g.a(th7);
                                        b(false);
                                        f.c(false);
                                        boolean y622 = g.y();
                                        if (!com.uc.crashsdk.a.d.d()) {
                                        }
                                        com.uc.crashsdk.a.a.a("crashsdk", "Call java default handler: " + y622);
                                        T.uncaughtException(thread, th);
                                        b.b(g.a());
                                        V = true;
                                        if (Process.myPid() <= 0) {
                                        }
                                    }
                                }
                                z12 = false;
                                b(false);
                                try {
                                    f.c(false);
                                } catch (Throwable th33) {
                                    g.a(th33);
                                }
                                try {
                                    boolean y6222 = g.y();
                                    if (!com.uc.crashsdk.a.d.d()) {
                                    }
                                    com.uc.crashsdk.a.a.a("crashsdk", "Call java default handler: " + y6222);
                                    T.uncaughtException(thread, th);
                                    b.b(g.a());
                                } catch (Throwable th34) {
                                    g.a(th34);
                                }
                                V = true;
                                if (Process.myPid() <= 0) {
                                }
                            } catch (Throwable th35) {
                                th2 = th35;
                                com.uc.crashsdk.a.a.d("DEBUG", "exception occurs while java log: " + th2);
                                a(th2);
                                if (!z3) {
                                }
                                JNIBridge.nativeClientCloseConnection(j2);
                                if (z2) {
                                }
                                z6 = false;
                                if (!z6) {
                                }
                                z7 = false;
                                f.c(z7);
                                boolean y32 = g.y();
                                if (!com.uc.crashsdk.a.d.d()) {
                                }
                                com.uc.crashsdk.a.a.a("crashsdk", "Call java default handler: " + y32);
                                T.uncaughtException(thread, th);
                                b.b(g.a());
                                V = true;
                                if (Process.myPid() <= 0) {
                                }
                            }
                        } else if (z8) {
                            if (i2 != 0 && b.d) {
                                JNIBridge.nativeClientCloseConnection(j2);
                            }
                            if (z2) {
                                try {
                                    if (g.r() && !z17) {
                                        try {
                                            a(true, false);
                                            z11 = true;
                                        } catch (Throwable th36) {
                                            th6 = th36;
                                            z11 = true;
                                            g.a(th6);
                                            b(false);
                                            f.c(false);
                                            boolean y7 = g.y();
                                            if (!com.uc.crashsdk.a.d.d()) {
                                            }
                                            com.uc.crashsdk.a.a.a("crashsdk", "Call java default handler: " + y7);
                                            T.uncaughtException(thread, th);
                                            b.b(g.a());
                                            V = true;
                                            if (Process.myPid() <= 0) {
                                            }
                                        }
                                        if (!z11 && !z17) {
                                            b(false);
                                        }
                                        f.c(false);
                                        boolean y72 = g.y();
                                        if (!com.uc.crashsdk.a.d.d()) {
                                            y72 = true;
                                        }
                                        com.uc.crashsdk.a.a.a("crashsdk", "Call java default handler: " + y72);
                                        if (y72 && T != null) {
                                            T.uncaughtException(thread, th);
                                        }
                                        if (b.L() && !z17) {
                                            b.b(g.a());
                                        }
                                        V = true;
                                        if (Process.myPid() <= 0) {
                                            Process.killProcess(Process.myPid());
                                            return;
                                        }
                                        return;
                                    }
                                } catch (Throwable th37) {
                                    th6 = th37;
                                    z11 = false;
                                    g.a(th6);
                                    b(false);
                                    f.c(false);
                                    boolean y722 = g.y();
                                    if (!com.uc.crashsdk.a.d.d()) {
                                    }
                                    com.uc.crashsdk.a.a.a("crashsdk", "Call java default handler: " + y722);
                                    T.uncaughtException(thread, th);
                                    b.b(g.a());
                                    V = true;
                                    if (Process.myPid() <= 0) {
                                    }
                                }
                            }
                            z11 = false;
                            b(false);
                            try {
                                f.c(false);
                            } catch (Throwable th38) {
                                g.a(th38);
                            }
                            try {
                                boolean y7222 = g.y();
                                if (!com.uc.crashsdk.a.d.d()) {
                                }
                                com.uc.crashsdk.a.a.a("crashsdk", "Call java default handler: " + y7222);
                                T.uncaughtException(thread, th);
                                b.b(g.a());
                            } catch (Throwable th39) {
                                g.a(th39);
                            }
                            V = true;
                            if (Process.myPid() <= 0) {
                            }
                        }
                    }
                    boolean z1822 = th instanceof OutOfMemoryError;
                    a(th, str, j2, z1822);
                    com.uc.crashsdk.a.a.d("DEBUG", "generate java report finished");
                    if (!b.I() && z1822 && g.z()) {
                        String name22 = new File(str).getName();
                        String t222 = g.t();
                        file = new File(t222);
                        if (!file.exists()) {
                            file.mkdirs();
                        }
                        String format22 = String.format(Locale.US, "%s%s.hprof", t222, name22);
                        com.uc.crashsdk.a.a.d("DEBUG", "begin dump hprof: " + format22);
                        long currentTimeMillis22 = System.currentTimeMillis();
                        Debug.dumpHprofData(format22);
                        com.uc.crashsdk.a.a.d("DEBUG", "end dump hprof, use " + (System.currentTimeMillis() - currentTimeMillis22) + " ms");
                    }
                    if (j2 != 0 && b.d) {
                        JNIBridge.nativeClientCloseConnection(j2);
                    }
                    if (z2) {
                        try {
                            if (g.r() && !z17) {
                                try {
                                    a(true, false);
                                    z9 = true;
                                } catch (Throwable th40) {
                                    th5 = th40;
                                    z9 = true;
                                    g.a(th5);
                                    if (!z9) {
                                    }
                                    z10 = false;
                                    f.c(z10);
                                    boolean y222 = g.y();
                                    if (!com.uc.crashsdk.a.d.d()) {
                                    }
                                    com.uc.crashsdk.a.a.a("crashsdk", "Call java default handler: " + y222);
                                    T.uncaughtException(thread, th);
                                    b.b(g.a());
                                    V = true;
                                    if (Process.myPid() <= 0) {
                                    }
                                }
                                if (!z9 || z17) {
                                    z10 = false;
                                } else {
                                    z10 = false;
                                    b(false);
                                }
                                f.c(z10);
                                boolean y2222 = g.y();
                                if (!com.uc.crashsdk.a.d.d()) {
                                    y2222 = true;
                                }
                                com.uc.crashsdk.a.a.a("crashsdk", "Call java default handler: " + y2222);
                                if (y2222 && T != null) {
                                    T.uncaughtException(thread, th);
                                }
                                if (b.L() && !z17) {
                                    b.b(g.a());
                                }
                                V = true;
                                if (Process.myPid() <= 0) {
                                    Process.killProcess(Process.myPid());
                                    return;
                                }
                                return;
                            }
                        } catch (Throwable th41) {
                            th5 = th41;
                            z9 = false;
                            g.a(th5);
                            if (!z9) {
                            }
                            z10 = false;
                            f.c(z10);
                            boolean y22222 = g.y();
                            if (!com.uc.crashsdk.a.d.d()) {
                            }
                            com.uc.crashsdk.a.a.a("crashsdk", "Call java default handler: " + y22222);
                            T.uncaughtException(thread, th);
                            b.b(g.a());
                            V = true;
                            if (Process.myPid() <= 0) {
                            }
                        }
                    }
                    z9 = false;
                    if (!z9) {
                    }
                    z10 = false;
                    try {
                        f.c(z10);
                    } catch (Throwable th42) {
                        g.a(th42);
                    }
                    try {
                        boolean y222222 = g.y();
                        if (!com.uc.crashsdk.a.d.d()) {
                        }
                        com.uc.crashsdk.a.a.a("crashsdk", "Call java default handler: " + y222222);
                        T.uncaughtException(thread, th);
                        b.b(g.a());
                    } catch (Throwable th43) {
                        g.a(th43);
                    }
                    V = true;
                    if (Process.myPid() <= 0) {
                    }
                } else {
                    com.uc.crashsdk.a.a.c("DEBUG", com.uc.crashsdk.a.d.b());
                    if (z2) {
                        try {
                            if (g.r() && !z17) {
                                try {
                                    a(true, false);
                                    z15 = true;
                                } catch (Throwable th44) {
                                    th11 = th44;
                                    z15 = true;
                                    g.a(th11);
                                    b(false);
                                    f.c(false);
                                    boolean y8 = g.y();
                                    if (!com.uc.crashsdk.a.d.d()) {
                                    }
                                    com.uc.crashsdk.a.a.a("crashsdk", "Call java default handler: " + y8);
                                    T.uncaughtException(thread, th);
                                    b.b(g.a());
                                    V = true;
                                    if (Process.myPid() <= 0) {
                                    }
                                }
                                if (!z15 && !z17) {
                                    b(false);
                                }
                                f.c(false);
                                boolean y82 = g.y();
                                if (!com.uc.crashsdk.a.d.d()) {
                                    y82 = true;
                                }
                                com.uc.crashsdk.a.a.a("crashsdk", "Call java default handler: " + y82);
                                if (y82 && T != null) {
                                    T.uncaughtException(thread, th);
                                }
                                if (b.L() && !z17) {
                                    b.b(g.a());
                                }
                                V = true;
                                if (Process.myPid() <= 0) {
                                    Process.killProcess(Process.myPid());
                                    return;
                                }
                                return;
                            }
                        } catch (Throwable th45) {
                            th11 = th45;
                            z15 = false;
                            g.a(th11);
                            b(false);
                            f.c(false);
                            boolean y822 = g.y();
                            if (!com.uc.crashsdk.a.d.d()) {
                            }
                            com.uc.crashsdk.a.a.a("crashsdk", "Call java default handler: " + y822);
                            T.uncaughtException(thread, th);
                            b.b(g.a());
                            V = true;
                            if (Process.myPid() <= 0) {
                            }
                        }
                    }
                    z15 = false;
                    b(false);
                    try {
                        f.c(false);
                    } catch (Throwable th46) {
                        g.a(th46);
                    }
                    try {
                        boolean y8222 = g.y();
                        if (!com.uc.crashsdk.a.d.d()) {
                        }
                        com.uc.crashsdk.a.a.a("crashsdk", "Call java default handler: " + y8222);
                        T.uncaughtException(thread, th);
                        b.b(g.a());
                    } catch (Throwable th47) {
                        g.a(th47);
                    }
                    V = true;
                    if (Process.myPid() <= 0) {
                    }
                }
            } else {
                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 i3 = 0;
                while (!V) {
                    try {
                        Thread.sleep(1000);
                    } catch (Throwable th48) {
                        g.a(th48);
                    }
                    i3++;
                    if (i3 >= 4) {
                        break;
                    }
                }
                Process.killProcess(Process.myPid());
                if (z2) {
                    try {
                        if (g.r() && !z17) {
                            try {
                                a(true, false);
                                z16 = true;
                            } catch (Throwable th49) {
                                th12 = th49;
                                z16 = true;
                                g.a(th12);
                                b(false);
                                f.c(false);
                                boolean y9 = g.y();
                                if (!com.uc.crashsdk.a.d.d()) {
                                }
                                com.uc.crashsdk.a.a.a("crashsdk", "Call java default handler: " + y9);
                                T.uncaughtException(thread, th);
                                b.b(g.a());
                                V = true;
                                if (Process.myPid() <= 0) {
                                }
                            }
                            if (!z16 && !z17) {
                                b(false);
                            }
                            f.c(false);
                            boolean y92 = g.y();
                            if (!com.uc.crashsdk.a.d.d()) {
                                y92 = true;
                            }
                            com.uc.crashsdk.a.a.a("crashsdk", "Call java default handler: " + y92);
                            if (y92 && T != null) {
                                T.uncaughtException(thread, th);
                            }
                            if (b.L() && !z17) {
                                b.b(g.a());
                            }
                            V = true;
                            if (Process.myPid() <= 0) {
                                Process.killProcess(Process.myPid());
                                return;
                            }
                            return;
                        }
                    } catch (Throwable th50) {
                        th12 = th50;
                        z16 = false;
                        g.a(th12);
                        b(false);
                        f.c(false);
                        boolean y922 = g.y();
                        if (!com.uc.crashsdk.a.d.d()) {
                        }
                        com.uc.crashsdk.a.a.a("crashsdk", "Call java default handler: " + y922);
                        T.uncaughtException(thread, th);
                        b.b(g.a());
                        V = true;
                        if (Process.myPid() <= 0) {
                        }
                    }
                }
                z16 = false;
                b(false);
                try {
                    f.c(false);
                } catch (Throwable th51) {
                    g.a(th51);
                }
                try {
                    boolean y9222 = g.y();
                    if (!com.uc.crashsdk.a.d.d()) {
                    }
                    com.uc.crashsdk.a.a.a("crashsdk", "Call java default handler: " + y9222);
                    T.uncaughtException(thread, th);
                    b.b(g.a());
                } catch (Throwable th52) {
                    g.a(th52);
                }
                V = true;
                if (Process.myPid() <= 0) {
                }
            }
        } catch (Throwable th53) {
            th2 = th53;
            z3 = false;
            j2 = 0;
            com.uc.crashsdk.a.a.d("DEBUG", "exception occurs while java log: " + th2);
            a(th2);
            if (!z3) {
                com.uc.crashsdk.a.a.d("DEBUG", "original exception is: " + th);
                a(th);
            }
            if (j2 != 0 && b.d) {
                JNIBridge.nativeClientCloseConnection(j2);
            }
            if (z2) {
                try {
                    if (g.r() && !z17) {
                        try {
                            a(true, false);
                            z6 = true;
                        } catch (Throwable th54) {
                            th4 = th54;
                            z6 = true;
                            g.a(th4);
                            if (!z6) {
                            }
                            z7 = false;
                            f.c(z7);
                            boolean y322 = g.y();
                            if (!com.uc.crashsdk.a.d.d()) {
                            }
                            com.uc.crashsdk.a.a.a("crashsdk", "Call java default handler: " + y322);
                            T.uncaughtException(thread, th);
                            b.b(g.a());
                            V = true;
                            if (Process.myPid() <= 0) {
                            }
                        }
                        if (!z6 || z17) {
                            z7 = false;
                        } else {
                            z7 = false;
                            b(false);
                        }
                        f.c(z7);
                        boolean y3222 = g.y();
                        if (!com.uc.crashsdk.a.d.d()) {
                            y3222 = true;
                        }
                        com.uc.crashsdk.a.a.a("crashsdk", "Call java default handler: " + y3222);
                        if (y3222 && T != null) {
                            T.uncaughtException(thread, th);
                        }
                        if (b.L() && !z17) {
                            b.b(g.a());
                        }
                        V = true;
                        if (Process.myPid() <= 0) {
                            Process.killProcess(Process.myPid());
                            return;
                        }
                        return;
                    }
                } catch (Throwable th55) {
                    th4 = th55;
                    z6 = false;
                    g.a(th4);
                    if (!z6) {
                    }
                    z7 = false;
                    f.c(z7);
                    boolean y32222 = g.y();
                    if (!com.uc.crashsdk.a.d.d()) {
                    }
                    com.uc.crashsdk.a.a.a("crashsdk", "Call java default handler: " + y32222);
                    T.uncaughtException(thread, th);
                    b.b(g.a());
                    V = true;
                    if (Process.myPid() <= 0) {
                    }
                }
            }
            z6 = false;
            if (!z6) {
            }
            z7 = false;
            f.c(z7);
            boolean y322222 = g.y();
            if (!com.uc.crashsdk.a.d.d()) {
            }
            com.uc.crashsdk.a.a.a("crashsdk", "Call java default handler: " + y322222);
            T.uncaughtException(thread, th);
            b.b(g.a());
            V = true;
            if (Process.myPid() <= 0) {
            }
        }
        V = true;
        if (Process.myPid() > 0) {
            Process.killProcess(Process.myPid());
        }
        throw th;
        boolean y10 = g.y();
        if (!com.uc.crashsdk.a.d.d()) {
            y10 = true;
        }
        com.uc.crashsdk.a.a.a("crashsdk", "Call java default handler: " + y10);
        if (y10 && T != null) {
            T.uncaughtException(thread, th);
        }
        if (b.L() && !z17) {
            b.b(g.a());
        }
        V = true;
        if (Process.myPid() > 0) {
        }
        throw th;
    }

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