package com.ss.android.agilelogger;

import X.0Rm;
import X.0Rn;
import X.0Ro;
import X.0Rp;
import X.0Rq;
import X.0Rr;
import X.0Rs;
import X.0Ru;
import X.0Rw;
import X.0Rx;
import X.4N2;
import X.7ra;
import X.7xn;
import X.8Kc;
import X.8Vw;
import X.8mf;
import X.8r0;
import X.8r1;
import X.9Ih;
import X.C2733Q1y;
import X.C2734Q1z;
import X.Q20;
import X.Q21;
import X.Q22;
import X.Q23;
import X.Q27;
import X.Q29;
import X.Q39;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;
import android.os.HandlerThread;
import android.os.Message;
import android.os.Process;
import android.text.TextUtils;
import com.bytedance.android.alog.Alog;
import com.bytedance.covode.number.Covode;
import com.bytedance.frameworks.apm.trace.MethodCollector;
import com.bytedance.ies.abmock.SettingsManager;
import java.io.File;
import java.io.FilenameFilter;
import java.lang.ref.WeakReference;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Queue;
import java.util.Set;
import java.util.concurrent.ScheduledExecutorService;
import java.util.regex.Pattern;

public class ALog {
    public static volatile Set<String> mBlockTagSet;
    public static Alog mainThreadRef = null;
    public static int prio = 3;
    public static Handler sAsyncHandler;
    public static HandlerThread sAsyncLogThread;
    public static Q20 sConfig;
    public static volatile boolean sDebug;
    public static volatile Q27 sILogCacheCallback;
    public static volatile List<C2733Q1y> sINativeFuncAddrCallbackList = new ArrayList();
    public static Object sInitLock = new Object();
    public static volatile boolean sInitSuccess;
    public static boolean sInitialized = false;
    public static long sMainThreadId = -1;
    public static ScheduledExecutorService sOuterExecutorService = null;
    public static ArrayList<WeakReference<Alog>> sStandaloneInstances = new ArrayList<>();

    public static void forceLogSharding() {
    }

    public static int level2AlogCoreLevel(int i) {
        return i - 2;
    }

    public static void setPrintStackTrace(boolean z) {
    }

    public static void setsPackageClassName(String str) {
    }

    public static Set<String> getBlockTagSet() {
        return mBlockTagSet;
    }

    public static List<C2733Q1y> getNativeFuncAddrCallbackList() {
        return sINativeFuncAddrCallbackList;
    }

    public static boolean isInitSuccess() {
        return sInitSuccess;
    }

    public static long getALogWriteFuncAddr() {
        return 0Rw.LIZJ();
    }

    public static void initMainThreadIdIfNeeded() {
        if (sMainThreadId == -1) {
            sMainThreadId = (long) Process.myTid();
        }
    }

    public static void destroy() {
        0Rw.LIZ();
        Alog alog = mainThreadRef;
        if (alog != null) {
            alog.LIZ();
        }
        if (sAsyncHandler != null) {
            sAsyncLogThread.quit();
            sAsyncLogThread = null;
            sAsyncHandler = null;
        }
    }

    public static void flush() {
        Handler handler = sAsyncHandler;
        if (handler != null) {
            handler.sendEmptyMessage(2);
        }
        0Rw.LIZIZ();
        Alog alog = mainThreadRef;
        if (alog != null) {
            alog.LIZIZ();
        }
    }

    public static void release() {
        0Rw.LIZ();
        Alog alog = mainThreadRef;
        if (alog != null) {
            alog.LIZ();
        }
        if (sAsyncHandler != null) {
            sAsyncLogThread.quit();
            sAsyncLogThread = null;
            sAsyncHandler = null;
        }
    }

    static {
        Covode.recordClassIndex(48121);
    }

    public static void asyncFlush() {
        Handler handler = sAsyncHandler;
        if (handler != null) {
            handler.sendEmptyMessage(2);
        }
        0Rw.LIZIZ();
        Alog alog = mainThreadRef;
        if (alog != null) {
            alog.LIZIZ();
        }
        Iterator<WeakReference<Alog>> it = sStandaloneInstances.iterator();
        while (it.hasNext()) {
            Alog alog2 = (Alog) it.next().get();
            if (alog2 != null) {
                alog2.LIZIZ();
            }
        }
    }

    public static long getALogSimpleWriteFuncAddr() {
        MethodCollector.i(2942);
        if (0Rw.LIZ == null) {
            MethodCollector.o(2942);
            return 0;
        } else if (0Rw.LIZ.LJIILL != 0) {
            long nativeGetNativeWriteFuncAddr = Alog.nativeGetNativeWriteFuncAddr();
            MethodCollector.o(2942);
            return nativeGetNativeWriteFuncAddr;
        } else {
            MethodCollector.o(2942);
            return 0;
        }
    }

    public static long getAlogNativeFlushV2FuncAddr() {
        MethodCollector.i(2811);
        if (0Rw.LIZ == null) {
            MethodCollector.o(2811);
            return 0;
        } else if (0Rw.LIZ.LJIILL != 0) {
            long nativeGetLegacyFlushFuncAddr = Alog.nativeGetLegacyFlushFuncAddr();
            MethodCollector.o(2811);
            return nativeGetLegacyFlushFuncAddr;
        } else {
            MethodCollector.o(2811);
            return 0;
        }
    }

    public static long getAlogNativeLogStoreDirFuncAddr() {
        MethodCollector.i(2873);
        if (0Rw.LIZ == null) {
            MethodCollector.o(2873);
            return 0;
        } else if (0Rw.LIZ.LJIILL != 0) {
            long nativeGetLegacyGetLogFileDirFuncAddr = Alog.nativeGetLegacyGetLogFileDirFuncAddr();
            MethodCollector.o(2873);
            return nativeGetLegacyGetLogFileDirFuncAddr;
        } else {
            MethodCollector.o(2873);
            return 0;
        }
    }

    public static void syncFlush() {
        Handler handler = sAsyncHandler;
        if (handler != null) {
            handler.sendEmptyMessage(2);
        }
        if (0Rw.LIZ != null) {
            0Rw.LIZ.LIZJ();
        }
        Alog alog = mainThreadRef;
        if (alog != null) {
            alog.LIZJ();
        }
        Iterator<WeakReference<Alog>> it = sStandaloneInstances.iterator();
        while (it.hasNext()) {
            Alog alog2 = (Alog) it.next().get();
            if (alog2 != null) {
                alog2.LIZJ();
            }
        }
    }

