QQ浏览器 v12.2.3.7053版本的 MD5 值为:8285ab3059e5c8b521a264dfbc5c3685
以下内容为反编译后的 CustomAnchorLiveWebModule.java 源代码,内容仅作参考
package com.tencent.now.anchor_live;
import android.content.Context;
import android.os.Build;
import android.view.ViewGroup;
import android.view.ViewStub;
import android.webkit.ValueCallback;
import android.widget.TextView;
import androidx.lifecycle.Observer;
import com.tencent.falco.base.libapi.log.LogInterface;
import com.tencent.falco.base.libapi.network.NetworkStateInterface;
import com.tencent.falco.base.libapi.network.OnNetworkListener;
import com.tencent.falco.utils.SPUtil;
import com.tencent.falco.utils.ThreadCenter;
import com.tencent.ilive.base.event.ModuleEvent;
import com.tencent.ilive.enginemanager.BizEngineMgr;
import com.tencent.ilive.interfaces.RoomPageActionInterface;
import com.tencent.ilive.pages.room.events.EnterRoomEvent;
import com.tencent.ilive.pages.room.events.RoomCloseEvent;
import com.tencent.ilivesdk.roomservice_interface.model.LiveAnchorInfo;
import com.tencent.ilivesdk.roomservice_interface.model.LiveInfo;
import com.tencent.ilivesdk.roomservice_interface.model.LiveMediaInfo;
import com.tencent.ilivesdk.roomservice_interface.model.LiveRoomInfo;
import com.tencent.ilivesdk.roomservice_interface.model.LiveWatchMediaInfo;
import com.tencent.livesdk.accountengine.UserEngine;
import com.tencent.livesdk.accountengine.UserInitStateCallback;
import com.tencent.livesdk.roomengine.RoomEngine;
import com.tencent.mtt.ContextHolder;
import com.tencent.mtt.R;
import com.tencent.mtt.base.skin.MttResources;
import com.tencent.mtt.base.webview.QBWebView;
import com.tencent.mtt.base.webview.common.QBWebSettings;
import com.tencent.mtt.hippy.qb.views.nowlive.HippyNowLiveRoomViewWrapper;
import com.tencent.mtt.setting.BaseSettings;
import com.tencent.now.custom_datareport_module.RoomExtInfo;
import com.tencent.now.custom_web_module.CustomWebModule;
import com.tencent.now.custom_web_module.LiveWebViewWapper;
import com.tencent.now.custom_web_module.QBRoomBizModule;
import com.tencent.now.utils.DeviceUtils;
import com.tencent.now.utils.NowLogs;
import com.tencent.now.utils.event.EventCenter;
import com.tencent.now.utils.event.Eventor;
import com.tencent.now.utils.event.impl.OnEvent;
import com.tencent.now.utils.network.NetworkUtil;
import com.tencent.now.webcomponent.LiteLiveWebViewClient;
import com.tencent.now.webcomponent.WebCookieManager;
import com.tencent.now.webcomponent.event.CloseNativePageEvent;
import com.tencent.now.webcomponent.event.NotifyWebClickBackPressEvent;
import com.tencent.now.webcomponent.jsmodule.JsBizAdapter;
import java.util.ArrayList;
import org.json.JSONException;
import org.json.JSONObject;
public class CustomAnchorLiveWebModule extends QBRoomBizModule implements OnNetworkListener {
private Context f75815c;
private QBWebView f75816d;
private ViewGroup e;
private boolean p;
private LiteLiveWebViewClient q;
private UserEngine r;
private TextView s;
private String u;
private String f75814b = "https://ilive.qq.com/h5/livetool/live.html?_t=%s&room_id=%d&program_id=%s&__bh=%d";
private Eventor v = new Eventor();
UserInitStateCallback f75813a = new UserInitStateCallback() {
@Override
public void a() {
CustomAnchorLiveWebModule.this.x().e("CustomAnchorPrepareWebModule", "onLoginSucceed", new Object[0]);
CustomAnchorLiveWebModule.this.J();
}
@Override
public void a(int i) {
CustomAnchorLiveWebModule.this.x().e("CustomAnchorPrepareWebModule", "wait login--fail--errCode=" + i, new Object[0]);
}
@Override
public void b() {
}
@Override
public void c() {
}
};
private void H() {
QBWebView qBWebView = this.f75816d;
if (qBWebView == null) {
NowLogs.e("CustomAnchorPrepareWebModule", "settingWebViewClient mWebView is null");
return;
}
this.q = new LiteLiveWebViewClient(qBWebView, n(), this.f75815c, new JsBizAdapter() {
@Override
public RoomEngine a() {
return null;
}
@Override
public void a(RoomExtInfo roomExtInfo) {
}
@Override
public void a(boolean z) {
}
@Override
public ModuleEvent b() {
return CustomAnchorLiveWebModule.this.w();
}
@Override
public LogInterface c() {
return CustomAnchorLiveWebModule.this.x();
}
@Override
public void d() {
}
@Override
public void e() {
}
@Override
public RoomPageActionInterface f() {
return null;
}
}, "");
this.q.a(new CustomWebModule.WebViewLoadStatusListener() {
@Override
public void a() {
if (CustomAnchorLiveWebModule.this.f75816d == null || CustomAnchorLiveWebModule.this.f75816d.getVisibility() == 0) {
return;
}
CustomAnchorLiveWebModule.this.f75816d.setVisibility(0);
}
});
this.f75816d.setQBWebViewClient(this.q);
}
private void I() {
if (this.r.f()) {
x().e("CustomAnchorPrepareWebModule", "initLogin has loginSuccess", new Object[0]);
J();
} else {
x().c("CustomAnchorPrepareWebModule", "initLogin wait login complete", new Object[0]);
this.r.b(this.f75813a);
this.r.a(this.f75813a);
}
}
public void J() {
WebCookieManager.a().a(this.u);
WebCookieManager.a().a("https://yutang.qq.com/");
WebCookieManager.a().a("https://ilive.qq.com/");
WebCookieManager.a().a("https://tencentlive.qq.com/");
a("__WEBVIEW_RELOADCOOKIES", (JSONObject) null);
}
public void a(String str, JSONObject jSONObject) {
String str2;
if (jSONObject != null) {
str2 = "javascript:(" + str + "(" + jSONObject.toString() + "))";
} else {
str2 = "javascript:" + str + "()";
}
QBWebView qBWebView = this.f75816d;
if (qBWebView == null) {
return;
}
qBWebView.evaluateJavascript(str2, new ValueCallback<String>() {
@Override
public void onReceiveValue(String str3) {
NowLogs.b("CustomAnchorPrepareWebModule", "onReceiveValue value = " + str3);
}
});
}
private void l() {
w().a(RoomCloseEvent.class, new Observer<RoomCloseEvent>() {
@Override
public void onChanged(RoomCloseEvent roomCloseEvent) {
EventCenter.a(new CloseNativePageEvent());
}
});
this.v.a(new OnEvent<NotifyWebClickBackPressEvent>() {
@Override
public void a(NotifyWebClickBackPressEvent notifyWebClickBackPressEvent) {
CustomAnchorLiveWebModule.this.a("__WEBVIEW_CLOSE", (JSONObject) null);
}
});
}
private void q() {
if (this.f75816d == null) {
this.f75816d = LiveWebViewWapper.a().b();
if (this.f75816d == null) {
this.f75816d = QBWebView.createAsy(ContextHolder.getAppContext(), new QBWebView.WebViewInitObserver() {
@Override
public void onWebViewPrepared() {
if (CustomAnchorLiveWebModule.this.p) {
return;
}
CustomAnchorLiveWebModule.this.r();
}
});
LiveWebViewWapper.a().a(this.f75816d);
} else {
r();
}
x().c("CustomAnchorPrepareWebModule", "webmodule--onCreateView webView=" + this.f75816d.hashCode(), new Object[0]);
this.f75816d.setVisibility(4);
if (this.f75816d.getParent() != null) {
((ViewGroup) this.f75816d.getParent()).removeView(this.f75816d);
}
this.e.addView(this.f75816d);
I();
}
}
public void r() {
QBWebView qBWebView = this.f75816d;
if (qBWebView == null) {
NowLogs.e("CustomAnchorPrepareWebModule", "initWeb webView is null");
return;
}
qBWebView.onResume();
this.f75816d.setEnableAutoPageDiscarding(false);
this.f75816d.setEnableAutoPageRestoration(false);
s();
H();
this.f75816d.setWebViewBackgroundColor(0);
this.f75816d.setBackgroundColor(0);
this.f75816d.setWebCoreNightModeEnabled(false);
this.f75816d.switchSkin(false);
NowLogs.c("CustomAnchorPrepareWebModule", "CustomWebModule initWeb before url = " + this.u);
this.f75816d.loadUrl(this.u);
}
private void s() {
QBWebSettings qBSettings;
QBWebView qBWebView = this.f75816d;
if (qBWebView == null || (qBSettings = qBWebView.getQBSettings()) == null) {
return;
}
qBSettings.b(1);
qBSettings.u(true);
qBSettings.o(true);
String e = qBSettings.e();
if (e.contains("NowSDK/")) {
return;
}
qBSettings.b(e + " NowLive/" + DeviceUtils.b() + "_" + Build.VERSION.RELEASE + " NetType/" + NetworkUtil.b(this.f75815c) + " NowSDK/18_10.20");
}
@Override
public void a(Context context) {
super.a(context);
this.f75815c = context;
this.r = BizEngineMgr.a().c();
ViewStub viewStub = (ViewStub) n().findViewById(R.id.biz_webview_container);
viewStub.setLayoutResource(R.layout.cq);
this.e = (ViewGroup) viewStub.inflate();
this.e.setBackgroundColor(0);
this.s = (TextView) this.e.findViewById(R.id.text_url);
this.u = f(false);
q();
l();
ThreadCenter.a(new Runnable() {
@Override
public void run() {
CustomAnchorLiveWebModule.this.i();
}
}, 2000);
((NetworkStateInterface) BizEngineMgr.a().d().a(NetworkStateInterface.class)).a(this);
}
@Override
public void a(boolean z, boolean z2) {
int b2 = NetworkUtil.b(this.f75815c);
try {
JSONObject jSONObject = new JSONObject();
jSONObject.put("type", b2);
this.f75816d.evaluateJavascript("javascript:(__WEBVIEW_NETWORK_CHANGE(" + jSONObject.toString() + "))", new ValueCallback<String>() {
@Override
public void onReceiveValue(String str) {
}
});
} catch (JSONException unused) {
}
}
@Override
public void b(boolean z) {
super.b(z);
}
public String f(boolean z) {
return String.format(this.f75814b, String.valueOf(System.currentTimeMillis()), Long.valueOf(o().e().f13245a), o().e().f13247c, Integer.valueOf(MttResources.r(BaseSettings.a().m())));
}
@Override
public void f() {
super.f();
this.p = true;
((NetworkStateInterface) BizEngineMgr.a().d().a(NetworkStateInterface.class)).b(this);
}
protected void i() {
String b2 = SPUtil.a(this.f75815c, "nowlive_config").b("liveInfo", "");
LiveInfo liveInfo = new LiveInfo();
liveInfo.f13254b = new LiveAnchorInfo();
liveInfo.f13255c = new LiveMediaInfo();
liveInfo.f13253a = new LiveRoomInfo();
liveInfo.f13256d = new ArrayList();
liveInfo.e = new LiveWatchMediaInfo();
try {
JSONObject jSONObject = new JSONObject(b2);
o().f12331a = liveInfo;
o().b().f13249a = jSONObject.getLong("uid");
o().a().f13259a = jSONObject.getInt("room_id");
o().a().f13262d = jSONObject.getInt("roomType");
o().c().f13257a = ((String) jSONObject.get("sig")).getBytes();
o().d().f12345a = false;
o().a().k = jSONObject.getInt("roomGameType");
o().a().e = jSONObject.getString(HippyNowLiveRoomViewWrapper.SRC_KEY_PROGRAM_ID);
w().a(new EnterRoomEvent(true));
} catch (JSONException unused) {
}
}
@Override
public boolean m() {
if (this.f75816d.canGoBack()) {
return super.m();
}
a("__WEBVIEW_RELOADCOOKIES", (JSONObject) null);
return false;
}
}