QQ浏览器 v12.2.3.7053版本的 MD5 值为:8285ab3059e5c8b521a264dfbc5c3685

以下内容为反编译后的 AppJavascriptInterface.java 源代码,内容仅作参考


package com.tencent.now.webcomponent.js;

import android.content.Context;
import android.content.DialogInterface;
import android.content.pm.PackageInfo;
import android.graphics.Rect;
import android.os.Bundle;
import android.os.IBinder;
import android.os.RemoteException;
import android.text.TextUtils;
import android.view.View;
import androidx.fragment.app.FragmentActivity;
import com.tencent.common.featuretoggle.FeatureToggle;
import com.tencent.common.http.ContentType;
import com.tencent.common.threadpool.BrowserExecutorSupplier;
import com.tencent.common.utils.TbsMode;
import com.tencent.falco.base.libapi.floatwindow.FloatWindowConfigServiceInterface;
import com.tencent.falco.base.libapi.login.LoginInfo;
import com.tencent.falco.base.libapi.login.LoginRequest;
import com.tencent.falco.base.libapi.login.LoginServiceInterface;
import com.tencent.falco.base.libapi.login.LoginType;
import com.tencent.falco.utils.AppInfoUtil;
import com.tencent.falco.utils.SPUtil;
import com.tencent.ilive.LiveSDK;
import com.tencent.ilive.enginemanager.BizEngineMgr;
import com.tencent.ilive.opensdk.pe.config.PEConst;
import com.tencent.ilive.pages.room.events.RoomCloseEvent;
import com.tencent.ilivesdk.avplayerbuilderservice_interface.AVPlayerBuilderServiceInterface;
import com.tencent.ilivesdk.avplayerservice_interface.PlayerParams;
import com.tencent.ilivesdk.avplayerservice_interface.PlayerStatusListener;
import com.tencent.ilivesdk.avpreloadservice_interface.AVPreloadTaskInterface;
import com.tencent.ilivesdk.roomservice_interface.RoomServiceInterface;
import com.tencent.livesdk.accountengine.SdkLoginCallback;
import com.tencent.mtt.AppInfoHolder;
import com.tencent.mtt.ContextHolder;
import com.tencent.mtt.R;
import com.tencent.mtt.account.base.IAccount;
import com.tencent.mtt.account.base.UserLoginListener;
import com.tencent.mtt.base.NowLiveInfoRepository;
import com.tencent.mtt.base.NowLiveLiteWrapper;
import com.tencent.mtt.base.NowLiveLoginInfo;
import com.tencent.mtt.base.NowLiveResult;
import com.tencent.mtt.base.NowLiveResultCallback;
import com.tencent.mtt.base.account.AccountConst;
import com.tencent.mtt.base.account.AccountInfo;
import com.tencent.mtt.base.account.facade.IAccountService;
import com.tencent.mtt.base.functionwindow.ActivityHandler;
import com.tencent.mtt.base.skin.MttResources;
import com.tencent.mtt.base.webview.QBWebView;
import com.tencent.mtt.base.wup.GUIDManager;
import com.tencent.mtt.browser.account.service.IAccountTokenRefreshListener;
import com.tencent.mtt.browser.share.export.socialshare.qqshare.QQShareActivity;
import com.tencent.mtt.browser.window.UrlParams;
import com.tencent.mtt.businesscenter.facade.IFrameworkDelegate;
import com.tencent.mtt.external.beacon.QimeiSDKWrapper;
import com.tencent.mtt.external.tencentsim.facade.ITencentSimService;
import com.tencent.mtt.hippy.qb.views.nowlive.HippyNowLiveEvent;
import com.tencent.mtt.hippy.qb.views.nowlive.HippyNowLiveRoomViewWrapper;
import com.tencent.mtt.log.access.Logs;
import com.tencent.mtt.nowlivewrapper.NowLiveConfig;
import com.tencent.mtt.qbcontext.core.QBContext;
import com.tencent.mtt.qbinfo.QUAUtils;
import com.tencent.mtt.sdkcontext.SDKContext;
import com.tencent.mtt.setting.BaseSettings;
import com.tencent.mtt.view.toast.MttToaster;
import com.tencent.now.custom_datareport_module.DataReportMgr;
import com.tencent.now.custom_datareport_module.RoomExtInfo;
import com.tencent.now.phoneauth.IQueryPhoneAuthStateCallback;
import com.tencent.now.phoneauth.NowUserPhoneAuthManager;
import com.tencent.now.short_video_ext.LiveSDKMgr;
import com.tencent.now.utils.AegisHelper;
import com.tencent.now.utils.NowLogs;
import com.tencent.now.utils.PackageUtil;
import com.tencent.now.utils.event.EventCenter;
import com.tencent.now.utils.network.NetworkUtil;
import com.tencent.now.utils.sql.WebCacheUtil;
import com.tencent.now.utils.ui.DeviceManager;
import com.tencent.now.webcomponent.LiteLiveWebViewClient;
import com.tencent.now.webcomponent.WebCookieManager;
import com.tencent.now.webcomponent.event.ContentLoadedEvent;
import com.tencent.now.webcomponent.event.GetLocationEvent;
import com.tencent.now.webcomponent.event.LoadHtmlSuccessEvent;
import com.tencent.now.webcomponent.event.LoadRoomInfoErrorEvent;
import com.tencent.now.webcomponent.event.ScreenModeEvent;
import com.tencent.now.webcomponent.event.ScrollByWebEvent;
import com.tencent.now.webcomponent.event.ShowKeyboardRoomEvent;
import com.tencent.now.webcomponent.event.WebviewTransmitEvent;
import com.tencent.now.webcomponent.jsmodule.JsBizAdapter;
import com.tencent.now.webcomponent.jsmodule.LiteBaseRoomJSModule;
import com.tencent.now.webcomponent.jsmodule.NewJavascriptInterface;
import com.tencent.now.webcomponent.widget.HalfSizeWebviewDialog;
import com.tencent.now.widget.bean.PlaceHolderInfo;
import com.tencent.now.widget.bean.ShortcutCommentInfo;
import com.tencent.now.widget.bean.ShortcutCommentItemInfo;
import com.tencent.now.widget.event.KeyboardCommentAndHintEvent;
import com.tencent.qqlive.module.videoreport.dtreport.constants.DTConstants;
import com.tencent.thumbplayer.tplayer.plugins.report.TPReportKeys;
import java.net.URLDecoder;
import java.util.Iterator;
import java.util.Map;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
import qb.nowlive.BuildConfig;