    /* renamed from: com.ss.android.agilelogger.ALog$7  reason: invalid class name */
    public static /* synthetic */ class AnonymousClass7 {
        public static final /* synthetic */ int[] LIZ;

        /* JADX WARNING: Can't wrap try/catch for region: R(18:0|1|2|3|4|5|6|7|8|9|10|11|12|13|14|15|16|(3:17|18|20)) */
        /* JADX WARNING: Can't wrap try/catch for region: R(20:0|1|2|3|4|5|6|7|8|9|10|11|12|13|14|15|16|17|18|20) */
        /* JADX WARNING: Failed to process nested try/catch */
        /* JADX WARNING: Missing exception handler attribute for start block: B:11:0x0044 */
        /* JADX WARNING: Missing exception handler attribute for start block: B:13:0x004f */
        /* JADX WARNING: Missing exception handler attribute for start block: B:15:0x005a */
        /* JADX WARNING: Missing exception handler attribute for start block: B:17:0x0066 */
        /* JADX WARNING: Missing exception handler attribute for start block: B:3:0x0018 */
        /* JADX WARNING: Missing exception handler attribute for start block: B:5:0x0023 */
        /* JADX WARNING: Missing exception handler attribute for start block: B:7:0x002e */
        /* JADX WARNING: Missing exception handler attribute for start block: B:9:0x0039 */
        static {
            /*
                r0 = 48128(0xbc00, float:6.7442E-41)
                com.bytedance.covode.number.Covode.recordClassIndex(r0)
                X.Q23[] r0 = X.Q23.values()
                int r0 = r0.length
                int[] r2 = new int[r0]
                LIZ = r2
                X.Q23 r0 = X.Q23.MSG     // Catch:{ NoSuchFieldError -> 0x0018 }
                int r1 = r0.ordinal()     // Catch:{ NoSuchFieldError -> 0x0018 }
                r0 = 1
                r2[r1] = r0     // Catch:{ NoSuchFieldError -> 0x0018 }
            L_0x0018:
                int[] r2 = LIZ     // Catch:{ NoSuchFieldError -> 0x0023 }
                X.Q23 r0 = X.Q23.STACKTRACE_STR     // Catch:{ NoSuchFieldError -> 0x0023 }
                int r1 = r0.ordinal()     // Catch:{ NoSuchFieldError -> 0x0023 }
                r0 = 2
                r2[r1] = r0     // Catch:{ NoSuchFieldError -> 0x0023 }
            L_0x0023:
                int[] r2 = LIZ     // Catch:{ NoSuchFieldError -> 0x002e }
                X.Q23 r0 = X.Q23.BORDER     // Catch:{ NoSuchFieldError -> 0x002e }
                int r1 = r0.ordinal()     // Catch:{ NoSuchFieldError -> 0x002e }
                r0 = 3
                r2[r1] = r0     // Catch:{ NoSuchFieldError -> 0x002e }
            L_0x002e:
                int[] r2 = LIZ     // Catch:{ NoSuchFieldError -> 0x0039 }
                X.Q23 r0 = X.Q23.JSON     // Catch:{ NoSuchFieldError -> 0x0039 }
                int r1 = r0.ordinal()     // Catch:{ NoSuchFieldError -> 0x0039 }
                r0 = 4
                r2[r1] = r0     // Catch:{ NoSuchFieldError -> 0x0039 }
            L_0x0039:
                int[] r2 = LIZ     // Catch:{ NoSuchFieldError -> 0x0044 }
                X.Q23 r0 = X.Q23.BUNDLE     // Catch:{ NoSuchFieldError -> 0x0044 }
                int r1 = r0.ordinal()     // Catch:{ NoSuchFieldError -> 0x0044 }
                r0 = 5
                r2[r1] = r0     // Catch:{ NoSuchFieldError -> 0x0044 }
            L_0x0044:
                int[] r2 = LIZ     // Catch:{ NoSuchFieldError -> 0x004f }
                X.Q23 r0 = X.Q23.INTENT     // Catch:{ NoSuchFieldError -> 0x004f }
                int r1 = r0.ordinal()     // Catch:{ NoSuchFieldError -> 0x004f }
                r0 = 6
                r2[r1] = r0     // Catch:{ NoSuchFieldError -> 0x004f }
            L_0x004f:
                int[] r2 = LIZ     // Catch:{ NoSuchFieldError -> 0x005a }
                X.Q23 r0 = X.Q23.THROWABLE     // Catch:{ NoSuchFieldError -> 0x005a }
                int r1 = r0.ordinal()     // Catch:{ NoSuchFieldError -> 0x005a }
                r0 = 7
                r2[r1] = r0     // Catch:{ NoSuchFieldError -> 0x005a }
            L_0x005a:
                int[] r2 = LIZ     // Catch:{ NoSuchFieldError -> 0x0066 }
                X.Q23 r0 = X.Q23.THREAD     // Catch:{ NoSuchFieldError -> 0x0066 }
                int r1 = r0.ordinal()     // Catch:{ NoSuchFieldError -> 0x0066 }
                r0 = 8
                r2[r1] = r0     // Catch:{ NoSuchFieldError -> 0x0066 }
            L_0x0066:
                int[] r2 = LIZ     // Catch:{ NoSuchFieldError -> 0x0072 }
                X.Q23 r0 = X.Q23.STACKTRACE     // Catch:{ NoSuchFieldError -> 0x0072 }
                int r1 = r0.ordinal()     // Catch:{ NoSuchFieldError -> 0x0072 }
                r0 = 9
                r2[r1] = r0     // Catch:{ NoSuchFieldError -> 0x0072 }
            L_0x0072:
                return
            */
            throw new UnsupportedOperationException("Method not decompiled: com.ss.android.agilelogger.ALog.AnonymousClass7.<clinit>():void");
        }
    }

    public static HashMap<String, String> getLastFetchErrorInfo() {
        if (0Rw.LIZ == null) {
            return null;
        }
        HashMap<String, String> hashMap = new HashMap<>();
        hashMap.put("start", Long.toString(0Ru.LIZIZ));
        hashMap.put("end", Long.toString(0Ru.LIZJ));
        hashMap.put("reason", 0Ru.LJ);
        if (0Ru.LIZLLL != null) {
            StringBuilder sb = new StringBuilder();
            Iterator it = 0Ru.LIZLLL.iterator();
            while (it.hasNext()) {
                String str = (String) it.next();
                if (str.endsWith(".alog.hot")) {
                    str = str.substring(0, str.length() - 0Ru.LIZ);
                }
                sb.append(str);
                sb.append(";");
            }
            hashMap.put("file", sb.toString());
        }
        0Ru.LJ = null;
        0Ru.LIZLLL = null;
        return hashMap;
    }

    public static String getStatus() {
        try {
            if (0Rw.LIZ == null) {
                return "default log instance is null";
            }
            Alog alog = 0Rw.LIZ;
            if (!Alog.LJII) {
                return "not inited";
            }
            if (alog.LJIILIIL == null) {
                alog.LJIILIIL = 0Rx.LIZ();
            }
            if (alog.LJIILIIL == null) {
                return "get process name failed";
            }
            String replace = alog.LJIILIIL.replace(':', '-');
            File file = new File(alog.LJIIJ);
            if (!file.exists()) {
                return "cache dir not exists";
            }
            File[] listFiles = file.listFiles();
            if (listFiles == null) {
                return "cache dir is empty";
            }
            String str = replace + "__" + alog.LJIILJJIL + ".alog.cache.guard";
            Pattern compile = Pattern.compile("^" + Pattern.quote(replace) + "__" + Pattern.quote(alog.LJIILJJIL) + "__\\d{5}\\.alog\\.cache$");
            int i = 0;
            int i2 = 0;
            int i3 = 0;
            int i4 = 0;
            for (File file2 : listFiles) {
                if (file2.getName().equals(str)) {
                    i++;
                    if (file2.length() >= 24576) {
                        i2++;
                    }
                } else {
                    if (file2.getName().startsWith(replace + "__" + alog.LJIILJJIL + "__") && compile.matcher(file2.getName()).find()) {
                        i3++;
                        if (file2.length() >= ((long) alog.LJIIJJI)) {
                            i4++;
                        }
                    }
                }
            }
            if (i <= 0) {
                return "cache guard not exists";
            }
            if (i2 <= 0) {
                return "cache guard size insufficiently";
            }
            if (i3 < alog.LJIIL) {
                return "cache block count insufficiently";
            }
            if (i4 < alog.LJIIL) {
                return "cache block size insufficiently";
            }
            File file3 = new File(alog.LJIIIZ);
            if (!file3.exists()) {
                return "log dir not exists";
            }
            File[] listFiles2 = file3.listFiles(new Alog.1(alog, Pattern.compile("^\\d{4}_\\d{2}_\\d{2}_\\d+__" + Pattern.quote(replace) + "__" + Pattern.quote(alog.LJIILJJIL) + "\\.alog\\.hot$")));
            if (listFiles2 == null || listFiles2.length == 0) {
                return "no log file for current process and instance";
            }
            return "OK";
        } catch (Exception unused) {
            return "getStatus exception";
        }
    }

    public static void setILogCacheCallback(Q27 q27) {
        sILogCacheCallback = q27;
    }

    public static void setOuterExecutorService(ScheduledExecutorService scheduledExecutorService) {
        sOuterExecutorService = scheduledExecutorService;
    }

    public static void addNativeFuncAddrCallback(C2733Q1y q1y) {
        sINativeFuncAddrCallbackList.add(q1y);
    }

    public static void setBlockTagSet(Set<String> set) {
        mBlockTagSet = Collections.unmodifiableSet(set);
    }

    public static void changeLevel(int i) {
        prio = i;
        int level2AlogCoreLevel = level2AlogCoreLevel(i);
        if (0Rw.LIZ != null) {
            0Rw.LIZ.LIZIZ(level2AlogCoreLevel);
        }
        Alog alog = mainThreadRef;
        if (alog != null) {
            alog.LIZIZ(level2AlogCoreLevel(i));
        }
    }

    public static void setDebug(boolean z) {
        sDebug = z;
        if (0Rw.LIZ != null) {
            0Rw.LIZ.LIZ(z);
        }
        Alog alog = mainThreadRef;
        if (alog != null) {
            alog.LIZ(sDebug);
        }
    }

