package com.bytedance.android.livesdk.init;

import X.0cP;
import X.0cm;
import X.7g6;
import X.7lW;
import X.9JC;
import X.GMD;
import android.app.Application;
import android.content.Context;
import com.bytedance.android.livesdk.livesetting.other.LiveChainMonitorExcludeErrorCodesSetting;
import com.bytedance.android.livesdk.livesetting.performance.LiveEnableTimeCostSetting;
import com.bytedance.android.livesdkapi.host.IHostContext;
import com.bytedance.android.monitor.HybridMonitor;
import com.bytedance.covode.number.Covode;
import java.util.List;

@9JC
public class MonitorInitTask extends 7g6 {
    static {
        Covode.recordClassIndex(16960);
    }

    public String getTaskName() {
        return "monitor_init_task";
    }

    public void run() {
        try {
            0cP.LIZ = LiveEnableTimeCostSetting.INSTANCE.enable();
            List<Integer> value = LiveChainMonitorExcludeErrorCodesSetting.INSTANCE.getValue();
            if (value != null && value.size() > 0) {
                GMD.LIZ = value;
            }
            initHybridMonitor();
        } catch (Throwable unused) {
        }
    }

    private void initHybridMonitor() {
        IHostContext LIZ = 0cm.LIZ(IHostContext.class);
        if (LIZ != null && LIZ.context() != null && INVOKEVIRTUAL_com_bytedance_android_livesdk_init_MonitorInitTask_com_ss_android_ugc_aweme_lancet_launch_ApplicationContextLancet_getApplicationContext(LIZ.context()) != null && (INVOKEVIRTUAL_com_bytedance_android_livesdk_init_MonitorInitTask_com_ss_android_ugc_aweme_lancet_launch_ApplicationContextLancet_getApplicationContext(LIZ.context()) instanceof Application)) {
            HybridMonitor.getInstance().init((Application) INVOKEVIRTUAL_com_bytedance_android_livesdk_init_MonitorInitTask_com_ss_android_ugc_aweme_lancet_launch_ApplicationContextLancet_getApplicationContext(LIZ.context()));
        }
    }

    public static Context INVOKEVIRTUAL_com_bytedance_android_livesdk_init_MonitorInitTask_com_ss_android_ugc_aweme_lancet_launch_ApplicationContextLancet_getApplicationContext(Context context) {
        Context applicationContext = context.getApplicationContext();
        if (7lW.LIZJ && applicationContext == null) {
            return 7lW.LIZ;
        }
        return applicationContext;
    }
}
