QQ浏览器 v12.2.3.7053版本的 MD5 值为:8285ab3059e5c8b521a264dfbc5c3685
以下内容为反编译后的 MarketService.java 源代码,内容仅作参考
package com.tencent.mtt.external.market.inhost;
import android.app.Activity;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.database.sqlite.SQLiteDatabase;
import android.os.Bundle;
import android.text.TextUtils;
import android.util.SparseArray;
import android.webkit.ValueCallback;
import com.tencent.common.http.HttpHeader;
import com.tencent.common.manifest.EventMessage;
import com.tencent.common.manifest.annotation.CreateMethod;
import com.tencent.common.manifest.annotation.EventReceiver;
import com.tencent.common.manifest.annotation.ExtensionImpl;
import com.tencent.common.manifest.annotation.ServiceImpl;
import com.tencent.common.threadpool.BrowserExecutorSupplier;
import com.tencent.connect.common.Constants;
import com.tencent.mm.opensdk.modelmsg.WXVideoFileObject;
import com.tencent.mtt.ContextHolder;
import com.tencent.mtt.R;
import com.tencent.mtt.base.db.DBTableUtils;
import com.tencent.mtt.base.functionwindow.IFunctionWindow;
import com.tencent.mtt.base.functionwindow.IFunctionWndFactory;
import com.tencent.mtt.base.functionwindow.IFuncwindowExtension;
import com.tencent.mtt.base.functionwindow.MttFunctionwindowProxy;
import com.tencent.mtt.base.nativeframework.NativePageBuilderListener;
import com.tencent.mtt.base.notification.facade.IMessageBubbleListener;
import com.tencent.mtt.base.notification.facade.IMessageBubbleService;
import com.tencent.mtt.base.notification.facade.NormalMessageBundle;
import com.tencent.mtt.base.skin.MttResources;
import com.tencent.mtt.base.wup.GUIDManager;
import com.tencent.mtt.browser.download.core.impl.DownloadServiceManager;
import com.tencent.mtt.browser.download.engine.DownloadTask;
import com.tencent.mtt.browser.file.facade.IFileOpenManager;
import com.tencent.mtt.browser.jsextension.facade.IJsapiModule;
import com.tencent.mtt.browser.window.IWebView;
import com.tencent.mtt.browser.window.IWebViewClient;
import com.tencent.mtt.browser.window.UrlParams;
import com.tencent.mtt.browser.window.WindowManager;
import com.tencent.mtt.businesscenter.facade.IFrameworkDelegate;
import com.tencent.mtt.common.dao.ext.DBUpgradeUtil;
import com.tencent.mtt.external.market.QQMarketSoftUpdateManager;
import com.tencent.mtt.external.market.facade.APKDownloadTaskAnnotation;
import com.tencent.mtt.external.market.facade.ApkDownloadStatInfo;
import com.tencent.mtt.external.market.facade.IMarketService;
import com.tencent.mtt.external.market.facade.MarketSoftUpdateListener;
import com.tencent.mtt.external.market.jsapi.JsMarketImpl;
import com.tencent.mtt.external.market.stat.QQMarketNormalReportHelper;
import com.tencent.mtt.external.market.utils.QQMarketApkInstallUtils;
import com.tencent.mtt.external.market.utils.QQMarketProtocolUtils;
import com.tencent.mtt.qbcontext.core.QBContext;
import com.tencent.mtt.qbinfo.QUAUtils;
import com.tencent.mtt.qbinfo.UserAgentUtils;
import com.tencent.mtt.view.toast.MttToaster;
import java.io.BufferedReader;
import java.io.Closeable;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.net.HttpURLConnection;
import java.net.URL;
import java.util.HashMap;
import org.json.JSONException;
import org.json.JSONObject;
import qb.a.h;
@ServiceImpl(createMethod = CreateMethod.GET, service = IMarketService.class)
@ExtensionImpl(createMethod = CreateMethod.GET, extension = IFuncwindowExtension.class, filters = {IFunctionWndFactory.WND_MARKET})
public class MarketService implements IFuncwindowExtension, IMarketService {
private static MarketService f53941a;
private MarketService() {
}
public void a(int i, ValueCallback<JSONObject> valueCallback) {
JSONObject jSONObject = new JSONObject();
try {
jSONObject.put("code", -1001);
jSONObject.put("message", i);
} catch (JSONException unused) {
}
if (valueCallback != null) {
valueCallback.onReceiveValue(jSONObject);
}
}
public void a(ValueCallback<JSONObject> valueCallback) {
JSONObject jSONObject = new JSONObject();
try {
jSONObject.put("code", -1002);
} catch (JSONException unused) {
}
if (valueCallback != null) {
valueCallback.onReceiveValue(jSONObject);
}
}
public void a(Closeable closeable) {
if (closeable != null) {
try {
closeable.close();
} catch (Exception unused) {
}
}
}
public static MarketService getInstance() {
if (f53941a == null) {
synchronized (MarketService.class) {
if (f53941a == null) {
f53941a = new MarketService();
}
}
}
return f53941a;
}
public int a(String str) {
return QQMarketUtils.b(str);
}
public IFunctionWindow a(Context context, MttFunctionwindowProxy mttFunctionwindowProxy) {
return new QQMarketController(context, mttFunctionwindowProxy);
}
public IWebView a(Context context, IWebViewClient iWebViewClient, UrlParams urlParams, MttFunctionwindowProxy mttFunctionwindowProxy, NativePageBuilderListener nativePageBuilderListener, int i) {
return new QQMarketPageBuilder(context, iWebViewClient, urlParams, null, nativePageBuilderListener, i).a();
}
public String a(DownloadTask downloadTask) {
return QQMarketProxy.getInstance().a(downloadTask);
}
public void a() {
try {
IntentFilter intentFilter = new IntentFilter();
intentFilter.addAction("android.intent.action.PACKAGE_ADDED");
intentFilter.addAction("android.intent.action.PACKAGE_REPLACED");
intentFilter.addAction("android.intent.action.PACKAGE_REMOVED");
intentFilter.addDataScheme("package");
ContextHolder.getAppContext().registerReceiver(new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
if (intent != null) {
String action = intent.getAction();
if (action.equalsIgnoreCase("android.intent.action.PACKAGE_ADDED") || action.equalsIgnoreCase("android.intent.action.PACKAGE_REMOVED") || action.equalsIgnoreCase("android.intent.action.PACKAGE_REPLACED")) {
QQMarketSoftUpdateManager.getInstance().a(intent);
}
}
}
}, intentFilter);
} catch (Exception unused) {
}
}
public void a(Bundle bundle) {
DownloadInfoStatManager.getInstance().a(bundle);
}
public void a(String str, String str2) {
QQMarketProxy.getInstance().b(str, str2);
}
public void a(HashMap<String, String> hashMap) {
new byte[1][0] = 1;
QQMarketNormalReportHelper.a().a(QQMarketProtocolUtils.a(hashMap));
}
public void a(JSONObject jSONObject) {
QQMarketProxy.getInstance().a(jSONObject);
}
@Override
public void addSoftUpdateListener(MarketSoftUpdateListener marketSoftUpdateListener) {
QQMarketSoftUpdateManager.getInstance().a(marketSoftUpdateListener);
}
public void b() {
BrowserExecutorSupplier.forMainThreadTasks().execute(new Runnable() {
@Override
public void run() {
IWebView currentWebView = WindowManager.a().s().getCurrentWebView();
if ((currentWebView == null || TextUtils.isEmpty(currentWebView.getUrl()) || !currentWebView.getUrl().startsWith("qb://pagedownload/downloadhomepage")) ? false : true) {
return;
}
Bundle bundle = new Bundle();
bundle.putBoolean("download_notify_from", true);
UrlParams urlParams = new UrlParams("qb://pagedownload/downloadhomepage");
urlParams.a(bundle);
urlParams.d(true);
((IFrameworkDelegate) QBContext.getInstance().getService(IFrameworkDelegate.class)).doLoad(urlParams);
}
});
}
public void b(String str) {
((IFrameworkDelegate) QBContext.getInstance().getService(IFrameworkDelegate.class)).doLoad(new UrlParams(str).d(true));
}
@Override
public IFunctionWindow createWindow(Context context, String str, MttFunctionwindowProxy mttFunctionwindowProxy) {
return a(context, mttFunctionwindowProxy);
}
@Override
public void downloadReportToNormalReport(JSONObject jSONObject) {
if (jSONObject == null) {
return;
}
QQMarketNormalReportHelper.a().a(jSONObject);
}
@Override
public SparseArray<String> getInfoFromTaskAnnotation(DownloadTask downloadTask) {
QQMarketProxy.getInstance();
return QQMarketProxy.b(downloadTask);
}
@Override
public IJsapiModule getJsMarketModuleImpl(Context context) {
return new JsMarketImpl(context);
}
@Override
public int getPageType(String str) {
return QQMarketUtils.a(str);
}
@Override
public String getSource(DownloadTask downloadTask) {
return DownloadInfoStatManager.a(downloadTask);
}
@Override
public void installApk(DownloadTask downloadTask, String str, Context context) {
QQMarketApkInstallUtils.InstallParam installParam = new QQMarketApkInstallUtils.InstallParam();
installParam.e = str;
installParam.f54159d = downloadTask.m();
installParam.f54156a = a(downloadTask);
installParam.f54158c = downloadTask.r();
installParam.f54157b = downloadTask.w();
installParam.f = new APKDownloadTaskAnnotation(downloadTask).t || (downloadTask.ay() & WXVideoFileObject.FILE_SIZE_LIMIT) > 0;
QQMarketApkInstallUtils.a(context, installParam);
}
@EventReceiver(createMethod = CreateMethod.GET, eventName = "browser.business.process.intent5")
public void onProcessIntentMsg(EventMessage eventMessage) {
IMarketService iMarketService;
if (eventMessage.arg instanceof Bundle) {
Bundle bundle = (Bundle) eventMessage.arg;
ApkDownloadStatInfo apkDownloadStatInfo = new ApkDownloadStatInfo();
apkDownloadStatInfo.f53911a = "4";
apkDownloadStatInfo.f = "3";
apkDownloadStatInfo.f53914d = bundle.getString("pkgName");
apkDownloadStatInfo.e = bundle.getString("taskUrl");
apkDownloadStatInfo.f53913c = bundle.getString("source");
((IMarketService) QBContext.getInstance().getService(IMarketService.class)).stat(apkDownloadStatInfo);
if (Constants.VIA_SHARE_TYPE_MINI_PROGRAM.equalsIgnoreCase(apkDownloadStatInfo.f53913c) && (iMarketService = (IMarketService) QBContext.getInstance().getService(IMarketService.class)) != null) {
iMarketService.statReservePush(0, "outside", apkDownloadStatInfo.f53914d, "1", "4", "7", "8");
iMarketService.statReserve("click_push", apkDownloadStatInfo.f53914d);
}
a(bundle);
}
}
@EventReceiver(createMethod = CreateMethod.GET, eventName = "com.tencent.mtt.browser.push.event.POST_CREATE")
public void onPushPostCreate(EventMessage eventMessage) {
a();
}
@Override
public void queryGamePortalStateNew(final String str, final ValueCallback<JSONObject> valueCallback) {
if (!TextUtils.isEmpty(str)) {
BrowserExecutorSupplier.postForBackgroundTasks(new BrowserExecutorSupplier.BackgroundRunable() {
@Override
public void doRun() {
BufferedReader bufferedReader;
Throwable th;
HttpURLConnection httpURLConnection;
InputStream inputStream = null;
try {
httpURLConnection = (HttpURLConnection) new URL("https://open.nfa.qq.com/api/reserveStatus?gameId=" + str).openConnection();
try {
httpURLConnection.setRequestMethod("GET");
httpURLConnection.setRequestProperty(HttpHeader.REQ.QGUID, GUIDManager.a().f());
httpURLConnection.setRequestProperty(HttpHeader.REQ.QUA2, QUAUtils.a());
httpURLConnection.setRequestProperty("User-agent", UserAgentUtils.a(0));
httpURLConnection.setConnectTimeout(5000);
httpURLConnection.setReadTimeout(3000);
httpURLConnection.connect();
int responseCode = httpURLConnection.getResponseCode();
if (responseCode == 200) {
InputStream inputStream2 = httpURLConnection.getInputStream();
try {
bufferedReader = new BufferedReader(new InputStreamReader(inputStream2));
try {
StringBuffer stringBuffer = new StringBuffer();
while (true) {
String readLine = bufferedReader.readLine();
if (readLine == null) {
break;
}
stringBuffer.append(readLine + "\n");
}
String stringBuffer2 = stringBuffer.toString();
if (!TextUtils.isEmpty(stringBuffer2)) {
JSONObject jSONObject = new JSONObject(stringBuffer2);
if (valueCallback != null) {
valueCallback.onReceiveValue(jSONObject);
}
if (httpURLConnection != null) {
httpURLConnection.disconnect();
}
MarketService.this.a(inputStream2);
MarketService.this.a(bufferedReader);
return;
}
inputStream = inputStream2;
} catch (Exception unused) {
inputStream = inputStream2;
if (httpURLConnection != null) {
httpURLConnection.disconnect();
}
MarketService.this.a(inputStream);
MarketService.this.a(bufferedReader);
MarketService.this.a((ValueCallback<JSONObject>) valueCallback);
} catch (Throwable th2) {
th = th2;
inputStream = inputStream2;
if (httpURLConnection != null) {
httpURLConnection.disconnect();
}
MarketService.this.a(inputStream);
MarketService.this.a(bufferedReader);
throw th;
}
} catch (Exception unused2) {
bufferedReader = null;
} catch (Throwable th3) {
th = th3;
bufferedReader = null;
}
} else {
bufferedReader = null;
}
try {
MarketService.this.a(responseCode, (ValueCallback<JSONObject>) valueCallback);
if (httpURLConnection != null) {
httpURLConnection.disconnect();
}
MarketService.this.a(inputStream);
MarketService.this.a(bufferedReader);
} catch (Exception unused3) {
if (httpURLConnection != null) {
}
MarketService.this.a(inputStream);
MarketService.this.a(bufferedReader);
MarketService.this.a((ValueCallback<JSONObject>) valueCallback);
} catch (Throwable th4) {
th = th4;
if (httpURLConnection != null) {
}
MarketService.this.a(inputStream);
MarketService.this.a(bufferedReader);
throw th;
}
} catch (Exception unused4) {
bufferedReader = null;
} catch (Throwable th5) {
th = th5;
bufferedReader = null;
}
} catch (Exception unused5) {
httpURLConnection = null;
bufferedReader = null;
} catch (Throwable th6) {
bufferedReader = null;
th = th6;
httpURLConnection = null;
}
}
});
return;
}
JSONObject jSONObject = new JSONObject();
try {
jSONObject.put("code", -1000);
} catch (JSONException unused) {
}
if (valueCallback != null) {
valueCallback.onReceiveValue(jSONObject);
}
}
@EventReceiver(createMethod = CreateMethod.GET, eventName = "browser.business.market.register_report_item")
public void registerReportItem(EventMessage eventMessage) {
a((JSONObject) eventMessage.arg);
}
@Override
public void removeMarketSoftUpdateListener(MarketSoftUpdateListener marketSoftUpdateListener) {
QQMarketSoftUpdateManager.getInstance().b(marketSoftUpdateListener);
}
@Override
public void showInstallNonMarketAppsGuidDialog(final Activity activity, final IMarketService.InstallNonMarketAppsCallback installNonMarketAppsCallback) {
BrowserExecutorSupplier.forMainThreadTasks().execute(new Runnable() {
@Override
public void run() {
QQMarketUtils.a(activity, installNonMarketAppsCallback);
}
});
}
@EventReceiver(createMethod = CreateMethod.GET, eventName = "browser.business.market.show_install_tips")
public void showIntallTips(EventMessage eventMessage) {
final String str = (String) eventMessage.arg;
DownloadTask b2 = DownloadServiceManager.b().b(str);
if (b2 != null) {
NormalMessageBundle normalMessageBundle = new NormalMessageBundle();
normalMessageBundle.f32713d = (1073741824 & b2.ay()) > 0 ? MttResources.a(R.string.b0x, b2.v()) : MttResources.a(R.string.b0y, b2.m());
normalMessageBundle.m = "";
normalMessageBundle.e = MttResources.l(h.z);
normalMessageBundle.f = true;
((IMessageBubbleService) QBContext.getInstance().getService(IMessageBubbleService.class)).showNormalBubble(normalMessageBundle, new IMessageBubbleListener() {
@Override
public void a() {
}
@Override
public void b() {
DownloadTask b3 = DownloadServiceManager.b().b(str);
if (b3 == null) {
MttToaster.show(R.string.b16, 0);
MarketService.this.statReservePush(10200004, "inside", "", "1", "4", "7", "8");
return;
}
IFileOpenManager iFileOpenManager = (IFileOpenManager) QBContext.getInstance().getService(IFileOpenManager.class);
if (iFileOpenManager != null) {
iFileOpenManager.openFileBySystem(b3.O());
}
ApkDownloadStatInfo apkDownloadStatInfo = new ApkDownloadStatInfo();
apkDownloadStatInfo.f53911a = "4";
apkDownloadStatInfo.f = "4";
apkDownloadStatInfo.f53914d = b3.s();
apkDownloadStatInfo.e = b3.j();
apkDownloadStatInfo.f53913c = MarketService.this.getSource(b3);
MarketService.this.stat(apkDownloadStatInfo);
if (Constants.VIA_SHARE_TYPE_MINI_PROGRAM.equalsIgnoreCase(apkDownloadStatInfo.f53913c)) {
MarketService.this.statReservePush(0, "inside", b3.s(), "1", "4", "7", "8");
MarketService.this.statReserve("click_push", apkDownloadStatInfo.f53914d);
}
}
@Override
public void c() {
}
});
}
}
@Override
public void stat(ApkDownloadStatInfo apkDownloadStatInfo) {
DownloadInfoStatManager.getInstance().a(apkDownloadStatInfo);
}
@EventReceiver(createMethod = CreateMethod.GET, eventName = "com.tencent.mtt.browser.search.MARKETSTAT")
public void statMarketInfoFromSearch(EventMessage eventMessage) {
Object obj = eventMessage.arg;
if (obj instanceof HashMap) {
a((HashMap<String, String>) obj);
}
}
@Override
public void statReserve(String str, String str2) {
QQMarketProxy.a(str, str2);
}
@Override
public void statReservePush(int i, String str, String str2, String... strArr) {
QQMarketQAStatManager.a(i, str, str2, strArr);
}
@Override
public void subscribeGamePortalNew(final String str, final ValueCallback<JSONObject> valueCallback) {
if (!TextUtils.isEmpty(str)) {
BrowserExecutorSupplier.postForBackgroundTasks(new BrowserExecutorSupplier.BackgroundRunable() {
@Override
public void doRun() {
BufferedReader bufferedReader;
Throwable th;
HttpURLConnection httpURLConnection;
InputStream inputStream = null;
try {
httpURLConnection = (HttpURLConnection) new URL("https://open.nfa.qq.com/api/reserve?idfa=&type=1&gameId=" + str).openConnection();
try {
httpURLConnection.setRequestMethod("GET");
httpURLConnection.setRequestProperty(HttpHeader.REQ.QGUID, GUIDManager.a().f());
httpURLConnection.setRequestProperty(HttpHeader.REQ.QUA2, QUAUtils.a());
httpURLConnection.setRequestProperty("User-agent", UserAgentUtils.a(0));
httpURLConnection.setConnectTimeout(5000);
httpURLConnection.setReadTimeout(3000);
httpURLConnection.connect();
int responseCode = httpURLConnection.getResponseCode();
if (responseCode == 200) {
InputStream inputStream2 = httpURLConnection.getInputStream();
try {
bufferedReader = new BufferedReader(new InputStreamReader(inputStream2));
try {
StringBuffer stringBuffer = new StringBuffer();
while (true) {
String readLine = bufferedReader.readLine();
if (readLine == null) {
break;
}
stringBuffer.append(readLine + "\n");
}
String stringBuffer2 = stringBuffer.toString();
if (!TextUtils.isEmpty(stringBuffer2)) {
JSONObject jSONObject = new JSONObject(stringBuffer2);
if (valueCallback != null) {
valueCallback.onReceiveValue(jSONObject);
}
if (httpURLConnection != null) {
httpURLConnection.disconnect();
}
MarketService.this.a(inputStream2);
MarketService.this.a(bufferedReader);
return;
}
inputStream = inputStream2;
} catch (Exception unused) {
inputStream = inputStream2;
if (httpURLConnection != null) {
httpURLConnection.disconnect();
}
MarketService.this.a(inputStream);
MarketService.this.a(bufferedReader);
MarketService.this.a((ValueCallback<JSONObject>) valueCallback);
} catch (Throwable th2) {
th = th2;
inputStream = inputStream2;
if (httpURLConnection != null) {
httpURLConnection.disconnect();
}
MarketService.this.a(inputStream);
MarketService.this.a(bufferedReader);
throw th;
}
} catch (Exception unused2) {
bufferedReader = null;
} catch (Throwable th3) {
th = th3;
bufferedReader = null;
}
} else {
bufferedReader = null;
}
try {
MarketService.this.a(responseCode, (ValueCallback<JSONObject>) valueCallback);
if (httpURLConnection != null) {
httpURLConnection.disconnect();
}
MarketService.this.a(inputStream);
MarketService.this.a(bufferedReader);
} catch (Exception unused3) {
if (httpURLConnection != null) {
}
MarketService.this.a(inputStream);
MarketService.this.a(bufferedReader);
MarketService.this.a((ValueCallback<JSONObject>) valueCallback);
} catch (Throwable th4) {
th = th4;
if (httpURLConnection != null) {
}
MarketService.this.a(inputStream);
MarketService.this.a(bufferedReader);
throw th;
}
} catch (Exception unused4) {
bufferedReader = null;
} catch (Throwable th5) {
th = th5;
bufferedReader = null;
}
} catch (Exception unused5) {
httpURLConnection = null;
bufferedReader = null;
} catch (Throwable th6) {
bufferedReader = null;
th = th6;
httpURLConnection = null;
}
}
});
return;
}
JSONObject jSONObject = new JSONObject();
try {
jSONObject.put("code", -1000);
} catch (JSONException unused) {
}
if (valueCallback != null) {
valueCallback.onReceiveValue(jSONObject);
}
}
@EventReceiver(createMethod = CreateMethod.GET, eventName = "browser.business.market.upgrade_market_table")
public void upgradeQQMarketTable(EventMessage eventMessage) {
SQLiteDatabase sQLiteDatabase = (SQLiteDatabase) eventMessage.arg;
String[] a2 = QQMarketContentProvider.a();
DBUpgradeUtil.a(sQLiteDatabase, "softwares", a2, DBTableUtils.a("softwares", a2, QQMarketContentProvider.b()), "DROP TABLE softwares;", null, null, null);
}
@EventReceiver(createMethod = CreateMethod.GET, eventName = "browser.business.stat.application_state_background_or_finish")
public void uploadToBeacon(EventMessage eventMessage) {
DownloadInfoStatManager.getInstance().a();
}
}