    public static void timedSyncFlush(int i) {
        Handler handler = sAsyncHandler;
        if (handler != null) {
            handler.sendEmptyMessage(2);
        }
        if (0Rw.LIZ != null) {
            0Rw.LIZ.LIZ(i);
        }
        Alog alog = mainThreadRef;
        if (alog != null) {
            alog.LIZ(i);
        }
        Iterator<WeakReference<Alog>> it = sStandaloneInstances.iterator();
        while (it.hasNext()) {
            Alog alog2 = (Alog) it.next().get();
            if (alog2 != null) {
                alog2.LIZ(i);
            }
        }
    }

    public static void writeCachedItems(Queue<7ra> queue) {
        for (7ra r3 : queue) {
            if (checkPrioAndTag(r3.LIZIZ, r3.LIZJ)) {
                handleItemMsg(r3);
                0Rw.LIZ(level2AlogCoreLevel(r3.LIZIZ), r3.LIZJ, r3.LIZLLL);
            }
        }
    }

    public static boolean INVOKEVIRTUAL_com_ss_android_agilelogger_ALog_com_ss_android_ugc_aweme_storage_FileLancet_delete(File file) {
        8r1 r3;
        MethodCollector.i(4863);
        try {
            if (8Kc.LIZIZ()) {
                r3 = (8r1) SettingsManager.LIZ().LIZ("storage_intercepter_key", 8r1.class, 4N2.LIZ);
            } else {
                r3 = 4N2.LIZ;
            }
            if (8r0.LIZ(file.getAbsolutePath(), r3)) {
                8r0.LIZ(file, new RuntimeException(), "exception_delete_log", 8r0.LIZ(r3));
            }
            if (8r0.LIZJ(file.getAbsolutePath(), r3)) {
                8r0.LIZ(file, new RuntimeException(), "exception_handle", 8r0.LIZ(r3));
                MethodCollector.o(4863);
                return false;
            }
        } catch (Throwable unused) {
        }
        boolean delete = file.delete();
        MethodCollector.o(4863);
        return delete;
    }

    public static void handleItemMsg(7ra r2) {
        String str;
        switch (AnonymousClass7.LIZ[r2.LJI.ordinal()]) {
            case 1:
                str = (String) r2.LJII;
                break;
            case 2:
                if (r2.LJIIIIZZ != null) {
                    str = r2.LJIIIIZZ + 8Vw.LIZ((Throwable) r2.LJII);
                    break;
                } else {
                    str = 8Vw.LIZ((Throwable) r2.LJII);
                    break;
                }
            case 3:
            case 4:
                str = Q22.LIZ(r2.LJI, (String) r2.LJII);
                break;
            case 5:
                str = Q22.LIZ(r2.LJI, (Bundle) r2.LJII);
                break;
            case 6:
                str = Q22.LIZ(r2.LJI, (Intent) r2.LJII);
                break;
            case 7:
                str = Q22.LIZ(r2.LJI, (Throwable) r2.LJII);
                break;
            case 8:
                str = Q22.LIZ(r2.LJI, (Thread) r2.LJII);
                break;
            case 9:
                str = Q22.LIZ(r2.LJI, (StackTraceElement[]) r2.LJII);
                break;
            default:
                str = Q39.LIZJ;
                break;
        }
        r2.LIZLLL = str;
    }

    public static void handleAsyncLog(Q21 q21) {
        String str;
        MethodCollector.i(3317);
        Q21 q212 = q21;
        int level2AlogCoreLevel = level2AlogCoreLevel(q212.LIZLLL);
        String str2 = Q39.LIZJ;
        if (q212.LJII == null) {
            if (q212.LJI == null) {
                str2 = q212.LJFF;
            } else {
                if (q212.LJFF == null) {
                    str = Q39.LIZJ;
                } else {
                    str = q212.LJFF + "\n";
                }
                str2 = str + 8Vw.LIZ(q212.LJI);
            }
        } else if (q212.LJII == Q23.BORDER) {
            str2 = Q22.LIZ(Q23.BORDER, q212.LJFF);
        } else if (q212.LJII == Q23.JSON) {
            str2 = Q22.LIZ(Q23.JSON, q212.LJFF);
        } else if (q212.LJII == Q23.BUNDLE) {
            str2 = Q22.LIZ(Q23.BUNDLE, (Bundle) q212.LJIIIIZZ);
        } else if (q212.LJII == Q23.INTENT) {
            str2 = Q22.LIZ(Q23.INTENT, (Intent) q212.LJIIIIZZ);
        } else if (q212.LJII == Q23.THROWABLE) {
            str2 = Q22.LIZ(Q23.THROWABLE, (Throwable) q212.LJIIIIZZ);
        } else if (q212.LJII == Q23.THREAD) {
            str2 = Q22.LIZ(Q23.THREAD, (Thread) q212.LJIIIIZZ);
        } else if (q212.LJII == Q23.STACKTRACE) {
            str2 = Q22.LIZ(Q23.STACKTRACE, (StackTraceElement[]) q212.LJIIIIZZ);
        }
        String str3 = q212.LJ;
        long j = q212.LJIIIZ;
        long j2 = q212.LJIIJ;
        if (0Rw.LIZ != null) {
            Alog alog = 0Rw.LIZ;
            if (!(alog.LJIILL == 0 || level2AlogCoreLevel < alog.LJIIIIZZ || str3 == null || str2 == null)) {
                Alog.nativeWriteAsyncMsg(alog.LJIILL, level2AlogCoreLevel, str3, str2, j, j2);
            }
        }
        q212.LJ = null;
        q212.LJFF = null;
        q212.LJI = null;
        q212.LJII = null;
        q212.LJIIIIZZ = null;
        q212.LJIIIZ = -1;
        q212.LJIIJ = 0;
        q212.LJIIJJI = null;
        synchronized (Q21.LIZ) {
            try {
                if (Q21.LIZJ < 50) {
                    q212.LJIIJJI = Q21.LIZIZ;
                    Q21.LIZIZ = q212;
                    Q21.LIZJ++;
                }
            } finally {
                MethodCollector.o(3317);
            }
        }
    }