public class AppJavascriptInterface extends LiteBaseRoomJSModule {
    private static final String TAG = "AppJavascriptInterface";
    private static PlayerStatusListener playerStatusListener = new PlayerStatusListener() {
        @Override
        public void a() {
            NowLogs.c(AppJavascriptInterface.TAG, "onReadyCompleted");
            MttToaster.show("切换清晰度成功", 0);
        }

        @Override
        public void a(int i) {
            NowLogs.c(AppJavascriptInterface.TAG, "onNetworkChanged");
        }

        @Override
        public void a(int i, String str) {
            NowLogs.c(AppJavascriptInterface.TAG, "onError");
        }

        @Override
        public void a(long j) {
            NowLogs.c(AppJavascriptInterface.TAG, "onPlayPause");
        }

        @Override
        public void a(AVPreloadTaskInterface aVPreloadTaskInterface) {
            NowLogs.c(AppJavascriptInterface.TAG, "onPreloadFirstFrame");
        }

        @Override
        public void b() {
            NowLogs.c(AppJavascriptInterface.TAG, "onFirstFrameCome");
        }

        @Override
        public void b(long j) {
            NowLogs.c(AppJavascriptInterface.TAG, "onPlayResume");
        }

        @Override
        public void c() {
            NowLogs.c(AppJavascriptInterface.TAG, "onPlayCompleted");
        }

        @Override
        public void d() {
            NowLogs.c(AppJavascriptInterface.TAG, "onPlayCaton");
        }

        @Override
        public void e() {
            NowLogs.c(AppJavascriptInterface.TAG, "onPlayCatonRecover");
        }

        @Override
        public void f() {
            NowLogs.c(AppJavascriptInterface.TAG, "onPushPlayOver");
        }

        @Override
        public void g() {
            NowLogs.c(AppJavascriptInterface.TAG, "onStartBuffer");
        }

        @Override
        public void h() {
            NowLogs.c(AppJavascriptInterface.TAG, "onStopBuffer");
        }

        @Override
        public void i() {
            NowLogs.c(AppJavascriptInterface.TAG, "onNetworkAnomaly");
        }

        @Override
        public void k() {
            NowLogs.c(AppJavascriptInterface.TAG, "onSurfaceCreated");
        }

        @Override
        public void l() {
            NowLogs.c(AppJavascriptInterface.TAG, "onSurfaceDestroyed");
        }
    };
    protected Context activityContext;
    private AVPlayerBuilderServiceInterface avPlayerService;
    public HalfSizeWebviewDialog halfSizeWebviewDialog;
    private boolean isLiveLoginSuccess;
    private int loginRetry;
    private LoginServiceInterface loginServiceInterface;
    private String preloadUrl;
    private RoomServiceInterface roomService;
    private View rootView;
    private UserLoginListener userLoginListener;

