package com.bytedance.android.livesdk.broadcast;

import X.0S6;
import X.0Uu;
import X.0Uw;
import X.0Ux;
import X.0VN;
import X.0VQ;
import X.0VS;
import X.0VT;
import X.0VW;
import X.0Vi;
import X.0Vk;
import X.0Vl;
import X.0Vm;
import X.0Xc;
import X.0Xd;
import X.0Xe;
import X.0Xf;
import X.0Xo;
import X.0cm;
import X.0cp;
import X.0yx;
import X.13y;
import X.142;
import X.143;
import X.158;
import X.1JN;
import X.1JV;
import X.1JW;
import X.1Mn;
import X.1jc;
import X.2fU;
import X.8eL;
import X.C1331FzQ;
import X.C1616G9p;
import X.C1762GFf;
import X.C1794GGl;
import X.C1803GGu;
import X.C1873GJm;
import X.C1876GJp;
import X.C1948GMj;
import X.C1962GMx;
import X.C1963GMy;
import X.C1964GMz;
import X.C1966GNb;
import X.C1968GNd;
import X.C1969GNe;
import X.C1970GNf;
import X.C1979GNo;
import X.C1987GNw;
import X.C2075GRg;
import X.C2159GUm;
import X.C2166GUt;
import X.C3905Gzq;
import X.C4186HAl;
import X.C4281HEc;
import X.C4327HFw;
import X.C4409HJa;
import X.G1Q;
import X.GD1;
import X.GEV;
import X.GF6;
import X.GFT;
import X.GGA;
import X.GGT;
import X.GI0;
import X.GJ2;
import X.GJ6;
import X.GJJ;
import X.GMZ;
import X.GN0;
import X.GN1;
import X.GN2;
import X.GN8;
import X.GNN;
import X.GNS;
import X.GNT;
import X.GOP;
import X.GP5;
import X.GSG;
import X.GVD;
import X.HEN;
import X.HEP;
import X.HEU;
import X.HEZ;
import X.HGP;
import X.HGS;
import X.HI7;
import X.M12;
import X.PgU;
import X.T94;
import android.app.Activity;
import android.content.Context;
import android.net.Uri;
import android.os.Bundle;
import android.view.View;
import androidx.fragment.app.Fragment;
import com.bytedance.android.live.broadcast.api.IBroadcastService;
import com.bytedance.android.live.liveinteract.api.IInteractService;
import com.bytedance.android.livesdk.api.BroadcastRoomApi;
import com.bytedance.android.livesdk.broadcast.interaction.widget.netspeed.GameLiveNetSpeedMonitorWidget;
import com.bytedance.android.livesdk.broadcast.interaction.widget.netspeed.NetSpeedMonitorWidget;
import com.bytedance.android.livesdk.broadcast.interaction.widget.pause.PauseLiveWidget;
import com.bytedance.android.livesdk.broadcast.obs.ObsBroadcastFragment;
import com.bytedance.android.livesdk.broadcast.preview.LiveBroadcastPreviewFragment;
import com.bytedance.android.livesdk.broadcast.video.LiveBroadcastFragment;
import com.bytedance.android.livesdk.chatroom.api.RoomRetrofitApi;
import com.bytedance.android.livesdk.livesetting.linkmic.TTliveOneTapGoliveEntranceSetting;
import com.bytedance.android.livesdk.livesetting.performance.LiveBroadcastPoorDeviceLiveCoreAsyncSetting;
import com.bytedance.android.livesdk.livesetting.performance.LiveBroadcastPoorDevicePreloadRetrofitSetting;
import com.bytedance.android.livesdk.log.monitor.IPerformanceManager;
import com.bytedance.android.livesdk.performance.LivePerformanceManager;
import com.bytedance.android.livesdk.ui.BaseFragment;
import com.bytedance.android.livesdkapi.depend.model.live.Room;
import com.bytedance.android.widget.Widget;
import com.bytedance.covode.number.Covode;
import com.bytedance.ies.sdk.datachannel.DataChannel;
import com.bytedance.ies.sdk.datachannel.DataChannelGlobal;
import com.bytedance.ies.sdk.widgets.LiveRecyclableWidget;
import com.bytedance.ies.sdk.widgets.RecyclableWidgetManager;
import java.util.HashMap;
import java.util.Map;
import kotlin.h.b.n;