    /* JADX WARNING: Code restructure failed: missing block: B:100:0x01f1, code lost:
        r6 = false;
     */
    /* JADX WARNING: Code restructure failed: missing block: B:19:0x0026, code lost:
        prio = r9.LJIIIIZZ;
        r2 = r9.LIZ;
        r1 = X.7xn.LIZIZ();
     */
    /* JADX WARNING: Code restructure failed: missing block: B:20:0x0030, code lost:
        if (r1 == null) goto L_0x01f1;
     */
    /* JADX WARNING: Code restructure failed: missing block: B:22:0x0038, code lost:
        if (r1.contains(":") != false) goto L_0x01f1;
     */
    /* JADX WARNING: Code restructure failed: missing block: B:24:0x0042, code lost:
        if (r1.equals(r2.getPackageName()) == false) goto L_0x01e3;
     */
    /* JADX WARNING: Code restructure failed: missing block: B:25:0x0044, code lost:
        r6 = true;
     */
    /* JADX WARNING: Code restructure failed: missing block: B:26:0x0045, code lost:
        r3 = r9.LJIIJJI;
     */
    /* JADX WARNING: Code restructure failed: missing block: B:27:0x0047, code lost:
        if (r3 != false) goto L_0x01e0;
     */
    /* JADX WARNING: Code restructure failed: missing block: B:29:0x004b, code lost:
        if (r9.LJIIJ == false) goto L_0x01e0;
     */
    /* JADX WARNING: Code restructure failed: missing block: B:30:0x004d, code lost:
        if (r6 == false) goto L_0x01e0;
     */
    /* JADX WARNING: Code restructure failed: missing block: B:31:0x004f, code lost:
        r5 = true;
     */
    /* JADX WARNING: Code restructure failed: missing block: B:32:0x0050, code lost:
        r4 = new X.0Rn(r9.LIZ);
        r4.LIZ("default");
        r4.LIZ = level2AlogCoreLevel(r9.LJIIIIZZ);
        r4.LIZIZ = sDebug;
        r4.LIZJ = r9.LJFF;
        r4.LIZLLL = r9.LIZLLL;
     */
    /* JADX WARNING: Code restructure failed: missing block: B:33:0x0070, code lost:
        if (r5 == false) goto L_0x01dc;
     */
    /* JADX WARNING: Code restructure failed: missing block: B:34:0x0072, code lost:
        r0 = (r9.LIZJ / 3) * 2;
     */
    /* JADX WARNING: Code restructure failed: missing block: B:35:0x0078, code lost:
        r4.LJ = r0;
        r4.LJFF = r9.LIZIZ;
        r4.LJI = r9.LJ;
        r1 = 65536;
     */
    /* JADX WARNING: Code restructure failed: missing block: B:36:0x0087, code lost:
        if (r6 == false) goto L_0x01d7;
     */
    /* JADX WARNING: Code restructure failed: missing block: B:37:0x0089, code lost:
        r0 = 65536;
     */
    /* JADX WARNING: Code restructure failed: missing block: B:38:0x008b, code lost:
        r4.LJII = r0;
     */
    /* JADX WARNING: Code restructure failed: missing block: B:39:0x008d, code lost:
        if (r6 == false) goto L_0x0091;
     */
    /* JADX WARNING: Code restructure failed: missing block: B:40:0x008f, code lost:
        r1 = 196608;
     */
    /* JADX WARNING: Code restructure failed: missing block: B:41:0x0091, code lost:
        r4.LJIIIIZZ = r1;
        r4.LIZ(X.0Rp.SAFE);
        r4.LIZ(X.0Rs.RAW);
        r4.LIZ(X.0Rq.LEGACY);
     */
    /* JADX WARNING: Code restructure failed: missing block: B:42:0x00a4, code lost:
        if (r9.LJI == false) goto L_0x01d3;
     */
    /* JADX WARNING: Code restructure failed: missing block: B:43:0x00a6, code lost:
        r0 = X.0Ro.ZSTD;
     */
    /* JADX WARNING: Code restructure failed: missing block: B:44:0x00a8, code lost:
        r4.LIZ(r0);
     */
    /* JADX WARNING: Code restructure failed: missing block: B:45:0x00ad, code lost:
        if (r9.LJII == false) goto L_0x01cf;
     */
    /* JADX WARNING: Code restructure failed: missing block: B:46:0x00af, code lost:
        r0 = X.0Rr.TEA_16;
     */
    /* JADX WARNING: Code restructure failed: missing block: B:47:0x00b1, code lost:
        r4.LIZ(r0);
     */
    /* JADX WARNING: Code restructure failed: missing block: B:48:0x00b6, code lost:
        if (r9.LJII == false) goto L_0x01cb;
     */
    /* JADX WARNING: Code restructure failed: missing block: B:49:0x00b8, code lost:
        r0 = X.0Rm.EC_SECP256K1;
     */
    /* JADX WARNING: Code restructure failed: missing block: B:50:0x00ba, code lost:
        r4.LIZ(r0);
        r4.LJIIIZ = r9.LJIIIZ;
        r0 = r4.LIZ();
        X.0Rw.LIZ = r0;
     */
    /* JADX WARNING: Code restructure failed: missing block: B:51:0x00c7, code lost:
        if (r0 != null) goto L_0x01c7;
     */
    /* JADX WARNING: Code restructure failed: missing block: B:52:0x00c9, code lost:
        r0 = 0;
     */
    /* JADX WARNING: Code restructure failed: missing block: B:53:0x00cb, code lost:
        com.bytedance.android.alog.Alog.nativeSetDefaultInstance(r0);
     */
    /* JADX WARNING: Code restructure failed: missing block: B:54:0x00ce, code lost:
        if (r3 == false) goto L_0x00eb;
     */
    /* JADX WARNING: Code restructure failed: missing block: B:55:0x00d0, code lost:
        if (r6 == false) goto L_0x00eb;
     */
    /* JADX WARNING: Code restructure failed: missing block: B:56:0x00d2, code lost:
        r1 = new android.os.HandlerThread("Alog_main_delegate");
        sAsyncLogThread = r1;
        r1.start();
        sAsyncHandler = new com.ss.android.agilelogger.ALog.AnonymousClass1(sAsyncLogThread.getLooper());
     */
    /* JADX WARNING: Code restructure failed: missing block: B:57:0x00eb, code lost:
        if (r5 == false) goto L_0x0158;
     */
    /* JADX WARNING: Code restructure failed: missing block: B:58:0x00ed, code lost:
        r1 = new X.0Rn(r9.LIZ);
        r1.LIZ("main");
        r1.LIZ = level2AlogCoreLevel(r9.LJIIIIZZ);
        r1.LIZIZ = sDebug;
        r1.LIZJ = r9.LJFF;
        r1.LIZLLL = r9.LIZLLL / 2;
        r1.LJ = r9.LIZJ / 3;
        r1.LJFF = r9.LIZIZ;
        r1.LJI = r9.LJ;
        r1.LJII = 32768;
        r1.LJIIIIZZ = 98304;
        r1.LIZ(X.0Rp.SAFE);
        r1.LIZ(X.0Rs.RAW);
        r1.LIZ(X.0Rq.LEGACY);
     */
    /* JADX WARNING: Code restructure failed: missing block: B:59:0x0135, code lost:
        if (r9.LJI == false) goto L_0x01c3;
     */
    /* JADX WARNING: Code restructure failed: missing block: B:60:0x0137, code lost:
        r0 = X.0Ro.ZSTD;
     */
    /* JADX WARNING: Code restructure failed: missing block: B:61:0x0139, code lost:
        r1.LIZ(r0);
     */
    /* JADX WARNING: Code restructure failed: missing block: B:62:0x013e, code lost:
        if (r9.LJII == false) goto L_0x01c0;
     */
    /* JADX WARNING: Code restructure failed: missing block: B:63:0x0140, code lost:
        r0 = X.0Rr.TEA_16;
     */
    /* JADX WARNING: Code restructure failed: missing block: B:64:0x0142, code lost:
        r1.LIZ(r0);
     */
    /* JADX WARNING: Code restructure failed: missing block: B:65:0x0147, code lost:
        if (r9.LJII == false) goto L_0x01bd;
     */
    /* JADX WARNING: Code restructure failed: missing block: B:66:0x0149, code lost:
        r0 = X.0Rm.EC_SECP256K1;
     */
    /* JADX WARNING: Code restructure failed: missing block: B:67:0x014b, code lost:
        r1.LIZ(r0);
        r1.LJIIIZ = r9.LJIIIZ;
        mainThreadRef = r1.LIZ();
     */
    /* JADX WARNING: Code restructure failed: missing block: B:68:0x0158, code lost:
        r6 = r9.LJ;
        r5 = r9.LJFF;
        r3 = null;
     */
    /* JADX WARNING: Code restructure failed: missing block: B:69:0x015f, code lost:
        if (sILogCacheCallback == null) goto L_0x016f;
     */
    /* JADX WARNING: Code restructure failed: missing block: B:70:0x0161, code lost:
        r1 = sILogCacheCallback.LIZ();
     */
    /* JADX WARNING: Code restructure failed: missing block: B:71:0x0167, code lost:
        if (r1 == null) goto L_0x01b9;
     */
    /* JADX WARNING: Code restructure failed: missing block: B:73:0x016d, code lost:
        if (r1.size() != 0) goto L_0x01b9;
     */
    /* JADX WARNING: Code restructure failed: missing block: B:75:0x0177, code lost:
        if (getNativeFuncAddrCallbackList().size() <= 0) goto L_0x0196;
     */
    /* JADX WARNING: Code restructure failed: missing block: B:76:0x0179, code lost:
        r2 = new com.ss.android.agilelogger.ALog.AnonymousClass2();
        r0 = sOuterExecutorService;
     */
    /* JADX WARNING: Code restructure failed: missing block: B:77:0x0180, code lost:
        if (r0 != null) goto L_0x0192;
     */
    /* JADX WARNING: Code restructure failed: missing block: B:78:0x0182, code lost:
        new java.lang.Thread(r2, "_ALOG_OPT_").start();
     */
    /* JADX WARNING: Code restructure failed: missing block: B:79:0x018c, code lost:
        sInitSuccess = true;
        com.bytedance.frameworks.apm.trace.MethodCollector.o(4784);
     */
    /* JADX WARNING: Code restructure failed: missing block: B:80:0x0191, code lost:
        return true;
     */
    /* JADX WARNING: Code restructure failed: missing block: B:81:0x0192, code lost:
        r0.execute(r2);
     */
    /* JADX WARNING: Code restructure failed: missing block: B:82:0x0196, code lost:
        r4 = sOuterExecutorService;
     */
    /* JADX WARNING: Code restructure failed: missing block: B:83:0x0198, code lost:
        if (r4 != null) goto L_0x01ac;
     */
    /* JADX WARNING: Code restructure failed: missing block: B:84:0x019a, code lost:
        new java.util.Timer("_ALOG_OPT_").schedule(new com.ss.android.agilelogger.ALog.AnonymousClass3(), 15000);
     */
    /* JADX WARNING: Code restructure failed: missing block: B:85:0x01ac, code lost:
        r4.schedule(new com.ss.android.agilelogger.ALog.AnonymousClass4(), 15, java.util.concurrent.TimeUnit.SECONDS);
     */
    /* JADX WARNING: Code restructure failed: missing block: B:86:0x01b9, code lost:
        r3 = r1;
     */
    /* JADX WARNING: Code restructure failed: missing block: B:87:0x01ba, code lost:
        if (r3 != null) goto L_0x0179;
     */
    /* JADX WARNING: Code restructure failed: missing block: B:88:0x01bd, code lost:
        r0 = X.0Rm.NONE;
     */
    /* JADX WARNING: Code restructure failed: missing block: B:89:0x01c0, code lost:
        r0 = X.0Rr.NONE;
     */
    /* JADX WARNING: Code restructure failed: missing block: B:90:0x01c3, code lost:
        r0 = X.0Ro.NONE;
     */
    /* JADX WARNING: Code restructure failed: missing block: B:91:0x01c7, code lost:
        r0 = r0.LJIILL;
     */
    /* JADX WARNING: Code restructure failed: missing block: B:92:0x01cb, code lost:
        r0 = X.0Rm.NONE;
     */
    /* JADX WARNING: Code restructure failed: missing block: B:93:0x01cf, code lost:
        r0 = X.0Rr.NONE;
     */
    /* JADX WARNING: Code restructure failed: missing block: B:94:0x01d3, code lost:
        r0 = X.0Ro.NONE;
     */
    /* JADX WARNING: Code restructure failed: missing block: B:95:0x01d7, code lost:
        r0 = 32768;
     */
    /* JADX WARNING: Code restructure failed: missing block: B:96:0x01dc, code lost:
        r0 = r9.LIZJ;
     */
    /* JADX WARNING: Code restructure failed: missing block: B:97:0x01e0, code lost:
        r5 = false;
     */
    /* JADX WARNING: Code restructure failed: missing block: B:99:0x01ed, code lost:
        if (r1.equals(r2.getApplicationInfo().processName) == false) goto L_0x01f1;
     */
    /* Code decompiled incorrectly, please refer to instructions dump. */
    public static boolean init(X.Q20 r9) {
        /*
            r8 = 4784(0x12b0, float:6.704E-42)
            com.bytedance.frameworks.apm.trace.MethodCollector.i(r8)
            r2 = 0
            if (r9 != 0) goto L_0x000c
            com.bytedance.frameworks.apm.trace.MethodCollector.o(r8)
            return r2
        L_0x000c:
            sConfig = r9
            X.8mf r0 = new X.8mf     // Catch:{ all -> 0x01fa }
            r0.<init>()     // Catch:{ all -> 0x01fa }
            com.bytedance.android.alog.Alog.LIZ(r0)     // Catch:{ all -> 0x01fa }
            java.lang.Object r1 = sInitLock
            monitor-enter(r1)
            boolean r0 = sInitialized     // Catch:{ all -> 0x01f4 }
            if (r0 == 0) goto L_0x0022
            monitor-exit(r1)     // Catch:{ all -> 0x01f4 }
            com.bytedance.frameworks.apm.trace.MethodCollector.o(r8)
            return r2
        L_0x0022:
            r7 = 1
            sInitialized = r7     // Catch:{ all -> 0x01f4 }
            monitor-exit(r1)     // Catch:{ all -> 0x01f4 }
            int r0 = r9.LJIIIIZZ
            prio = r0
            android.content.Context r2 = r9.LIZ
            java.lang.String r1 = X.7xn.LIZIZ()
            if (r1 == 0) goto L_0x01f1
            java.lang.String r0 = ":"
            boolean r0 = r1.contains(r0)
            if (r0 != 0) goto L_0x01f1
            java.lang.String r0 = r2.getPackageName()
            boolean r0 = r1.equals(r0)
            if (r0 == 0) goto L_0x01e3
        L_0x0044:
            r6 = 1
        L_0x0045:
            boolean r3 = r9.LJIIJJI
            if (r3 != 0) goto L_0x01e0
            boolean r0 = r9.LJIIJ
            if (r0 == 0) goto L_0x01e0
            if (r6 == 0) goto L_0x01e0
            r5 = 1
        L_0x0050:
            X.0Rn r4 = new X.0Rn
            android.content.Context r0 = r9.LIZ
            r4.<init>(r0)
            java.lang.String r0 = "default"
            r4.LIZ(r0)
            int r0 = r9.LJIIIIZZ
            int r0 = level2AlogCoreLevel(r0)
            r4.LIZ = r0
            boolean r0 = sDebug
            r4.LIZIZ = r0
            java.lang.String r0 = r9.LJFF
            r4.LIZJ = r0
            int r0 = r9.LIZLLL
            r4.LIZLLL = r0
            if (r5 == 0) goto L_0x01dc
            int r0 = r9.LIZJ
            int r0 = r0 / 3
            int r0 = r0 * 2
        L_0x0078:
            r4.LJ = r0
            int r0 = r9.LIZIZ
            r4.LJFF = r0
            java.lang.String r0 = r9.LJ
            r4.LJI = r0
            r1 = 65536(0x10000, float:9.18355E-41)
            r2 = 32768(0x8000, float:4.5918E-41)
            if (r6 == 0) goto L_0x01d7
            r0 = 65536(0x10000, float:9.18355E-41)
        L_0x008b:
            r4.LJII = r0
            if (r6 == 0) goto L_0x0091
            r1 = 196608(0x30000, float:2.75506E-40)
        L_0x0091:
            r4.LJIIIIZZ = r1
            X.0Rp r0 = X.0Rp.SAFE
            r4.LIZ(r0)
            X.0Rs r0 = X.0Rs.RAW
            r4.LIZ(r0)
            X.0Rq r0 = X.0Rq.LEGACY
            r4.LIZ(r0)
            boolean r0 = r9.LJI
            if (r0 == 0) goto L_0x01d3
            X.0Ro r0 = X.0Ro.ZSTD
        L_0x00a8:
            r4.LIZ(r0)
            boolean r0 = r9.LJII
            if (r0 == 0) goto L_0x01cf
            X.0Rr r0 = X.0Rr.TEA_16
        L_0x00b1:
            r4.LIZ(r0)
            boolean r0 = r9.LJII
            if (r0 == 0) goto L_0x01cb
            X.0Rm r0 = X.0Rm.EC_SECP256K1
        L_0x00ba:
            r4.LIZ(r0)
            java.lang.String r0 = r9.LJIIIZ
            r4.LJIIIZ = r0
            com.bytedance.android.alog.Alog r0 = r4.LIZ()
            X.0Rw.LIZ = r0
            if (r0 != 0) goto L_0x01c7
            r0 = 0
        L_0x00cb:
            com.bytedance.android.alog.Alog.nativeSetDefaultInstance(r0)
            if (r3 == 0) goto L_0x00eb
            if (r6 == 0) goto L_0x00eb
            android.os.HandlerThread r1 = new android.os.HandlerThread
            java.lang.String r0 = "Alog_main_delegate"
            r1.<init>(r0)
            sAsyncLogThread = r1
            r1.start()
            com.ss.android.agilelogger.ALog$1 r1 = new com.ss.android.agilelogger.ALog$1
            android.os.HandlerThread r0 = sAsyncLogThread
            android.os.Looper r0 = r0.getLooper()
            r1.<init>(r0)
            sAsyncHandler = r1
        L_0x00eb:
            if (r5 == 0) goto L_0x0158
            X.0Rn r1 = new X.0Rn
            android.content.Context r0 = r9.LIZ
            r1.<init>(r0)
            java.lang.String r0 = "main"
            r1.LIZ(r0)
            int r0 = r9.LJIIIIZZ
            int r0 = level2AlogCoreLevel(r0)
            r1.LIZ = r0
            boolean r0 = sDebug
            r1.LIZIZ = r0
            java.lang.String r0 = r9.LJFF
            r1.LIZJ = r0
            int r0 = r9.LIZLLL
            int r0 = r0 / 2
            r1.LIZLLL = r0
            int r0 = r9.LIZJ
            int r0 = r0 / 3
            r1.LJ = r0
            int r0 = r9.LIZIZ
            r1.LJFF = r0
            java.lang.String r0 = r9.LJ
            r1.LJI = r0
            r1.LJII = r2
            r0 = 98304(0x18000, float:1.37753E-40)
            r1.LJIIIIZZ = r0
            X.0Rp r0 = X.0Rp.SAFE
            r1.LIZ(r0)
            X.0Rs r0 = X.0Rs.RAW
            r1.LIZ(r0)
            X.0Rq r0 = X.0Rq.LEGACY
            r1.LIZ(r0)
            boolean r0 = r9.LJI
            if (r0 == 0) goto L_0x01c3
            X.0Ro r0 = X.0Ro.ZSTD
        L_0x0139:
            r1.LIZ(r0)
            boolean r0 = r9.LJII
            if (r0 == 0) goto L_0x01c0
            X.0Rr r0 = X.0Rr.TEA_16
        L_0x0142:
            r1.LIZ(r0)
            boolean r0 = r9.LJII
            if (r0 == 0) goto L_0x01bd
            X.0Rm r0 = X.0Rm.EC_SECP256K1
        L_0x014b:
            r1.LIZ(r0)
            java.lang.String r0 = r9.LJIIIZ
            r1.LJIIIZ = r0
            com.bytedance.android.alog.Alog r0 = r1.LIZ()
            mainThreadRef = r0
        L_0x0158:
            java.lang.String r6 = r9.LJ
            java.lang.String r5 = r9.LJFF
            X.Q27 r0 = sILogCacheCallback
            r3 = 0
            if (r0 == 0) goto L_0x016f
            X.Q27 r0 = sILogCacheCallback
            java.util.Queue r1 = r0.LIZ()
            if (r1 == 0) goto L_0x01b9
            int r0 = r1.size()
            if (r0 != 0) goto L_0x01b9
        L_0x016f:
            java.util.List r0 = getNativeFuncAddrCallbackList()
            int r0 = r0.size()
            if (r0 <= 0) goto L_0x0196
        L_0x0179:
            com.ss.android.agilelogger.ALog$2 r2 = new com.ss.android.agilelogger.ALog$2
            r2.<init>(r3, r6, r5)
            java.util.concurrent.ScheduledExecutorService r0 = sOuterExecutorService
            if (r0 != 0) goto L_0x0192
            java.lang.Thread r1 = new java.lang.Thread
            java.lang.String r0 = "_ALOG_OPT_"
            r1.<init>(r2, r0)
            r1.start()
        L_0x018c:
            sInitSuccess = r7
            com.bytedance.frameworks.apm.trace.MethodCollector.o(r8)
            return r7
        L_0x0192:
            r0.execute(r2)
            goto L_0x018c
        L_0x0196:
            java.util.concurrent.ScheduledExecutorService r4 = sOuterExecutorService
            if (r4 != 0) goto L_0x01ac
            java.util.Timer r3 = new java.util.Timer
            java.lang.String r0 = "_ALOG_OPT_"
            r3.<init>(r0)
            com.ss.android.agilelogger.ALog$3 r2 = new com.ss.android.agilelogger.ALog$3
            r2.<init>(r6, r5)
            r0 = 15000(0x3a98, double:7.411E-320)
            r3.schedule(r2, r0)
            goto L_0x018c
        L_0x01ac:
            com.ss.android.agilelogger.ALog$4 r3 = new com.ss.android.agilelogger.ALog$4
            r3.<init>(r6, r5)
            r1 = 15
            java.util.concurrent.TimeUnit r0 = java.util.concurrent.TimeUnit.SECONDS
            r4.schedule(r3, r1, r0)
            goto L_0x018c
        L_0x01b9:
            r3 = r1
            if (r3 != 0) goto L_0x0179
            goto L_0x016f
        L_0x01bd:
            X.0Rm r0 = X.0Rm.NONE
            goto L_0x014b
        L_0x01c0:
            X.0Rr r0 = X.0Rr.NONE
            goto L_0x0142
        L_0x01c3:
            X.0Ro r0 = X.0Ro.NONE
            goto L_0x0139
        L_0x01c7:
            long r0 = r0.LJIILL
            goto L_0x00cb
        L_0x01cb:
            X.0Rm r0 = X.0Rm.NONE
            goto L_0x00ba
        L_0x01cf:
            X.0Rr r0 = X.0Rr.NONE
            goto L_0x00b1
        L_0x01d3:
            X.0Ro r0 = X.0Ro.NONE
            goto L_0x00a8
        L_0x01d7:
            r0 = 32768(0x8000, float:4.5918E-41)
            goto L_0x008b
        L_0x01dc:
            int r0 = r9.LIZJ
            goto L_0x0078
        L_0x01e0:
            r5 = 0
            goto L_0x0050
        L_0x01e3:
            android.content.pm.ApplicationInfo r0 = r2.getApplicationInfo()
            java.lang.String r0 = r0.processName
            boolean r0 = r1.equals(r0)
            if (r0 == 0) goto L_0x01f1
            goto L_0x0044
        L_0x01f1:
            r6 = 0
            goto L_0x0045
        L_0x01f4:
            r0 = move-exception
            monitor-exit(r1)
            com.bytedance.frameworks.apm.trace.MethodCollector.o(r8)
            throw r0
        L_0x01fa:
            com.bytedance.frameworks.apm.trace.MethodCollector.o(r8)
            return r2
        */
        throw new UnsupportedOperationException("Method not decompiled: com.ss.android.agilelogger.ALog.init(X.Q20):boolean");
    }