    public AppJavascriptInterface(LiteLiveWebViewClient liteLiveWebViewClient, View view, QBWebView qBWebView, Context context, String str) {
        super(liteLiveWebViewClient, qBWebView);
        this.isLiveLoginSuccess = true;
        this.loginRetry = 0;
        this.rootView = null;
        this.userLoginListener = new UserLoginListener() {
            @Override
            public void onLoginFailed(int i, String str2) {
                Logs.c(AppJavascriptInterface.TAG, "onLoginFailed");
            }

            @Override
            public void onLoginSuccess() {
                Logs.c(AppJavascriptInterface.TAG, "onLoginSuccess");
                AppJavascriptInterface.this.requestLiveLogin();
            }
        };
        this.activityContext = context;
        this.rootView = view;
        this.preloadUrl = str;
    }

    static int access$104(AppJavascriptInterface appJavascriptInterface) {
        int i = appJavascriptInterface.loginRetry + 1;
        appJavascriptInterface.loginRetry = i;
        return i;
    }

    public void doRequestLiveLogin(final LoginRequest loginRequest) {
        LiveSDK.a(loginRequest, new SdkLoginCallback() {
            @Override
            public void onFail(int i, String str) {
                Logs.c(AppJavascriptInterface.TAG, "requestLiveLogin onFail, " + String.format("livesdk 登录失败 errcode = %d, errMsg =%s, appid = %s, id = %s, token = %s, loginType = %d", Integer.valueOf(i), str, loginRequest.f10866d, loginRequest.f10863a, loginRequest.f10864b, Integer.valueOf(loginRequest.f10865c.ordinal())));
                AegisHelper.a(String.format("livesdk 登录失败 errcode = %d, errMsg =%s, appid = %s, id = %s, token = %s, loginType = %d", Integer.valueOf(i), str, loginRequest.f10866d, loginRequest.f10863a, loginRequest.f10864b, Integer.valueOf(loginRequest.f10865c.ordinal())), AppJavascriptInterface.TAG);
                if (AppJavascriptInterface.access$104(AppJavascriptInterface.this) > 2) {
                    AegisHelper.a("登录重试超过2次后停止重试", AppJavascriptInterface.TAG);
                    AppJavascriptInterface.this.loginRetry = 0;
                } else {
                    AppJavascriptInterface.this.isLiveLoginSuccess = false;
                    if (i == 1007) {
                        ((IAccountService) QBContext.getInstance().getService(IAccountService.class)).refreshToken(((IAccount) SDKContext.getInstance().getService(IAccount.class)).getCurrentUserInfo(), new IAccountTokenRefreshListener() {
                            @Override
                            public IBinder asBinder() {
                                return null;
                            }

                            @Override
                            public void onRefreshToken(AccountInfo accountInfo, int i2) throws RemoteException {
                                if (i2 != 0 || accountInfo == null) {
                                    NowLogs.c(AppJavascriptInterface.TAG, "onRefreshToken fail, exit NowLive");
                                    MttToaster.show(MttResources.l(R.string.bxk), 0);
                                } else {
                                    NowLogs.c(AppJavascriptInterface.TAG, "onRefreshToken success, do NowLive login");
                                    AppJavascriptInterface.this.requestLiveLogin();
                                }
                            }
                        });
                    }
                }
            }

            @Override
            public void onSucceed(LoginInfo loginInfo) {
                if (AppJavascriptInterface.this.loginRetry != 0) {
                    AegisHelper.a("登录成功,重试次数为" + AppJavascriptInterface.this.loginRetry, AppJavascriptInterface.TAG);
                    AppJavascriptInterface.this.loginRetry = 0;
                }
                AppJavascriptInterface.this.isLiveLoginSuccess = true;
                Logs.c(AppJavascriptInterface.TAG, "requestLiveLogin onLoginSuccess");
                WebCookieManager.a().a("https://cgi.kandian.qq.com");
                WebCookieManager.a().a("https://now.qq.com/");
                WebCookieManager.a().a("https://yutang.qq.com/");
                WebCookieManager.a().a("https://ilive.qq.com/");
                WebCookieManager.a().a("https://tencentlive.qq.com/");
                AppJavascriptInterface.this.callJsFunctionByNative("__WEBVIEW_RELOADCOOKIES", null);
            }
        });
    }