public class BroadcastService implements IBroadcastService {
    public static Activity currentActivity;
    public C1794GGl startLiveManager;

    static {
        Covode.recordClassIndex(11702);
    }

    public C1969GNe createBgBroadcastBinder() {
        return null;
    }

    public String getLiveCoreVersion() {
        return "12.0.0.6-a";
    }

    public Activity getBroadcastActivity() {
        return currentActivity;
    }

    public 0VS getEchoHelper() {
        return C2075GRg.LIZJ;
    }

    public 0Xf createMonitorReport() {
        return new C1966GNb();
    }

    public 0Xd createStreamLogger() {
        return new GNN();
    }

    public 0Xc createStreamUploader() {
        return new C1948GMj();
    }

    public String getLiveComposerFilePath() {
        return GSG.INST.getLiveComposerFilePath();
    }

    public void init() {
        GJJ.LIZ().LIZIZ();
    }

    public void initLiveBroadcastContext() {
        GJJ.LIZ().LIZIZ();
    }

    public void releaseLiveStream() {
        C1962GMx.LJ.LIZ();
    }

    public void showEndPageForPaidEvent() {
        DataChannelGlobal.LIZLLL.LIZLLL(HGS.class);
    }

    public void smoothLiveTab() {
        DataChannelGlobal.LIZLLL.LIZLLL(HGP.class);
    }

    public 0VQ getBroadcastPreviewService() {
        return (1JW) 1JW.LIZ.getValue();
    }

    public Map<String, String> getRoomInfo() {
        return (Map) DataChannelGlobal.LIZLLL.LIZIZ(HEN.class);
    }

    public PgU<Integer> loadShortVideoRes() {
        GJJ.LIZ();
        return PgU.LIZIZ(1);
    }

    public void onInit() {
        0cp.LIZ.LIZ(2131234807, new 1jc());
    }

    public GNS startLiveManager() {
        if (this.startLiveManager == null) {
            this.startLiveManager = new C1794GGl();
        }
        return this.startLiveManager;
    }

    private void preloadRetrofitApi() {
        if (LiveBroadcastPoorDevicePreloadRetrofitSetting.INSTANCE.enable()) {
            8eL.LIZJ().submit(GNT.LIZ);
        }
    }

    public static final /* synthetic */ void lambda$preloadRetrofitApi$0$BroadcastService() {
        ((BroadcastRoomApi) 0yx.LIZ().LIZ(BroadcastRoomApi.class)).getPreviewRoomCreateInfo(0);
        ((BroadcastRoomApi) 0yx.LIZ().LIZ(BroadcastRoomApi.class)).getLivePermissionApply("");
        ((RoomRetrofitApi) 0yx.LIZ().LIZ(RoomRetrofitApi.class)).createRoom((HashMap<String, String>) null);
        GD1.LIZIZ.LIZ().LIZJ().sendStatus(0, 0, 0, 0, "", 0, 0);
        GI0.LJIIL().preloadBroadcastApi();
        GI0.LJIILJJIL().preloadBroadcastApi();
    }

    public String getBroadcastScene() {
        Room room = (Room) DataChannelGlobal.LIZLLL.LIZIZ(HEP.class);
        IInteractService LIZ = 0cm.LIZ(IInteractService.class);
        GJ2 gj2 = (GJ2) DataChannelGlobal.LIZLLL.LIZIZ(C4327HFw.class);
        if (gj2 == null || gj2.isPreviewPage()) {
            return "";
        }
        if (room != null && room.roomLayout == 2) {
            return "video_anchor_order";
        }
        if (LIZ.isRoomInBattle()) {
            return "video_anchor_pk";
        }
        if (LIZ.isInCoHost()) {
            return "video_anchor_connect";
        }
        if (LIZ.isInMultiGuest()) {
            return "video_anchor_guest_connect";
        }
        return "normal_video_live";
    }

    public void setBroadcastActivity(Activity activity) {
        currentActivity = activity;
    }

    public 0VN createLiveStream(0Xe r2) {
        return new C4409HJa(r2);
    }