    public static boolean checkPrioAndTag(int i, String str) {
        if (i < prio) {
            return false;
        }
        if (mBlockTagSet == null || TextUtils.isEmpty(str) || !mBlockTagSet.contains(str)) {
            return true;
        }
        return false;
    }

    public static Q29 createInstance(String str, Context context) {
        if (context == null) {
            return null;
        }
        return createInstance(str, new C2734Q1z(context).LIZ());
    }

    public static List<String> getALogFiles(long j, long j2) {
        ArrayList arrayList = new ArrayList();
        try {
            for (File absolutePath : 0Rw.LIZ((String) null, (String) null, j * 1000, j2 * 1000)) {
                arrayList.add(absolutePath.getAbsolutePath());
            }
        } catch (Exception unused) {
        }
        return arrayList;
    }

    public static void d(String str, String str2) {
        if (checkPrioAndTag(3, str)) {
            boolean LIZ = 7xn.LIZ();
            if (!LIZ || sAsyncHandler == null) {
                Alog alog = mainThreadRef;
                if (alog == null || !LIZ) {
                    0Rw.LIZ(1, str, str2);
                } else {
                    alog.LIZ(1, str, str2);
                }
            } else {
                postAsyncLog(3, str, str2);
            }
        }
    }

    public static void e(String str, String str2) {
        if (checkPrioAndTag(6, str)) {
            boolean LIZ = 7xn.LIZ();
            if (!LIZ || sAsyncHandler == null) {
                Alog alog = mainThreadRef;
                if (alog == null || !LIZ) {
                    0Rw.LIZ(4, str, str2);
                } else {
                    alog.LIZ(4, str, str2);
                }
            } else {
                postAsyncLog(6, str, str2);
            }
        }
    }