    private boolean handleLogin() {
        this.isLiveLoginSuccess = false;
        IAccount iAccount = (IAccount) SDKContext.getInstance().getService(IAccount.class);
        iAccount.addUIListener(this.userLoginListener);
        AccountInfo currentUserInfo = iAccount.getCurrentUserInfo();
        if (currentUserInfo == null || !currentUserInfo.isLogined()) {
            BrowserExecutorSupplier.forMainThreadTasks().execute(new Runnable() {
                @Override
                public void run() {
                    Bundle bundle = new Bundle(9);
                    bundle.putInt(QQShareActivity.KEY_FROM_WHERE, 35);
                    bundle.putString(AccountConst.LOGIN_CUSTOM_TITLE, MttResources.l(R.string.bxl));
                    ((IAccount) SDKContext.getInstance().getService(IAccount.class)).callUserLogin(ActivityHandler.b().n(), bundle);
                }
            });
            return false;
        }
        LoginInfo a2 = this.loginServiceInterface.a();
        if ((a2 != null && a2.g != LoginType.GUEST) || this.isLiveLoginSuccess) {
            return true;
        }
        MttToaster.show("直播中台正在登录中,请稍后", 0);
        requestLiveLogin();
        return true;
    }

    @NewJavascriptInterface
    public void addHistory(Map<String, String> map) {
        NowLiveLiteWrapper.q().n().a(map.get("title"), map.get("jump_url"), map.get("cover"), 0L);
    }

    @NewJavascriptInterface
    public void beginDraw(Map<String, String> map) {
        ScrollByWebEvent scrollByWebEvent = new ScrollByWebEvent();
        scrollByWebEvent.f76181a = true;
        getJsBizAdapter().b().a(scrollByWebEvent);
    }

    @NewJavascriptInterface
    public void changeVideoRate(Map<String, String> map) {
        String str;
        int parseInt = Integer.parseInt(map.get(TPReportKeys.Common.COMMON_MEDIA_RATE));
        String str2 = map.get("callback");
        this.avPlayerService.m();
        this.avPlayerService.g();
        PlayerParams playerParams = new PlayerParams();
        if (parseInt != 0) {
            if (parseInt == 1) {
                str = this.roomService.a().e.h;
            } else if (parseInt == 2) {
                str = this.roomService.a().e.i;
            } else if (parseInt == 3) {
                str = this.roomService.a().e.j;
            }
            playerParams.f12615b = str;
            this.avPlayerService.a(playerParams);
            this.avPlayerService.q();
            this.avPlayerService.f();
            this.avPlayerService.k();
            callJsFunctionByNative(str2, null);
        }
        str = this.roomService.a().e.f;
        playerParams.f12615b = str;
        this.avPlayerService.a(playerParams);
        this.avPlayerService.q();
        this.avPlayerService.f();
        this.avPlayerService.k();
        callJsFunctionByNative(str2, null);
    }

    @NewJavascriptInterface
    public void checkcertificated(final Map<String, String> map) {
        NowUserPhoneAuthManager.a();
        if (NowUserPhoneAuthManager.b()) {
            return;
        }
        NowUserPhoneAuthManager.a().a(new IQueryPhoneAuthStateCallback() {
            @Override
            public void a(int i) {
                int i2 = 0;
                if (i == 0) {
                    i2 = 1;
                } else if (i == 1) {
                    NowUserPhoneAuthManager.a().a(AppJavascriptInterface.this.activityContext);
                }
                try {
                    String str = "";
                    JSONObject jSONObject = new JSONObject();
                    jSONObject.put("certificated", i2);
                    if (map != null && map.size() > 0) {
                        Iterator it = map.keySet().iterator();
                        while (it.hasNext()) {
                            str = (String) map.get((String) it.next());
                        }
                    }
                    AppJavascriptInterface.this.callJsFunctionByNative(str, jSONObject);
                } catch (JSONException unused) {
                }
            }
        }, false);
    }

    @NewJavascriptInterface
    public void clearLocalstorage(Map<String, String> map) {
        WebCacheUtil.a();
        String str = map.get("callback");
        try {
            JSONObject jSONObject = new JSONObject();
            jSONObject.put("code", 0);
            callJsFunctionByNative(str, jSONObject);
        } catch (JSONException unused) {
        }
    }

    @NewJavascriptInterface
    public void close(Map<String, String> map) {
        getJsBizAdapter().b().a(new RoomCloseEvent());
        HalfSizeWebviewDialog halfSizeWebviewDialog = this.halfSizeWebviewDialog;
        if (halfSizeWebviewDialog != null) {
            halfSizeWebviewDialog.dismiss();
        }
    }

    @NewJavascriptInterface
    public void closeAndGoLive(Map<String, String> map) {
        getJsBizAdapter().b().a(new RoomCloseEvent());
        String format = String.format("qb://home/feeds?tabId=110016&fromid=%s&refresh=1", NowLiveLiteWrapper.q().v());
        Logs.c(TAG, "jumpLiveTab jumpLiveTabUrl = " + format);
        ((IFrameworkDelegate) QBContext.getInstance().getService(IFrameworkDelegate.class)).doLoad(new UrlParams(format).b(33));
    }