    public Widget createPauseLiveWidget(View view) {
        return new PauseLiveWidget(view);
    }

    public T94 createStartLiveFragment(C1762GFf gFf) {
        GF6.LIZ = gFf;
        return new LiveBroadcastPreviewFragment();
    }

    public 0Vi createStatusReporter(Room room) {
        return new C1987GNw(room);
    }

    public 0Vm createSyncGiftHelper(Room room) {
        return new GOP(room);
    }

    public 1JN getMultiGuestV3OriginFrameReviewManager(long j) {
        return new C1876GJp(j);
    }

    public void setApplyLivePermission(GFT gft) {
        DataChannelGlobal.LIZLLL.LIZ(C4281HEc.class, gft);
    }

    public void setDetailLivePermission(GGT ggt) {
        DataChannelGlobal.LIZLLL.LIZ(HEZ.class, ggt);
    }

    public 143 createLiveBroadcastEndFragment(Bundle bundle) {
        LiveBroadcastEndFragment liveBroadcastEndFragment = new LiveBroadcastEndFragment();
        liveBroadcastEndFragment.setArguments(bundle);
        return liveBroadcastEndFragment;
    }

    public LiveRecyclableWidget createNetSpeedMonitorWidget(boolean z) {
        if (z) {
            return new GameLiveNetSpeedMonitorWidget();
        }
        return new NetSpeedMonitorWidget();
    }

    public void loadPauseLiveButton(DataChannel dataChannel) {
        158.PAUSE_LIVE.load(dataChannel, new C2159GUm());
    }

    public boolean isCommerce(DataChannel dataChannel) {
        G1Q g1q;
        if (dataChannel == null || (g1q = (G1Q) dataChannel.LIZIZ(C1331FzQ.class)) == null || !g1q.LIZIZ) {
            return false;
        }
        return true;
    }

    public void onLiveTabShow(Context context) {
        M12.LIZ(context);
        0S6.LJFF.LIZ(context);
        1Mn.LIZIZ(GEV.LIZ);
        0S6.LJFF.LIZ(2131561751);
        preloadRetrofitApi();
    }

    public void logLiveOver(Room room, DataChannel dataChannel) {
        GMZ.LIZ.LIZ(room, dataChannel);
    }

    public C3905Gzq createObsBroadcastFragment(GP5 gp5, Bundle bundle) {
        ObsBroadcastFragment obsBroadcastFragment = new ObsBroadcastFragment();
        Bundle bundle2 = new Bundle();
        bundle2.putBundle("extra", bundle);
        obsBroadcastFragment.setArguments(bundle2);
        obsBroadcastFragment.LJFF = gp5;
        return obsBroadcastFragment;
    }

    public void preloadLiveStream(Context context, boolean z) {
        Class cls;
        M12.LIZ(context);
        C1962GMx.LIZIZ = context;
        C1962GMx.LIZLLL = z;
        DataChannelGlobal dataChannelGlobal = DataChannelGlobal.LIZLLL;
        if (z) {
            cls = HEU.class;
        } else {
            cls = HEP.class;
        }
        Room room = (Room) dataChannelGlobal.LIZIZ(cls);
        if (room != null) {
            C1962GMx.LIZJ = room;
            if (LiveBroadcastPoorDeviceLiveCoreAsyncSetting.INSTANCE.preloadAtBroadcast()) {
                8eL.LIZJ().submit(GN8.LIZ);
            }
        }
    }

    public C1873GJm createLiveBroadcastFragment(GP5 gp5, Bundle bundle) {
        M12.LIZ(gp5);
        IPerformanceManager instance = LivePerformanceManager.getInstance();
        instance.monitorPerformance("create_live");
        instance.startTimerMonitor();
        instance.onEnterRoom();
        if (bundle != null) {
            bundle.putLong("live.intent.extra.EXTRA_ENTER_ROOM_STAR_TIME", System.currentTimeMillis());
        }
        boolean z = false;
        if (bundle != null) {
            z = bundle.getBoolean("is_one_tap_go_live", false);
        }
        LiveBroadcastFragment.LJJIIJZLJL = z;
        LiveBroadcastFragment liveBroadcastFragment = new LiveBroadcastFragment();
        Bundle bundle2 = new Bundle();
        bundle2.putBundle("extra", bundle);
        liveBroadcastFragment.setArguments(bundle2);
        liveBroadcastFragment.LJFF = gp5;
        liveBroadcastFragment.LIZJ = LiveBroadcastFragment.LJJIIJZLJL;
        return liveBroadcastFragment;
    }