    public static void i(String str, String str2) {
        if (checkPrioAndTag(4, str)) {
            boolean LIZ = 7xn.LIZ();
            if (!LIZ || sAsyncHandler == null) {
                Alog alog = mainThreadRef;
                if (alog == null || !LIZ) {
                    0Rw.LIZ(2, str, str2);
                } else {
                    alog.LIZ(2, str, str2);
                }
            } else {
                postAsyncLog(4, str, str2);
            }
        }
    }

    public static void v(String str, String str2) {
        if (checkPrioAndTag(2, str)) {
            boolean LIZ = 7xn.LIZ();
            if (!LIZ || sAsyncHandler == null) {
                Alog alog = mainThreadRef;
                if (alog == null || !LIZ) {
                    0Rw.LIZ(0, str, str2);
                } else {
                    alog.LIZ(0, str, str2);
                }
            } else {
                postAsyncLog(2, str, str2);
            }
        }
    }

    public static void w(String str, String str2) {
        if (checkPrioAndTag(5, str)) {
            boolean LIZ = 7xn.LIZ();
            if (!LIZ || sAsyncHandler == null) {
                Alog alog = mainThreadRef;
                if (alog == null || !LIZ) {
                    0Rw.LIZ(3, str, str2);
                } else {
                    alog.LIZ(3, str, str2);
                }
            } else {
                postAsyncLog(5, str, str2);
            }
        }
    }