    @NewJavascriptInterface
    public void closePendantWebview(Map<String, String> map) {
        HalfSizeWebviewDialog halfSizeWebviewDialog = this.halfSizeWebviewDialog;
        if (halfSizeWebviewDialog != null) {
            halfSizeWebviewDialog.dismiss();
        }
        JSONObject jSONObject = new JSONObject();
        try {
            jSONObject.put("url", map.get("url"));
            callJsFunctionByNative("__PENDANT_WEBVIEW_CLOSE", jSONObject);
        } catch (JSONException unused) {
        }
    }

    @NewJavascriptInterface
    public void contentLoaded(Map<String, String> map) {
        String str = map.get("_t");
        if (TextUtils.isEmpty(str)) {
            str = "0";
        }
        if (map != null) {
            String str2 = map.get(HippyNowLiveRoomViewWrapper.SRC_KEY_PROGRAM_ID);
            String str3 = map.get("state");
            String str4 = map.get("ilive_type");
            String str5 = map.get("followed");
            String str6 = map.get("anchor_uid");
            NowLogs.c(TAG, "AppJavascriptInterface contentLoaded programId = " + str2 + ", state = " + str3 + ", ilive_type = " + str4 + ", followed = " + str5 + ", anchor_uid = " + str6);
            getJsBizAdapter().a(new RoomExtInfo(str2, str3, str4, str5, str6));
        }
        ContentLoadedEvent contentLoadedEvent = new ContentLoadedEvent();
        contentLoadedEvent.f76170a = true;
        contentLoadedEvent.f76171b = Long.parseLong(str);
        getJsBizAdapter().b().a(contentLoadedEvent);
        String str7 = map.get("callback");
        ITencentSimService iTencentSimService = (ITencentSimService) QBContext.getInstance().getService(ITencentSimService.class);
        boolean z = iTencentSimService != null && iTencentSimService.isTencentSimUser();
        try {
            JSONObject jSONObject = new JSONObject();
            jSONObject.put("ab_token", DataReportMgr.a().d().get("ab_token"));
            jSONObject.put("kingCard", z ? 1 : 0);
            jSONObject.put("statusBarHeight", MttResources.r(BaseSettings.a().m()));
            String str8 = !TextUtils.isEmpty(this.preloadUrl) ? this.preloadUrl : this.roomService.a().e.f;
            if (TextUtils.isEmpty(str8)) {
                str8 = "";
            }
            jSONObject.put("url", str8);
            JSONObject jSONObject2 = new JSONObject();
            jSONObject2.put("result", jSONObject);
            callJsFunctionByNative(str7, jSONObject2);
        } catch (JSONException unused) {
        }
    }

    @NewJavascriptInterface
    public void delLocalstorage(Map<String, String> map) {
        WebCacheUtil.a(map.get("key"));
        String str = map.get("callback");
        try {
            JSONObject jSONObject = new JSONObject();
            jSONObject.put("code", 0);
            callJsFunctionByNative(str, jSONObject);
        } catch (JSONException unused) {
        }
    }

    @NewJavascriptInterface
    public void doShare(Map<String, String> map) {
        LiveSDKCustomizedShare.a().e(map);
    }

    @NewJavascriptInterface
    public void endDraw(Map<String, String> map) {
        ScrollByWebEvent scrollByWebEvent = new ScrollByWebEvent();
        scrollByWebEvent.f76181a = false;
        getJsBizAdapter().b().a(scrollByWebEvent);
    }

    @NewJavascriptInterface
    public void getBrowserParam(Map<String, String> map) {
        String str = map.get("callback");
        String appInfoByID = AppInfoHolder.getAppInfoByID(AppInfoHolder.AppInfoID.APP_INFO_QIMEI36);
        try {
            JSONObject jSONObject = new JSONObject();
            jSONObject.put("qua", QUAUtils.a());
            jSONObject.put("guid", GUIDManager.a().f());
            jSONObject.put("qimei36", appInfoByID);
            jSONObject.put("qimei36Token", QimeiSDKWrapper.b().c());
            callJsFunctionByNative(str, jSONObject);
        } catch (Exception unused) {
        }
    }

