恐 怖 老 奶 奶1破 解 版 中 文 版 无 敌 版 v4.15.00版本的 MD5 值为:2c4218ea002b12a6cce81f33a9f0144d

以下内容为反编译后的 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.Looper;
import android.os.ParcelFileDescriptor;
import android.os.Process;
import android.os.StatFs;
import android.os.StrictMode;
import android.support.v4.media.session.PlaybackStateCompat;
import androidx.appcompat.widget.ActivityChooserModel;
import androidx.core.os.EnvironmentCompat;
import androidx.renderscript.ScriptIntrinsicBLAS;
import com.kuaishou.weapon.p0.bh;
import com.kuaishou.weapon.p0.bj;
import com.kwad.sdk.api.model.AdnName;
import com.kwad.sdk.core.imageloader.utils.MemoryCacheUtils;
import com.qq.e.comm.adevent.AdEventType;
import com.uc.crashsdk.a.h;
import com.uc.crashsdk.export.LogType;
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.UUID;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class e implements Thread.UncaughtExceptionHandler {
    public static long f9671b;
    public static String f9677i;
    public final List<FileInputStream> f9678e = new ArrayList();
    public static final boolean f9670a = !e.class.desiredAssertionStatus();
    public static final AtomicBoolean f9672c = new AtomicBoolean(false);
    public static boolean f9673d = false;
    public static long f9674f = 0;
    public static long f9675g = -1;
    public static boolean f9676h = true;
    public static String j = "";
    public static String k = null;
    public static String l = null;
    public static String m = null;
    public static final Object n = new Object();
    public static final Object o = new Object();
    public static final Object p = new Object();
    public static final Object q = new Object();
    public static final ArrayList<String> r = new ArrayList<>();
    public static int s = 0;
    public static String t = null;
    public static boolean u = false;
    public static String v = null;
    public static String w = null;
    public static String x = null;
    public static final Object y = new Object();
    public static final Object z = new Object();
    public static Map<String, Integer> A = null;
    public static String B = null;
    public static int C = -1;
    public static int D = -1;
    public static int E = -1;
    public static int F = -1;
    public static int G = -1;
    public static int H = -1;
    public static int I = -1;
    public static String J = "?";
    public static boolean K = false;
    public static boolean L = false;
    public static int M = 0;
    public static int N = 0;
    public static boolean O = false;
    public static com.uc.crashsdk.a.e P = new com.uc.crashsdk.a.e(AdEventType.ADAPTER_APK_DOWNLOAD_FINISH);
    public static c Q = new c((byte) 0);
    public static boolean R = false;
    public static final com.uc.crashsdk.a.e S = new com.uc.crashsdk.a.e(412);
    public static Thread.UncaughtExceptionHandler T = null;
    public static Throwable U = null;
    public static boolean V = false;
    public static boolean W = false;
    public static Runnable X = null;
    public static final Object Y = new Object();
    public static int Z = 101;
    public static Runnable aa = new com.uc.crashsdk.a.e(AdEventType.APP_AD_CLICKED);
    public static final Object ab = new Object();
    public static boolean ac = false;
    public static ParcelFileDescriptor ad = null;
    public static boolean ae = false;
    public static boolean af = false;

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

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

        public b(byte b2) {
            this();
        }
    }

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

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

        public c(byte b2) {
            this();
        }
    }

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

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

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

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

    public static ParcelFileDescriptor D() {
        if (!com.uc.crashsdk.b.f9655d) {
            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;
        }
        ParcelFileDescriptor adoptFd = ParcelFileDescriptor.adoptFd(cmd);
        ad = adoptFd;
        ae = true;
        return adoptFd;
    }

    public static boolean E() {
        return af;
    }

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

    public static boolean H() {
        return N();
    }

    public static int I() {
        int i2 = M + 1;
        M = i2;
        return i2;
    }

    public static void J() {
        StringBuilder X2;
        if (com.uc.crashsdk.b.f9655d && (X2 = X()) != null) {
            JNIBridge.set(125, X2.toString());
        }
        L = true;
        Y();
    }

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

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

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

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

    public static String O() {
        return g.e() + MemoryCacheUtils.URI_AND_SIZE_SEPARATOR;
    }

    public static String P() {
        return com.uc.crashsdk.b.y() ? "fg" : "bg";
    }

    public 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;
    }

    public static String R() {
        return (!com.uc.crashsdk.b.C() || f9673d) ? LogType.JAVA_TYPE : "ucebujava";
    }

    public static void S() {
        String str;
        BufferedReader bufferedReader;
        Throwable th;
        FileReader fileReader;
        String str2 = "-";
        try {
            str = Build.HARDWARE;
        } catch (Throwable th2) {
            com.uc.crashsdk.a.g.a(th2);
            str = "-";
        }
        try {
            fileReader = new FileReader(new File(bj.f9039a));
            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(":") + 1).trim();
                        } else if (readLine.startsWith("Processor")) {
                            str2 = readLine.substring(readLine.indexOf(":") + 1).trim();
                        }
                        i2++;
                    } catch (Throwable th3) {
                        th = th3;
                        try {
                            com.uc.crashsdk.a.g.a(th);
                            com.uc.crashsdk.a.g.a(fileReader);
                            com.uc.crashsdk.a.g.a(bufferedReader);
                            k = str;
                            l = str2;
                        } catch (Throwable th4) {
                            com.uc.crashsdk.a.g.a(fileReader);
                            com.uc.crashsdk.a.g.a(bufferedReader);
                            throw th4;
                        }
                    }
                } while (i2 < 2);
                com.uc.crashsdk.a.g.a(fileReader);
            } catch (Throwable th5) {
                bufferedReader = null;
                th = th5;
            }
        } catch (Throwable th6) {
            bufferedReader = null;
            th = th6;
            fileReader = null;
        }
        com.uc.crashsdk.a.g.a(bufferedReader);
        k = str;
        l = str2;
    }

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

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

    public static void V() {
        if (O || com.uc.crashsdk.b.C() || com.uc.crashsdk.b.I()) {
            return;
        }
        JNIBridge.cmd(18);
    }

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

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

    public static void Y() {
        if (com.uc.crashsdk.b.f9654c && L && com.uc.crashsdk.a.f9595c) {
            L = false;
            if (com.uc.crashsdk.a.f.b(P)) {
                return;
            }
            com.uc.crashsdk.a.f.a(0, P, 2000L);
        }
    }

    public static boolean Z() {
        return com.uc.crashsdk.b.f9655d && JNIBridge.nativeIsCrashing();
    }

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

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

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

    public static String d(boolean z2) {
        return z2 ? "https://errlogos.umeng.com/upload" : "https://errlog.umeng.com/upload";
    }

    public static String j(String str) {
        return String.format(Locale.US, "%s%s_%s_%s.log", d(), m(), P(), str);
    }

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

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

    public static boolean[] m(String str) {
        boolean v2 = g.v();
        boolean x2 = g.x();
        if (v2 || x2) {
            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 w2 = g.w();
                    if (!str.endsWith(com.anythink.china.common.a.a.f2078f)) {
                        if (!com.uc.crashsdk.a.g.a(w2)) {
                        }
                    } else if (!com.uc.crashsdk.a.g.a(w2)) {
                    }
                    v2 = false;
                }
            }
            v2 = false;
            x2 = false;
        }
        return new boolean[]{v2, x2};
    }

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

    public static boolean o(String str) {
        boolean z2;
        boolean z3;
        int i2;
        Integer num;
        synchronized (z) {
            z2 = false;
            if (A == null) {
                A = p(com.uc.crashsdk.a.g.a(com.uc.crashsdk.b.i(), "all:1", false));
            }
            if (A.containsKey("all")) {
                num = A.get("all");
            } else if (A.containsKey(str)) {
                num = A.get(str);
            } else {
                if (!LogType.JAVA_TYPE.equals(str) && !LogType.NATIVE_TYPE.equals(str) && !LogType.ANR_TYPE.equals(str) && !LogType.UNEXP_TYPE.equals(str)) {
                    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(AdnName.OTHER)) {
                        i2 = 1;
                        if (i2 != 0) {
                            long j2 = 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 = com.uc.crashsdk.a.b();
                                long currentTimeMillis = b2 == 0 ? -1L : (System.currentTimeMillis() - b2) / 86400000;
                                j2 = currentTimeMillis <= j3 ? 1L : currentTimeMillis - j3;
                            }
                            if (j2 != 1) {
                                if (j2 > 0) {
                                    if (System.currentTimeMillis() % j2 == 0) {
                                    }
                                }
                            }
                            z2 = true;
                        }
                    } else {
                        num = A.get(AdnName.OTHER);
                    }
                }
                z3 = true;
                if (!z3) {
                }
                if (z3) {
                }
                if (A.containsKey(AdnName.OTHER)) {
                }
            }
            i2 = num.intValue();
            if (i2 != 0) {
            }
        }
        return z2;
    }

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

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

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

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

    public static boolean t() {
        return f9672c.get() || Z();
    }

    public static Throwable u() {
        return U;
    }

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

    public static void w() {
        long o2 = g.o();
        if (o2 < 0) {
            return;
        }
        boolean z2 = com.uc.crashsdk.b.F() == 5;
        com.uc.crashsdk.a.f.a(0, new com.uc.crashsdk.a.e(AdEventType.ADAPTER_APK_DOWNLOAD_START));
        if (z2) {
            com.uc.crashsdk.a.e eVar = new com.uc.crashsdk.a.e(AdEventType.ADAPTER_APK_DOWNLOAD_PAUSE);
            X = eVar;
            com.uc.crashsdk.a.f.a(0, eVar, o2);
        }
    }

    public static void x() {
        if (com.uc.crashsdk.b.f9654c && com.uc.crashsdk.a.f9595c && !com.uc.crashsdk.a.f.b(aa)) {
            com.uc.crashsdk.a.f.a(0, aa, 1000L);
        }
    }

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

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

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

    public static String d() {
        String str = f9677i;
        if (str != null) {
            return str;
        }
        String i2 = i((String) null);
        f9677i = i2;
        return i2;
    }

    public static String e() {
        String str;
        String str2;
        boolean z2;
        String str3;
        String str4;
        Method declaredMethod;
        if (!com.uc.crashsdk.a.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(",");
                        }
                        sb.append(str6);
                        i2++;
                        z3 = false;
                    }
                    j = sb.toString();
                }
            }
        } catch (Throwable unused) {
        }
        if (com.uc.crashsdk.a.g.a(j)) {
            try {
                str = Build.CPU_ABI;
            } catch (Throwable unused2) {
                str = null;
            }
            try {
                str2 = Build.CPU_ABI2;
            } catch (Throwable unused3) {
                str2 = null;
                z2 = !com.uc.crashsdk.a.g.a(str);
                if (z2) {
                }
                if (!com.uc.crashsdk.a.g.a(str2)) {
                }
                declaredMethod = Class.forName("android.os.SystemProperties").getDeclaredMethod("get", String.class, String.class);
                if (declaredMethod == null) {
                }
            }
            z2 = !com.uc.crashsdk.a.g.a(str);
            if (z2) {
                j = str;
            }
            if (!com.uc.crashsdk.a.g.a(str2)) {
                if (z2) {
                    j += ",";
                    j += str2;
                } else {
                    j = str2;
                }
            }
        }
        try {
            declaredMethod = Class.forName("android.os.SystemProperties").getDeclaredMethod("get", String.class, String.class);
        } catch (Throwable th) {
            th = th;
            str3 = null;
        }
        if (declaredMethod == null) {
            declaredMethod.setAccessible(true);
            str3 = (String) declaredMethod.invoke(null, "ro.product.cpu.abi", null);
            try {
                str4 = (String) declaredMethod.invoke(null, "ro.product.cpu.abi2", null);
            } catch (Throwable th2) {
                th = th2;
                com.uc.crashsdk.a.g.a(th);
                str4 = null;
                str5 = str3;
                if (!com.uc.crashsdk.a.g.a(str5)) {
                }
                if (!com.uc.crashsdk.a.g.a(str4)) {
                }
                return j;
            }
            str5 = str3;
            if (!com.uc.crashsdk.a.g.a(str5) && !j.contains(str5)) {
                j += ",";
                j += str5;
            }
            if (!com.uc.crashsdk.a.g.a(str4) && !j.contains(str4)) {
                j += ",";
                j += str4;
            }
            return j;
        }
        str4 = null;
        if (!com.uc.crashsdk.a.g.a(str5)) {
            j += ",";
            j += str5;
        }
        if (!com.uc.crashsdk.a.g.a(str4)) {
            j += ",";
            j += str4;
        }
        return j;
    }

    public 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) {
            com.uc.crashsdk.a.g.a(th);
        }
        return 0L;
    }

    public static String h(String str) {
        try {
            return str.replaceAll("[^0-9a-zA-Z-.]", "-");
        } catch (Throwable unused) {
            return EnvironmentCompat.MEDIA_UNKNOWN;
        }
    }

    public 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);
    }

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

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

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

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

    public static void c(OutputStream outputStream) {
        if (com.uc.crashsdk.b.f9655d) {
            String l2 = com.uc.crashsdk.b.l();
            f9676h = false;
            if (1 == JNIBridge.cmd(17, l2)) {
                File file = new File(l2);
                try {
                    byte[] e2 = com.uc.crashsdk.a.g.e(file);
                    if (e2 != null) {
                        outputStream.write(e2);
                    }
                } catch (Throwable th) {
                    a(th, outputStream);
                }
                try {
                    file.delete();
                } catch (Throwable th2) {
                    a(th2, outputStream);
                }
                f9676h = true;
                a(outputStream);
            }
            f9676h = true;
            return;
        }
        File[] fileArr = null;
        int i2 = com.anythink.expressad.d.a.b.by;
        try {
            i2 = g.H();
            fileArr = new File("/proc/self/fd").listFiles();
            if (fileArr != null) {
                outputStream.write(String.format(Locale.US, "opened file count: %d, write limit: %d.\n", Integer.valueOf(fileArr.length), Integer.valueOf(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();
                    for (File file2 : fileArr) {
                        sb.append(file2.getName());
                        sb.append(" -> ");
                        sb.append(file2.getCanonicalPath());
                        sb.append("\n");
                    }
                    outputStream.write(sb.toString().getBytes("UTF-8"));
                }
            } catch (Throwable th4) {
                a(th4, outputStream);
            }
        }
        a(outputStream);
    }

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

    public static void d(OutputStream outputStream) {
        int i2;
        int i3;
        File[] fileArr = null;
        try {
            i2 = g.I();
            try {
                fileArr = new File("/proc/self/task").listFiles();
            } catch (Throwable th) {
                th = th;
                com.uc.crashsdk.a.g.a(th);
                i3 = 0;
                if (fileArr != null) {
                }
            }
        } catch (Throwable th2) {
            th = th2;
            i2 = 300;
        }
        if (fileArr == null) {
            return;
        }
        i3 = fileArr.length;
        if (i3 < i2) {
            return;
        }
        if (fileArr != null) {
            return;
        }
        try {
            outputStream.write("threads info:\n".getBytes("UTF-8"));
            outputStream.write(String.format(Locale.US, "threads count: %d, dump limit: %d.\n", Integer.valueOf(i3), Integer.valueOf(i2)).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(com.uc.crashsdk.a.g.a(new File(file.getPath(), "comm"), 128, false))).getBytes("UTF-8"));
            }
        } catch (Throwable th3) {
            a(th3, outputStream);
        }
        a(outputStream);
    }

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

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

    public static void a(int i2, Object[] objArr) {
        int i3;
        switch (i2) {
            case AdEventType.ADAPTER_APK_DOWNLOAD_START:
                JNIBridge.nativeCmd(10, com.uc.crashsdk.b.F() == 5 ? 1L : 0L, null, null);
                com.uc.crashsdk.a.f9595c = true;
                com.uc.crashsdk.a.a(false);
                L = true;
                Y();
                x();
                return;
            case AdEventType.ADAPTER_APK_DOWNLOAD_PAUSE:
                synchronized (Y) {
                    if (X == null) {
                        return;
                    }
                    W = true;
                    if (com.uc.crashsdk.b.n()) {
                        return;
                    }
                    if (!com.uc.crashsdk.a.d.d()) {
                        com.uc.crashsdk.a.a.c("DEBUG", com.uc.crashsdk.a.d.b());
                        return;
                    } else if (!c(LogType.UNEXP_TYPE)) {
                        com.uc.crashsdk.a.a.d("DEBUG", "unexp sample miss");
                        return;
                    } else {
                        int nativeGenerateUnexpLog = JNIBridge.nativeGenerateUnexpLog(g.o(), g.p());
                        if (nativeGenerateUnexpLog != 0) {
                            f.a(11);
                            if ((nativeGenerateUnexpLog & 4352) != 0) {
                                Z = 105;
                                i3 = 30;
                            } else if ((nativeGenerateUnexpLog & LogType.UNEXP_EXIT) != 0) {
                                Z = 104;
                                i3 = 31;
                            } else if ((nativeGenerateUnexpLog & LogType.UNEXP_RESTART) != 0) {
                                Z = 106;
                                i3 = 32;
                            } else {
                                if ((nativeGenerateUnexpLog & LogType.UNEXP_ANR) != 0) {
                                    Z = 103;
                                    f.a(10);
                                } else if ((nativeGenerateUnexpLog & LogType.UNEXP_LOW_MEMORY) != 0) {
                                    Z = 107;
                                    f.a(29);
                                } else {
                                    Z = 102;
                                }
                                a(true);
                            }
                            f.a(i3);
                            a(true);
                        }
                        synchronized (Y) {
                            X = null;
                        }
                        return;
                    }
                }
            case AdEventType.ADAPTER_APK_DOWNLOAD_RESUME:
                aa();
                return;
            case 404:
            default:
                if (!f9670a) {
                    throw new AssertionError();
                }
                return;
            case AdEventType.ADAPTER_APK_DOWNLOAD_FINISH:
                L = false;
                StringBuilder X2 = X();
                String d2 = com.uc.crashsdk.b.d();
                if (X2 != null) {
                    com.uc.crashsdk.a.g.a(new File(d2), X2.toString());
                    return;
                }
                return;
            case AdEventType.ADAPTER_APK_INSTALLED:
                if (!f9670a && objArr == null) {
                    throw new AssertionError();
                }
                a((String) objArr[0], ((Boolean) objArr[1]).booleanValue(), ((Boolean) objArr[2]).booleanValue());
                return;
            case AdEventType.APP_AD_CLICKED:
                try {
                    com.uc.crashsdk.a.d();
                    return;
                } catch (Throwable th) {
                    com.uc.crashsdk.a.g.a(th);
                    return;
                }
            case 408:
                synchronized (ab) {
                    if (!ac && g.O() && com.uc.crashsdk.b.w()) {
                        com.uc.crashsdk.b.p();
                        h.f();
                        f.c();
                        if (com.uc.crashsdk.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 (com.uc.crashsdk.b.f9655d) {
                    JNIBridge.set(28, c(LogType.NATIVE_TYPE));
                    JNIBridge.set(29, c(LogType.ANR_TYPE));
                    return;
                }
                return;
            case 412:
                if (!R && com.uc.crashsdk.b.y() && g.K()) {
                    b(com.uc.crashsdk.a.g.a());
                    return;
                } else if (R) {
                    if (com.uc.crashsdk.b.y() && g.K()) {
                        return;
                    }
                    try {
                        com.uc.crashsdk.a.g.a().unregisterReceiver(Q);
                        R = false;
                        return;
                    } catch (Throwable th2) {
                        com.uc.crashsdk.a.g.a(th2);
                        return;
                    }
                } else {
                    return;
                }
            case 413:
                JNIBridge.cmd(8);
                return;
            case 414:
                try {
                    if (d(com.uc.crashsdk.a.g.a())) {
                        return;
                    }
                    int i4 = N + 1;
                    N = i4;
                    if (i4 < 10) {
                        W();
                        return;
                    } else if (com.uc.crashsdk.b.f9655d) {
                        JNIBridge.set((int) ScriptIntrinsicBLAS.RsBlas_ctrsm, "(get failed)");
                        return;
                    } else {
                        return;
                    }
                } catch (Throwable th3) {
                    com.uc.crashsdk.a.g.a(th3);
                    return;
                }
            case 415:
                if (!f9670a && objArr == null) {
                    throw new AssertionError();
                }
                long longValue = ((Long) objArr[0]).longValue();
                Calendar calendar = Calendar.getInstance();
                if (calendar.getTimeInMillis() >= longValue) {
                    h.g();
                    f.a(100);
                    b(true, true);
                    h.b();
                } else {
                    h.h();
                    h.i();
                    h.c();
                }
                a(calendar);
                break;
            case 416:
                break;
        }
        V();
    }

    public static class a extends OutputStream {
        public final long f9679a;
        public final OutputStream f9680b;
        public int f9681c = 0;
        public int f9682d = 0;
        public boolean f9683e = false;

        public a(long j, OutputStream outputStream) {
            this.f9679a = j;
            this.f9680b = outputStream;
        }

        private int a(byte[] bArr, int i2, int i3) {
            int i4;
            this.f9682d += i3;
            if (this.f9683e) {
                return 0;
            }
            int y = g.y();
            if (y > 0) {
                int i5 = this.f9681c;
                if (i5 + i3 > y) {
                    i4 = y - i5;
                    this.f9681c += i4;
                    if (this.f9679a == 0) {
                        b(new String(bArr, i2, i4));
                    } else {
                        this.f9680b.write(bArr, i2, i4);
                    }
                    if (i4 < i3) {
                        this.f9683e = true;
                    }
                    return i4;
                }
            }
            i4 = i3;
            this.f9681c += i4;
            if (this.f9679a == 0) {
            }
            if (i4 < i3) {
            }
            return i4;
        }

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

        @Override
        public final void write(int i2) {
            if (e.f9676h && e.H()) {
                com.uc.crashsdk.a.a.d("DEBUG", String.format(Locale.US, "%c", Integer.valueOf(i2)));
            }
            if (this.f9679a != 0) {
                b(String.format(Locale.US, "%c", Integer.valueOf(i2)));
            } else {
                this.f9680b.write(i2);
            }
            this.f9681c++;
            this.f9682d++;
        }

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

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

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

        public final void a(String str) {
            if (e.f9676h && e.H()) {
                com.uc.crashsdk.a.a.d("DEBUG", str);
            }
            if (this.f9679a != 0) {
                b(str);
            } else {
                this.f9680b.write(str.getBytes("UTF-8"));
            }
        }
    }

    public static void f(OutputStream outputStream) {
        String m2;
        try {
            outputStream.write("recent status:\n".getBytes("UTF-8"));
        } catch (Throwable th) {
            a(th, outputStream);
        }
        try {
            if (af) {
                m2 = r("LASTVER");
            } else {
                m2 = com.uc.crashsdk.a.m();
            }
            outputStream.write(String.format(Locale.US, "last version: '%s'\n", m2).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> it = r.iterator();
                    while (it.hasNext()) {
                        outputStream.write(String.format(Locale.US, "* %s\n", it.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 g() {
        try {
            StringBuilder sb = new StringBuilder();
            sb.append("JavaMax:    ");
            sb.append(Runtime.getRuntime().maxMemory() / PlaybackStateCompat.ACTION_PLAY_FROM_MEDIA_ID);
            sb.append(" kB\n");
            sb.append("JavaTotal:  ");
            sb.append(Runtime.getRuntime().totalMemory() / PlaybackStateCompat.ACTION_PLAY_FROM_MEDIA_ID);
            sb.append(" kB\n");
            sb.append("JavaFree:   ");
            sb.append(Runtime.getRuntime().freeMemory() / PlaybackStateCompat.ACTION_PLAY_FROM_MEDIA_ID);
            sb.append(" kB\n");
            sb.append("NativeHeap: ");
            sb.append(Debug.getNativeHeapSize() / PlaybackStateCompat.ACTION_PLAY_FROM_MEDIA_ID);
            sb.append(" kB\n");
            sb.append("NativeAllocated: ");
            sb.append(Debug.getNativeHeapAllocatedSize() / PlaybackStateCompat.ACTION_PLAY_FROM_MEDIA_ID);
            sb.append(" kB\n");
            sb.append("NativeFree: ");
            sb.append(Debug.getNativeHeapFreeSize() / PlaybackStateCompat.ACTION_PLAY_FROM_MEDIA_ID);
            sb.append(" kB\n");
            ActivityManager activityManager = (ActivityManager) com.uc.crashsdk.a.g.a().getSystemService(ActivityChooserModel.ATTRIBUTE_ACTIVITY);
            if (activityManager != null) {
                ActivityManager.MemoryInfo memoryInfo = new ActivityManager.MemoryInfo();
                activityManager.getMemoryInfo(memoryInfo);
                sb.append("availMem:   ");
                sb.append(memoryInfo.availMem / PlaybackStateCompat.ACTION_PLAY_FROM_MEDIA_ID);
                sb.append(" kB\n");
                sb.append("threshold:  ");
                sb.append(memoryInfo.threshold / PlaybackStateCompat.ACTION_PLAY_FROM_MEDIA_ID);
                sb.append(" kB\n");
                sb.append("lowMemory:  ");
                sb.append(memoryInfo.lowMemory);
                sb.append("\n");
            }
            return sb.toString();
        } catch (Throwable th) {
            com.uc.crashsdk.a.g.a(th);
            return "";
        }
    }

    public static class d {
        public long f9684a;
        public long f9685b;
        public int f9686c;
        public int f9687d;
        public boolean f9688e;
        public boolean f9689f;
        public boolean f9690g;

        public d() {
            this.f9684a = 0L;
            this.f9685b = 0L;
            this.f9686c = 0;
            this.f9687d = 0;
            this.f9688e = false;
            this.f9689f = false;
            this.f9690g = false;
        }

        public d(byte b2) {
            this();
        }
    }

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

    public static boolean i() {
        return f9673d;
    }

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

    public static String p() {
        return B;
    }

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

    public static void b(OutputStream outputStream, String str, String str2) {
        String str3;
        String str4;
        try {
            outputStream.write("*** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***\n".getBytes("UTF-8"));
        } catch (Throwable th) {
            a(th, outputStream);
        }
        try {
            outputStream.write(String.format(Locale.US, "Basic Information: 'pid: %d/tid: %d/time: %s'\n", Integer.valueOf(Process.myPid()), Integer.valueOf(Process.myTid()), m()).getBytes("UTF-8"));
            Locale locale = Locale.US;
            Object[] objArr = new Object[3];
            objArr[0] = e();
            if (com.uc.crashsdk.a.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(f9671b));
            objArr2[1] = Long.valueOf(Runtime.getRuntime().maxMemory());
            objArr2[2] = com.uc.crashsdk.a.g.d();
            objArr2[3] = com.uc.crashsdk.b.y() ? "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(com.uc.crashsdk.a.c())).getBytes("UTF-8"));
            String str5 = "0";
            String str6 = "";
            if (com.uc.crashsdk.b.f9655d) {
                String nativeGet = JNIBridge.nativeGet(1, 0L, null);
                str4 = JNIBridge.nativeGet(2, 0L, null);
                str5 = nativeGet;
            } else {
                str4 = "";
            }
            outputStream.write(String.format(Locale.US, "CrashSDK Information: 'version: %s/nativeseq: %s/javaseq: %s/arch: %s/target: %s'\n", "3.2.0.4", str5, "210105150455", str4, "release").getBytes("UTF-8"));
            if (str != null) {
                str6 = str;
            }
            outputStream.write(("Report Name: " + str6.substring(str6.lastIndexOf(47) + 1) + "\n").getBytes("UTF-8"));
        } catch (Throwable th4) {
            a(th4, outputStream);
        }
        try {
            if (af) {
                str3 = r("UUID");
            } else {
                str3 = B;
            }
            outputStream.write(String.format("UUID: %s\n", str3).getBytes("UTF-8"));
            outputStream.write(("Log Type: " + str2 + "\n").getBytes("UTF-8"));
        } catch (Throwable th5) {
            a(th5, outputStream);
        }
        try {
            String B2 = com.uc.crashsdk.b.B();
            if (com.uc.crashsdk.a.g.a(B2)) {
                B2 = "(none)";
            }
            outputStream.write(("Activity: " + B2 + "\n").getBytes("UTF-8"));
        } catch (Throwable th6) {
            a(th6, outputStream);
        }
        a(outputStream);
        try {
            com.uc.crashsdk.a.a(outputStream, "UTF-8");
            if (af) {
                f9676h = false;
                outputStream.write(r("HEADER").getBytes("UTF-8"));
                f9676h = true;
            }
        } catch (Throwable th7) {
            a(th7, outputStream);
        }
        a(outputStream);
    }

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

    public static boolean d(Context context) {
        List<ActivityManager.ProcessErrorStateInfo> processesInErrorState;
        ActivityManager activityManager = (ActivityManager) context.getSystemService(ActivityChooserModel.ATTRIBUTE_ACTIVITY);
        boolean z2 = false;
        if (activityManager == null || (processesInErrorState = activityManager.getProcessesInErrorState()) == null) {
            return false;
        }
        int myPid = Process.myPid();
        Iterator<ActivityManager.ProcessErrorStateInfo> it = processesInErrorState.iterator();
        while (true) {
            if (!it.hasNext()) {
                break;
            }
            ActivityManager.ProcessErrorStateInfo next = it.next();
            if (next.pid == myPid) {
                O = true;
                if (N()) {
                    com.uc.crashsdk.a.a.d("crashsdk", "ANR occurred in process: " + next.processName);
                }
                if (com.uc.crashsdk.b.f9655d) {
                    JNIBridge.set((int) ScriptIntrinsicBLAS.RsBlas_ctrsm, next.longMsg);
                }
                z2 = true;
            }
        }
        if (!z2 && com.uc.crashsdk.b.f9655d) {
            V();
        }
        return true;
    }

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

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

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

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

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

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

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

    public 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;
    }

    public static int e(boolean z2) {
        int b2;
        if (z2) {
            b2 = f.a(com.uc.crashsdk.b.c()) ? 1 : 0;
        } else {
            b2 = f.b();
        }
        int b3 = f.b(z2);
        return b3 > b2 ? b3 : b2;
    }

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

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

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

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

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

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

    public static int a(OutputStream outputStream, String str, int i2) {
        int i3 = 0;
        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!";
            }
            int length = a2.length();
            if (length <= i2 + 32) {
                i2 = length;
            }
            if (i2 > 0) {
                try {
                    outputStream.write(a2.getBytes("UTF-8"), 0, i2);
                    outputStream.write("\n".getBytes("UTF-8"));
                } catch (Throwable th) {
                    th = th;
                    i3 = i2;
                    a(th, outputStream);
                    i2 = i3;
                    a(outputStream);
                    return i2;
                }
            }
            if (i2 < a2.length()) {
                outputStream.write(String.format(Locale.US, "(truncated %d bytes)\n", Integer.valueOf(a2.length() - i2)).getBytes("UTF-8"));
            }
        } catch (Throwable th2) {
            th = th2;
        }
        a(outputStream);
        return i2;
    }

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

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

    public static String a(Throwable th, String str, long j2, boolean z2) {
        int i2;
        a aVar;
        String str2;
        String str3;
        int i3;
        HashSet hashSet;
        String a2;
        StatFs statFs;
        long a3;
        long a4;
        try {
            if (!com.uc.crashsdk.b.I()) {
                try {
                    g.a();
                    a(true);
                } catch (Throwable th2) {
                    th = th2;
                    try {
                        a(th, (OutputStream) null);
                        if (!af) {
                        }
                        b(!af ? a(l(str)) : str, LogType.JAVA_TYPE);
                        return str;
                    } finally {
                        if (j2 != 0) {
                            b((a) null);
                        }
                        com.uc.crashsdk.a.g.a((Closeable) null);
                    }
                }
            }
            i2 = (j2 > 0L ? 1 : (j2 == 0L ? 0 : -1));
            aVar = new a(j2, i2 == 0 ? new FileOutputStream(str) : null);
            try {
                if (com.uc.crashsdk.b.f9655d) {
                    JNIBridge.set(126, str);
                }
                b(aVar, str, R());
                if (z2) {
                    aVar.flush();
                }
                aVar.write(("Process Name: '" + h() + "'\n").getBytes("UTF-8"));
                aVar.write(("Thread Name: '" + Thread.currentThread().getName() + "'\n").getBytes("UTF-8"));
                aVar.write("Back traces starts.\n".getBytes("UTF-8"));
                Field declaredField = Throwable.class.getDeclaredField("detailMessage");
                declaredField.setAccessible(true);
                Object obj = declaredField.get(th);
                if (obj != null) {
                    declaredField.set(th, ((String) obj).replaceAll("\n\t", "\n->  "));
                }
                String message = th.getMessage();
                if (message != null && !message.equals(th.getLocalizedMessage())) {
                    aVar.write(("Message: " + message + "\n").getBytes("UTF-8"));
                }
                th.printStackTrace(new PrintStream(aVar));
                aVar.write("Back traces ends.\n".getBytes("UTF-8"));
                a((OutputStream) aVar);
                aVar.flush();
                com.uc.crashsdk.a.a(aVar, "UTF-8", "--- --- --- --- --- --- --- --- --- --- --- --- --- --- --- ---\n");
                if (z2) {
                    aVar.flush();
                }
                aVar.write("meminfo:\n".getBytes("UTF-8"));
                b(aVar, "/proc/meminfo", 10240);
                String format = String.format(Locale.US, "/proc/%d/status", Integer.valueOf(Process.myPid()));
                aVar.write("status:\n".getBytes("UTF-8"));
                b(aVar, format, 10240);
                aVar.write(("memory info:\n" + g()).getBytes("UTF-8"));
                a((OutputStream) aVar);
                f(aVar);
                com.uc.crashsdk.a.a(aVar, "UTF-8", (ArrayList<String>) null);
                if (af) {
                    f9676h = false;
                    aVar.write(r("JAVADUMPFILES").getBytes("UTF-8"));
                    f9676h = true;
                }
                aVar.flush();
                b((OutputStream) aVar);
                aVar.flush();
                aVar.write("battery info:\n".getBytes("UTF-8"));
                if (af) {
                    f9676h = false;
                    aVar.write(r("BATTERYINFO").getBytes("UTF-8"));
                    f9676h = true;
                } else {
                    StringBuilder X2 = X();
                    if (X2 != null) {
                        aVar.write(X2.toString().getBytes("UTF-8"));
                    }
                }
                a((OutputStream) aVar);
                aVar.write("disk info:\n".getBytes("UTF-8"));
            }
        } catch (Throwable th3) {
            th = th3;
        }
        if (af) {
            f9676h = false;
            aVar.write(r("FSSTAT").getBytes("UTF-8"));
            f9676h = true;
        } else {
            try {
                hashSet = new HashSet();
                a2 = a(new File(com.uc.crashsdk.a.g.b()));
            } catch (Throwable th4) {
                th = th4;
                str2 = "\n";
                str3 = "--- --- --- --- --- --- --- --- --- --- --- --- --- --- --- ---\n";
            }
            if (!com.uc.crashsdk.a.g.a(a2) && !hashSet.contains(a2) && !a2.equals("/storage/emulated")) {
                hashSet.add(a2);
                try {
                    statFs = new StatFs(a2);
                    a3 = a(statFs, "getBlockCountLong", "getBlockCount");
                    str3 = "--- --- --- --- --- --- --- --- --- --- --- --- --- --- --- ---\n";
                    try {
                        a4 = a(statFs, "getBlockSizeLong", "getBlockSize");
                    } catch (Throwable th5) {
                        th = th5;
                        str2 = "\n";
                        i3 = i2;
                        a(th, aVar);
                        a((OutputStream) aVar);
                        aVar.write("device status:\n".getBytes("UTF-8"));
                        if (!af) {
                        }
                        a((OutputStream) aVar);
                        c(aVar);
                        d(aVar);
                        String str4 = str3;
                        com.uc.crashsdk.a.b(aVar, "UTF-8", str4, null);
                        if (af) {
                        }
                        aVar.flush();
                        com.uc.crashsdk.a.a(aVar, "UTF-8", str4, null);
                        if (af) {
                        }
                        aVar.a();
                        a(aVar);
                        aVar.flush();
                        if (i3 != 0) {
                        }
                        com.uc.crashsdk.a.g.a(aVar);
                        if (!af) {
                        }
                        b(!af ? a(l(str)) : str, LogType.JAVA_TYPE);
                        return str;
                    }
                } catch (Throwable unused) {
                }
                if ((a3 / PlaybackStateCompat.ACTION_PLAY_FROM_MEDIA_ID) * a4 >= 10240) {
                    i3 = i2;
                    try {
                        long a5 = a(statFs, "getAvailableBlocksLong", "getAvailableBlocks");
                        long a6 = a(statFs, "getFreeBlocksLong", "getFreeBlocks");
                        try {
                            aVar.write(String.format(Locale.US, "%s:\n", a2).getBytes("UTF-8"));
                            Locale locale = Locale.US;
                            Object[] objArr = new Object[1];
                            str2 = "\n";
                            double d2 = a4;
                            try {
                                objArr[0] = Long.valueOf((long) (((a3 * 1.0d) * d2) / 1024.0d));
                                aVar.write(String.format(locale, "  total:      %d kB\n", objArr).getBytes("UTF-8"));
                                aVar.write(String.format(Locale.US, "  available:  %d kB\n", Long.valueOf((long) (((a5 * 1.0d) * d2) / 1024.0d))).getBytes("UTF-8"));
                                aVar.write(String.format(Locale.US, "  free:       %d kB\n", Long.valueOf((long) (((a6 * 1.0d) * d2) / 1024.0d))).getBytes("UTF-8"));
                                aVar.write(String.format(Locale.US, "  block size: %d B\n\n", Long.valueOf(a4)).getBytes("UTF-8"));
                            } catch (Throwable th6) {
                                th = th6;
                                try {
                                    a(th, aVar);
                                } catch (Throwable th7) {
                                    th = th7;
                                    a(th, aVar);
                                    a((OutputStream) aVar);
                                    aVar.write("device status:\n".getBytes("UTF-8"));
                                    if (!af) {
                                    }
                                    a((OutputStream) aVar);
                                    c(aVar);
                                    d(aVar);
                                    String str42 = str3;
                                    com.uc.crashsdk.a.b(aVar, "UTF-8", str42, null);
                                    if (af) {
                                    }
                                    aVar.flush();
                                    com.uc.crashsdk.a.a(aVar, "UTF-8", str42, null);
                                    if (af) {
                                    }
                                    aVar.a();
                                    a(aVar);
                                    aVar.flush();
                                    if (i3 != 0) {
                                    }
                                    com.uc.crashsdk.a.g.a(aVar);
                                    if (!af) {
                                    }
                                    b(!af ? a(l(str)) : str, LogType.JAVA_TYPE);
                                    return str;
                                }
                                a((OutputStream) aVar);
                                aVar.write("device status:\n".getBytes("UTF-8"));
                                if (!af) {
                                }
                                a((OutputStream) aVar);
                                c(aVar);
                                d(aVar);
                                String str422 = str3;
                                com.uc.crashsdk.a.b(aVar, "UTF-8", str422, null);
                                if (af) {
                                }
                                aVar.flush();
                                com.uc.crashsdk.a.a(aVar, "UTF-8", str422, null);
                                if (af) {
                                }
                                aVar.a();
                                a(aVar);
                                aVar.flush();
                                if (i3 != 0) {
                                }
                                com.uc.crashsdk.a.g.a(aVar);
                                if (!af) {
                                }
                                b(!af ? a(l(str)) : str, LogType.JAVA_TYPE);
                                return str;
                            }
                        } catch (Throwable th8) {
                            th = th8;
                            str2 = "\n";
                        }
                    } catch (Throwable th9) {
                        th = th9;
                        str2 = "\n";
                    }
                    a((OutputStream) aVar);
                    aVar.write("device status:\n".getBytes("UTF-8"));
                    if (!af) {
                        try {
                            f9676h = false;
                            aVar.write(r("DEVICESTATUS").getBytes("UTF-8"));
                            f9676h = true;
                        } catch (Throwable th10) {
                            th = th10;
                            a(th, aVar);
                            a((OutputStream) aVar);
                            c(aVar);
                            d(aVar);
                            String str4222 = str3;
                            com.uc.crashsdk.a.b(aVar, "UTF-8", str4222, null);
                            if (af) {
                            }
                            aVar.flush();
                            com.uc.crashsdk.a.a(aVar, "UTF-8", str4222, null);
                            if (af) {
                            }
                            aVar.a();
                            a(aVar);
                            aVar.flush();
                            if (i3 != 0) {
                            }
                            com.uc.crashsdk.a.g.a(aVar);
                            if (!af) {
                            }
                            b(!af ? a(l(str)) : str, LogType.JAVA_TYPE);
                            return str;
                        }
                    } else {
                        try {
                            aVar.write(String.format(Locale.US, "has root: %s\n", Boolean.valueOf(com.uc.crashsdk.a.g.e())).getBytes("UTF-8"));
                            String str5 = Build.TAGS != null ? Build.TAGS : "";
                            StringBuilder sb = new StringBuilder();
                            sb.append("build tags: ");
                            sb.append(str5);
                            if (com.uc.crashsdk.a.g.f()) {
                                sb.append(" (default root)");
                            }
                            sb.append(str2);
                            aVar.write(sb.toString().getBytes("UTF-8"));
                            String h2 = com.uc.crashsdk.a.g.h();
                            if (com.uc.crashsdk.a.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(com.uc.crashsdk.a.g.g() ? "valid (" : "invalid (");
                                sb2.append(com.uc.crashsdk.a.g.i());
                                sb2.append(")\n");
                                aVar.write(sb2.toString().getBytes("UTF-8"));
                            }
                        } catch (Throwable th11) {
                            th = th11;
                            a(th, aVar);
                            a((OutputStream) aVar);
                            c(aVar);
                            d(aVar);
                            String str42222 = str3;
                            com.uc.crashsdk.a.b(aVar, "UTF-8", str42222, null);
                            if (af) {
                            }
                            aVar.flush();
                            com.uc.crashsdk.a.a(aVar, "UTF-8", str42222, null);
                            if (af) {
                            }
                            aVar.a();
                            a(aVar);
                            aVar.flush();
                            if (i3 != 0) {
                            }
                            com.uc.crashsdk.a.g.a(aVar);
                            if (!af) {
                            }
                            b(!af ? a(l(str)) : str, LogType.JAVA_TYPE);
                            return str;
                        }
                    }
                    a((OutputStream) aVar);
                    c(aVar);
                    d(aVar);
                    String str422222 = str3;
                    com.uc.crashsdk.a.b(aVar, "UTF-8", str422222, null);
                    if (af) {
                        f9676h = false;
                        aVar.write(r("JAVACACHEDINFOS").getBytes("UTF-8"));
                        f9676h = true;
                    }
                    aVar.flush();
                    com.uc.crashsdk.a.a(aVar, "UTF-8", str422222, null);
                    if (af) {
                        f9676h = false;
                        aVar.write(r("JAVACALLBACKINFOS").getBytes("UTF-8"));
                        f9676h = true;
                    }
                    aVar.a();
                    a(aVar);
                    aVar.flush();
                    if (i3 != 0) {
                        b(aVar);
                    }
                    com.uc.crashsdk.a.g.a(aVar);
                    if (!af) {
                        q(str);
                    }
                    b(!af ? a(l(str)) : str, LogType.JAVA_TYPE);
                    return str;
                }
                str2 = "\n";
                i3 = i2;
                a((OutputStream) aVar);
                aVar.write("device status:\n".getBytes("UTF-8"));
                if (!af) {
                }
                a((OutputStream) aVar);
                c(aVar);
                d(aVar);
                String str4222222 = str3;
                com.uc.crashsdk.a.b(aVar, "UTF-8", str4222222, null);
                if (af) {
                }
                aVar.flush();
                com.uc.crashsdk.a.a(aVar, "UTF-8", str4222222, null);
                if (af) {
                }
                aVar.a();
                a(aVar);
                aVar.flush();
                if (i3 != 0) {
                }
                com.uc.crashsdk.a.g.a(aVar);
                if (!af) {
                }
                b(!af ? a(l(str)) : str, LogType.JAVA_TYPE);
                return str;
            }
        }
        str2 = "\n";
        str3 = "--- --- --- --- --- --- --- --- --- --- --- --- --- --- --- ---\n";
        i3 = i2;
        a((OutputStream) aVar);
        aVar.write("device status:\n".getBytes("UTF-8"));
        if (!af) {
        }
        a((OutputStream) aVar);
        c(aVar);
        d(aVar);
        String str42222222 = str3;
        com.uc.crashsdk.a.b(aVar, "UTF-8", str42222222, null);
        if (af) {
        }
        aVar.flush();
        com.uc.crashsdk.a.a(aVar, "UTF-8", str42222222, null);
        if (af) {
        }
        aVar.a();
        a(aVar);
        aVar.flush();
        if (i3 != 0) {
        }
        com.uc.crashsdk.a.g.a(aVar);
        if (!af) {
        }
        b(!af ? a(l(str)) : str, LogType.JAVA_TYPE);
        return str;
    }

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

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

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

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

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

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

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

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

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

    public static int b(boolean z2, boolean z3) {
        int i2;
        if (z3 && !ac) {
            f.d(false);
        }
        if (z2) {
            boolean a2 = f.a(com.uc.crashsdk.b.c(), false);
            h.i();
            i2 = a2;
        } else {
            int a3 = f.a();
            h.i();
            i2 = a3;
        }
        return z3 ? f.a(z2) : i2;
    }

    public static String a(String str) {
        int lastIndexOf;
        int indexOf;
        int i2;
        int indexOf2;
        File file;
        byte[] e2;
        if (g.x() && (lastIndexOf = str.lastIndexOf(47)) > 0 && (indexOf = str.indexOf(95, lastIndexOf)) > lastIndexOf && (indexOf2 = str.indexOf(95, (i2 = indexOf + 1))) > indexOf) {
            String d2 = com.uc.crashsdk.a.g.d("CrashSDK" + str.substring(lastIndexOf + 1, indexOf) + str.substring(i2, indexOf2));
            if (d2 == null || (e2 = com.uc.crashsdk.a.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) {
                com.uc.crashsdk.a.g.a(th);
            }
            if (bArr == null) {
                return str;
            }
            String str2 = str + ".ec";
            File file2 = new File(str2 + ".tmp");
            if (com.uc.crashsdk.a.g.a(file2, bArr)) {
                if (!file2.renameTo(new File(str2))) {
                    file2.delete();
                    return str;
                }
                file.delete();
                return str2;
            }
            return str;
        }
        return str;
    }

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

    public static void a(String str, boolean z2, boolean z3) {
        int i2;
        boolean z4;
        boolean z5;
        int i3;
        String path;
        String b2;
        File a2;
        int i4;
        String str2;
        String str3;
        int i5;
        File file;
        boolean z6;
        com.uc.crashsdk.a.a.a("crashsdk", "crashsdk uploading logs");
        synchronized (n) {
            try {
                if (com.uc.crashsdk.a.g.b(str)) {
                    String V2 = g.V();
                    File file2 = new File(V2);
                    if (file2.exists()) {
                        File[] listFiles = file2.listFiles();
                        if (listFiles == null) {
                            com.uc.crashsdk.a.a.b("List folder failed: " + V2);
                        } else {
                            int length = listFiles.length;
                            int i6 = 0;
                            int i7 = 0;
                            int i8 = 0;
                            int i9 = 0;
                            int i10 = 0;
                            int i11 = 0;
                            int i12 = 0;
                            int i13 = 0;
                            int i14 = 0;
                            boolean z7 = false;
                            boolean z8 = false;
                            boolean z9 = false;
                            while (true) {
                                if (i6 >= length) {
                                    i2 = i9;
                                    z4 = z7;
                                    z5 = z8;
                                    break;
                                }
                                File file3 = listFiles[i6];
                                File[] fileArr = listFiles;
                                if (file3.isFile()) {
                                    String name = file3.getName();
                                    if (!name.endsWith(".tmp")) {
                                        i3 = length;
                                        z4 = z7;
                                        z5 = z8;
                                        if (file3.length() == 0) {
                                            i7++;
                                            com.uc.crashsdk.a.g.a(file3);
                                        } else {
                                            if (z2) {
                                                long currentTimeMillis = (System.currentTimeMillis() - file3.lastModified()) / 1000;
                                                if (currentTimeMillis < 0 || (currentTimeMillis >= 2 && (currentTimeMillis >= 5 || !file3.getName().endsWith(com.anythink.china.common.a.a.f2078f)))) {
                                                    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) {
                                                        i9++;
                                                    }
                                                }
                                                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) {
                                                }
                                            }
                                            try {
                                            } catch (Throwable th) {
                                                th = th;
                                                i2 = i9;
                                            }
                                            if (g.k()) {
                                                Matcher matcher = Pattern.compile("([^_]+)_([^_]+)_([^_]+)\\.crashsdk").matcher(file3.getName());
                                                if (matcher.matches()) {
                                                    i2 = i9;
                                                    try {
                                                        file = new File(g.V() + String.format(Locale.US, "%s%s_%s_%s.%s", i(matcher.group(2)), m(), P(), matcher.group(1), matcher.group(3)));
                                                        com.uc.crashsdk.a.a.a("crashsdk", "File " + file3.getPath() + " matches, rename to " + file.getPath());
                                                        file3.renameTo(file);
                                                        if (file != file3) {
                                                            i13++;
                                                        }
                                                        file3 = file;
                                                    } catch (Throwable th2) {
                                                        th = th2;
                                                        com.uc.crashsdk.a.g.a(th);
                                                        path = file3.getPath();
                                                        boolean[] m2 = m(path);
                                                        b2 = b(path, m2[0], m2[1]);
                                                        if (path != b2) {
                                                        }
                                                        a2 = com.uc.crashsdk.d.a(file3);
                                                        if (a2 == null) {
                                                        }
                                                        if (a2 == null) {
                                                        }
                                                        z8 = z5;
                                                        i6++;
                                                        listFiles = fileArr;
                                                        length = i3;
                                                        z7 = z4;
                                                        i9 = i2;
                                                    }
                                                    path = file3.getPath();
                                                    boolean[] m22 = m(path);
                                                    b2 = b(path, m22[0], m22[1]);
                                                    if (path != b2) {
                                                        if (m22[0]) {
                                                            i12++;
                                                        }
                                                        if (m22[1]) {
                                                            i10++;
                                                        }
                                                        file3 = new File(b2);
                                                    }
                                                    a2 = com.uc.crashsdk.d.a(file3);
                                                    if (a2 == null) {
                                                        a2 = null;
                                                    } else if (file3 != a2 && !file3.getName().equals(a2.getName()) && file3.exists()) {
                                                        file3.delete();
                                                    }
                                                    if (a2 == null) {
                                                        com.uc.crashsdk.a.a.b("onBeforeUploadLog return null, skip upload: " + file3.getAbsolutePath());
                                                    } else {
                                                        int z10 = g.z();
                                                        if (z10 <= 0 || a2.length() < z10) {
                                                            d dVar = new d((byte) 0);
                                                            dVar.f9685b = 0L;
                                                            dVar.f9684a = System.currentTimeMillis();
                                                            String T2 = T();
                                                            if (new File(T2).exists()) {
                                                                a(T2, new com.uc.crashsdk.a.e(451, new Object[]{T2, dVar}));
                                                            }
                                                            long A2 = g.A();
                                                            int B2 = g.B();
                                                            int C2 = g.C();
                                                            if (A2 >= 0) {
                                                                i4 = i10;
                                                                if (dVar.f9685b + a2.length() > A2) {
                                                                    dVar.f9688e = true;
                                                                    str2 = "Reach max upload bytes: " + A2;
                                                                    com.uc.crashsdk.a.a.b(str2);
                                                                    if (!dVar.f9688e) {
                                                                        i10 = i4;
                                                                        z8 = z5;
                                                                        z4 = true;
                                                                    } else if (dVar.f9690g) {
                                                                        i10 = i4;
                                                                        z8 = true;
                                                                    } else if (dVar.f9689f) {
                                                                        i10 = i4;
                                                                        z8 = z5;
                                                                        z9 = true;
                                                                    } else {
                                                                        String name2 = a2.getName();
                                                                        if (name2.startsWith(O())) {
                                                                            String[] split = name2.split(MemoryCacheUtils.URI_AND_SIZE_SEPARATOR, 10);
                                                                            if (split.length == 9) {
                                                                                str3 = split[1];
                                                                                boolean z11 = str3 == null && str3.equals(g.R());
                                                                                if (com.uc.crashsdk.a.c.a(a2, a2.getName(), str)) {
                                                                                    i14++;
                                                                                    if (z11) {
                                                                                        f.a(14);
                                                                                    }
                                                                                    i5 = 3;
                                                                                } else {
                                                                                    com.uc.crashsdk.a.a.a("crashsdk", "Uploaded log: " + a2.getName(), null);
                                                                                    if (z11) {
                                                                                        f.a(13);
                                                                                    }
                                                                                    dVar.f9685b += a2.length();
                                                                                    if (b(a2)) {
                                                                                        dVar.f9686c++;
                                                                                    } else {
                                                                                        dVar.f9687d++;
                                                                                    }
                                                                                    String T3 = T();
                                                                                    a(T3, new com.uc.crashsdk.a.e(452, new Object[]{T3, dVar}));
                                                                                    a2.delete();
                                                                                    i5 = 3;
                                                                                    i14 = 0;
                                                                                }
                                                                                if (i14 < i5) {
                                                                                    com.uc.crashsdk.a.a.a("crashsdk", "Upload failed 3 times continuously, abort upload!", null);
                                                                                    i10 = i4;
                                                                                    break;
                                                                                }
                                                                                i10 = i4;
                                                                                z8 = z5;
                                                                            }
                                                                        }
                                                                        str3 = null;
                                                                        if (str3 == null) {
                                                                        }
                                                                        if (com.uc.crashsdk.a.c.a(a2, a2.getName(), str)) {
                                                                        }
                                                                        if (i14 < i5) {
                                                                        }
                                                                    }
                                                                    i6++;
                                                                    listFiles = fileArr;
                                                                    length = i3;
                                                                    z7 = z4;
                                                                    i9 = i2;
                                                                }
                                                            } else {
                                                                i4 = i10;
                                                            }
                                                            if (!g.f()) {
                                                                if (b(a2)) {
                                                                    if (B2 >= 0 && dVar.f9686c >= B2) {
                                                                        dVar.f9690g = true;
                                                                        str2 = "Reach max upload builtin log count: " + B2;
                                                                        com.uc.crashsdk.a.a.b(str2);
                                                                    }
                                                                } else if (C2 >= 0 && dVar.f9687d >= C2) {
                                                                    dVar.f9689f = true;
                                                                    str2 = "Reach max upload custom log count: " + C2;
                                                                    com.uc.crashsdk.a.a.b(str2);
                                                                }
                                                            }
                                                            if (!dVar.f9688e) {
                                                            }
                                                            i6++;
                                                            listFiles = fileArr;
                                                            length = i3;
                                                            z7 = z4;
                                                            i9 = i2;
                                                        } else {
                                                            i11++;
                                                            com.uc.crashsdk.a.g.a(a2);
                                                        }
                                                    }
                                                    z8 = z5;
                                                    i6++;
                                                    listFiles = fileArr;
                                                    length = i3;
                                                    z7 = z4;
                                                    i9 = i2;
                                                }
                                            }
                                            i2 = i9;
                                            file = file3;
                                            if (file != file3) {
                                            }
                                            file3 = file;
                                            path = file3.getPath();
                                            boolean[] m222 = m(path);
                                            b2 = b(path, m222[0], m222[1]);
                                            if (path != b2) {
                                            }
                                            a2 = com.uc.crashsdk.d.a(file3);
                                            if (a2 == null) {
                                            }
                                            if (a2 == null) {
                                            }
                                            z8 = z5;
                                            i6++;
                                            listFiles = fileArr;
                                            length = i3;
                                            z7 = z4;
                                            i9 = i2;
                                        }
                                        i2 = i9;
                                        z8 = z5;
                                        i6++;
                                        listFiles = fileArr;
                                        length = i3;
                                        z7 = z4;
                                        i9 = i2;
                                    } else if ((System.currentTimeMillis() - file3.lastModified()) / 1000 > 30) {
                                        i3 = length;
                                        com.uc.crashsdk.a.a.b("delete legacy tmp file: " + name);
                                        i8++;
                                        com.uc.crashsdk.a.g.a(file3);
                                        i2 = i9;
                                        z4 = z7;
                                        i6++;
                                        listFiles = fileArr;
                                        length = i3;
                                        z7 = z4;
                                        i9 = i2;
                                    }
                                } else {
                                    com.uc.crashsdk.a.g.a(file3);
                                }
                                i3 = length;
                                i2 = i9;
                                z4 = z7;
                                i6++;
                                listFiles = fileArr;
                                length = i3;
                                z7 = z4;
                                i9 = i2;
                            }
                            if (i8 > 0) {
                                f.a(200, i8);
                            }
                            if (i7 > 0) {
                                f.a(15, i7);
                            }
                            if (i11 > 0) {
                                f.a(17, i11);
                            }
                            if (z4) {
                                f.a(19);
                            }
                            if (z5) {
                                f.a(20);
                            }
                            if (z9) {
                                f.a(21);
                            }
                            if (z4 || z5 || z9) {
                                f.a(18);
                            }
                            if (i12 > 0) {
                                f.a(24, i12);
                            }
                            if (i10 > 0) {
                                f.a(201, i10);
                            }
                            if (i13 > 0) {
                                f.a(25, i13);
                            }
                            if (i2 > 0) {
                                f.a(26, i2);
                            }
                        }
                    } else {
                        com.uc.crashsdk.a.a.a("crashsdk", "Folder not exist: " + V2);
                    }
                } else {
                    com.uc.crashsdk.a.a.a("crashsdk", "upload url is empty!");
                }
                if (z3) {
                    n.notify();
                }
            } catch (Throwable th3) {
                throw th3;
            }
        }
    }

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

    public static boolean a(String str, com.uc.crashsdk.a.e eVar) {
        boolean z2;
        FileChannel fileChannel;
        Exception e2;
        synchronized (o) {
            File file = new File(str);
            if (!file.exists()) {
                try {
                    file.createNewFile();
                } catch (Exception e3) {
                    com.uc.crashsdk.a.g.a(e3);
                }
            }
            ?? r5 = 0;
            r5 = null;
            FileLock lock = null;
            z2 = false;
            try {
                try {
                    try {
                        fileChannel = new RandomAccessFile(file, "rw").getChannel();
                    } catch (Throwable th) {
                        th = th;
                        r5 = file;
                        com.uc.crashsdk.a.g.a((Closeable) r5);
                        throw th;
                    }
                } catch (Exception e4) {
                    try {
                        com.uc.crashsdk.a.g.a(e4);
                        fileChannel = null;
                    } catch (Exception e5) {
                        fileChannel = null;
                        e2 = e5;
                        com.uc.crashsdk.a.g.a(e2);
                        com.uc.crashsdk.a.g.a(fileChannel);
                        return z2;
                    }
                }
                if (fileChannel != null) {
                    try {
                        lock = fileChannel.lock();
                    } catch (Exception e6) {
                        try {
                            com.uc.crashsdk.a.g.a(e6);
                        } catch (Exception e7) {
                            e2 = e7;
                            com.uc.crashsdk.a.g.a(e2);
                            com.uc.crashsdk.a.g.a(fileChannel);
                            return z2;
                        }
                    }
                }
                try {
                    z2 = eVar.a();
                    com.uc.crashsdk.a.g.a(fileChannel);
                } finally {
                    if (lock != null) {
                        try {
                            lock.release();
                        } catch (Exception e8) {
                            com.uc.crashsdk.a.g.a(e8);
                        }
                    }
                }
            } catch (Throwable th2) {
                th = th2;
            }
        }
        return z2;
    }

    public static boolean a(String str, d dVar) {
        String a2 = com.uc.crashsdk.a.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.f9685b = Long.parseLong(matcher.group(2));
                    dVar.f9686c = Integer.parseInt(matcher.group(3));
                    dVar.f9687d = Integer.parseInt(matcher.group(4));
                    dVar.f9684a = parseLong;
                }
            }
        } catch (Throwable th) {
            com.uc.crashsdk.a.g.a(th);
        }
        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 z2;
        boolean a2;
        if (f9672c.get()) {
            com.uc.crashsdk.a.a.b("Processing java crash, skip generate custom log: " + str);
            return false;
        }
        boolean z3 = af || com.uc.crashsdk.b.I();
        if (!z3 && !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.V() + j(str);
            ?? r11 = (j2 & 32) != 0 ? 1 : 0;
            if (z3) {
                long nativeClientCreateConnection = com.uc.crashsdk.b.f9655d ? JNIBridge.nativeClientCreateConnection(str3, "custom", str, r11) : 0L;
                if (nativeClientCreateConnection == 0) {
                    com.uc.crashsdk.a.a.d("DEBUG", "skip custom log: " + str);
                    return false;
                }
                j3 = nativeClientCreateConnection;
            } else if (a(h(), str, (boolean) r11)) {
                return false;
            } else {
                g.a();
                a(false);
                j3 = 0;
            }
            synchronized (p) {
                z2 = r11;
                a2 = a(str3, j3, stringBuffer, str, j2, arrayList, arrayList2, arrayList3, str2);
            }
            if (a2 && !z3) {
                b(h(), str, z2);
            }
            if (j3 != 0) {
                JNIBridge.nativeClientCloseConnection(j3);
            }
            if (a2) {
                if (!z3) {
                    q(str3);
                }
                if (!z3) {
                    str3 = a(l(str3));
                }
                b(str3, str);
                if (!z2 || z3) {
                    return true;
                }
                try {
                    a(true, false);
                    return true;
                } catch (Throwable th) {
                    com.uc.crashsdk.a.g.a(th);
                    return true;
                }
            }
            return false;
        }
    }

    public static boolean a(String str, String str2, boolean z2) {
        if (n(str2)) {
            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;
        }
        return false;
    }

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

    public static boolean a(String str, long j2, StringBuffer stringBuffer, String str2, long j3, ArrayList<String> arrayList, ArrayList<String> arrayList2, ArrayList<String> arrayList3, String str3) {
        FileOutputStream fileOutputStream;
        a aVar;
        int i2 = (j2 > 0L ? 1 : (j2 == 0L ? 0 : -1));
        if (i2 == 0) {
            try {
                fileOutputStream = new FileOutputStream(str);
            } catch (Throwable th) {
                th = th;
                fileOutputStream = null;
                aVar = null;
                com.uc.crashsdk.a.g.a(th);
                if (aVar == null) {
                }
            }
        } else {
            fileOutputStream = null;
        }
        try {
            aVar = new a(j2, fileOutputStream);
            try {
                synchronized (r) {
                    t = str;
                    if (com.uc.crashsdk.b.f9655d) {
                        JNIBridge.set(126, t);
                    }
                }
            } catch (Throwable th2) {
                th = th2;
                com.uc.crashsdk.a.g.a(th);
                if (aVar == null) {
                }
            }
        } catch (Throwable th3) {
            th = th3;
            aVar = null;
        }
        if (aVar == null) {
            return false;
        }
        if ((j3 & 1) != 0) {
            try {
                b(aVar, str, str2);
            } catch (Throwable th4) {
                try {
                    a(th4, aVar);
                } finally {
                    com.uc.crashsdk.a.g.a(aVar);
                    com.uc.crashsdk.a.g.a(fileOutputStream);
                }
            }
        }
        aVar.write(stringBuffer.toString().getBytes());
        aVar.write("\n".getBytes("UTF-8"));
        aVar.flush();
        a((OutputStream) aVar);
        if ((j3 & 4) != 0) {
            b((OutputStream) aVar);
            aVar.flush();
        }
        if (arrayList != null && arrayList.size() > 0) {
            com.uc.crashsdk.a.a(aVar, "UTF-8", arrayList);
        }
        if (arrayList2 != null && arrayList2.size() > 0) {
            com.uc.crashsdk.a.a(aVar, "UTF-8", "--- --- --- --- --- --- --- --- --- --- --- --- --- --- --- ---\n", arrayList2);
        }
        if (arrayList3 != null && arrayList3.size() > 0) {
            com.uc.crashsdk.a.b(aVar, "UTF-8", "--- --- --- --- --- --- --- --- --- --- --- --- --- --- --- ---\n", arrayList3);
        }
        if (str3 != null) {
            aVar.flush();
            aVar.write("threads dump:\n".getBytes("UTF-8"));
            f9676h = false;
            v = str3;
            a(aVar, str3, j2);
            v = null;
            f9676h = true;
        }
        if ((j3 & 8) != 0 && i2 == 0) {
            aVar.flush();
            aVar.write("all threads dump:\n".getBytes("UTF-8"));
            u = true;
            a(aVar, "all", 0L);
            u = false;
        }
        if ((j3 & 16) != 0) {
            e(aVar);
        }
        if ((j3 & 2) != 0) {
            aVar.a();
            a(aVar);
        }
        if (i2 != 0) {
            b(aVar);
        }
        try {
            synchronized (r) {
                s++;
                if (t != null) {
                    r.add(t);
                    if (r.size() > 3) {
                        r.remove(0);
                    }
                    if (com.uc.crashsdk.b.f9655d) {
                        JNIBridge.set(127, t);
                    }
                    t = null;
                }
                if (com.uc.crashsdk.b.f9655d) {
                    JNIBridge.set(25, s);
                }
            }
        } catch (Throwable th5) {
            com.uc.crashsdk.a.g.a(th5);
        }
        return true;
    }

    public static void a(String str, boolean z2) {
        if (z2) {
            x = str;
            return;
        }
        synchronized (y) {
            w = str;
            com.uc.crashsdk.a.b.a(com.uc.crashsdk.b.f(), str + "\n");
        }
    }

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

    public static void a(OutputStream outputStream, String str, String str2, int i2, boolean z2, boolean z3) {
        f9676h = 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);
            objArr[4] = Integer.valueOf(z3 ? 1 : 0);
            outputStream.write(String.format(locale, "$^%s`%s`%d`%d,%d^$", objArr).getBytes("UTF-8"));
        } catch (Throwable th) {
            com.uc.crashsdk.a.g.a(th);
        }
        f9676h = true;
        a(outputStream);
    }

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

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

    public final void a(Thread thread, Throwable th, boolean z2) {
        boolean z3;
        long j2;
        boolean z4;
        boolean i2;
        Throwable th2;
        boolean z5;
        boolean i3;
        boolean z6;
        String str;
        long nativeClientCreateConnection;
        boolean z7;
        boolean i4;
        boolean z8;
        boolean i5;
        Throwable th3;
        boolean z9;
        boolean i6;
        File file;
        boolean z10;
        boolean i7;
        boolean z11;
        boolean i8;
        boolean z12;
        boolean i9;
        boolean z13;
        boolean i10;
        boolean z14 = (af && com.uc.crashsdk.b.f9655d) || com.uc.crashsdk.b.I();
        try {
            j2 = 4;
            if (f9672c.getAndSet(true) && Process.myPid() > 0) {
                com.uc.crashsdk.a.a.d("DEBUG", "another thread is generating java report!");
                com.uc.crashsdk.a.a.d("DEBUG", "current thread exception is:");
                a(th);
                int i11 = 0;
                while (!V) {
                    Thread.sleep(1000L);
                    i11++;
                    if (i11 >= 4) {
                        break;
                    }
                }
                Process.killProcess(Process.myPid());
                if (z2) {
                    try {
                    } catch (Throwable th4) {
                        th = th4;
                        z13 = false;
                    }
                    if (g.r() && !z14) {
                        try {
                            a(true, false);
                            z13 = true;
                        } catch (Throwable th5) {
                            th = th5;
                            z13 = true;
                            com.uc.crashsdk.a.g.a(th);
                            if (!z13) {
                            }
                            f.c(false);
                            i10 = g.i();
                            if (!com.uc.crashsdk.a.d.d()) {
                            }
                            com.uc.crashsdk.a.a.a("crashsdk", "Call java default handler: " + i10);
                            if (i10) {
                            }
                            if (com.uc.crashsdk.b.y()) {
                            }
                            V = true;
                            if (Process.myPid() > 0) {
                            }
                        }
                        if (!z13 && !z14) {
                            b(false);
                        }
                        f.c(false);
                        i10 = g.i();
                        if (!com.uc.crashsdk.a.d.d()) {
                            i10 = true;
                        }
                        com.uc.crashsdk.a.a.a("crashsdk", "Call java default handler: " + i10);
                        if (i10 && T != null) {
                            T.uncaughtException(thread, th);
                        }
                        if (com.uc.crashsdk.b.y() && !z14) {
                            com.uc.crashsdk.b.b(com.uc.crashsdk.a.g.a());
                        }
                        V = true;
                        if (Process.myPid() > 0) {
                            Process.killProcess(Process.myPid());
                            return;
                        }
                        return;
                    }
                }
                z13 = false;
                if (!z13) {
                    b(false);
                }
                f.c(false);
                i10 = g.i();
                if (!com.uc.crashsdk.a.d.d()) {
                }
                com.uc.crashsdk.a.a.a("crashsdk", "Call java default handler: " + i10);
                if (i10) {
                    T.uncaughtException(thread, th);
                }
                if (com.uc.crashsdk.b.y()) {
                    com.uc.crashsdk.b.b(com.uc.crashsdk.a.g.a());
                }
                V = true;
                if (Process.myPid() > 0) {
                }
            } else {
                U = th;
                if (!z14 && !com.uc.crashsdk.a.d.d()) {
                    com.uc.crashsdk.a.a.c("DEBUG", com.uc.crashsdk.a.d.b());
                    if (z2) {
                        try {
                        } catch (Throwable th6) {
                            th = th6;
                            z12 = false;
                        }
                        if (g.r() && !z14) {
                            try {
                                a(true, false);
                                z12 = true;
                            } catch (Throwable th7) {
                                th = th7;
                                z12 = true;
                                com.uc.crashsdk.a.g.a(th);
                                if (!z12) {
                                }
                                f.c(false);
                                i9 = g.i();
                                if (!com.uc.crashsdk.a.d.d()) {
                                }
                                com.uc.crashsdk.a.a.a("crashsdk", "Call java default handler: " + i9);
                                if (i9) {
                                }
                                if (com.uc.crashsdk.b.y()) {
                                }
                                V = true;
                                if (Process.myPid() > 0) {
                                }
                            }
                            if (!z12 && !z14) {
                                b(false);
                            }
                            f.c(false);
                            i9 = g.i();
                            if (!com.uc.crashsdk.a.d.d()) {
                                i9 = true;
                            }
                            com.uc.crashsdk.a.a.a("crashsdk", "Call java default handler: " + i9);
                            if (i9 && T != null) {
                                T.uncaughtException(thread, th);
                            }
                            if (com.uc.crashsdk.b.y() && !z14) {
                                com.uc.crashsdk.b.b(com.uc.crashsdk.a.g.a());
                            }
                            V = true;
                            if (Process.myPid() > 0) {
                                Process.killProcess(Process.myPid());
                                return;
                            }
                            return;
                        }
                    }
                    z12 = false;
                    if (!z12) {
                        b(false);
                    }
                    f.c(false);
                    i9 = g.i();
                    if (!com.uc.crashsdk.a.d.d()) {
                    }
                    com.uc.crashsdk.a.a.a("crashsdk", "Call java default handler: " + i9);
                    if (i9) {
                        T.uncaughtException(thread, th);
                    }
                    if (com.uc.crashsdk.b.y()) {
                        com.uc.crashsdk.b.b(com.uc.crashsdk.a.g.a());
                    }
                    V = true;
                    if (Process.myPid() > 0) {
                    }
                } else {
                    com.uc.crashsdk.a.a.d("DEBUG", "encryptLog: " + g.x() + ", zipCrashLog: " + g.x());
                    if (g.f9701a != null) {
                        com.uc.crashsdk.a.a.d("DEBUG", "the set zip log to false stack is:");
                        g.f9701a.printStackTrace();
                    }
                    if (g.f9702b != null) {
                        com.uc.crashsdk.a.a.d("DEBUG", "the set encrypt to true stack is:");
                        g.f9702b.printStackTrace();
                    }
                    com.uc.crashsdk.a.a.d("DEBUG", "begin to generate java report");
                    M();
                    try {
                        z6 = g.t();
                        try {
                            String g2 = g.g();
                            if (g2 == null || g2.equals("")) {
                                g2 = j(R());
                            }
                            str = g.V() + g2;
                            z3 = false;
                        } catch (Throwable th8) {
                            th = th8;
                            com.uc.crashsdk.a.a.d("DEBUG", "get java log name failed: " + th);
                            a(th);
                            com.uc.crashsdk.a.a.d("DEBUG", "original exception is: " + th);
                            a(th);
                            str = null;
                            z3 = true;
                            try {
                                if (z14) {
                                }
                                boolean z15 = th instanceof OutOfMemoryError;
                                a(th, str, nativeClientCreateConnection, z15);
                                com.uc.crashsdk.a.a.d("DEBUG", "generate java report finished");
                                if (!com.uc.crashsdk.b.I()) {
                                    String name = new File(str).getName();
                                    String W2 = g.W();
                                    file = new File(W2);
                                    if (!file.exists()) {
                                    }
                                    String format = String.format(Locale.US, "%s%s.hprof", W2, name);
                                    com.uc.crashsdk.a.a.d("DEBUG", "begin dump hprof: " + format);
                                    long currentTimeMillis = System.currentTimeMillis();
                                    Debug.dumpHprofData(format);
                                    com.uc.crashsdk.a.a.d("DEBUG", "end dump hprof, use " + (System.currentTimeMillis() - currentTimeMillis) + " ms");
                                }
                                if (nativeClientCreateConnection != 0) {
                                    JNIBridge.nativeClientCloseConnection(nativeClientCreateConnection);
                                }
                                if (z2) {
                                }
                                z9 = false;
                                if (!z9) {
                                }
                                f.c(false);
                                i6 = g.i();
                                if (!com.uc.crashsdk.a.d.d()) {
                                }
                                com.uc.crashsdk.a.a.a("crashsdk", "Call java default handler: " + i6);
                                if (i6) {
                                }
                                if (com.uc.crashsdk.b.y()) {
                                }
                                V = true;
                                if (Process.myPid() <= 0) {
                                }
                            } catch (Throwable th9) {
                                th = th9;
                                try {
                                    com.uc.crashsdk.a.a.d("DEBUG", "exception occurs while java log: " + th);
                                    a(th);
                                    if (!z3) {
                                        com.uc.crashsdk.a.a.d("DEBUG", "original exception is: " + th);
                                        a(th);
                                    }
                                    if (j2 != 0 && com.uc.crashsdk.b.f9655d) {
                                        JNIBridge.nativeClientCloseConnection(j2);
                                    }
                                    if (z2) {
                                        try {
                                        } catch (Throwable th10) {
                                            th2 = th10;
                                            z5 = false;
                                        }
                                        if (g.r() && !z14) {
                                            try {
                                                a(true, false);
                                                z5 = true;
                                            } catch (Throwable th11) {
                                                th2 = th11;
                                                z5 = true;
                                                com.uc.crashsdk.a.g.a(th2);
                                                if (!z5) {
                                                }
                                                f.c(false);
                                                i3 = g.i();
                                                if (!com.uc.crashsdk.a.d.d()) {
                                                }
                                                com.uc.crashsdk.a.a.a("crashsdk", "Call java default handler: " + i3);
                                                if (i3) {
                                                }
                                                if (com.uc.crashsdk.b.y()) {
                                                }
                                                V = true;
                                                if (Process.myPid() > 0) {
                                                }
                                            }
                                            if (!z5 && !z14) {
                                                b(false);
                                            }
                                            f.c(false);
                                            i3 = g.i();
                                            if (!com.uc.crashsdk.a.d.d()) {
                                                i3 = true;
                                            }
                                            com.uc.crashsdk.a.a.a("crashsdk", "Call java default handler: " + i3);
                                            if (i3 && T != null) {
                                                T.uncaughtException(thread, th);
                                            }
                                            if (com.uc.crashsdk.b.y() && !z14) {
                                                com.uc.crashsdk.b.b(com.uc.crashsdk.a.g.a());
                                            }
                                            V = true;
                                            if (Process.myPid() > 0) {
                                                Process.killProcess(Process.myPid());
                                                return;
                                            }
                                            return;
                                        }
                                    }
                                    z5 = false;
                                    if (!z5) {
                                        b(false);
                                    }
                                    f.c(false);
                                    i3 = g.i();
                                    if (!com.uc.crashsdk.a.d.d()) {
                                    }
                                    com.uc.crashsdk.a.a.a("crashsdk", "Call java default handler: " + i3);
                                    if (i3) {
                                        T.uncaughtException(thread, th);
                                    }
                                    if (com.uc.crashsdk.b.y()) {
                                        com.uc.crashsdk.b.b(com.uc.crashsdk.a.g.a());
                                    }
                                    V = true;
                                    if (Process.myPid() > 0) {
                                    }
                                } catch (Throwable th12) {
                                    if (j2 != 0 && com.uc.crashsdk.b.f9655d) {
                                        JNIBridge.nativeClientCloseConnection(j2);
                                    }
                                    if (z2) {
                                        try {
                                        } catch (Throwable th13) {
                                            th = th13;
                                            z4 = false;
                                        }
                                        if (g.r() && !z14) {
                                            try {
                                                a(true, false);
                                                z4 = true;
                                            } catch (Throwable th14) {
                                                th = th14;
                                                z4 = true;
                                                com.uc.crashsdk.a.g.a(th);
                                                if (!z4) {
                                                }
                                                f.c(false);
                                                i2 = g.i();
                                                if (!com.uc.crashsdk.a.d.d()) {
                                                }
                                                com.uc.crashsdk.a.a.a("crashsdk", "Call java default handler: " + i2);
                                                if (i2) {
                                                }
                                                if (com.uc.crashsdk.b.y()) {
                                                }
                                                V = true;
                                                if (Process.myPid() > 0) {
                                                }
                                                throw th12;
                                            }
                                            if (!z4 && !z14) {
                                                b(false);
                                            }
                                            f.c(false);
                                            i2 = g.i();
                                            if (!com.uc.crashsdk.a.d.d()) {
                                                i2 = true;
                                            }
                                            com.uc.crashsdk.a.a.a("crashsdk", "Call java default handler: " + i2);
                                            if (i2 && T != null) {
                                                T.uncaughtException(thread, th);
                                            }
                                            if (com.uc.crashsdk.b.y() && !z14) {
                                                com.uc.crashsdk.b.b(com.uc.crashsdk.a.g.a());
                                            }
                                            V = true;
                                            if (Process.myPid() > 0) {
                                                Process.killProcess(Process.myPid());
                                            }
                                            throw th12;
                                        }
                                    }
                                    z4 = false;
                                    if (!z4) {
                                        b(false);
                                    }
                                    f.c(false);
                                    i2 = g.i();
                                    if (!com.uc.crashsdk.a.d.d()) {
                                    }
                                    com.uc.crashsdk.a.a.a("crashsdk", "Call java default handler: " + i2);
                                    if (i2) {
                                        T.uncaughtException(thread, th);
                                    }
                                    if (com.uc.crashsdk.b.y()) {
                                        com.uc.crashsdk.b.b(com.uc.crashsdk.a.g.a());
                                    }
                                    V = true;
                                    if (Process.myPid() > 0) {
                                    }
                                    throw th12;
                                }
                            }
                        }
                    } catch (Throwable th15) {
                        th = th15;
                        z6 = false;
                    }
                    try {
                        if (z14) {
                            g.a();
                            try {
                                if (com.uc.crashsdk.b.y()) {
                                    f.a(3);
                                } else {
                                    f.a(4);
                                }
                            } catch (Throwable th16) {
                                com.uc.crashsdk.a.g.a(th16);
                            }
                            new File(com.uc.crashsdk.b.b()).createNewFile();
                            if (z6) {
                                com.uc.crashsdk.a.a.d("DEBUG", "omit java crash");
                                if (z2) {
                                    try {
                                    } catch (Throwable th17) {
                                        th = th17;
                                        z11 = false;
                                    }
                                    if (g.r() && !z14) {
                                        try {
                                            a(true, false);
                                            z11 = true;
                                        } catch (Throwable th18) {
                                            th = th18;
                                            z11 = true;
                                            com.uc.crashsdk.a.g.a(th);
                                            if (!z11) {
                                            }
                                            f.c(false);
                                            i8 = g.i();
                                            if (!com.uc.crashsdk.a.d.d()) {
                                            }
                                            com.uc.crashsdk.a.a.a("crashsdk", "Call java default handler: " + i8);
                                            if (i8) {
                                            }
                                            if (com.uc.crashsdk.b.y()) {
                                            }
                                            V = true;
                                            if (Process.myPid() > 0) {
                                            }
                                        }
                                        if (!z11 && !z14) {
                                            b(false);
                                        }
                                        f.c(false);
                                        i8 = g.i();
                                        if (!com.uc.crashsdk.a.d.d()) {
                                            i8 = true;
                                        }
                                        com.uc.crashsdk.a.a.a("crashsdk", "Call java default handler: " + i8);
                                        if (i8 && T != null) {
                                            T.uncaughtException(thread, th);
                                        }
                                        if (com.uc.crashsdk.b.y() && !z14) {
                                            com.uc.crashsdk.b.b(com.uc.crashsdk.a.g.a());
                                        }
                                        V = true;
                                        if (Process.myPid() > 0) {
                                            Process.killProcess(Process.myPid());
                                            return;
                                        }
                                        return;
                                    }
                                }
                                z11 = false;
                                if (!z11) {
                                    b(false);
                                }
                                f.c(false);
                                i8 = g.i();
                                if (!com.uc.crashsdk.a.d.d()) {
                                }
                                com.uc.crashsdk.a.a.a("crashsdk", "Call java default handler: " + i8);
                                if (i8) {
                                    T.uncaughtException(thread, th);
                                }
                                if (com.uc.crashsdk.b.y()) {
                                    com.uc.crashsdk.b.b(com.uc.crashsdk.a.g.a());
                                }
                                V = true;
                                if (Process.myPid() > 0) {
                                }
                            } else if (c(LogType.JAVA_TYPE)) {
                                nativeClientCreateConnection = 0;
                            } else {
                                com.uc.crashsdk.a.a.d("DEBUG", "java log sample miss");
                                if (z2) {
                                    try {
                                    } catch (Throwable th19) {
                                        th = th19;
                                        z10 = false;
                                    }
                                    if (g.r() && !z14) {
                                        try {
                                            a(true, false);
                                            z10 = true;
                                        } catch (Throwable th20) {
                                            th = th20;
                                            z10 = true;
                                            com.uc.crashsdk.a.g.a(th);
                                            if (!z10) {
                                            }
                                            f.c(false);
                                            i7 = g.i();
                                            if (!com.uc.crashsdk.a.d.d()) {
                                            }
                                            com.uc.crashsdk.a.a.a("crashsdk", "Call java default handler: " + i7);
                                            if (i7) {
                                            }
                                            if (com.uc.crashsdk.b.y()) {
                                            }
                                            V = true;
                                            if (Process.myPid() > 0) {
                                            }
                                        }
                                        if (!z10 && !z14) {
                                            b(false);
                                        }
                                        f.c(false);
                                        i7 = g.i();
                                        if (!com.uc.crashsdk.a.d.d()) {
                                            i7 = true;
                                        }
                                        com.uc.crashsdk.a.a.a("crashsdk", "Call java default handler: " + i7);
                                        if (i7 && T != null) {
                                            T.uncaughtException(thread, th);
                                        }
                                        if (com.uc.crashsdk.b.y() && !z14) {
                                            com.uc.crashsdk.b.b(com.uc.crashsdk.a.g.a());
                                        }
                                        V = true;
                                        if (Process.myPid() > 0) {
                                            Process.killProcess(Process.myPid());
                                            return;
                                        }
                                        return;
                                    }
                                }
                                z10 = false;
                                if (!z10) {
                                    b(false);
                                }
                                f.c(false);
                                i7 = g.i();
                                if (!com.uc.crashsdk.a.d.d()) {
                                }
                                com.uc.crashsdk.a.a.a("crashsdk", "Call java default handler: " + i7);
                                if (i7) {
                                    T.uncaughtException(thread, th);
                                }
                                if (com.uc.crashsdk.b.y()) {
                                    com.uc.crashsdk.b.b(com.uc.crashsdk.a.g.a());
                                }
                                V = true;
                                if (Process.myPid() > 0) {
                                }
                            }
                        } else {
                            if (z6) {
                                str = "omit";
                                com.uc.crashsdk.a.a.d("DEBUG", "omit java crash");
                            }
                            nativeClientCreateConnection = com.uc.crashsdk.b.f9655d ? JNIBridge.nativeClientCreateConnection(str, LogType.JAVA_TYPE, null, 0) : 0L;
                            int i12 = (nativeClientCreateConnection > 0L ? 1 : (nativeClientCreateConnection == 0L ? 0 : -1));
                            if (i12 == 0) {
                                com.uc.crashsdk.a.a.d("DEBUG", "skip java crash:");
                                a(th);
                                if (i12 != 0 && com.uc.crashsdk.b.f9655d) {
                                    JNIBridge.nativeClientCloseConnection(nativeClientCreateConnection);
                                }
                                if (z2) {
                                    try {
                                    } catch (Throwable th21) {
                                        th = th21;
                                        z8 = false;
                                    }
                                    if (g.r() && !z14) {
                                        try {
                                            a(true, false);
                                            z8 = true;
                                        } catch (Throwable th22) {
                                            th = th22;
                                            z8 = true;
                                            com.uc.crashsdk.a.g.a(th);
                                            if (!z8) {
                                            }
                                            f.c(false);
                                            i5 = g.i();
                                            if (!com.uc.crashsdk.a.d.d()) {
                                            }
                                            com.uc.crashsdk.a.a.a("crashsdk", "Call java default handler: " + i5);
                                            if (i5) {
                                            }
                                            if (com.uc.crashsdk.b.y()) {
                                            }
                                            V = true;
                                            if (Process.myPid() > 0) {
                                            }
                                        }
                                        if (!z8 && !z14) {
                                            b(false);
                                        }
                                        f.c(false);
                                        i5 = g.i();
                                        if (!com.uc.crashsdk.a.d.d()) {
                                            i5 = true;
                                        }
                                        com.uc.crashsdk.a.a.a("crashsdk", "Call java default handler: " + i5);
                                        if (i5 && T != null) {
                                            T.uncaughtException(thread, th);
                                        }
                                        if (com.uc.crashsdk.b.y() && !z14) {
                                            com.uc.crashsdk.b.b(com.uc.crashsdk.a.g.a());
                                        }
                                        V = true;
                                        if (Process.myPid() > 0) {
                                            Process.killProcess(Process.myPid());
                                            return;
                                        }
                                        return;
                                    }
                                }
                                z8 = false;
                                if (!z8) {
                                    b(false);
                                }
                                f.c(false);
                                i5 = g.i();
                                if (!com.uc.crashsdk.a.d.d()) {
                                }
                                com.uc.crashsdk.a.a.a("crashsdk", "Call java default handler: " + i5);
                                if (i5) {
                                    T.uncaughtException(thread, th);
                                }
                                if (com.uc.crashsdk.b.y()) {
                                    com.uc.crashsdk.b.b(com.uc.crashsdk.a.g.a());
                                }
                                V = true;
                                if (Process.myPid() > 0) {
                                }
                            } else if (z6) {
                                if (i12 != 0 && com.uc.crashsdk.b.f9655d) {
                                    JNIBridge.nativeClientCloseConnection(nativeClientCreateConnection);
                                }
                                if (z2) {
                                    try {
                                    } catch (Throwable th23) {
                                        th = th23;
                                        z7 = false;
                                    }
                                    if (g.r() && !z14) {
                                        try {
                                            a(true, false);
                                            z7 = true;
                                        } catch (Throwable th24) {
                                            th = th24;
                                            z7 = true;
                                            com.uc.crashsdk.a.g.a(th);
                                            if (!z7) {
                                            }
                                            f.c(false);
                                            i4 = g.i();
                                            if (!com.uc.crashsdk.a.d.d()) {
                                            }
                                            com.uc.crashsdk.a.a.a("crashsdk", "Call java default handler: " + i4);
                                            if (i4) {
                                            }
                                            if (com.uc.crashsdk.b.y()) {
                                            }
                                            V = true;
                                            if (Process.myPid() > 0) {
                                            }
                                        }
                                        if (!z7 && !z14) {
                                            b(false);
                                        }
                                        f.c(false);
                                        i4 = g.i();
                                        if (!com.uc.crashsdk.a.d.d()) {
                                            i4 = true;
                                        }
                                        com.uc.crashsdk.a.a.a("crashsdk", "Call java default handler: " + i4);
                                        if (i4 && T != null) {
                                            T.uncaughtException(thread, th);
                                        }
                                        if (com.uc.crashsdk.b.y() && !z14) {
                                            com.uc.crashsdk.b.b(com.uc.crashsdk.a.g.a());
                                        }
                                        V = true;
                                        if (Process.myPid() > 0) {
                                            Process.killProcess(Process.myPid());
                                            return;
                                        }
                                        return;
                                    }
                                }
                                z7 = false;
                                if (!z7) {
                                    b(false);
                                }
                                f.c(false);
                                i4 = g.i();
                                if (!com.uc.crashsdk.a.d.d()) {
                                }
                                com.uc.crashsdk.a.a.a("crashsdk", "Call java default handler: " + i4);
                                if (i4) {
                                    T.uncaughtException(thread, th);
                                }
                                if (com.uc.crashsdk.b.y()) {
                                    com.uc.crashsdk.b.b(com.uc.crashsdk.a.g.a());
                                }
                                V = true;
                                if (Process.myPid() > 0) {
                                }
                            }
                        }
                        boolean z152 = th instanceof OutOfMemoryError;
                        a(th, str, nativeClientCreateConnection, z152);
                        com.uc.crashsdk.a.a.d("DEBUG", "generate java report finished");
                        if (!com.uc.crashsdk.b.I() && z152 && g.j()) {
                            String name2 = new File(str).getName();
                            String W22 = g.W();
                            file = new File(W22);
                            if (!file.exists()) {
                                file.mkdirs();
                            }
                            String format2 = String.format(Locale.US, "%s%s.hprof", W22, name2);
                            com.uc.crashsdk.a.a.d("DEBUG", "begin dump hprof: " + format2);
                            long currentTimeMillis2 = System.currentTimeMillis();
                            Debug.dumpHprofData(format2);
                            com.uc.crashsdk.a.a.d("DEBUG", "end dump hprof, use " + (System.currentTimeMillis() - currentTimeMillis2) + " ms");
                        }
                        if (nativeClientCreateConnection != 0 && com.uc.crashsdk.b.f9655d) {
                            JNIBridge.nativeClientCloseConnection(nativeClientCreateConnection);
                        }
                        if (z2) {
                            try {
                            } catch (Throwable th25) {
                                th3 = th25;
                                z9 = false;
                            }
                            if (g.r() && !z14) {
                                try {
                                    a(true, false);
                                    z9 = true;
                                } catch (Throwable th26) {
                                    th3 = th26;
                                    z9 = true;
                                    com.uc.crashsdk.a.g.a(th3);
                                    if (!z9) {
                                    }
                                    f.c(false);
                                    i6 = g.i();
                                    if (!com.uc.crashsdk.a.d.d()) {
                                    }
                                    com.uc.crashsdk.a.a.a("crashsdk", "Call java default handler: " + i6);
                                    if (i6) {
                                    }
                                    if (com.uc.crashsdk.b.y()) {
                                    }
                                    V = true;
                                    if (Process.myPid() <= 0) {
                                    }
                                }
                                if (!z9 && !z14) {
                                    b(false);
                                }
                                f.c(false);
                                i6 = g.i();
                                if (!com.uc.crashsdk.a.d.d()) {
                                    i6 = true;
                                }
                                com.uc.crashsdk.a.a.a("crashsdk", "Call java default handler: " + i6);
                                if (i6 && T != null) {
                                    T.uncaughtException(thread, th);
                                }
                                if (com.uc.crashsdk.b.y() && !z14) {
                                    com.uc.crashsdk.b.b(com.uc.crashsdk.a.g.a());
                                }
                                V = true;
                                if (Process.myPid() <= 0) {
                                    Process.killProcess(Process.myPid());
                                    return;
                                }
                                return;
                            }
                        }
                        z9 = false;
                        if (!z9) {
                            b(false);
                        }
                        f.c(false);
                        i6 = g.i();
                        if (!com.uc.crashsdk.a.d.d()) {
                        }
                        com.uc.crashsdk.a.a.a("crashsdk", "Call java default handler: " + i6);
                        if (i6) {
                            T.uncaughtException(thread, th);
                        }
                        if (com.uc.crashsdk.b.y()) {
                            com.uc.crashsdk.b.b(com.uc.crashsdk.a.g.a());
                        }
                        V = true;
                        if (Process.myPid() <= 0) {
                        }
                    }
                }
            }
        } catch (Throwable th27) {
            th = th27;
            z3 = false;
            j2 = 0;
        }
    }

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

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

    public 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("\n");
                if (!z2 && stackTraceElement.getMethodName().contains(str)) {
                    sb.delete(0, sb.length());
                    z2 = true;
                    i3 = 0;
                }
            }
            i2 = i3;
        }
        if (i2 == 0) {
            sb.append("  (no java stack)\n");
        }
        return sb;
    }

    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 (!com.uc.crashsdk.b.f9655d) {
            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, fd, null, null);
            af = nativeCmd != -1;
            return fd == -1 || nativeCmd != -1;
        }
    }
}