    public static void removeLegacyFiles(String str, String str2) {
        File[] listFiles;
        File[] listFiles2;
        File file = new File(str);
        if (file.exists() && (listFiles2 = file.listFiles(new FilenameFilter() {
            static {
                Covode.recordClassIndex(48126);
            }

            public final boolean accept(File file, String str) {
                return str.startsWith(".logCache_");
            }
        })) != null) {
            for (File INVOKEVIRTUAL_com_ss_android_agilelogger_ALog_com_ss_android_ugc_aweme_storage_FileLancet_delete : listFiles2) {
                INVOKEVIRTUAL_com_ss_android_agilelogger_ALog_com_ss_android_ugc_aweme_storage_FileLancet_delete(INVOKEVIRTUAL_com_ss_android_agilelogger_ALog_com_ss_android_ugc_aweme_storage_FileLancet_delete);
            }
        }
        File file2 = new File(str2);
        if (file2.exists() && (listFiles = file2.listFiles(new FilenameFilter() {
            static {
                Covode.recordClassIndex(48127);
            }

            public final boolean accept(File file, String str) {
                if (str.endsWith(".hoting")) {
                    return true;
                }
                if (!str.endsWith(".hot") || str.endsWith(".alog.hot")) {
                    return false;
                }
                return true;
            }
        })) != null) {
            for (File INVOKEVIRTUAL_com_ss_android_agilelogger_ALog_com_ss_android_ugc_aweme_storage_FileLancet_delete2 : listFiles) {
                INVOKEVIRTUAL_com_ss_android_agilelogger_ALog_com_ss_android_ugc_aweme_storage_FileLancet_delete(INVOKEVIRTUAL_com_ss_android_agilelogger_ALog_com_ss_android_ugc_aweme_storage_FileLancet_delete2);
            }
        }
    }

    public static Q29 createInstance(String str, Q20 q20) {
        String str2;
        String str3;
        0Ro r0;
        0Rr r02;
        0Rm r03;
        if (q20 == null) {
            return null;
        }
        if (!sInitSuccess) {
            try {
                Alog.LIZ(new 8mf());
            } catch (Throwable unused) {
                return null;
            }
        }
        0Rn r1 = new 0Rn(q20.LIZ);
        r1.LIZ(str);
        r1.LIZ = level2AlogCoreLevel(q20.LJIIIIZZ);
        r1.LIZIZ = sDebug;
        Q20 q202 = sConfig;
        if (q202 != null) {
            str2 = q202.LJFF;
        } else {
            str2 = q20.LJFF;
        }
        r1.LIZJ = str2;
        r1.LIZLLL = q20.LIZLLL;
        r1.LJ = q20.LIZJ;
        r1.LJFF = q20.LIZIZ;
        Q20 q203 = sConfig;
        if (q203 != null) {
            str3 = q203.LJ;
        } else {
            str3 = q20.LJ;
        }
        r1.LJI = str3;
        r1.LJII = 65536;
        r1.LJIIIIZZ = 196608;
        r1.LIZ(0Rp.SAFE);
        r1.LIZ(0Rs.RAW);
        r1.LIZ(0Rq.LEGACY);
        if (q20.LJI) {
            r0 = 0Ro.ZSTD;
        } else {
            r0 = 0Ro.NONE;
        }
        r1.LIZ(r0);
        if (q20.LJII) {
            r02 = 0Rr.TEA_16;
        } else {
            r02 = 0Rr.NONE;
        }
        r1.LIZ(r02);
        if (q20.LJII) {
            r03 = 0Rm.EC_SECP256K1;
        } else {
            r03 = 0Rm.NONE;
        }
        r1.LIZ(r03);
        r1.LJIIIZ = q20.LJIIIZ;
        Alog LIZ = r1.LIZ();
        if (LIZ == null) {
            return null;
        }
        sStandaloneInstances.add(new WeakReference(LIZ));
        return new Q29(LIZ);
    }

    public static void e(String str, Throwable th) {
        String str2 = str;
        if (checkPrioAndTag(6, str2)) {
            boolean LIZ = 7xn.LIZ();
            Throwable th2 = th;
            if (!LIZ || sAsyncHandler == null) {
                String LIZ2 = 8Vw.LIZ(th2);
                Alog alog = mainThreadRef;
                if (alog == null || !LIZ) {
                    0Rw.LIZ(4, str2, LIZ2);
                } else {
                    alog.LIZ(4, str2, LIZ2);
                }
            } else {
                postAsyncLog(6, str2, (String) null, th2, (Q23) null, (Object) null);
            }
        }
    }

    public static void w(String str, Throwable th) {
        String str2 = str;
        if (checkPrioAndTag(5, str2)) {
            boolean LIZ = 7xn.LIZ();
            Throwable th2 = th;
            if (!LIZ || sAsyncHandler == null) {
                String LIZ2 = 8Vw.LIZ(th2);
                Alog alog = mainThreadRef;
                if (alog == null || !LIZ) {
                    0Rw.LIZ(3, str2, LIZ2);
                } else {
                    alog.LIZ(3, str2, LIZ2);
                }
            } else {
                postAsyncLog(5, str2, (String) null, th2, (Q23) null, (Object) null);
            }
        }
    }

    public static void statcktrace(int i, String str, StackTraceElement[] stackTraceElementArr) {
        stacktrace(i, str, stackTraceElementArr);
    }

    public static void postAsyncLog(int i, String str, String str2) {
        postAsyncLog(i, str, str2, (Throwable) null, (Q23) null, (Object) null);
    }

    public static void bundle(int i, String str, Bundle bundle) {
        String str2 = str;
        int i2 = i;
        if (checkPrioAndTag(i2, str2)) {
            boolean LIZ = 7xn.LIZ();
            Bundle bundle2 = bundle;
            if (!LIZ || sAsyncHandler == null) {
                int level2AlogCoreLevel = level2AlogCoreLevel(i2);
                String LIZ2 = Q22.LIZ(Q23.BUNDLE, bundle2);
                Alog alog = mainThreadRef;
                if (alog == null || !LIZ) {
                    0Rw.LIZ(level2AlogCoreLevel, str2, LIZ2);
                } else {
                    alog.LIZ(level2AlogCoreLevel, str2, LIZ2);
                }
            } else {
                postAsyncLog(i2, str2, (String) null, (Throwable) null, Q23.BUNDLE, bundle2);
            }
        }
    }

    public static void header(int i, String str, String str2) {
        String str3 = str;
        int i2 = i;
        if (checkPrioAndTag(i2, str3)) {
            boolean LIZ = 7xn.LIZ();
            String str4 = str2;
            if (!LIZ || sAsyncHandler == null) {
                int level2AlogCoreLevel = level2AlogCoreLevel(i2);
                String LIZ2 = Q22.LIZ(Q23.BORDER, str4);
                Alog alog = mainThreadRef;
                if (alog == null || !LIZ) {
                    0Rw.LIZ(level2AlogCoreLevel, str3, LIZ2);
                } else {
                    alog.LIZ(level2AlogCoreLevel, str3, LIZ2);
                }
            } else {
                postAsyncLog(i2, str3, str4, (Throwable) null, Q23.BORDER, (Object) null);
            }
        }
    }

    public static void intent(int i, String str, Intent intent) {
        String str2 = str;
        int i2 = i;
        if (checkPrioAndTag(i2, str2)) {
            boolean LIZ = 7xn.LIZ();
            Intent intent2 = intent;
            if (!LIZ || sAsyncHandler == null) {
                int level2AlogCoreLevel = level2AlogCoreLevel(i2);
                String LIZ2 = Q22.LIZ(Q23.INTENT, intent2);
                Alog alog = mainThreadRef;
                if (alog == null || !LIZ) {
                    0Rw.LIZ(level2AlogCoreLevel, str2, LIZ2);
                } else {
                    alog.LIZ(level2AlogCoreLevel, str2, LIZ2);
                }
            } else {
                postAsyncLog(i2, str2, (String) null, (Throwable) null, Q23.INTENT, intent2);
            }
        }
    }

    public static void json(int i, String str, String str2) {
        String str3 = str;
        int i2 = i;
        if (checkPrioAndTag(i2, str3)) {
            boolean LIZ = 7xn.LIZ();
            String str4 = str2;
            if (!LIZ || sAsyncHandler == null) {
                int level2AlogCoreLevel = level2AlogCoreLevel(i2);
                String LIZ2 = Q22.LIZ(Q23.JSON, str4);
                Alog alog = mainThreadRef;
                if (alog == null || !LIZ) {
                    0Rw.LIZ(level2AlogCoreLevel, str3, LIZ2);
                } else {
                    alog.LIZ(level2AlogCoreLevel, str3, LIZ2);
                }
            } else {
                postAsyncLog(i2, str3, str4, (Throwable) null, Q23.JSON, (Object) null);
            }
        }
    }