    @NewJavascriptInterface
    public void getClientScreenMode(Map<String, String> map) {
        int o = this.avPlayerService.o();
        int n = this.avPlayerService.n();
        int i = (o <= 0 || n <= 0 || o >= n) ? 0 : 1;
        Rect rect = new Rect();
        this.rootView.getGlobalVisibleRect(rect);
        Rect p = this.avPlayerService.p();
        int a2 = DeviceManager.a(this.activityContext, (p.top - rect.top) + p.height());
        NowLogs.c(TAG, "getClientScreenMode screenmode = " + i + " topMarginDp = " + a2 + " this = " + this);
        try {
            JSONObject jSONObject = new JSONObject();
            jSONObject.put("screenmode", i);
            jSONObject.put("bottom", a2);
            callJsFunctionByNative("__WEBVIEW_CLIENTSCREENMODE", jSONObject);
        } catch (JSONException unused) {
        }
    }

    @NewJavascriptInterface
    public void getLittleWindowStatus(Map<String, String> map) {
        String b2 = SPUtil.a(this.activityContext, "nowlive_config").b("status", "1");
        NowLogs.c(TAG, "getLittleWindowStatus status = " + b2);
        try {
            JSONObject jSONObject = new JSONObject();
            jSONObject.put("status", b2);
            callJsFunctionByNative("__WEBVIEW_LITTLE_WINDOW_STATUS", jSONObject);
        } catch (JSONException unused) {
        }
    }

    @NewJavascriptInterface
    public void getLocalstorage(Map<String, String> map) {
        String str = map.get("key");
        String str2 = map.get("callback");
        String b2 = WebCacheUtil.b(str);
        try {
            JSONObject jSONObject = new JSONObject();
            jSONObject.put("code", 0);
            jSONObject.put("value", b2);
            callJsFunctionByNative(str2, jSONObject);
        } catch (JSONException unused) {
        }
    }

    @NewJavascriptInterface
    public void getLocation(Map<String, String> map) {
        String str = map.get("callback");
        GetLocationEvent getLocationEvent = new GetLocationEvent();
        getLocationEvent.f76172a = str;
        getJsBizAdapter().b().a(getLocationEvent);
    }

    @Override
    public String getName() {
        return DTConstants.TAG.APP;
    }

    @NewJavascriptInterface
    public void getNetworkType(Map<String, String> map) {
        int b2 = NetworkUtil.b(ContextHolder.getAppContext());
        try {
            String str = "";
            JSONObject jSONObject = new JSONObject();
            jSONObject.put("type", b2);
            if (map != null && map.size() > 0) {
                Iterator<String> it = map.keySet().iterator();
                while (it.hasNext()) {
                    str = map.get(it.next());
                }
            }
            callJsFunctionByNative(str, jSONObject);
        } catch (JSONException unused) {
        }
    }

    @NewJavascriptInterface
    public void isAppInstalled(Map<String, String> map) {
        String str;
        int i;
        String str2 = map.get(PEConst.DESC.MEDIA_DESC_KEY_IDENTIFIER);
        String str3 = map.get("callback");
        if (TextUtils.isEmpty(str2)) {
            Logs.e(TAG, "packageName is Null");
            return;
        }
        PackageInfo a2 = PackageUtil.a(this.activityContext, str2);
        if (a2 != null) {
            i = 1;
            str = a2.versionName;
        } else {
            str = "";
            i = 0;
        }
        try {
            JSONObject jSONObject = new JSONObject();
            jSONObject.put("installed", i);
            jSONObject.put("version", str);
            JSONObject jSONObject2 = new JSONObject();
            jSONObject2.put("code", 0);
            jSONObject2.put("result", jSONObject);
            callJsFunctionByNative(str3, jSONObject2);
        } catch (JSONException unused) {
        }
    }

    @NewJavascriptInterface
    public void jumpAppSettings(Map<String, String> map) {
        AppInfoUtil.c(this.activityContext);
    }

    @NewJavascriptInterface
    public void loadFailed(Map<String, String> map) {
        LoadRoomInfoErrorEvent loadRoomInfoErrorEvent = new LoadRoomInfoErrorEvent();
        loadRoomInfoErrorEvent.f76175a = map.get("errCode");
        getJsBizAdapter().b().a(loadRoomInfoErrorEvent);
    }

    @NewJavascriptInterface
    public void loadInputViewPlaceholder(Map<String, String> map) {
        try {
            JSONObject jSONObject = new JSONObject(URLDecoder.decode(map.get("placeholder"), "UTF-8"));
            PlaceHolderInfo placeHolderInfo = new PlaceHolderInfo();
            placeHolderInfo.f76355a = jSONObject.getString(ContentType.TYPE_TEXT);
            placeHolderInfo.f76356b = jSONObject.getString("textId");
            KeyboardCommentAndHintEvent keyboardCommentAndHintEvent = new KeyboardCommentAndHintEvent(0);
            keyboardCommentAndHintEvent.a(placeHolderInfo);
            getJsBizAdapter().b().a(keyboardCommentAndHintEvent);
        } catch (Exception unused) {
        }
    }

