package com.ss.android.ugc.aweme.legoImp.task;

import X.2lm;
import X.4U3;
import X.AnonymousClass95C;
import X.AnonymousClass95D;
import X.AnonymousClass95K;
import X.AnonymousClass95N;
import X.AnonymousClass9EH;
import X.C22428Zd;
import X.C22438Ze;
import X.C25518ec;
import X.C35468uf;
import X.C403195y;
import X.C42869Ft;
import X.C42909Fx;
import X.C49349bx;
import X.RY1;
import X.S9B;
import android.content.Context;
import android.text.TextUtils;
import com.bytedance.apm.impl.DefaultTTNetImpl;
import com.bytedance.covode.number.Covode;
import com.ss.android.common.applog.AppLog;
import com.ss.android.common.util.NetworkUtils;
import com.ss.android.deviceregister.DeviceRegisterManager;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.concurrent.atomic.AtomicBoolean;
import org.json.JSONObject;

public class MonitorInitTask implements C22438Ze {
    public static final AtomicBoolean LIZ = new AtomicBoolean(false);
    public static final String[] LIZIZ = {"https://mon-va.tiktokv.com/monitor/collect/c/exception"};
    public static final List<String> LIZJ;

    public boolean meetTrigger() {
        return true;
    }

    public String prefix() {
        return "task_";
    }

    public boolean serialExecute() {
        return false;
    }

    public int targetProcess() {
        return 1048575;
    }

    public List triggerOtherLegoComponents() {
        return null;
    }

    public C42869Ft triggerType() {
        return C22428Zd.LIZ(this);
    }

    public C42909Fx scenesType() {
        return C42909Fx.DEFAULT;
    }

    public C25518ec type() {
        return C25518ec.BOOT_FINISH;
    }

    public String key() {
        return getClass().getSimpleName();
    }

    static {
        String str;
        Covode.recordClassIndex(90529);
        String[] strArr = new String[3];
        String str2 = "https://mon.tiktokv.com/monitor/collect/";
        if (S9B.LIZJ()) {
            str = str2;
        } else {
            str = "https://mon-va.tiktokv.com/monitor/collect/";
        }
        strArr[0] = str;
        if (S9B.LIZJ()) {
            str2 = "https://mon-va.tiktokv.com/monitor/collect/";
        }
        strArr[1] = str2;
        strArr[2] = "https://mon-sg.tiktokv.com/monitor/collect/";
        LIZJ = new ArrayList(Arrays.asList(strArr));
    }

    public void run(Context context) {
        String str;
        long j;
        if (LIZ.compareAndSet(false, true)) {
            AnonymousClass95K.LIZ.LIZ(AnonymousClass9EH.LJJIFFI.LIZ());
            AnonymousClass95C r2 = new AnonymousClass95C();
            JSONObject headerCopy = AppLog.getHeaderCopy();
            if (headerCopy != null) {
                r2.LIZ(headerCopy);
            }
            String[] strArr = new String[3];
            String str2 = "https://mon.tiktokv.com/monitor/appmonitor/v2/settings";
            if (S9B.LIZJ()) {
                str = str2;
            } else {
                str = "https://mon-va.tiktokv.com/monitor/appmonitor/v2/settings";
            }
            strArr[0] = str;
            if (S9B.LIZJ()) {
                str2 = "https://mon-va.tiktokv.com/monitor/appmonitor/v2/settings";
            }
            strArr[1] = str2;
            strArr[2] = "https://mon-sg.tiktokv.com/monitor/appmonitor/v2/settings";
            r2.LJIIL = Arrays.asList(strArr);
            if (((Boolean) RY1.LIZLLL.getValue()).booleanValue()) {
                j = 0;
            } else {
                j = 60;
            }
            r2.LJIJI = Math.min(j, 30);
            r2.LJIILJJIL = Arrays.asList(LIZIZ);
            r2.LJIILIIL = LIZJ;
            r2.LIZ("aid", AnonymousClass9EH.LJIILJJIL);
            r2.LIZ("device_id", AppLog.getServerDeviceId());
            r2.LIZ("app_version", AnonymousClass9EH.LJJIFFI.LJFF());
            r2.LIZ("update_version_code", String.valueOf(AnonymousClass9EH.LJJIFFI.LIZLLL()));
            r2.LIZ("channel", AnonymousClass9EH.LJIJI);
            r2.LJIJJ = new AnonymousClass95N() {
                static {
                    Covode.recordClassIndex(90530);
                }

                public final void LIZ() {
                    4U3 r1 = new 4U3();
                    r1.LIZ(new RheaTraceUploadTask());
                    r1.LIZ();
                }
            };
            if (TextUtils.equals(AnonymousClass9EH.LJIJI, "local_test")) {
                r2.LJIJJLI = new 2lm(context);
            }
            r2.LJIIJJI = true;
            Context LIZ2 = AnonymousClass9EH.LJJIFFI.LIZ();
            r2.LJIIZILJ = new DefaultTTNetImpl();
            r2.LJIILLIIL = new C35468uf();
            C403195y.LIZ(r2);
            DeviceRegisterManager.addOnDeviceConfigUpdateListener(new AnonymousClass95D(LIZ2, r2));
            NetworkUtils.setMonitorProcessHook(C49349bx.LIZ);
        }
    }
}