    public static void stacktrace(int i, String str, StackTraceElement[] stackTraceElementArr) {
        String str2 = str;
        int i2 = i;
        if (checkPrioAndTag(i2, str2)) {
            boolean LIZ = 7xn.LIZ();
            StackTraceElement[] stackTraceElementArr2 = stackTraceElementArr;
            if (!LIZ || sAsyncHandler == null) {
                int level2AlogCoreLevel = level2AlogCoreLevel(i2);
                String LIZ2 = Q22.LIZ(Q23.STACKTRACE, stackTraceElementArr2);
                Alog alog = mainThreadRef;
                if (alog == null || !LIZ) {
                    0Rw.LIZ(level2AlogCoreLevel, str2, LIZ2);
                } else {
                    alog.LIZ(level2AlogCoreLevel, str2, LIZ2);
                }
            } else {
                postAsyncLog(i2, str2, (String) null, (Throwable) null, Q23.STACKTRACE, stackTraceElementArr2);
            }
        }
    }

    public static void thread(int i, String str, Thread thread) {
        String str2 = str;
        int i2 = i;
        if (checkPrioAndTag(i2, str2)) {
            boolean LIZ = 7xn.LIZ();
            Thread thread2 = thread;
            if (!LIZ || sAsyncHandler == null) {
                int level2AlogCoreLevel = level2AlogCoreLevel(i2);
                String LIZ2 = Q22.LIZ(Q23.THREAD, thread2);
                Alog alog = mainThreadRef;
                if (alog == null || !LIZ) {
                    0Rw.LIZ(level2AlogCoreLevel, str2, LIZ2);
                } else {
                    alog.LIZ(level2AlogCoreLevel, str2, LIZ2);
                }
            } else {
                postAsyncLog(i2, str2, (String) null, (Throwable) null, Q23.THREAD, thread2);
            }
        }
    }

    public static void throwable(int i, String str, Throwable th) {
        String str2 = str;
        int i2 = i;
        if (checkPrioAndTag(i2, str2)) {
            boolean LIZ = 7xn.LIZ();
            Throwable th2 = th;
            if (!LIZ || sAsyncHandler == null) {
                int level2AlogCoreLevel = level2AlogCoreLevel(i2);
                String LIZ2 = Q22.LIZ(Q23.THROWABLE, th2);
                Alog alog = mainThreadRef;
                if (alog == null || !LIZ) {
                    0Rw.LIZ(level2AlogCoreLevel, str2, LIZ2);
                } else {
                    alog.LIZ(level2AlogCoreLevel, str2, LIZ2);
                }
            } else {
                postAsyncLog(i2, str2, (String) null, (Throwable) null, Q23.THROWABLE, th2);
            }
        }
    }

    public static void e(String str, String str2, Throwable th) {
        String str3 = str;
        if (checkPrioAndTag(6, str3)) {
            boolean LIZ = 7xn.LIZ();
            String str4 = str2;
            Throwable th2 = th;
            if (!LIZ || sAsyncHandler == null) {
                String str5 = str4 + "\n" + 8Vw.LIZ(th2);
                Alog alog = mainThreadRef;
                if (alog == null || !LIZ) {
                    0Rw.LIZ(4, str3, str5);
                } else {
                    alog.LIZ(4, str3, str5);
                }
            } else {
                postAsyncLog(6, str3, str4, th2, (Q23) null, (Object) null);
            }
        }
    }

    public static void w(String str, String str2, Throwable th) {
        String str3 = str;
        if (checkPrioAndTag(5, str3)) {
            boolean LIZ = 7xn.LIZ();
            String str4 = str2;
            Throwable th2 = th;
            if (!LIZ || sAsyncHandler == null) {
                String str5 = str4 + "\n" + 8Vw.LIZ(th2);
                Alog alog = mainThreadRef;
                if (alog == null || !LIZ) {
                    0Rw.LIZ(3, str3, str5);
                } else {
                    alog.LIZ(3, str3, str5);
                }
            } else {
                postAsyncLog(5, str3, str4, th2, (Q23) null, (Object) null);
            }
        }
    }

    public static void removeObsoleteInstance(String str, Context context, boolean z) {
        String absolutePath;
        String LIZIZ;
        String LIZIZ2 = 7xn.LIZIZ();
        if (LIZIZ2 != null && !LIZIZ2.contains(":")) {
            if (!z) {
                LIZIZ2 = LIZIZ2 + '-';
            }
            Q20 q20 = sConfig;
            if (q20 != null) {
                absolutePath = q20.LJFF;
                LIZIZ = sConfig.LJ;
            } else {
                absolutePath = 9Ih.LIZ(context).getAbsolutePath();
                LIZIZ = 9Ih.LIZIZ(context);
            }
            File file = new File(absolutePath);
            if (file.exists() && file.isDirectory()) {
                String str2 = "__" + str + ".alog.hot";
                for (File file2 : file.listFiles()) {
                    String name = file2.getName();
                    if (name != null && name.endsWith(str2) && name.contains(LIZIZ2)) {
                        INVOKEVIRTUAL_com_ss_android_agilelogger_ALog_com_ss_android_ugc_aweme_storage_FileLancet_delete(file2);
                    }
                }
                File file3 = new File(LIZIZ);
                if (file3.exists() && file3.isDirectory()) {
                    String concat = "__".concat(String.valueOf(str));
                    for (File file4 : file3.listFiles()) {
                        String name2 = file4.getName();
                        if (name2 != null && name2.contains(concat) && name2.contains(LIZIZ2)) {
                            INVOKEVIRTUAL_com_ss_android_agilelogger_ALog_com_ss_android_ugc_aweme_storage_FileLancet_delete(file4);
                        }
                    }
                }
            }
        }
    }

    public static List<String> getALogFiles(String str, String str2, long j, long j2) {
        ArrayList arrayList = new ArrayList();
        try {
            for (File absolutePath : 0Rw.LIZ(str, str2, j * 1000, j2 * 1000)) {
                arrayList.add(absolutePath.getAbsolutePath());
            }
        } catch (Exception unused) {
        }
        return arrayList;
    }

    public static void println(int i, String str, Object obj, Q23 q23) {
        String str2;
        if (checkPrioAndTag(i, str)) {
            int level2AlogCoreLevel = level2AlogCoreLevel(i);
            switch (AnonymousClass7.LIZ[q23.ordinal()]) {
                case 1:
                    str2 = (String) obj;
                    break;
                case 2:
                    str2 = 8Vw.LIZ((Throwable) obj);
                    break;
                case 3:
                    str2 = Q22.LIZ(Q23.BORDER, (String) obj);
                    break;
                case 4:
                    str2 = Q22.LIZ(Q23.JSON, (String) obj);
                    break;
                case 5:
                    str2 = Q22.LIZ(Q23.BUNDLE, (Bundle) obj);
                    break;
                case 6:
                    str2 = Q22.LIZ(Q23.INTENT, (Intent) obj);
                    break;
                case 7:
                    str2 = Q22.LIZ(Q23.THROWABLE, (Throwable) obj);
                    break;
                case 8:
                    str2 = Q22.LIZ(Q23.THREAD, (Thread) obj);
                    break;
                case 9:
                    str2 = Q22.LIZ(Q23.STACKTRACE, (StackTraceElement[]) obj);
                    break;
                default:
                    str2 = Q39.LIZJ;
                    break;
            }
            boolean LIZ = 7xn.LIZ();
            if (!LIZ || sAsyncHandler == null) {
                Alog alog = mainThreadRef;
                if (alog == null || !LIZ) {
                    0Rw.LIZ(level2AlogCoreLevel, str, str2);
                } else {
                    alog.LIZ(level2AlogCoreLevel, str, str2);
                }
            } else {
                postAsyncLog(i, str, str2);
            }
        }
    }

    public static void postAsyncLog(int i, String str, String str2, Throwable th, Q23 q23, Object obj) {
        initMainThreadIdIfNeeded();
        Q21 LIZ = Q21.LIZ();
        LIZ.LIZLLL = i;
        LIZ.LJ = str;
        LIZ.LJFF = str2;
        LIZ.LJI = th;
        LIZ.LJII = q23;
        LIZ.LJIIIIZZ = obj;
        LIZ.LJIIIZ = sMainThreadId;
        LIZ.LJIIJ = System.currentTimeMillis();
        Message obtain = Message.obtain();
        obtain.what = 1;
        obtain.obj = LIZ;
        sAsyncHandler.sendMessage(obtain);
    }
}