    @NewJavascriptInterface
    public void loadLiveVerticalGuideUserCommentData(Map<String, String> map) {
        try {
            JSONArray jSONArray = new JSONArray(URLDecoder.decode(map.get("items"), "UTF-8"));
            ShortcutCommentInfo shortcutCommentInfo = new ShortcutCommentInfo();
            for (int i = 0; i < jSONArray.length(); i++) {
                JSONObject jSONObject = jSONArray.getJSONObject(i);
                ShortcutCommentItemInfo shortcutCommentItemInfo = new ShortcutCommentItemInfo();
                shortcutCommentItemInfo.f76358a = jSONObject.getString(ContentType.TYPE_TEXT);
                shortcutCommentItemInfo.f76359b = jSONObject.getString("textId");
                shortcutCommentInfo.f76357a.add(shortcutCommentItemInfo);
            }
            KeyboardCommentAndHintEvent keyboardCommentAndHintEvent = new KeyboardCommentAndHintEvent(1);
            keyboardCommentAndHintEvent.a(shortcutCommentInfo);
            getJsBizAdapter().b().a(keyboardCommentAndHintEvent);
        } catch (Exception unused) {
        }
    }

    @NewJavascriptInterface
    public void loadSucc(Map<String, String> map) {
        LoadHtmlSuccessEvent loadHtmlSuccessEvent = new LoadHtmlSuccessEvent();
        String str = map.get("_t");
        if (TextUtils.isEmpty(str)) {
            str = "0";
        }
        loadHtmlSuccessEvent.f76173a = Long.parseLong(str);
        getJsBizAdapter().b().a(loadHtmlSuccessEvent);
    }

    @Override
    public void onJsCreate() {
    }

    @Override
    public void onJsDestroy() {
        ((IAccount) SDKContext.getInstance().getService(IAccount.class)).removeUIListener(this.userLoginListener);
    }

    @NewJavascriptInterface
    public void onReConnect(Map<String, String> map) {
        String valueOf;
        JSONObject jSONObject = new JSONObject();
        try {
            if (!NetworkUtil.b() || this.avPlayerService.i()) {
                valueOf = String.valueOf(4);
            } else {
                this.avPlayerService.m();
                this.avPlayerService.g();
                this.avPlayerService.q();
                this.avPlayerService.f();
                this.avPlayerService.k();
                valueOf = String.valueOf(9);
            }
            jSONObject.put("state", valueOf);
            callJsFunctionByNative("__WEBVIEW_CLIENTAVSTATE", jSONObject);
        } catch (JSONException unused) {
        }
    }

    @NewJavascriptInterface
    public void onSubscribeChanged(Map<String, String> map) {
        JsBizAdapter jsBizAdapter;
        boolean z;
        String str = map.get("state");
        NowLogs.c(TAG, "onSubscribeChanged state = " + str);
        if ("1".equals(str)) {
            jsBizAdapter = getJsBizAdapter();
            z = true;
        } else {
            jsBizAdapter = getJsBizAdapter();
            z = false;
        }
        jsBizAdapter.a(z);
    }

    @NewJavascriptInterface
    public void openLoginPage(Map<String, String> map) {
        Logs.c(TAG, "AppJavascriptInterface openLoginPage js fun");
        handleLogin();
    }

    @NewJavascriptInterface
    public void openPendantWebview(final Map<String, String> map) {
        Bundle bundle = new Bundle();
        bundle.putBoolean("showTitleBar", false);
        bundle.putString("url", map.get("url"));
        bundle.putBoolean(HippyNowLiveEvent.PARAMS_EVENT_REQUEST_ORIENTATION_LANDSCAPE, false);
        bundle.putFloat("dimAmount", 0.0f);
        bundle.putBoolean("leftClickClose", true);
        bundle.putBoolean("plantCookieWhenResume", true);
        bundle.putInt("height", DeviceManager.a(this.activityContext, Float.parseFloat(map.get("height"))));
        this.halfSizeWebviewDialog = new HalfSizeWebviewDialog();
        this.halfSizeWebviewDialog.a(getJsBizAdapter().b());
        this.halfSizeWebviewDialog.setArguments(bundle);
        this.halfSizeWebviewDialog.a(new DialogInterface.OnDismissListener() {
            @Override
            public void onDismiss(DialogInterface dialogInterface) {
                JSONObject jSONObject = new JSONObject();
                try {
                    jSONObject.put("url", map.get("url"));
                    AppJavascriptInterface.this.callJsFunctionByNative("__PENDANT_WEBVIEW_CLOSE", jSONObject);
                } catch (JSONException unused) {
                }
            }
        });
        this.halfSizeWebviewDialog.show(((FragmentActivity) this.activityContext).getSupportFragmentManager(), "");
    }