    /* JADX WARNING: type inference failed for: r1v0, types: [X.HAl, android.app.Dialog] */
    public boolean oneTapGoLive(Context context, Uri uri) {
        int i = 0;
        if (!TTliveOneTapGoliveEntranceSetting.INSTANCE.getValue()) {
            return false;
        }
        GGA gga = new GGA(GI0.LIZIZ().context());
        M12.LIZ(uri);
        try {
            if (!gga.LJIILL.LIZ()) {
                if (0Uu.LIZJ) {
                    i = 1;
                } else if (!GI0.LJIIIIZZ().isNotInLinkMicProgress()) {
                    i = 2;
                }
                gga.LJIILJJIL = i;
                Activity topActivity = GI0.LJFF().getTopActivity();
                n.LIZIZ(topActivity, "");
                ? hAl = new C4186HAl(topActivity, uri, i, new C1803GGu(gga));
                hAl.show();
                2fU.LIZ.LIZ(hAl);
            }
        } catch (Throwable unused) {
            gga.LIZ();
        }
        return true;
    }

    public C1968GNd createLinkMicPreviewView(Context context, 0VT r3, DataChannel dataChannel) {
        return new C1963GMy(context, r3, dataChannel);
    }

    public void createPauseLiveHelper(DataChannel dataChannel, 0VN r3, 0Xo r4) {
        new HI7(dataChannel, r3, r4);
    }

    public 1JV createLinkInRoomView(0VN r2, Context context, int i) {
        if (i == 1) {
            return new GN0(context);
        }
        if (i == 0) {
            return new GN2(r2, context);
        }
        return null;
    }

    public 0Vk createLiveIllegalHelper(Room room, Context context, DataChannel dataChannel, 0Vl r5) {
        return new C1979GNo(room, context, dataChannel, r5);
    }

    public C1968GNd createVirtualVideoView(Context context, 0VT r3, String str, String str2) {
        return new GN1(context, r3, str, str2);
    }

    public void reportStreamEnd(int i, long j, long j2, boolean z) {
        C1970GNf.LIZIZ(i, j, j2, z);
    }

    public void reportStreamEndForApi(int i, long j, long j2, boolean z) {
        C1970GNf.LIZ(i, j, j2, z);
    }

    public void showGuideBirthdayEditDialog(Activity activity, String str, String str2, 0Uw r5) {
        C1616G9p.LIZ.LIZ(activity, str, str2, r5);
    }

    public 1JV createLinkInRoomView(0VN r2, Context context, int i, 0VT r5) {
        if (r5 == null || i != 1) {
            return createLinkInRoomView(r2, context, i);
        }
        return new GN0(context, r5);
    }

    public C1968GNd createLinkVideoView(Context context, 0VT r3, 0Ux r4, DataChannel dataChannel) {
        C1964GMz gMz = new C1964GMz(context, r3);
        gMz.setLinkMicLiveEffectCallback(r4);
        if (dataChannel != null) {
            gMz.setDataChannel(dataChannel);
        }
        return gMz;
    }

    public void createCloseRoomHelper(Room room, Context context, DataChannel dataChannel, Fragment fragment, 0Vl r11) {
        new GJ6(room, context, dataChannel, fragment, r11);
    }

    public 13y createCommonInteractionFunctionHelper(Context context, BaseFragment baseFragment, 142 r9, View view, RecyclableWidgetManager recyclableWidgetManager) {
        return new C2166GUt(context, baseFragment, r9, view, recyclableWidgetManager);
    }

    public 0VW createLongPressHelper(Room room, Fragment fragment, View view, Context context, DataChannel dataChannel) {
        return new GVD(room, fragment, view, context, dataChannel);
    }

    public void reportStreamEndForLiveCore(int i, int i2, String str, long j, long j2, boolean z) {
        long j3 = j;
        C1970GNf.LIZ(i, i2, str, j3, j2, z);
    }
}
