package com.bytedance.skynet.base;

import X.4Ms;
import X.4Sh;
import X.C11507x7;
import X.C11747xV;
import android.content.Context;
import android.os.SystemClock;
import com.bytedance.covode.number.Covode;
import com.bytedance.frameworks.apm.trace.MethodCollector;
import com.bytedance.librarian.Librarian;
import java.io.File;

public class BaseIniter {
    public static final String TAG = BaseIniter.class.getSimpleName();
    public static volatile boolean started = false;

    public static native void init();

    public static native void setProxy(long j);

    public static native void startDns(String str, String str2, String str3, String str4);

    static {
        MethodCollector.i(16715);
        Covode.recordClassIndex(38104);
        INVOKESTATIC_com_bytedance_skynet_base_BaseIniter_com_ss_android_ugc_aweme_lancet_LoadSoLancet_loadLibrary("skbase");
        init();
        MethodCollector.o(16715);
    }

    public static void INVOKESTATIC_com_bytedance_skynet_base_BaseIniter_com_ss_android_ugc_aweme_lancet_LoadSoLancet_loadLibrary(String str) {
        long uptimeMillis = SystemClock.uptimeMillis();
        Librarian.LIZ(str);
        4Sh.LIZ(uptimeMillis, str);
    }

    public static void initDns(Context context, boolean z, boolean z2) {
        String str;
        MethodCollector.i(16581);
        if (!started) {
            synchronized (BaseIniter.class) {
                try {
                    if (!started) {
                        StringBuilder sb = new StringBuilder();
                        if (4Ms.LIZIZ == null || !4Ms.LJ) {
                            4Ms.LIZIZ = context.getCacheDir();
                        }
                        sb.append(4Ms.LIZIZ.getAbsolutePath());
                        sb.append(File.separator);
                        sb.append("skynet:");
                        sb.append(C11747xV.LIZ(context));
                        File LIZ = C11507x7.LIZ(sb.toString());
                        File LIZIZ = C11507x7.LIZIZ(LIZ.getAbsolutePath() + File.separator + ".proxyfd");
                        File LIZ2 = C11507x7.LIZ(LIZ.getAbsolutePath() + File.separator + "dns_dump");
                        File LIZIZ2 = C11507x7.LIZIZ(LIZ2.getAbsolutePath() + File.separator + System.currentTimeMillis());
                        String str2 = null;
                        if (z2) {
                            File LIZ3 = C11507x7.LIZ(LIZ.getAbsolutePath() + File.separator + "dns_trace");
                            str = C11507x7.LIZIZ(LIZ3.getAbsolutePath() + File.separator + System.currentTimeMillis()).getAbsolutePath();
                        } else {
                            str = null;
                        }
                        if (z) {
                            File LIZ4 = C11507x7.LIZ(LIZ.getAbsolutePath() + File.separator + "local_dump");
                            str2 = C11507x7.LIZIZ(LIZ4.getAbsolutePath() + File.separator + System.currentTimeMillis()).getAbsolutePath();
                        }
                        startDns(LIZIZ.getAbsolutePath(), str2, LIZIZ2.getAbsolutePath(), str);
                        started = true;
                    }
                } finally {
                    MethodCollector.o(16581);
                }
            }
            return;
        }
        MethodCollector.o(16581);
    }
}
