QQ浏览器 v12.2.3.7053版本的 MD5 值为:8285ab3059e5c8b521a264dfbc5c3685
以下内容为反编译后的 SafetySheetManager.java 源代码,内容仅作参考
package com.tencent.mtt.browser.security;
import android.app.Activity;
import android.os.Build;
import android.os.Bundle;
import android.os.Handler;
import android.os.Looper;
import android.os.Message;
import android.text.TextUtils;
import android.view.View;
import com.huawei.hms.support.hianalytics.HiAnalyticsConstant;
import com.tencent.common.manifest.EventEmiter;
import com.tencent.common.manifest.EventMessage;
import com.tencent.common.manifest.annotation.CreateMethod;
import com.tencent.common.manifest.annotation.EventReceiver;
import com.tencent.common.task.QBTask;
import com.tencent.common.threadpool.BrowserExecutorSupplier;
import com.tencent.common.utils.UrlUtils;
import com.tencent.common.wup.IWUPRequestCallBack;
import com.tencent.common.wup.WUPRequestBase;
import com.tencent.common.wup.WUPResponseBase;
import com.tencent.common.wup.WUPTaskProxy;
import com.tencent.luggage.wxa.mg.v;
import com.tencent.mtt.base.functionwindow.ActivityHandler;
import com.tencent.mtt.base.stat.StatManager;
import com.tencent.mtt.base.stat.utils.PlatformStatUtils;
import com.tencent.mtt.base.webview.QBNewJsDialogFactory;
import com.tencent.mtt.base.webview.QBWebView;
import com.tencent.mtt.base.wup.DomainListDataManager;
import com.tencent.mtt.base.wup.GUIDManager;
import com.tencent.mtt.base.wup.WUPRequest;
import com.tencent.mtt.browser.db.DangerBehaviorInterceptionManager;
import com.tencent.mtt.browser.file.facade.IFileStatService;
import com.tencent.mtt.browser.security.datastruct.SecurityLevel;
import com.tencent.mtt.browser.security.datastruct.WebBehaviorCheckInfo;
import com.tencent.mtt.browser.security.datastruct.WebBehivorInfo;
import com.tencent.mtt.browser.ui.DangerInterceptBottomSheet;
import com.tencent.mtt.browser.window.IWebView;
import com.tencent.mtt.browser.window.PageFrame;
import com.tencent.mtt.browser.window.WindowManager;
import com.tencent.mtt.browser.window.templayer.QBWebviewWrapper;
import com.tencent.mtt.external.websecurity.MTT.ReportWebInfoReq;
import com.tencent.mtt.log.access.Logs;
import com.tencent.mtt.operation.event.EventLog;
import com.tencent.mtt.qbinfo.QUAUtils;
import com.tencent.mtt.setting.PublicSettingManager;
import com.tencent.mtt.utils.SafetyPerceptionConsts;
import com.tencent.mtt.view.dialog.alert.QBAlertDialog;
import com.tencent.mtt.view.dialog.manager.GlobalDialogManager;
import com.tencent.mtt.view.dialog.newui.SimpleDialogBuilder;
import com.tencent.mtt.view.dialog.newui.builder.api.base.IDialogBuilder;
import com.tencent.mtt.view.dialog.newui.dialog.DialogBase;
import com.tencent.mtt.view.dialog.newui.view.ViewOnClickListener;
import com.tencent.mtt.view.toast.NotificationBar;
import com.tencent.qqlive.module.videoreport.collect.EventCollector;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.concurrent.Callable;
import org.json.JSONArray;
import org.slf4j.Marker;
public class SafetySheetManager implements Handler.Callback, IWUPRequestCallBack {
private static volatile SafetySheetManager f44564d;
public JSONArray f44566b;
QBAlertDialog f44567c;
private DangerInterceptBottomSheet e;
private HashMap<String, WebBehaviorCheckInfo> g = new HashMap<>();
private long h = 0;
public Handler f44565a = new Handler(Looper.getMainLooper());
private Handler f = new Handler(BrowserExecutorSupplier.getLooperForRunShortTime(), this);
private SafetySheetManager() {
e();
EventEmiter.getDefault().register("com.tencent.mtt.base.webview.onAlertDialogShow", this);
Logs.a("QBWebSecurity", new String[]{"SafetySheetManagerUpload"});
}
private void a(final WebBehaviorCheckInfo webBehaviorCheckInfo, String str, int i) {
StatManager b2;
String str2;
EventLog.a("SafeCheckManager", "checkWebBehaviorType :" + i);
Logs.c("SafetySheetManagerkey", "checkWebBehaviorType :" + i);
if (i == 2) {
QBTask.b((Callable) new Callable<Object>() {
@Override
public Object call() throws Exception {
SafetySheetManager.this.a(webBehaviorCheckInfo);
return null;
}
});
} else if (i == 6) {
b(webBehaviorCheckInfo);
} else if (i == 3) {
if (!a(webBehaviorCheckInfo.a(), true, v.CTRL_INDEX)) {
a(webBehaviorCheckInfo.a(), (SecurityLevel) null, i);
a(webBehaviorCheckInfo.a(), 20);
}
} else if (i == 4) {
b(webBehaviorCheckInfo, str, i);
}
a(i, "1", webBehaviorCheckInfo.a(), str);
a(webBehaviorCheckInfo.a(), i != 3 ? 10 : 20);
if (i == 2) {
b2 = StatManager.b();
str2 = "BZRISK999";
} else if (i == 3) {
b2 = StatManager.b();
str2 = "BZRISK998";
} else if (i == 4) {
b2 = StatManager.b();
str2 = "BZRISK997";
} else {
if (i != 5) {
return;
}
b2 = StatManager.b();
str2 = "BZRISK996";
}
b2.c(str2);
}
private void a(String str, int i) {
ReportWebInfoReq reportWebInfoReq = new ReportWebInfoReq();
reportWebInfoReq.sGuid = GUIDManager.a().f();
reportWebInfoReq.sQua2 = QUAUtils.a();
reportWebInfoReq.sUrl = str;
reportWebInfoReq.iAppid = i;
WUPRequest wUPRequest = new WUPRequest("Security", "reportWebInfo");
wUPRequest.setNeedCloseConnection(true);
wUPRequest.setEncodeName("UTF-8");
wUPRequest.put(HiAnalyticsConstant.Direction.REQUEST, reportWebInfoReq);
wUPRequest.setRequestCallBack(this);
wUPRequest.setClassLoader(getClass().getClassLoader());
WUPTaskProxy.send(wUPRequest);
}
private void b(WebBehaviorCheckInfo webBehaviorCheckInfo) {
String str = webBehaviorCheckInfo.f44599b;
if (DangerBehaviorInterceptionManager.a().e(str)) {
return;
}
PlatformStatUtils.a("WEB_SECURITY_INTERCEPTDOWNLOAD");
DangerBehaviorInterceptionManager.a().a(str, true);
Logs.c("SafetySheetManagerkey", "interceptDownload");
}
private void b(WebBehaviorCheckInfo webBehaviorCheckInfo, String str, int i) {
String str2;
if (webBehaviorCheckInfo == null) {
return;
}
if (DangerBehaviorInterceptionManager.a().f(webBehaviorCheckInfo.f44599b)) {
Logs.c("SafetySheetManagerkey", "isRelieveAlertInterception false");
return;
}
boolean z = false;
if (!a(webBehaviorCheckInfo.f44599b, false, 426) && c() && i == 4) {
z = true;
}
if (z) {
String str3 = webBehaviorCheckInfo.f44599b;
PlatformStatUtils.a("WEB_SECURITY_INTERCEPTALERT");
DangerBehaviorInterceptionManager.a().b(str3, true);
str2 = "interceptJsAlert";
} else {
str2 = "checkBehavierWhenJsAlertTooMany not goto interceptJsAlert";
}
Logs.c("SafetySheetManagerkey", str2);
Logs.c("SafetySheetManagerUpload", "[ID856158207] checkWebBehaviorType type=" + i + ";info.alertCount=" + webBehaviorCheckInfo.e + ";info.downloadWithoutClickCount=" + webBehaviorCheckInfo.f44600c + ";info.mixCount=" + webBehaviorCheckInfo.g + ";info.cannotBackCount=" + webBehaviorCheckInfo.h);
}
private boolean b(int i) {
int i2 = (i & 1) == 1 ? 1 : 0;
if ((i & 2) == 2) {
i2++;
}
if ((i & 4) == 4) {
i2++;
}
if ((i & 8) == 8) {
i2++;
}
if ((i & 15) == 15) {
i2++;
}
return i2 >= 2;
}
public void c(WebBehaviorCheckInfo webBehaviorCheckInfo) {
PageFrame s = WindowManager.a().s();
if (s != null) {
IWebView currentWebView = s.getCurrentWebView();
if (currentWebView != null && (currentWebView instanceof QBWebviewWrapper)) {
QBWebviewWrapper qBWebviewWrapper = (QBWebviewWrapper) currentWebView;
qBWebviewWrapper.e(UrlUtils.getHostNew(webBehaviorCheckInfo.a()));
QBWebView qBWebView = qBWebviewWrapper.getQBWebView();
if (qBWebView != null && QBNewJsDialogFactory.c(qBWebView)) {
QBNewJsDialogFactory.b(qBWebView);
}
}
s.back(false);
}
PlatformStatUtils.a("WEB_SECURITY_FORCEGOBACK");
Logs.c("SafetySheetManagerkey", "forceGoBack");
}
private boolean c(String str, SecurityLevel securityLevel) {
if (securityLevel.flag != 0 || securityLevel.level == 0 || securityLevel.level == 4) {
return false;
}
if (securityLevel.evilclass != 5 && securityLevel.evilclass != 6 && securityLevel.evilclass != 7) {
return false;
}
HashMap hashMap = new HashMap();
hashMap.put("action_id", "1");
hashMap.put("risk_type", String.valueOf(securityLevel.evilclass));
hashMap.put("url", str);
hashMap.put("domain", UrlUtils.getHost(str));
hashMap.put("webview_type", "2");
hashMap.put("operation_system", "0");
StatManager.b().b("MTT_DANGER_WEB_INTERCEPT_REPORT", hashMap);
Activity a2 = ActivityHandler.b().a();
if (a2 == null) {
return false;
}
Logs.c("ShowDangerBottomSheet", "start show");
DangerInterceptBottomSheet dangerInterceptBottomSheet = this.e;
if (dangerInterceptBottomSheet != null) {
dangerInterceptBottomSheet.a();
}
this.e = new DangerInterceptBottomSheet(a2, str, securityLevel, 1);
this.e.b();
return true;
}
private boolean d(String str, SecurityLevel securityLevel) {
if (securityLevel.flag != 2) {
return false;
}
HashMap hashMap = new HashMap();
hashMap.put("action_id", "1");
hashMap.put("risk_type", String.valueOf(securityLevel.evilclass));
hashMap.put("url", str);
hashMap.put("domain", UrlUtils.getHost(str));
hashMap.put("webview_type", "2");
hashMap.put("operation_system", "0");
StatManager.b().b("MTT_DANGER_WEB_INTERCEPT_REPORT", hashMap);
Activity a2 = ActivityHandler.b().a();
if (a2 == null) {
return false;
}
Logs.c("ShowDangerBottomSheet", "start show");
DangerInterceptBottomSheet dangerInterceptBottomSheet = this.e;
if (dangerInterceptBottomSheet != null) {
dangerInterceptBottomSheet.a();
}
this.e = new DangerInterceptBottomSheet(a2, str, securityLevel, 1);
this.e.b();
return true;
}
private void e() {
if (this.f44566b == null) {
this.f44566b = new JSONArray();
}
}
private boolean e(String str) {
if (TextUtils.isEmpty(str)) {
return false;
}
String v = WindowManager.a().v();
if (TextUtils.isEmpty(v)) {
return false;
}
return (UrlUtils.isHttpsUrl(v) || UrlUtils.isHttpUrl(v)) && UrlUtils.getHostNew(str).equals(UrlUtils.getHostNew(v));
}
public boolean f() {
String v = WindowManager.a().v();
return UrlUtils.isHttpsUrl(v) || UrlUtils.isHttpUrl(v);
}
public static SafetySheetManager getInstance() {
if (f44564d == null) {
synchronized (SafetySheetManager.class) {
if (f44564d == null) {
f44564d = new SafetySheetManager();
}
}
}
return f44564d;
}
public Object a(QBWebView qBWebView, String str, Bundle bundle) {
if (qBWebView == null || bundle == null) {
return null;
}
if (!TextUtils.equals(str, "onNotifyAudioStatus")) {
if (!TextUtils.equals(str, "onNotifyTouchEvent") || bundle.getInt("action") != 1) {
return null;
}
this.h = System.currentTimeMillis();
Logs.c("SafetySheetManagerkey", "update mLastClickOnWeb = " + this.h);
return null;
}
if (!bundle.getBoolean("status")) {
return null;
}
String url = qBWebView.getUrl();
if (TextUtils.isEmpty(url)) {
return null;
}
WebBehivorInfo webBehivorInfo = new WebBehivorInfo();
webBehivorInfo.f44602a = url;
webBehivorInfo.f44603b = 4;
a(webBehivorInfo);
return null;
}
public void a(int i) {
StatManager.b().b("CYSECURITY001_" + i);
}
public void a(int i, String str, String str2, String str3) {
HashMap hashMap = new HashMap();
hashMap.put("type", String.valueOf(i));
hashMap.put("url", str2);
if (!TextUtils.isEmpty(str3)) {
hashMap.put(IFileStatService.EVENT_REPORT_EXT, str3);
}
hashMap.put("action", str);
StatManager.b().b("MTT_WEB_DANGER_BEHAVIOR_REPORT", hashMap);
}
public void a(final WebBehaviorCheckInfo webBehaviorCheckInfo) {
SimpleDialogBuilder.e().e("检测到当前网页无法返回").b(true).a("关闭网页").a(new IDialogBuilder.BackListener() {
@Override
public boolean handleBack(DialogBase dialogBase) {
return true;
}
}).a_(new ViewOnClickListener() {
@Override
public void onClick(View view, DialogBase dialogBase) {
PlatformStatUtils.a("WEB_SECURITY_GOBACKDIALOG_CLOSE");
SafetySheetManager.this.c(webBehaviorCheckInfo);
dialogBase.dismiss();
}
}).b("继续访问").b(new ViewOnClickListener() {
@Override
public void onClick(View view, DialogBase dialogBase) {
PlatformStatUtils.a("WEB_SECURITY_GOBACKDIALOG_CONTINUE");
dialogBase.dismiss();
}
}).e();
PlatformStatUtils.a("WEB_SECURITY_GOBACKDIALOG_SHOW");
}
public void a(WebBehaviorCheckInfo webBehaviorCheckInfo, String str) {
if (webBehaviorCheckInfo == null) {
return;
}
int i = 6;
if (webBehaviorCheckInfo.e >= 1) {
i = 4;
webBehaviorCheckInfo.e = 0;
} else if (webBehaviorCheckInfo.f44600c >= 1) {
StatManager.b().c("BZRISK995");
a(6, "1", webBehaviorCheckInfo.a(), null);
webBehaviorCheckInfo.f44600c = 0;
} else {
i = webBehaviorCheckInfo.h >= 1 ? 2 : 0;
}
if (i != 0) {
a(webBehaviorCheckInfo, str, i);
}
if (b(webBehaviorCheckInfo.g)) {
webBehaviorCheckInfo.g = 0;
webBehaviorCheckInfo.e = 0;
webBehaviorCheckInfo.f44600c = 0;
webBehaviorCheckInfo.f44601d = 0;
webBehaviorCheckInfo.f = 0;
a(webBehaviorCheckInfo, str, 3);
}
}
public void a(WebBehivorInfo webBehivorInfo) {
if (webBehivorInfo == null || TextUtils.isEmpty(webBehivorInfo.f44602a)) {
return;
}
Message obtainMessage = this.f.obtainMessage();
obtainMessage.obj = webBehivorInfo;
obtainMessage.what = 1000;
this.f.sendMessageDelayed(obtainMessage, 10L);
}
public void a(String str, SecurityLevel securityLevel) {
if (TextUtils.isEmpty(str) || a(str)) {
return;
}
if (securityLevel == null) {
securityLevel = SecurityManager.a().a(str, SafetyPerceptionConsts.f72315d);
}
if (securityLevel != null) {
DangerInterceptBottomSheet dangerInterceptBottomSheet = this.e;
if (dangerInterceptBottomSheet != null && dangerInterceptBottomSheet.d()) {
String c2 = this.e.c();
String host = UrlUtils.getHost(str);
if (!TextUtils.isEmpty(c2) && !TextUtils.isEmpty(host) && str.equalsIgnoreCase(host)) {
return;
}
}
if (PublicSettingManager.a().getBoolean("key_show_danger_intercept_bottom_sheet_" + securityLevel.evilclass, false)) {
return;
}
Logs.c("ShowDangerBottomSheet", "start show 2");
b(str, securityLevel);
}
}
public void a(final String str, final SecurityLevel securityLevel, final int i) {
if (TextUtils.isEmpty(str) || i == 0) {
return;
}
BrowserExecutorSupplier.forMainThreadTasks().execute(new Runnable() {
@Override
public void run() {
Activity a2 = ActivityHandler.b().a();
if (a2 != null && SafetySheetManager.this.f()) {
if (SafetySheetManager.this.e != null) {
SafetySheetManager.this.e.a();
}
SafetySheetManager.this.e = new DangerInterceptBottomSheet(a2, str, securityLevel, i);
SafetySheetManager.this.e.b();
}
}
});
}
public boolean a() {
DangerInterceptBottomSheet dangerInterceptBottomSheet = this.e;
return dangerInterceptBottomSheet != null && dangerInterceptBottomSheet.d();
}
public boolean a(String str) {
if (!TextUtils.isEmpty(str) && this.f44566b != null) {
String host = UrlUtils.getHost(str);
if (TextUtils.isEmpty(host)) {
return false;
}
try {
return this.f44566b.toString().contains(host);
} catch (Exception unused) {
}
}
return false;
}
public boolean a(String str, boolean z, int i) {
SecurityLevel a2;
if (TextUtils.equals(str, "https://static.res.qq.com/nav/filetest/safety_page_test.html")) {
return false;
}
if (z && (a2 = SecurityManager.a().a(str, SafetyPerceptionConsts.f72315d)) != null && a2.level != 0) {
return true;
}
ArrayList<String> a3 = DomainListDataManager.a().a(i);
if (a3 != null && a3.size() > 0) {
for (int i2 = 0; i2 < a3.size(); i2++) {
if ((!TextUtils.isEmpty(a3.get(i2)) && a3.get(i2).equals(Marker.ANY_MARKER)) || str.matches(a3.get(i2))) {
return true;
}
}
}
return false;
}
public boolean b() {
QBAlertDialog qBAlertDialog = this.f44567c;
return qBAlertDialog != null && qBAlertDialog.isShowing();
}
public boolean b(String str) {
JSONArray jSONArray;
if (TextUtils.isEmpty(str)) {
return false;
}
String host = UrlUtils.getHost(str);
if (TextUtils.isEmpty(host) || (jSONArray = this.f44566b) == null || jSONArray.toString().contains(host)) {
return false;
}
if (this.f44566b.length() >= 50 && Build.VERSION.SDK_INT >= 19) {
this.f44566b.remove(0);
}
this.f44566b.put(host);
return true;
}
public boolean b(String str, SecurityLevel securityLevel) {
if (TextUtils.isEmpty(str)) {
return false;
}
if (securityLevel == null) {
securityLevel = SecurityManager.a().a(str, SafetyPerceptionConsts.f72315d);
}
if (securityLevel != null) {
if (SecurityManager.a().b()) {
if (d(str, securityLevel)) {
return true;
}
} else if (c(str, securityLevel)) {
return true;
}
}
return false;
}
public boolean c() {
return PublicSettingManager.a().getInt("ANDROID_PUBLIC_PREFS_SECURITY_DANGER_DLG_SWITCH", 0) == 1;
}
public boolean c(final String str) {
if (!c() || a(str, true, 426)) {
return false;
}
boolean z = a() || b();
boolean b2 = DangerBehaviorInterceptionManager.a().b(str);
boolean z2 = z || b2;
if (b2 && e(str)) {
QBTask.b((Callable) new Callable<Object>() {
@Override
public Object call() throws Exception {
NotificationBar notificationBar = new NotificationBar("该网站频繁弹窗,已拦截,", "点击允许", 1);
notificationBar.a(new View.OnClickListener() {
@Override
public void onClick(View view) {
EventCollector.getInstance().onViewClickedBefore(view);
NotificationBar.e();
PlatformStatUtils.a("WEB_SECURITY_AGREE_ALERT");
DangerBehaviorInterceptionManager.a().d(str);
EventCollector.getInstance().onViewClicked(view);
}
});
notificationBar.c();
return null;
}
});
}
if (z2) {
PlatformStatUtils.a("WEB_SECURITY_DO_INTERCEPTALERT");
}
return z2;
}
public void d() {
}
public boolean d(final String str) {
String str2;
String str3;
if (!c()) {
str3 = "!isDangerInterceptDialogGlobalSwitchOn";
} else {
if (!a(str, true, 427)) {
boolean isHttpsUrl = UrlUtils.isHttpsUrl(str);
boolean isHttpsUrl2 = UrlUtils.isHttpsUrl(str);
boolean f = f();
if ((isHttpsUrl || isHttpsUrl2) && !f) {
str2 = "网页调起下载,但是当前已经不是网页,不能调起下载弹窗";
} else if (a() || b()) {
str2 = "如果安全拦截弹框已经展示,则不弹alert";
} else {
if ((!isHttpsUrl && !isHttpsUrl2) || !f || !GlobalDialogManager.a().a(false)) {
boolean a2 = DangerBehaviorInterceptionManager.a().a(str);
if (a2 && e(str)) {
QBTask.b((Callable) new Callable<Object>() {
@Override
public Object call() throws Exception {
NotificationBar notificationBar = new NotificationBar("该网站频繁发起下载,已拦截,", "点击允许", 1);
notificationBar.a(new View.OnClickListener() {
@Override
public void onClick(View view) {
EventCollector.getInstance().onViewClickedBefore(view);
NotificationBar.e();
PlatformStatUtils.a("WEB_SECURITY_AGREE_DOWNLOAD");
DangerBehaviorInterceptionManager.a().c(str);
EventCollector.getInstance().onViewClicked(view);
}
});
notificationBar.c();
return null;
}
});
}
if (a2) {
PlatformStatUtils.a("WEB_SECURITY_DO_INTERCEPTDOWNLOAD");
}
return a2;
}
str2 = "网页调起下载,但是当前已经有其他弹窗(包括且不限于下载弹窗)展示";
}
EventLog.a("SafeCheckManager", str2);
return true;
}
str3 = "在云控白名单内,不拦截";
}
EventLog.a("SafeCheckManager", str3);
return false;
}
@Override
public boolean handleMessage(Message message) {
if (message.what != 1000 || !(message.obj instanceof WebBehivorInfo)) {
return false;
}
WebBehivorInfo webBehivorInfo = (WebBehivorInfo) message.obj;
String str = webBehivorInfo.f44602a;
int i = webBehivorInfo.f44603b;
if (i == -1) {
this.g.remove(str);
DangerBehaviorInterceptionManager.a().g(str);
return false;
}
String str2 = webBehivorInfo.f44604c;
WebBehaviorCheckInfo webBehaviorCheckInfo = this.g.get(str);
if (webBehaviorCheckInfo == null && i == 0) {
if (this.g.size() > 50) {
this.g.clear();
}
webBehaviorCheckInfo = new WebBehaviorCheckInfo(str);
this.g.put(str, webBehaviorCheckInfo);
}
if (i == 0) {
return false;
}
if (webBehaviorCheckInfo == null) {
webBehaviorCheckInfo = new WebBehaviorCheckInfo(str);
}
webBehaviorCheckInfo.a(i, str2, this.h);
a(webBehaviorCheckInfo, str2);
return false;
}
@EventReceiver(createMethod = CreateMethod.NONE, eventName = "com.tencent.mtt.base.webview.onAlertDialogShow")
public void onJsAlertDialogShow(EventMessage eventMessage) {
if (eventMessage.args != null && eventMessage.args.length == 2 && (eventMessage.args[0] instanceof String) && (eventMessage.args[1] instanceof String)) {
String str = (String) eventMessage.args[0];
if (TextUtils.isEmpty(str)) {
return;
}
WebBehivorInfo webBehivorInfo = new WebBehivorInfo();
webBehivorInfo.f44602a = str;
webBehivorInfo.f44603b = 3;
a(webBehivorInfo);
}
}
@Override
public void onWUPTaskFail(WUPRequestBase wUPRequestBase) {
}
@Override
public void onWUPTaskSuccess(WUPRequestBase wUPRequestBase, WUPResponseBase wUPResponseBase) {
}
}