    public void requestLiveLogin() {
        final LoginRequest t = NowLiveLiteWrapper.t();
        if (!FeatureToggle.a(BuildConfig.FEATURE_TOGGLE_ILIVE_869300421) || t.f10865c == LoginType.GUEST) {
            doRequestLiveLogin(t);
        } else {
            t.f = TbsMode.PR_QB;
            NowLiveInfoRepository.a(NowLiveLoginInfo.a(t, NowLiveLiteWrapper.u()), new NowLiveResultCallback<Map<String, String>>() {
                @Override
                public void onResult(NowLiveResult<Map<String, String>> nowLiveResult) {
                    if (nowLiveResult.f31614a != 0 || nowLiveResult.f31616c == null) {
                        Logs.e(AppJavascriptInterface.TAG, "initLiveSDKLoginData requestLoginData result error, status = " + nowLiveResult.f31614a);
                        return;
                    }
                    t.f10866d = NowLiveConfig.a();
                    t.f10863a = nowLiveResult.f31616c.get("loginId");
                    t.f10864b = nowLiveResult.f31616c.get("loginToken");
                    AppJavascriptInterface.this.doRequestLiveLogin(t);
                }
            });
        }
    }

    @Override
    public void setJsBizAdapter(JsBizAdapter jsBizAdapter) {
        super.setJsBizAdapter(jsBizAdapter);
        if (jsBizAdapter.a() != null) {
            this.avPlayerService = (AVPlayerBuilderServiceInterface) jsBizAdapter.a().a(AVPlayerBuilderServiceInterface.class);
            this.roomService = (RoomServiceInterface) jsBizAdapter.a().a(RoomServiceInterface.class);
            this.loginServiceInterface = (LoginServiceInterface) jsBizAdapter.a().a(LoginServiceInterface.class);
        }
    }

    @NewJavascriptInterface
    public void setLittleWindowStatus(Map<String, String> map) {
        String str = map.get("status");
        NowLogs.c(TAG, "setLittleWindowStatus status = " + str);
        SPUtil.a(this.activityContext, "nowlive_config").a("status", str);
        ((FloatWindowConfigServiceInterface) BizEngineMgr.a().d().a(FloatWindowConfigServiceInterface.class)).a(str.equals("1"));
    }

    @NewJavascriptInterface
    public void setLocalstorage(Map<String, String> map) {
        WebCacheUtil.a(map.get("key"), map.get("value"));
        String str = map.get("callback");
        try {
            JSONObject jSONObject = new JSONObject();
            jSONObject.put("code", 0);
            callJsFunctionByNative(str, jSONObject);
        } catch (JSONException unused) {
        }
    }

    @NewJavascriptInterface
    public void setScreenMode(Map<String, String> map) {
        String str = map.get("mode");
        boolean z = (TextUtils.isEmpty(str) ? 1 : Integer.parseInt(str)) == 1;
        if (getJsBizAdapter().f() != null) {
            getJsBizAdapter().f().a(z);
        }
        if (LiveSDKMgr.a().c() != null) {
            LiveSDKMgr.a().c().requestOrientation(z);
        }
        if (getJsBizAdapter().b() != null) {
            getJsBizAdapter().b().a(new ScreenModeEvent(z));
        }
    }

    @NewJavascriptInterface
    public void setVideoRate(Map<String, String> map) {
        String str = map.get("url");
        String str2 = map.get("callback");
        PlayerParams playerParams = new PlayerParams();
        playerParams.f12615b = str;
        this.avPlayerService.a(playerParams, playerStatusListener);
        callJsFunctionByNative(str2, null);
    }

    @NewJavascriptInterface
    public void showKeyboard(Map<String, String> map) {
        String str = map.get("type");
        ShowKeyboardRoomEvent showKeyboardRoomEvent = new ShowKeyboardRoomEvent();
        showKeyboardRoomEvent.a(str);
        getJsBizAdapter().b().a(showKeyboardRoomEvent);
    }

    @NewJavascriptInterface
    public void transferBetweenWebviews(Map<String, String> map) {
        WebviewTransmitEvent webviewTransmitEvent = new WebviewTransmitEvent(map.get("action"), map.get("callback"));
        getJsBizAdapter().b().a(webviewTransmitEvent);
        EventCenter.a(webviewTransmitEvent);
    }

    @NewJavascriptInterface
    public void welfaredatareport(Map<String, String> map) {
        NowLiveLiteWrapper.q().o().a(map.get("bid"), map.get("data"));
    }
}