QQ浏览器 v12.2.3.7053版本的 MD5 值为:8285ab3059e5c8b521a264dfbc5c3685
以下内容为反编译后的 UrlDispatcher.java 源代码,内容仅作参考
package com.tencent.mtt.businesscenter.urldispatch;
import android.content.Context;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.text.TextUtils;
import com.tencent.common.manifest.AppManifest;
import com.tencent.common.utils.StringUtils;
import com.tencent.common.utils.UrlUtils;
import com.tencent.matrix.report.Issue;
import com.tencent.mtt.ContextHolder;
import com.tencent.mtt.base.account.facade.IUserCenterService;
import com.tencent.mtt.base.functionwindow.ActivityHandler;
import com.tencent.mtt.base.stat.StatManager;
import com.tencent.mtt.base.stat.utils.StatSettingProvider;
import com.tencent.mtt.base.utils.Base64Utils;
import com.tencent.mtt.base.utils.PackageUtils;
import com.tencent.mtt.base.utils.QBUrlUtils;
import com.tencent.mtt.boot.facade.IBootService;
import com.tencent.mtt.browser.download.core.impl.DownloadServiceManager;
import com.tencent.mtt.browser.file.facade.IFileOpenManager;
import com.tencent.mtt.browser.intent.facade.IShortcutInstallerService;
import com.tencent.mtt.browser.push.facade.IServiceManager;
import com.tencent.mtt.browser.security.SecurityManager;
import com.tencent.mtt.browser.security.datastruct.SecurityLevel;
import com.tencent.mtt.browser.window.PageFrame;
import com.tencent.mtt.browser.window.UrlParams;
import com.tencent.mtt.browser.window.WindowManager;
import com.tencent.mtt.browser.window.ext.IUrlRedirectExtension;
import com.tencent.mtt.browser.window.home.FrameWorkLogUtil;
import com.tencent.mtt.businesscenter.facade.IExternalDispatchServer;
import com.tencent.mtt.businesscenter.facade.IFrameworkDelegate;
import com.tencent.mtt.businesscenter.facade.IUrlDispatherExtension;
import com.tencent.mtt.businesscenter.intent.QBModuleDispather;
import com.tencent.mtt.businesscenter.utils.BusinessFileUtils;
import com.tencent.mtt.businesscenter.utils.SearchUrlUtils;
import com.tencent.mtt.hippy.qb.views.base.IWebViewController;
import com.tencent.mtt.qbcontext.core.QBContext;
import com.tencent.mtt.search.facade.ISearchService;
import com.tencent.mtt.setting.PublicSettingManager;
import com.tencent.mtt.utils.SafetyPerceptionConsts;
import com.tencent.mtt.view.toast.MttToaster;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.HashMap;
import java.util.regex.Pattern;
public class UrlDispatcher {
public static String a(String str) {
return b(str, false);
}
public static String a(String str, boolean z, Bundle bundle) {
if (TextUtils.isEmpty(str)) {
return "";
}
d(UrlUtils.deleteHttpPrefix(str));
if (str.startsWith("qb://navicard") || str.startsWith("qb://navicardpool")) {
return "qb://home";
}
String a2 = SearchUrlUtils.a(b(str));
if (b(a2, z, bundle)) {
FrameWorkLogUtil.a("UrlDispatcher", Issue.ISSUE_REPORT_PROCESS, "特殊url地址已被拦截", a2);
return "";
}
if (!a2.startsWith("qb://")) {
a2 = ((ISearchService) QBContext.getInstance().getService(ISearchService.class)).getUrlAsSearchKeyOrAddress(a2);
FrameWorkLogUtil.a("UrlDispatcher", Issue.ISSUE_REPORT_PROCESS, "非qb地址或者转搜索", a2);
}
return StringUtils.b(a2) ? "" : a2;
}
public static boolean a(String str, boolean z) {
return b(str, z, null);
}
public static String b(String str) {
IUrlRedirectExtension iUrlRedirectExtension = (IUrlRedirectExtension) AppManifest.getInstance().queryExtension(IUrlRedirectExtension.class, str);
if (iUrlRedirectExtension == null) {
return str;
}
String redirect = iUrlRedirectExtension.redirect(str);
if (TextUtils.isEmpty(redirect)) {
return str;
}
FrameWorkLogUtil.a("UrlDispatcher", "checkHolderPreUrlRedirect", "IUrlRedirectExtension 拦截," + iUrlRedirectExtension.getClass().getSimpleName(), redirect);
return redirect;
}
private static String b(String str, boolean z) {
return a(str, z, null);
}
private static boolean b(String str, boolean z, Bundle bundle) {
String str2;
Context appContext;
String str3;
InputStream a2;
IUrlDispatherExtension[] iUrlDispatherExtensionArr = (IUrlDispatherExtension[]) AppManifest.getInstance().queryExtensions(IUrlDispatherExtension.class, str);
if (iUrlDispatherExtensionArr.length > 0) {
IUrlDispatherExtension iUrlDispatherExtension = iUrlDispatherExtensionArr[0];
FrameWorkLogUtil.a("UrlDispatcher", "lunchCustomUrl", "特殊url拦截," + iUrlDispatherExtension.getClass().getSimpleName(), str);
return iUrlDispatherExtension.lunchCustomUrl(str, z, bundle);
}
if (QBUrlUtils.n(str)) {
DownloadServiceManager.a().handleXunleiDownloadUrl(str, null, null, true, 1);
return true;
}
if (UrlUtils.isFileUrl(str) && str.endsWith(".torrent")) {
IFileOpenManager iFileOpenManager = (IFileOpenManager) QBContext.getInstance().getService(IFileOpenManager.class);
if (iFileOpenManager != null) {
iFileOpenManager.showNotSupportedDialogOnUi();
}
return true;
}
if (UrlUtils.isHttpUrl(str) || UrlUtils.isHttpsUrl(str)) {
return e(str) || ((IUserCenterService) QBContext.getInstance().getService(IUserCenterService.class)).isCpLogin(str);
}
if (UrlUtils.isSecurityCacheUrl(str)) {
SecurityLevel a3 = SecurityManager.a().a(UrlUtils.deleteCustomPrefix(str), SafetyPerceptionConsts.e);
if (a3 != null) {
String b2 = Base64Utils.b(a3.f44594c, 0);
PageFrame s = WindowManager.a().s();
if (s != null) {
s.loadData(b2, IWebViewController.HTML_MIME_TYPE, "base64");
}
}
return true;
}
if (UrlUtils.isSecurityFileUrl(str)) {
String deletePrefix = UrlUtils.deletePrefix(str);
SecurityLevel a4 = SecurityManager.a().a(deletePrefix, SafetyPerceptionConsts.f);
if (a4 == null || (a2 = BusinessFileUtils.a(deletePrefix, a4)) == null) {
return true;
}
ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
byte[] bArr = new byte[4096];
while (true) {
try {
int read = a2.read(bArr, 0, 4096);
if (read != -1) {
byteArrayOutputStream.write(bArr, 0, read);
}
} catch (IOException unused) {
} catch (Throwable th) {
try {
a2.close();
} catch (Exception unused2) {
}
throw th;
}
try {
break;
} catch (Exception unused3) {
}
}
a2.close();
String b3 = Base64Utils.b(byteArrayOutputStream.toByteArray(), 0);
PageFrame s2 = WindowManager.a().s();
if (s2 != null) {
s2.loadData(b3, IWebViewController.HTML_MIME_TYPE, "base64");
}
return true;
}
if (str.startsWith("qb://appcenter/")) {
((IFrameworkDelegate) QBContext.getInstance().getService(IFrameworkDelegate.class)).doLoad(new UrlParams("https://app.html5.qq.com/x5/index").b(33).c(11).a((Bundle) null));
return true;
}
if (str.startsWith("qb://logcmd")) {
((IFrameworkDelegate) QBContext.getInstance().getService(IFrameworkDelegate.class)).handleMttMessage(250, 0, 0, null, 0L);
return true;
}
if (UrlUtils.isTelUrl(str) || UrlUtils.isWtaiUrl(str)) {
String telUrl = UrlUtils.getTelUrl(str);
if (telUrl != null) {
((IExternalDispatchServer) QBContext.getInstance().getService(IExternalDispatchServer.class)).doDial(telUrl);
}
return true;
}
if (UrlUtils.isMailUrl(str)) {
String mailUrl = UrlUtils.getMailUrl(str);
if (mailUrl != null) {
((IExternalDispatchServer) QBContext.getInstance().getService(IExternalDispatchServer.class)).doMailTo(mailUrl);
return true;
}
} else {
if (UrlUtils.isSmsUrl(str)) {
((IFrameworkDelegate) QBContext.getInstance().getService(IFrameworkDelegate.class)).handleMttMessage(40, 0, 0, str, 0L);
return true;
}
if (str.startsWith("qb://pushchange")) {
String urlParamValue = UrlUtils.getUrlParamValue(str, "ip");
PublicSettingManager.a().setString("push_test_server_ip", urlParamValue);
((IServiceManager) QBContext.getInstance().getService(IServiceManager.class)).changeServerAndStopPushServcie(ContextHolder.getAppContext());
((IServiceManager) QBContext.getInstance().getService(IServiceManager.class)).doPush();
if (!((IServiceManager) QBContext.getInstance().getService(IServiceManager.class)).isUsingTestServer(ContextHolder.getAppContext())) {
appContext = ContextHolder.getAppContext();
str3 = "push已切换到正式环境";
} else {
if (!TextUtils.isEmpty(urlParamValue)) {
MttToaster.showSysToast(ContextHolder.getAppContext(), "push已切换到指定服务器:" + urlParamValue, 1);
return true;
}
appContext = ContextHolder.getAppContext();
str3 = "push已切换到测试环境";
}
MttToaster.showSysToast(appContext, str3, 1);
return true;
}
if (str.equals("qb://piratechange")) {
if (PublicSettingManager.a().getBoolean("key_pirate_novel_env_switch", false)) {
PublicSettingManager.a().setBoolean("key_pirate_novel_env_switch", false);
str2 = "盗版转码切换为正式环境...";
} else {
PublicSettingManager.a().setBoolean("key_pirate_novel_env_switch", true);
str2 = "盗版转码切换为测试环境...";
}
MttToaster.show(str2, 0);
return true;
}
if (str.startsWith("qb://hotpatch")) {
((IBootService) QBContext.getInstance().getService(IBootService.class)).processPatchUrl(str);
return true;
}
if ("qb://beacon/direct_upload".equals(str)) {
StatSettingProvider.a().d();
MttToaster.show("Beacon立即上报已开启,请重启浏览器", 0);
return true;
}
if (str.startsWith("qb://queen")) {
return true;
}
if (QBUrlUtils.w(str)) {
if (bundle == null) {
return QbUrlProcessor.a(str);
}
Intent intent = new Intent();
intent.putExtras(bundle);
return QbUrlProcessor.a(str, intent);
}
if (QBUrlUtils.g(str)) {
((IFrameworkDelegate) QBContext.getInstance().getService(IFrameworkDelegate.class)).handleMttMessage(49, 0, 0, str, 0L);
return true;
}
if (QBUrlUtils.t(str)) {
HashMap hashMap = new HashMap();
hashMap.put("weburl", WindowManager.a().v());
hashMap.put("jumpUrl", str);
StatManager.b().b("third_scheme_to_qq_app", hashMap);
if (str.startsWith("mqqapi://microapp/") && str.contains("1108314714")) {
return false;
}
QBUrlUtils.a(ActivityHandler.b().n(), str);
return true;
}
if (QBUrlUtils.h(str)) {
((IExternalDispatchServer) QBContext.getInstance().getService(IExternalDispatchServer.class)).doSamsungApps(str);
return true;
}
if (QBUrlUtils.E(str)) {
try {
QbUrlProcessor.b(str);
} catch (Exception unused4) {
}
return true;
}
}
return false;
}
public static String c(String str) {
if (StringUtils.b(str)) {
return "";
}
if (UrlUtils.isDeprecatedSechema(str)) {
return UrlUtils.deletePrefix(str);
}
if (UrlUtils.isJavascript(str)) {
return "";
}
if (str.equalsIgnoreCase("qb://app/com.tencent.qqmarket.forbrowserplugin.main")) {
return "qb://market/startpage";
}
if (!QBUrlUtils.a(str)) {
return str;
}
Integer num = 0;
try {
num = Integer.valueOf(QBUrlUtils.a(str, "windowType"));
} catch (NumberFormatException unused) {
}
int i = 1;
if (num.intValue() == 1) {
return str;
}
Intent intent = new Intent();
intent.setData(Uri.parse(str));
try {
i = Integer.valueOf(QBUrlUtils.a(str, "openType")).intValue();
} catch (NumberFormatException unused2) {
}
intent.putExtra("openType", i);
QBModuleDispather.a(ActivityHandler.b().a(), intent, 0);
return "";
}
private static void d(String str) {
if ((str.startsWith("www.baidu.com") || str.startsWith("m.baidu.com")) && PublicSettingManager.a().getBoolean("key_baidu_need_create_desktop_icon", true) && !PublicSettingManager.a().getBoolean("key_baidu_create_desktop_icon_new", false) && ((IShortcutInstallerService) QBContext.getInstance().getService(IShortcutInstallerService.class)).canShowAddShortcutDlg(5)) {
((IFrameworkDelegate) QBContext.getInstance().getService(IFrameworkDelegate.class)).getAppEngineHandler().postDelayed(new Runnable() {
@Override
public void run() {
((IShortcutInstallerService) QBContext.getInstance().getService(IShortcutInstallerService.class)).createShortCut(8);
}
}, 1500L);
}
}
private static boolean e(String str) {
String string = PublicSettingManager.a().getString("key_call_wechat_pattern", "https://weixin.qq.com/r/");
if (!TextUtils.isEmpty(string) && Pattern.compile(string).matcher(str).find()) {
return PackageUtils.a("com.tencent.mm");
}
return false;
}
}