package com.tencent.smtt.sdk; import aegon.chrome.net.NetError; import android.content.Context; import android.content.SharedPreferences; import android.os.Build; import android.os.Handler; import android.os.HandlerThread; import android.os.Message; import android.telephony.TelephonyManager; import android.text.TextUtils; import android.util.Log; import com.sigmob.sdk.archives.tar.e; import com.tencent.smtt.sdk.TbsDownloadConfig; import com.tencent.smtt.sdk.TbsListener; import com.tencent.smtt.sdk.TbsLogReport; import com.tencent.smtt.sdk.c; import com.tencent.smtt.utils.Apn; import com.tencent.smtt.utils.FileUtil; import com.tencent.smtt.utils.TbsLog; import com.tencent.smtt.utils.a; import com.tencent.smtt.utils.b; import com.tencent.smtt.utils.f; import com.tencent.smtt.utils.g; import com.tencent.smtt.utils.n; import com.tencent.smtt.utils.r; import java.io.File; import java.io.FileOutputStream; import java.io.IOException; import java.nio.channels.FileLock; import java.util.Locale; import java.util.Map; import java.util.TimeZone; import java.util.regex.Pattern; import org.json.JSONArray; import org.json.JSONObject; public class TbsDownloader { public static final boolean DEBUG_DISABLE_DOWNLOAD = false; public static boolean DOWNLOAD_OVERSEA_TBS = false; public static final String LOGTAG = "TbsDownload"; public static final String TBS_METADATA = "com.tencent.mm.BuildInfo.CLIENT_VERSION"; static boolean a = false; private static String b = null; private static Context c = null; private static Handler d = null; private static String e = null; private static final Object f = new byte[0]; private static m g = null; private static HandlerThread h = null; private static boolean i = false; private static String j = ""; private static String k = ""; private static boolean l = false; private static boolean m = false; private static JSONObject n = null; private static JSONObject o = null; private static boolean p = false; private static int q = 0; private static int r = 0; private static JSONObject s = null; private static long t = -1; public interface TbsDownloaderCallback { void onNeedDownloadFinish(boolean z, int i); } protected static File a(int i2) { String str; String[] coreProviderAppList = TbsShareManager.getCoreProviderAppList(); int length = coreProviderAppList.length; File file = null; int i3 = 0; while (true) { if (i3 >= length) { break; } String str2 = coreProviderAppList[i3]; if (!str2.equals(c.getApplicationInfo().packageName)) { file = new File(FileUtil.a(c, str2, 4, false), getOverSea(c) ? "x5.oversea.tbs.org" : getBackupFileName(false)); if (!file.exists()) { str = "can not find local backup core file"; } else if (a.a(c, file) == i2) { TbsLog.i(LOGTAG, "local tbs version fond,path = " + file.getAbsolutePath()); break; } else { str = "version is not match"; } TbsLog.i(LOGTAG, str); } i3++; } return file; } private static String a(String str) { return str == null ? "" : str; } private static JSONArray a(boolean z) { File file; boolean z2; JSONArray jSONArray = new JSONArray(); for (String str : TbsShareManager.getCoreProviderAppList()) { String a2 = FileUtil.a(c, str, 4, false); if (z) { String backupFileName = getOverSea(c) ? "x5.oversea.tbs.org" : getBackupFileName(false); } else { file = new File(a2, "x5.tbs.decouple"); } if (file.exists()) { long a3 = (long) a.a(c, file); if (a3 > 0) { int i2 = 0; while (true) { if (i2 >= jSONArray.length()) { z2 = false; break; } else if (((long) jSONArray.optInt(i2)) == a3) { z2 = true; break; } else { i2++; } } if (!z2) { jSONArray.put(a3); } } } } return jSONArray; } /* JADX WARNING: Removed duplicated region for block: B:100:0x02cd */ /* JADX WARNING: Removed duplicated region for block: B:103:0x0310 */ /* JADX WARNING: Removed duplicated region for block: B:125:0x0377 */ /* JADX WARNING: Removed duplicated region for block: B:132:0x0390 */ /* JADX WARNING: Removed duplicated region for block: B:133:0x0394 */ /* JADX WARNING: Removed duplicated region for block: B:135:0x0398 */ /* JADX WARNING: Removed duplicated region for block: B:138:0x03a5 */ /* JADX WARNING: Removed duplicated region for block: B:139:0x03ac */ /* JADX WARNING: Removed duplicated region for block: B:141:0x03af */ /* JADX WARNING: Removed duplicated region for block: B:38:0x00f2 A[Catch:{ Exception -> 0x03b5 }] */ /* JADX WARNING: Removed duplicated region for block: B:39:0x00f9 A[Catch:{ Exception -> 0x03b5 }] */ /* JADX WARNING: Removed duplicated region for block: B:42:0x0107 A[Catch:{ Exception -> 0x03b5 }] */ /* JADX WARNING: Removed duplicated region for block: B:46:0x0125 A[Catch:{ Exception -> 0x03b5 }] */ /* JADX WARNING: Removed duplicated region for block: B:64:0x01a5 */ /* JADX WARNING: Removed duplicated region for block: B:65:0x01ac */ /* JADX WARNING: Removed duplicated region for block: B:76:0x01d9 A[Catch:{ Exception -> 0x03b7 }] */ /* JADX WARNING: Removed duplicated region for block: B:79:0x0219 A[Catch:{ Exception -> 0x03b7 }] */ /* JADX WARNING: Removed duplicated region for block: B:88:0x0281 A[Catch:{ Exception -> 0x03b7 }] */ /* JADX WARNING: Removed duplicated region for block: B:91:0x02b0 A[Catch:{ Exception -> 0x03b7 }] */ /* JADX WARNING: Removed duplicated region for block: B:92:0x02b2 A[Catch:{ Exception -> 0x03b7 }] */ /* JADX WARNING: Removed duplicated region for block: B:95:0x02bc A[Catch:{ Exception -> 0x03b7 }] */ /* JADX WARNING: Removed duplicated region for block: B:96:0x02be A[Catch:{ Exception -> 0x03b7 }] */ private static JSONObject a(boolean z, boolean z2, boolean z3) { String str; String str2; boolean z4; int i2; int i3; String str3; boolean z5; int i4; int i5; Object a2; int i6; int i7; String str4; TbsLog.i(LOGTAG, "[TbsDownloader.postJsonData]isQuery: " + z + " forDecoupleCore is " + z3); TbsDownloadConfig instance = TbsDownloadConfig.getInstance(c); String b2 = b(c); String i8 = b.i(c); String h2 = b.h(c); String k2 = b.k(c); String id = TimeZone.getDefault().getID(); String str5 = id != null ? id : ""; try { TelephonyManager telephonyManager = (TelephonyManager) c.getSystemService("phone"); TelephonyManager telephonyManager2 = telephonyManager; if (telephonyManager != null) { id = telephonyManager.getSimCountryIso(); } } catch (Exception e2) { e2.printStackTrace(); } if (id == null) { id = ""; } JSONObject jSONObject = new JSONObject(); if (z3) { try { if (r.b(c)) { jSONObject.put("REQUEST_TPATCH", 1); if (b.c()) { str2 = "TBSDV"; if (n.a(c).c("stable_64_tpatch_fail") == 1) { jSONObject.put("REQUEST_TPATCH", 0); str4 = "[TbsDownloader.postJsonData] stable_64_last_tpatch_fail and set REQUEST_TPATCH 0 "; } z4 = false; jSONObject.put("TIMEZONEID", str5); jSONObject.put("COUNTRYISO", id); if (!b.c()) { i2 = 1; jSONObject.put("REQUEST_64", 1); } else { i2 = 1; } jSONObject.put("PROTOCOLVERSION", i2); if (!TbsShareManager.isThirdPartyApp(c)) { i3 = QbSdk.c ? TbsShareManager.a(c, false) : TbsDownloadConfig.getInstance(c).mPreferences.getInt(TbsDownloadConfig.TbsConfigKey.KEY_TBS_DOWNLOAD_V, 0); } else { i3 = z3 ? p.a().j(c) : p.a().n(c); if (i3 == 0 && p.a().m(c)) { i3 = -1; if (TbsConfig.APP_QQ.equals(c.getApplicationInfo().packageName)) { TbsPVConfig.releaseInstance(); if (TbsPVConfig.getInstance(c).getLocalCoreVersionMoreTimes() == 1) { i3 = p.a().j(c); } } } TbsLog.i(LOGTAG, "[TbsDownloader.postJsonData] tbsLocalVersion=" + i3 + " isDownloadForeground=" + z2); if (z2 && !p.a().m(c)) { i3 = 0; } } if (!z) { jSONObject.put("FUNCTION", 2); str3 = "A"; } else { jSONObject.put("FUNCTION", i3 == 0 ? 0 : 1); str3 = i3 == 0 ? "C" : "B"; } StringBuilder sb = new StringBuilder(); str = LOGTAG; sb.append("2"); sb.append(str3); r.a(sb.toString()); if (!TbsShareManager.isThirdPartyApp(c)) { JSONArray f2 = f(); jSONObject.put("TBSVLARR", f2); j = f2.toString(); r.a("3is" + f2.toString()); instance.mSyncMap.put(TbsDownloadConfig.TbsConfigKey.KEY_LAST_THIRDAPP_SENDREQUEST_COREVERSION, f2.toString()); instance.commit(); if (QbSdk.c) { jSONObject.put("THIRDREQ", 1); } } else { JSONArray a3 = a(z3); if (Apn.getApnType(c) != 3 && a3.length() != 0 && i3 == 0 && z) { jSONObject.put("TBSBACKUPARR", a3); } } jSONObject.put("APPN", c.getPackageName()); jSONObject.put("APPVN", a(instance.mPreferences.getString(TbsDownloadConfig.TbsConfigKey.KEY_APP_VERSIONNAME, null))); jSONObject.put("APPVC", instance.mPreferences.getInt(TbsDownloadConfig.TbsConfigKey.KEY_APP_VERSIONCODE, 0)); jSONObject.put("APPMETA", a(instance.mPreferences.getString(TbsDownloadConfig.TbsConfigKey.KEY_APP_METADATA, null))); jSONObject.put("TBSSDKV", 44181); jSONObject.put("TBSV", i3); if (i3 == 0) { jSONObject.put("ISFORCE", true); } k = "" + i3; r.a("4is" + i3); jSONObject.put("DOWNLOADDECOUPLECORE", !z3 ? 1 : 0); instance.mSyncMap.put(TbsDownloadConfig.TbsConfigKey.KEY_DOWNLOADDECOUPLECORE, Integer.valueOf(!z3 ? 1 : 0)); instance.commit(); if (i3 != 0) { jSONObject.put("TBSBACKUPV", g.c(z3)); } jSONObject.put("CPU", e); jSONObject.put("UA", b2); jSONObject.put("IMSI", a(i8)); jSONObject.put("IMEI", a(h2)); jSONObject.put("ANDROID_ID", a(k2)); jSONObject.put("GUID", b.f(c)); if (!TbsShareManager.isThirdPartyApp(c)) { if (i3 != 0) { jSONObject.put("STATUS", QbSdk.a(c, i3) ? 0 : 1); i6 = 0; } else { i6 = 0; jSONObject.put("STATUS", 0); } if (r.b(c)) { i7 = TbsShareManager.getTbsStableCoreVersion(c, i6); if (z3 && i7 > 0 && jSONObject.getInt("FUNCTION") == 0) { jSONObject.put("FUNCTION", 1); } } else { i7 = p.a().i(c); } jSONObject.put(str2, i3 % 10000); jSONObject.put("TBSBACKUPV", i7); if (z4) { jSONObject.put(str2, 0); jSONObject.put("TBSBACKUPV", 0); } } boolean z6 = TbsDownloadConfig.getInstance(c).mPreferences.getBoolean(TbsDownloadConfig.TbsConfigKey.KEY_FULL_PACKAGE, false); if (!((QbSdk.isEnableSensitiveApi() || (a2 = QbSdk.a(c, "can_unlzma", null)) == null || !(a2 instanceof Boolean)) ? false : ((Boolean) a2).booleanValue())) { i4 = 1; z5 = !z6; } else { i4 = 1; z5 = false; } if (z5) { jSONObject.put("REQUEST_LZMA", i4); } if (!getOverSea(c)) { i5 = 1; jSONObject.put("OVERSEA", 1); } else { i5 = 1; } if (z2) { jSONObject.put("DOWNLOAD_FOREGROUND", i5); } TbsLog.i(str, "[TbsDownloader.postJsonData] jsonData=" + jSONObject.toString()); return jSONObject; } str2 = "TBSDV"; if (n.a(c).c("stable_32_tpatch_fail") == 1) { jSONObject.put("REQUEST_TPATCH", 0); str4 = "[TbsDownloader.postJsonData] stable_32_last_tpatch_fail and set REQUEST_TPATCH 0 "; } z4 = false; jSONObject.put("TIMEZONEID", str5); jSONObject.put("COUNTRYISO", id); if (!b.c()) { } jSONObject.put("PROTOCOLVERSION", i2); if (!TbsShareManager.isThirdPartyApp(c)) { } if (!z) { } StringBuilder sb2 = new StringBuilder(); str = LOGTAG; sb2.append("2"); sb2.append(str3); r.a(sb2.toString()); if (!TbsShareManager.isThirdPartyApp(c)) { } jSONObject.put("APPN", c.getPackageName()); jSONObject.put("APPVN", a(instance.mPreferences.getString(TbsDownloadConfig.TbsConfigKey.KEY_APP_VERSIONNAME, null))); jSONObject.put("APPVC", instance.mPreferences.getInt(TbsDownloadConfig.TbsConfigKey.KEY_APP_VERSIONCODE, 0)); jSONObject.put("APPMETA", a(instance.mPreferences.getString(TbsDownloadConfig.TbsConfigKey.KEY_APP_METADATA, null))); jSONObject.put("TBSSDKV", 44181); jSONObject.put("TBSV", i3); if (i3 == 0) { } k = "" + i3; r.a("4is" + i3); jSONObject.put("DOWNLOADDECOUPLECORE", !z3 ? 1 : 0); instance.mSyncMap.put(TbsDownloadConfig.TbsConfigKey.KEY_DOWNLOADDECOUPLECORE, Integer.valueOf(!z3 ? 1 : 0)); instance.commit(); if (i3 != 0) { } jSONObject.put("CPU", e); jSONObject.put("UA", b2); jSONObject.put("IMSI", a(i8)); jSONObject.put("IMEI", a(h2)); jSONObject.put("ANDROID_ID", a(k2)); jSONObject.put("GUID", b.f(c)); if (!TbsShareManager.isThirdPartyApp(c)) { } boolean z62 = TbsDownloadConfig.getInstance(c).mPreferences.getBoolean(TbsDownloadConfig.TbsConfigKey.KEY_FULL_PACKAGE, false); if (!((QbSdk.isEnableSensitiveApi() || (a2 = QbSdk.a(c, "can_unlzma", null)) == null || !(a2 instanceof Boolean)) ? false : ((Boolean) a2).booleanValue())) { } if (z5) { } if (!getOverSea(c)) { } if (z2) { } TbsLog.i(str, "[TbsDownloader.postJsonData] jsonData=" + jSONObject.toString()); return jSONObject; TbsLog.i(LOGTAG, str4); z4 = true; jSONObject.put("TIMEZONEID", str5); jSONObject.put("COUNTRYISO", id); if (!b.c()) { } jSONObject.put("PROTOCOLVERSION", i2); if (!TbsShareManager.isThirdPartyApp(c)) { } if (!z) { } StringBuilder sb22 = new StringBuilder(); str = LOGTAG; sb22.append("2"); sb22.append(str3); r.a(sb22.toString()); if (!TbsShareManager.isThirdPartyApp(c)) { } jSONObject.put("APPN", c.getPackageName()); jSONObject.put("APPVN", a(instance.mPreferences.getString(TbsDownloadConfig.TbsConfigKey.KEY_APP_VERSIONNAME, null))); jSONObject.put("APPVC", instance.mPreferences.getInt(TbsDownloadConfig.TbsConfigKey.KEY_APP_VERSIONCODE, 0)); jSONObject.put("APPMETA", a(instance.mPreferences.getString(TbsDownloadConfig.TbsConfigKey.KEY_APP_METADATA, null))); jSONObject.put("TBSSDKV", 44181); jSONObject.put("TBSV", i3); if (i3 == 0) { } k = "" + i3; r.a("4is" + i3); jSONObject.put("DOWNLOADDECOUPLECORE", !z3 ? 1 : 0); instance.mSyncMap.put(TbsDownloadConfig.TbsConfigKey.KEY_DOWNLOADDECOUPLECORE, Integer.valueOf(!z3 ? 1 : 0)); instance.commit(); if (i3 != 0) { } jSONObject.put("CPU", e); jSONObject.put("UA", b2); jSONObject.put("IMSI", a(i8)); jSONObject.put("IMEI", a(h2)); jSONObject.put("ANDROID_ID", a(k2)); jSONObject.put("GUID", b.f(c)); if (!TbsShareManager.isThirdPartyApp(c)) { } boolean z622 = TbsDownloadConfig.getInstance(c).mPreferences.getBoolean(TbsDownloadConfig.TbsConfigKey.KEY_FULL_PACKAGE, false); if (!((QbSdk.isEnableSensitiveApi() || (a2 = QbSdk.a(c, "can_unlzma", null)) == null || !(a2 instanceof Boolean)) ? false : ((Boolean) a2).booleanValue())) { } if (z5) { } if (!getOverSea(c)) { } if (z2) { } TbsLog.i(str, "[TbsDownloader.postJsonData] jsonData=" + jSONObject.toString()); return jSONObject; } } catch (Exception unused) { str = LOGTAG; } } str2 = "TBSDV"; jSONObject.put("REQUEST_TPATCH", n.a(c).c("tpatch_num") < 5 ? TbsShareManager.isThirdPartyApp(c) ? 2 : 1 : 0); z4 = false; jSONObject.put("TIMEZONEID", str5); jSONObject.put("COUNTRYISO", id); if (!b.c()) { } jSONObject.put("PROTOCOLVERSION", i2); if (!TbsShareManager.isThirdPartyApp(c)) { } if (!z) { } StringBuilder sb222 = new StringBuilder(); str = LOGTAG; try { sb222.append("2"); sb222.append(str3); r.a(sb222.toString()); if (!TbsShareManager.isThirdPartyApp(c)) { } jSONObject.put("APPN", c.getPackageName()); jSONObject.put("APPVN", a(instance.mPreferences.getString(TbsDownloadConfig.TbsConfigKey.KEY_APP_VERSIONNAME, null))); jSONObject.put("APPVC", instance.mPreferences.getInt(TbsDownloadConfig.TbsConfigKey.KEY_APP_VERSIONCODE, 0)); jSONObject.put("APPMETA", a(instance.mPreferences.getString(TbsDownloadConfig.TbsConfigKey.KEY_APP_METADATA, null))); jSONObject.put("TBSSDKV", 44181); jSONObject.put("TBSV", i3); if (i3 == 0) { } k = "" + i3; r.a("4is" + i3); jSONObject.put("DOWNLOADDECOUPLECORE", !z3 ? 1 : 0); instance.mSyncMap.put(TbsDownloadConfig.TbsConfigKey.KEY_DOWNLOADDECOUPLECORE, Integer.valueOf(!z3 ? 1 : 0)); instance.commit(); if (i3 != 0) { } jSONObject.put("CPU", e); jSONObject.put("UA", b2); jSONObject.put("IMSI", a(i8)); jSONObject.put("IMEI", a(h2)); jSONObject.put("ANDROID_ID", a(k2)); jSONObject.put("GUID", b.f(c)); if (!TbsShareManager.isThirdPartyApp(c)) { } boolean z6222 = TbsDownloadConfig.getInstance(c).mPreferences.getBoolean(TbsDownloadConfig.TbsConfigKey.KEY_FULL_PACKAGE, false); if (!((QbSdk.isEnableSensitiveApi() || (a2 = QbSdk.a(c, "can_unlzma", null)) == null || !(a2 instanceof Boolean)) ? false : ((Boolean) a2).booleanValue())) { } if (z5) { } if (!getOverSea(c)) { } if (z2) { } } catch (Exception unused2) { } TbsLog.i(str, "[TbsDownloader.postJsonData] jsonData=" + jSONObject.toString()); return jSONObject; } private static void a(JSONArray jSONArray) { boolean z; String[] e2 = e(); for (String str : e2) { int stableCoreVersion = TbsShareManager.getStableCoreVersion(c, str); if (stableCoreVersion > 0) { Context packageContext = TbsShareManager.getPackageContext(c, str, false); if (packageContext == null || p.a().g(packageContext)) { int i2 = 0; while (true) { if (i2 >= jSONArray.length()) { z = false; break; } else if (jSONArray.optInt(i2) == stableCoreVersion) { z = true; break; } else { i2++; } } if (!z) { TbsLog.i(LOGTAG, "addStableVersionToJsonData,pkg=" + str + ";version=" + stableCoreVersion); jSONArray.put(stableCoreVersion); } } else { TbsLog.e(LOGTAG, "addStableVersionToJsonData,host check failed,packageName = " + str); } } } } private static void a(boolean z, TbsDownloaderCallback tbsDownloaderCallback, boolean z2) { TbsLog.i(LOGTAG, "[TbsDownloader.queryConfig]"); d.removeMessages(100); Message obtain = Message.obtain(d, 100); if (tbsDownloaderCallback != null) { obtain.obj = tbsDownloaderCallback; } obtain.arg1 = 0; obtain.arg1 = z ? 1 : 0; obtain.arg2 = z2 ? 1 : 0; obtain.sendToTarget(); } private static boolean a(int i2, int i3, int i4) { try { TbsLog.i(LOGTAG, "copyFromOldBackupDone newCoreVersion is " + i2 + " localStableCoreVersion is " + i3 + " cpuType is " + i4); if (i2 > 0 && i2 != i3) { File file = new File(FileUtil.a(c, 3), getBackupFileName(false, i4)); int i5 = -1; if (file.exists() && file.canRead() && (i5 = a.b(file)) <= 0) { i5 = a.a(c, file); } r = i5; TbsLog.i(LOGTAG, "copyFromOldBackupDone oldBackupCoreVersion is " + i5); if (i2 == i5) { File file2 = new File(FileUtil.a(c, TbsConfig.APP_WX, 4, true)); boolean b2 = FileUtil.b(file, new File(file2, getBackupFileName(false, i4))); TbsLog.i(LOGTAG, "copyFromOldBackupDone #01 result is " + b2); if (b2) { File[] listFiles = file2.listFiles(); Pattern compile = Pattern.compile(a.a(false, i4)); for (File file3 : listFiles) { if (compile.matcher(file3.getName()).find() && file3.isFile() && file3.exists()) { file3.delete(); } } File file4 = new File(file2, a.a(false, i4) + "." + i2); if (!file4.exists()) { file4.createNewFile(); } } return b2; } } } catch (Throwable th) { TbsLog.i(LOGTAG, "stack is " + Log.getStackTraceString(th)); } TbsLog.i(LOGTAG, "copyFromOldBackupDone result is false #10"); return false; } static boolean a(Context context) { return TbsDownloadConfig.getInstance(context).mPreferences.getInt(TbsDownloadConfig.TbsConfigKey.KEY_DOWNLOADDECOUPLECORE, 0) == 1; } static boolean a(Context context, int i2) { return Build.VERSION.SDK_INT > 28 && context.getApplicationInfo().targetSdkVersion > 28 && i2 > 0 && i2 < 45114; } private static boolean a(Context context, boolean z) { int i2; TbsDownloadConfig instance = TbsDownloadConfig.getInstance(context); if (Build.VERSION.SDK_INT < 8) { i2 = -102; } else { if (!instance.mPreferences.contains(TbsDownloadConfig.TbsConfigKey.KEY_IS_OVERSEA)) { if (z && !TbsConfig.APP_WX.equals(context.getApplicationInfo().packageName)) { TbsLog.i(LOGTAG, "needDownload-oversea is true, but not WX"); z = false; } instance.mSyncMap.put(TbsDownloadConfig.TbsConfigKey.KEY_IS_OVERSEA, Boolean.valueOf(z)); instance.commit(); l = z; TbsLog.i(LOGTAG, "needDownload-first-called--isoversea = " + z); } if (!getOverSea(context) || Build.VERSION.SDK_INT == 16 || Build.VERSION.SDK_INT == 17 || Build.VERSION.SDK_INT == 18) { String string = instance.mPreferences.getString(TbsDownloadConfig.TbsConfigKey.KEY_DEVICE_CPUABI, null); e = string; if (TextUtils.isEmpty(string) || b.a(e)) { return true; } TbsLog.e(LOGTAG, "can not support x86 devices!!"); i2 = NetError.ERR_CONNECTION_FAILED; } else { TbsLog.i(LOGTAG, "needDownload- return false, because of version is " + Build.VERSION.SDK_INT + ", and overea"); i2 = -103; } } instance.setDownloadInterruptCode(i2); return false; } private static boolean a(Context context, boolean z, boolean z2) { boolean z3; String str; String str2; final TbsDownloadConfig instance = TbsDownloadConfig.getInstance(context); c.a().a(context, (Integer) 1000, (c.a) new c.a() { /* class com.tencent.smtt.sdk.TbsDownloader.AnonymousClass1 */ @Override // com.tencent.smtt.sdk.c.a public void a(String str) { TbsLog.i(TbsDownloader.LOGTAG, "Execute command [1000](" + str + "), force tbs downloader request"); SharedPreferences.Editor edit = instance.mPreferences.edit(); edit.putLong(TbsDownloadConfig.TbsConfigKey.KEY_LAST_CHECK, 0); edit.apply(); } }); if (!z) { String string = instance.mPreferences.getString(TbsDownloadConfig.TbsConfigKey.KEY_APP_VERSIONNAME, null); int i2 = instance.mPreferences.getInt(TbsDownloadConfig.TbsConfigKey.KEY_APP_VERSIONCODE, 0); String string2 = instance.mPreferences.getString(TbsDownloadConfig.TbsConfigKey.KEY_APP_METADATA, null); String d2 = b.d(c); int e2 = b.e(c); String a2 = b.a(c, TBS_METADATA); TbsLog.i(LOGTAG, "[TbsDownloader.needSendQueryRequest] appVersionName=" + d2 + " oldAppVersionName=" + string + " appVersionCode=" + e2 + " oldAppVersionCode=" + i2 + " appMetadata=" + a2 + " oldAppVersionMetadata=" + string2); long currentTimeMillis = System.currentTimeMillis(); long j2 = instance.mPreferences.getLong(TbsDownloadConfig.TbsConfigKey.KEY_LAST_CHECK, 0); StringBuilder sb = new StringBuilder(); sb.append("[TbsDownloader.needSendQueryRequest] timeLastCheck="); sb.append(j2); sb.append(" timeNow="); sb.append(currentTimeMillis); TbsLog.i(LOGTAG, sb.toString()); if (z2) { boolean contains = instance.mPreferences.contains(TbsDownloadConfig.TbsConfigKey.KEY_LAST_CHECK); TbsLog.i(LOGTAG, "[TbsDownloader.needSendQueryRequest] hasLaskCheckKey=" + contains); if (contains && j2 == 0) { j2 = currentTimeMillis; } } long j3 = instance.mPreferences.getLong(TbsDownloadConfig.TbsConfigKey.KEY_LAST_REQUEST_SUCCESS, 0); long j4 = instance.mPreferences.getLong(TbsDownloadConfig.TbsConfigKey.KEY_COUNT_REQUEST_FAIL_IN_24HOURS, 0); long retryInterval = instance.getRetryInterval(); TbsLog.i(LOGTAG, "retryInterval = " + retryInterval + " s"); TbsPVConfig.releaseInstance(); int emergentCoreVersion = TbsPVConfig.getInstance(c).getEmergentCoreVersion(); int i3 = TbsDownloadConfig.getInstance(c).mPreferences.getInt(TbsDownloadConfig.TbsConfigKey.KEY_TBS_DOWNLOAD_V, 0); long j5 = currentTimeMillis - j2; long j6 = retryInterval * 1000; if (j5 > j6) { str2 = "needSendRequest true #1"; } else if (emergentCoreVersion > p.a().j(c) && emergentCoreVersion > i3) { str2 = "emergentCoreVersion is " + emergentCoreVersion + " getTbsCoreInstalledVerInNolock is " + p.a().j(c) + " responseCoreVersion is " + i3; } else if (TbsShareManager.isThirdPartyApp(c) && j3 > 0 && currentTimeMillis - j3 > j6 && j4 < 11) { str2 = "needSendRequest true #3"; } else if (!TbsShareManager.isThirdPartyApp(c) || TbsShareManager.findCoreForThirdPartyApp(c) != 0 || d()) { if (d2 == null || e2 == 0 || a2 == null) { if (TbsShareManager.isThirdPartyApp(c)) { str = "timeNow - timeLastCheck is " + j5 + " TbsShareManager.findCoreForThirdPartyApp(sAppContext) is " + TbsShareManager.findCoreForThirdPartyApp(c) + " sendRequestWithSameHostCoreVersion() is " + d() + " appVersionName is " + d2 + " appVersionCode is " + e2 + " appMetadata is " + a2 + " oldAppVersionName is " + string + " oldAppVersionCode is " + i2 + " oldAppVersionMetadata is " + string2; z3 = false; if (!z3 && TbsShareManager.isThirdPartyApp(c)) { TbsLogReport.TbsLogInfo tbsLogInfo = TbsLogReport.getInstance(c).tbsLogInfo(); tbsLogInfo.setErrorCode(NetError.ERR_HOST_RESOLVER_QUEUE_TOO_LARGE); tbsLogInfo.setFailDetail(str); TbsLogReport.getInstance(c).eventReport(TbsLogReport.EventType.TYPE_DOWNLOAD, tbsLogInfo); } return z3; } } else if (!d2.equals(string) || e2 != i2 || !a2.equals(string2)) { str2 = "needSendRequest true #5"; } str = null; z3 = false; TbsLogReport.TbsLogInfo tbsLogInfo2 = TbsLogReport.getInstance(c).tbsLogInfo(); tbsLogInfo2.setErrorCode(NetError.ERR_HOST_RESOLVER_QUEUE_TOO_LARGE); tbsLogInfo2.setFailDetail(str); TbsLogReport.getInstance(c).eventReport(TbsLogReport.EventType.TYPE_DOWNLOAD, tbsLogInfo2); return z3; } else { TbsLog.i(LOGTAG, "needSendRequest true #4"); p.a().e(c); str = null; z3 = true; TbsLogReport.TbsLogInfo tbsLogInfo22 = TbsLogReport.getInstance(c).tbsLogInfo(); tbsLogInfo22.setErrorCode(NetError.ERR_HOST_RESOLVER_QUEUE_TOO_LARGE); tbsLogInfo22.setFailDetail(str); TbsLogReport.getInstance(c).eventReport(TbsLogReport.EventType.TYPE_DOWNLOAD, tbsLogInfo22); return z3; } } else { str2 = "needSendRequest true download foreground, stack: " + Log.getStackTraceString(new Throwable()); } TbsLog.i(LOGTAG, str2); str = null; z3 = true; TbsLogReport.TbsLogInfo tbsLogInfo222 = TbsLogReport.getInstance(c).tbsLogInfo(); tbsLogInfo222.setErrorCode(NetError.ERR_HOST_RESOLVER_QUEUE_TOO_LARGE); tbsLogInfo222.setFailDetail(str); TbsLogReport.getInstance(c).eventReport(TbsLogReport.EventType.TYPE_DOWNLOAD, tbsLogInfo222); return z3; } /* JADX WARNING: Removed duplicated region for block: B:232:0x0767 */ /* JADX WARNING: Removed duplicated region for block: B:43:0x0182 A[Catch:{ all -> 0x0189 }] */ /* JADX WARNING: Removed duplicated region for block: B:44:0x0184 A[Catch:{ all -> 0x0189 }] */ /* JADX WARNING: Removed duplicated region for block: B:49:0x01a6 */ /* JADX WARNING: Removed duplicated region for block: B:72:0x029b */ /* JADX WARNING: Removed duplicated region for block: B:73:0x029d */ /* JADX WARNING: Removed duplicated region for block: B:76:0x02a9 */ /* JADX WARNING: Removed duplicated region for block: B:77:0x02ab */ /* JADX WARNING: Removed duplicated region for block: B:80:0x02b6 */ private static boolean a(String str, int i2, boolean z, boolean z2, boolean z3) throws Exception { int i3; String str2; long j2; int i4; int i5; boolean z4; int i6; Integer num; boolean z5; String str3; String str4; boolean z6; String str5; int tbsVersion; TbsLog.i(LOGTAG, "[TbsDownloader.readResponse] response=" + str + "isNeedInstall=" + z3); TbsDownloadConfig instance = TbsDownloadConfig.getInstance(c); if (TextUtils.isEmpty(str)) { instance.setDownloadInterruptCode(NetError.ERR_ADDRESS_INVALID); TbsLog.i(LOGTAG, "[TbsDownloader.readResponse] return #1,response is empty..."); return false; } JSONObject jSONObject = new JSONObject(str); int i7 = jSONObject.getInt("RET"); if (i7 != 0) { instance.setDownloadInterruptCode(NetError.ERR_ADDRESS_UNREACHABLE); TbsLog.i(LOGTAG, "[TbsDownloader.readResponse] return #2,returnCode=" + i7); return false; } int i8 = jSONObject.getInt("RESPONSECODE"); String string = jSONObject.getString("DOWNLOADURL"); String optString = jSONObject.optString("URLLIST", ""); int i9 = jSONObject.getInt("TBSAPKSERVERVERSION"); if (!QbSdk.isCoreVerEnabled(c, i9)) { instance.setDownloadInterruptCode(NetError.ERR_SSL_BAD_RECORD_MAC_ALERT); return false; } int i10 = jSONObject.getInt("DOWNLOADMAXFLOW") * 2; int i11 = jSONObject.getInt("DOWNLOAD_MIN_FREE_SPACE"); int i12 = jSONObject.getInt("DOWNLOAD_SUCCESS_MAX_RETRYTIMES"); int i13 = jSONObject.getInt("DOWNLOAD_FAILED_MAX_RETRYTIMES"); long j3 = jSONObject.getLong("DOWNLOAD_SINGLE_TIMEOUT"); long j4 = jSONObject.getLong("TBSAPKFILESIZE"); long optLong = jSONObject.optLong("RETRY_INTERVAL", 0); int optInt = jSONObject.optInt("FLOWCTR", -1); int optInt2 = jSONObject.optInt("USEX5", 1); i(); h(); if (optInt2 == 0 && (tbsVersion = QbSdk.getTbsVersion(c)) != 0) { e(tbsVersion); } String str6 = ""; try { if (TextUtils.isEmpty(string)) { str5 = "A"; } else { if (string.contains("" + i9)) { str5 = "B"; } else { str6 = string; r.a("6is" + str6); int optInt3 = jSONObject.optInt("USEBBACKUPVER", 0); optInt3 = jSONObject.getInt("USEBBACKUPVER"); instance.mSyncMap.put(TbsDownloadConfig.TbsConfigKey.KEY_USE_BACKUP_VERSION, Integer.valueOf(optInt3)); if (z && QbSdk.i && TbsShareManager.isThirdPartyApp(c)) { TbsExtensionFunctionManager.getInstance().setFunctionEnable(c, TbsExtensionFunctionManager.BUGLY_SWITCH_FILE_NAME, jSONObject.optInt("BUGLY", 0) != 1); } if (z) { try { int optInt4 = jSONObject.optInt("TEMPLATESWITCH", 0); boolean z7 = (optInt4 & 1) != 0; TbsExtensionFunctionManager.getInstance().setFunctionEnable(c, TbsExtensionFunctionManager.COOKIE_SWITCH_FILE_NAME, z7); TbsLog.w(LOGTAG, "useCookieCompatiable:" + z7); boolean z8 = (optInt4 & 2) != 0; TbsExtensionFunctionManager.getInstance().setFunctionEnable(c, TbsExtensionFunctionManager.DISABLE_GET_APK_VERSION_SWITCH_FILE_NAME, z8); TbsLog.w(LOGTAG, "disableGetApkVersionByReadFile:" + z8); boolean z9 = (optInt4 & 4) != 0; TbsExtensionFunctionManager.getInstance().setFunctionEnable(c, TbsExtensionFunctionManager.DISABLE_UNPREINIT, z9); QbSdk.setDisableUnpreinitBySwitch(z9); TbsLog.i(LOGTAG, "disableUnpreinitBySwitch:" + z9); boolean z10 = (optInt4 & 8) != 0; TbsExtensionFunctionManager.getInstance().setFunctionEnable(c, TbsExtensionFunctionManager.DISABLE_USE_HOST_BACKUP_CORE, z10); QbSdk.setDisableUseHostBackupCoreBySwitch(z10); TbsLog.i(LOGTAG, "disableUseHostBackupCoreBySwitch:" + z10); } catch (Throwable th) { TbsLog.i("qbsdk", "throwable:" + th.toString()); } } String optString2 = jSONObject.optString("PKGMD5", null); int optInt5 = jSONObject.optInt("RESETX5", 0); int optInt6 = jSONObject.optInt("UPLOADLOG", 0); jSONObject.optInt("RESETDECOUPLECORE", 0); String optString3 = jSONObject.optString("SETTOKEN", ""); boolean z11 = jSONObject.optInt("RESETTOKEN", 0) == 0; boolean z12 = jSONObject.optInt("ENABLE_LOAD_RENAME_FILE_LOCK_WAIT", 1) == 0; int optInt7 = jSONObject.optInt("RESETTODECOUPLECORE", 0); synchronized (f) { if (z11) { str2 = optString2; i3 = i8; instance.mSyncMap.put(TbsDownloadConfig.TbsConfigKey.KEY_DESkEY_TOKEN, ""); } else { str2 = optString2; i3 = i8; } if (!TextUtils.isEmpty(optString3) && optString3.length() == 96) { instance.mSyncMap.put(TbsDownloadConfig.TbsConfigKey.KEY_DESkEY_TOKEN, optString3 + "&" + g.c()); } } if (optInt5 == 1) { instance.setDownloadInterruptCode(-110); QbSdk.reset(c, optInt7 == 1); TbsLog.i(LOGTAG, "[TbsDownloader.readResponse] return #3,needResetTbs=1,isQuery=" + z); return false; } if (!z12) { instance.setTbsCoreLoadRenameFileLockWaitEnable(z12); } if (optInt6 == 1) { d.removeMessages(104); Message.obtain(d, 104).sendToTarget(); } long j5 = TbsDownloadConfig.DEFAULT_RETRY_INTERVAL_SEC; if (optInt == 1) { if (optLong > 604800) { optLong = 604800; } j2 = 0; if (optLong > 0) { j5 = optLong; } } else { j2 = 0; } if (getRetryIntervalInSeconds() >= j2) { j5 = getRetryIntervalInSeconds(); } instance.mSyncMap.put(TbsDownloadConfig.TbsConfigKey.KEY_RETRY_INTERVAL, Long.valueOf(j5)); TbsLog.i(LOGTAG, "in response isQuery is " + z); if (z) { try { i4 = jSONObject.getInt("DECOUPLECOREVERSION"); } catch (Exception unused) { i4 = 0; } } else { i4 = TbsDownloadConfig.getInstance(c).mPreferences.getInt(TbsDownloadConfig.TbsConfigKey.KEY_DECOUPLECOREVERSION, 0); } try { i5 = TbsDownloadConfig.getInstance(c).mPreferences.getInt(TbsDownloadConfig.TbsConfigKey.KEY_DOWNLOADDECOUPLECORE, 0); } catch (Exception unused2) { i5 = 0; } TbsLog.i(LOGTAG, "in response #01 decoupleCoreVersion is " + i4); if (z && !TbsShareManager.isThirdPartyApp(c) && i4 == 0) { i4 = p.a().i(c); } TbsLog.i(LOGTAG, "in response decoupleCoreVersion is " + i4); instance.mSyncMap.put(TbsDownloadConfig.TbsConfigKey.KEY_DECOUPLECOREVERSION, Integer.valueOf(i4)); instance.mSyncMap.put(TbsDownloadConfig.TbsConfigKey.KEY_DOWNLOADDECOUPLECORE, Integer.valueOf(i5)); if (!TbsShareManager.isThirdPartyApp(c)) { if (i4 > 0 && i4 != p.a().i(c) && i4 == p.a().j(c)) { p.a().o(c); } else if (i4 == 0) { try { FileUtil.b(p.a().q(c)); } catch (Throwable unused3) { } } } boolean isEmpty = TextUtils.isEmpty(string); int i14 = NetError.ERR_WINSOCK_UNEXPECTED_WRITTEN_BYTES; if (!isEmpty || !TbsShareManager.isThirdPartyApp(c)) { TbsLog.i(LOGTAG, "in response responseCode is " + i3); if (i3 == 0) { instance.mSyncMap.put(TbsDownloadConfig.TbsConfigKey.KEY_RESPONSECODE, Integer.valueOf(i3)); instance.mSyncMap.put(TbsDownloadConfig.TbsConfigKey.KEY_NEEDDOWNLOAD, false); instance.setDownloadInterruptCode(NetError.ERR_TUNNEL_CONNECTION_FAILED); instance.commit(); if (!TbsShareManager.isThirdPartyApp(c)) { TbsLog.i(LOGTAG, "[TbsDownloader.readResponse] responseCode=0 and ready to startDecoupleCoreIfNeeded"); startDecoupleCoreIfNeeded(); } TbsLog.i(LOGTAG, "[TbsDownloader.readResponse] return #5,responseCode=0"); return false; } int i15 = TbsDownloadConfig.getInstance(c).mPreferences.getInt(TbsDownloadConfig.TbsConfigKey.KEY_TBS_DOWNLOAD_V, 0); if (i15 > i9) { g.c(); p.a().p(c); } if (!TbsShareManager.isThirdPartyApp(c)) { int e2 = p.a().e(c, 0); z4 = e2 >= i9; TbsLog.i(LOGTAG, "tmpCoreVersion is " + e2 + " tbsDownloadVersion is" + i9); i6 = i2; } else { i6 = i2; z4 = false; } if ((i6 >= i9 || TextUtils.isEmpty(string) || z4) && i5 != 1) { instance.mSyncMap.put(TbsDownloadConfig.TbsConfigKey.KEY_NEEDDOWNLOAD, false); instance.commit(); if (!TextUtils.isEmpty(string)) { i14 = i9 <= 0 ? NetError.ERR_SSL_DECOMPRESSION_FAILURE_ALERT : i6 >= i9 ? NetError.ERR_PROXY_AUTH_REQUESTED : NetError.ERR_NO_SSL_VERSIONS_ENABLED; } instance.setDownloadInterruptCode(i14); TbsLog.i(LOGTAG, "version error or downloadUrl empty ,return ahead tbsLocalVersion=" + i6 + " tbsDownloadVersion=" + i9 + " tbsLastDownloadVersion=" + i15 + " downloadUrl=" + string); return false; } if (!string.equals(instance.mPreferences.getString(TbsDownloadConfig.TbsConfigKey.KEY_TBSDOWNLOADURL, null))) { g.c(); num = 0; instance.mSyncMap.put(TbsDownloadConfig.TbsConfigKey.KEY_DOWNLOAD_FAILED_RETRYTIMES, null); instance.mSyncMap.put(TbsDownloadConfig.TbsConfigKey.KEY_DOWNLOAD_SUCCESS_RETRYTIMES, null); } else { num = 0; } instance.mSyncMap.put(TbsDownloadConfig.TbsConfigKey.KEY_TBS_DOWNLOAD_V, Integer.valueOf(i9)); TbsLog.i(LOGTAG, "put KEY_TBS_DOWNLOAD_V is " + i9); if (i9 > 0) { Map<String, Object> map = instance.mSyncMap; if (i5 == 1) { map.put(TbsDownloadConfig.TbsConfigKey.KEY_TBS_DOWNLOAD_V_TYPE, 1); } else { map.put(TbsDownloadConfig.TbsConfigKey.KEY_TBS_DOWNLOAD_V_TYPE, num); } TbsLog.i(LOGTAG, "put KEY_TBS_DOWNLOAD_V_TYPE is " + i5); } instance.mSyncMap.put(TbsDownloadConfig.TbsConfigKey.KEY_TBSDOWNLOADURL, string); instance.mSyncMap.put(TbsDownloadConfig.TbsConfigKey.KEY_DOWNLOADURL_LIST, optString); instance.mSyncMap.put(TbsDownloadConfig.TbsConfigKey.KEY_RESPONSECODE, Integer.valueOf(i3)); instance.mSyncMap.put(TbsDownloadConfig.TbsConfigKey.KEY_DOWNLOAD_MAXFLOW, Integer.valueOf(i10)); instance.mSyncMap.put(TbsDownloadConfig.TbsConfigKey.KEY_DOWNLOAD_MIN_FREE_SPACE, Integer.valueOf(i11)); instance.mSyncMap.put(TbsDownloadConfig.TbsConfigKey.KEY_DOWNLOAD_SUCCESS_MAX_RETRYTIMES, Integer.valueOf(i12)); instance.mSyncMap.put(TbsDownloadConfig.TbsConfigKey.KEY_DOWNLOAD_FAILED_MAX_RETRYTIMES, Integer.valueOf(i13)); instance.mSyncMap.put(TbsDownloadConfig.TbsConfigKey.KEY_DOWNLOAD_SINGLE_TIMEOUT, Long.valueOf(j3)); instance.mSyncMap.put(TbsDownloadConfig.TbsConfigKey.KEY_TBSAPKFILESIZE, Long.valueOf(j4)); instance.commit(); if (str2 != null) { instance.mSyncMap.put(TbsDownloadConfig.TbsConfigKey.KEY_TBSAPK_MD5, str2); } if (z2 || !z3 || !p.a().b(c, i9)) { if (!z2 && z3) { if (g.a(z2, i3 == 1 || i3 == 2)) { instance.mSyncMap.put(TbsDownloadConfig.TbsConfigKey.KEY_NEEDDOWNLOAD, false); TbsLogReport.TbsLogInfo tbsLogInfo = TbsLogReport.getInstance(c).tbsLogInfo(); tbsLogInfo.setErrorCode(100); tbsLogInfo.setFailDetail("use local backup apk in needDownload" + g.a); TbsLogReport.getInstance(c).eventReport(TbsLogReport.EventType.TYPE_DOWNLOAD, tbsLogInfo); str4 = LOGTAG; str3 = "[TbsDownloader.readResponse] ##7 set needDownload=false"; TbsLog.i(str4, str3); z5 = true; if (jSONObject.optInt("stop_pre_oat", 0) == z5) { instance.mSyncMap.put(TbsDownloadConfig.TbsConfigKey.KEY_STOP_PRE_OAT, Boolean.valueOf(z5)); } instance.commit(); return z5; } } if (TbsDownloadConfig.getInstance(c).mPreferences.getInt(TbsDownloadConfig.TbsConfigKey.KEY_TBS_DOWNLOAD_V_TYPE, 0) != 1 || !g.a()) { if (!z) { instance.setDownloadInterruptCode(NetError.ERR_CERT_END); } z5 = true; instance.mSyncMap.put(TbsDownloadConfig.TbsConfigKey.KEY_NEEDDOWNLOAD, true); TbsLog.i(LOGTAG, "[TbsDownloader.readResponse] ##9 set needDownload=true"); if (jSONObject.optInt("stop_pre_oat", 0) == z5) { } instance.commit(); return z5; } instance.mSyncMap.put(TbsDownloadConfig.TbsConfigKey.KEY_NEEDDOWNLOAD, false); TbsLogReport.TbsLogInfo tbsLogInfo2 = TbsLogReport.getInstance(c).tbsLogInfo(); tbsLogInfo2.setErrorCode(100); tbsLogInfo2.setFailDetail("installDecoupleCoreFromBackup" + g.a); TbsLogReport.getInstance(c).eventReport(TbsLogReport.EventType.TYPE_DOWNLOAD, tbsLogInfo2); str4 = LOGTAG; str3 = "[TbsDownloader.readResponse] ##8 set needDownload=false"; TbsLog.i(str4, str3); z5 = true; if (jSONObject.optInt("stop_pre_oat", 0) == z5) { } instance.commit(); return z5; } instance.setDownloadInterruptCode(NetError.ERR_CERT_VALIDITY_TOO_LONG); instance.mSyncMap.put(TbsDownloadConfig.TbsConfigKey.KEY_NEEDDOWNLOAD, false); TbsLog.i(LOGTAG, "[TbsDownloader.readResponse] ##6 set needDownload=false"); return false; } instance.mSyncMap.put(TbsDownloadConfig.TbsConfigKey.KEY_NEEDDOWNLOAD, false); instance.commit(); if (z) { r.a(c, "response_query_host_has_core", "hostCoreIs" + i9); z6 = false; TbsShareManager.writeCoreInfoForThirdPartyApp(c, i9, false); } else { z6 = false; } instance.setDownloadInterruptCode(NetError.ERR_WINSOCK_UNEXPECTED_WRITTEN_BYTES); TbsLog.i(LOGTAG, "[TbsDownloader.readResponse] return #4,current app is third app..."); return z6; } } str6 = str5; } catch (Throwable th2) { TbsLog.i(LOGTAG, "throwable is " + Log.getStackTraceString(th2)); } r.a("6is" + str6); int optInt32 = jSONObject.optInt("USEBBACKUPVER", 0); try { optInt32 = jSONObject.getInt("USEBBACKUPVER"); } catch (Exception unused4) { } instance.mSyncMap.put(TbsDownloadConfig.TbsConfigKey.KEY_USE_BACKUP_VERSION, Integer.valueOf(optInt32)); try { TbsExtensionFunctionManager.getInstance().setFunctionEnable(c, TbsExtensionFunctionManager.BUGLY_SWITCH_FILE_NAME, jSONObject.optInt("BUGLY", 0) != 1); } catch (Throwable th3) { TbsLog.i("qbsdk", "throwable:" + th3.toString()); } if (z) { } String optString22 = jSONObject.optString("PKGMD5", null); int optInt52 = jSONObject.optInt("RESETX5", 0); int optInt62 = jSONObject.optInt("UPLOADLOG", 0); jSONObject.optInt("RESETDECOUPLECORE", 0); String optString32 = jSONObject.optString("SETTOKEN", ""); if (jSONObject.optInt("RESETTOKEN", 0) == 0) { } if (jSONObject.optInt("ENABLE_LOAD_RENAME_FILE_LOCK_WAIT", 1) == 0) { } int optInt72 = jSONObject.optInt("RESETTODECOUPLECORE", 0); synchronized (f) { } } protected static File b(int i2) { String[] coreProviderAppList = TbsShareManager.getCoreProviderAppList(); int length = coreProviderAppList.length; File file = null; int i3 = 0; while (i3 < length) { File file2 = new File(FileUtil.a(c, coreProviderAppList[i3], 4, false), getOverSea(c) ? "x5.oversea.tbs.org" : getBackupFileName(false)); if (!file2.exists() || a.a(c, file2) != i2) { i3++; file = file2; } else { TbsLog.i(LOGTAG, "local tbs version fond,path = " + file2.getAbsolutePath()); return file2; } } return file; } /* JADX WARNING: Removed duplicated region for block: B:24:0x0068 */ /* JADX WARNING: Removed duplicated region for block: B:36:0x0090 */ /* JADX WARNING: Removed duplicated region for block: B:37:0x0092 */ /* JADX WARNING: Removed duplicated region for block: B:40:0x009e */ /* JADX WARNING: Removed duplicated region for block: B:42:0x00a7 */ static String b(Context context) { String replaceAll; String str; if (!TextUtils.isEmpty(b)) { return b; } Locale locale = Locale.getDefault(); StringBuffer stringBuffer = new StringBuffer(); String str2 = Build.VERSION.RELEASE; try { str2 = new String(str2.getBytes("UTF-8"), "ISO8859-1"); } catch (Exception unused) { } if (str2 != null && str2.length() > 0) { stringBuffer.append(str2); } else { stringBuffer.append("1.0"); } stringBuffer.append("; "); String language = locale.getLanguage(); if (language != null) { stringBuffer.append(language.toLowerCase()); String country = locale.getCountry(); if (country != null) { stringBuffer.append("-"); str = country.toLowerCase(); } if ("REL".equals(Build.VERSION.CODENAME)) { String d2 = r.d(context); try { d2 = new String(d2.getBytes("UTF-8"), "ISO8859-1"); } catch (Exception unused2) { } if (d2 == null) { stringBuffer.append("; "); } else if (d2.length() > 0) { stringBuffer.append("; "); stringBuffer.append(d2); } } replaceAll = (Build.ID != null ? "" : Build.ID).replaceAll("[一-龥]", ""); if (replaceAll != null) { stringBuffer.append(" Build/"); replaceAll = e.V; } else { if (replaceAll.length() > 0) { stringBuffer.append(" Build/"); } String format = String.format("Mozilla/5.0 (Linux; U; Android %s) AppleWebKit/533.1 (KHTML, like Gecko)Version/4.0 Mobile Safari/533.1", stringBuffer); b = format; return format; } stringBuffer.append(replaceAll); String format2 = String.format("Mozilla/5.0 (Linux; U; Android %s) AppleWebKit/533.1 (KHTML, like Gecko)Version/4.0 Mobile Safari/533.1", stringBuffer); b = format2; return format2; } str = "en"; stringBuffer.append(str); if ("REL".equals(Build.VERSION.CODENAME)) { } replaceAll = (Build.ID != null ? "" : Build.ID).replaceAll("[一-龥]", ""); if (replaceAll != null) { } stringBuffer.append(replaceAll); String format22 = String.format("Mozilla/5.0 (Linux; U; Android %s) AppleWebKit/533.1 (KHTML, like Gecko)Version/4.0 Mobile Safari/533.1", stringBuffer); b = format22; return format22; } /* access modifiers changed from: private */ public static boolean b(final boolean z, boolean z2, boolean z3, boolean z4) { boolean z5; Throwable th; final TbsDownloadConfig instance = TbsDownloadConfig.getInstance(c); m.b(c); if (QbSdk.o == null || !QbSdk.o.containsKey(QbSdk.KEY_SET_SENDREQUEST_AND_UPLOAD) || !QbSdk.o.get(QbSdk.KEY_SET_SENDREQUEST_AND_UPLOAD).equals("false")) { TbsLog.i(LOGTAG, "[TbsDownloader.sendRequest]isQuery: " + z + " forDecoupleCore is " + z3); if (p.a().d(c)) { TbsLog.i(LOGTAG, "[TbsDownloader.sendRequest] -- isTbsLocalInstalled!"); instance.setDownloadInterruptCode(-132); return false; } if (e == null) { e = b.a(); instance.mSyncMap.put(TbsDownloadConfig.TbsConfigKey.KEY_DEVICE_CPUABI, e); instance.commit(); } if (TextUtils.isEmpty(e) || b.a(e)) { instance.mSyncMap.put(TbsDownloadConfig.TbsConfigKey.KEY_APP_VERSIONNAME, b.d(c)); instance.mSyncMap.put(TbsDownloadConfig.TbsConfigKey.KEY_APP_VERSIONCODE, Integer.valueOf(b.e(c))); instance.commit(); JSONObject a2 = a(z, z2, z3); int optInt = a2.optInt("TBSV", -1); if (optInt != -1) { long currentTimeMillis = System.currentTimeMillis(); if (TbsShareManager.isThirdPartyApp(c)) { long j2 = instance.mPreferences.getLong(TbsDownloadConfig.TbsConfigKey.KEY_REQUEST_FAIL, 0); long j3 = instance.mPreferences.getLong(TbsDownloadConfig.TbsConfigKey.KEY_COUNT_REQUEST_FAIL_IN_24HOURS, 0); long j4 = 1; if (currentTimeMillis - j2 < instance.getRetryInterval() * 1000) { j4 = j3 + 1; } instance.mSyncMap.put(TbsDownloadConfig.TbsConfigKey.KEY_COUNT_REQUEST_FAIL_IN_24HOURS, Long.valueOf(j4)); } instance.mSyncMap.put(TbsDownloadConfig.TbsConfigKey.KEY_REQUEST_FAIL, Long.valueOf(currentTimeMillis)); instance.mSyncMap.put(TbsDownloadConfig.TbsConfigKey.KEY_APP_VERSIONNAME, b.d(c)); instance.mSyncMap.put(TbsDownloadConfig.TbsConfigKey.KEY_APP_VERSIONCODE, Integer.valueOf(b.e(c))); instance.mSyncMap.put(TbsDownloadConfig.TbsConfigKey.KEY_APP_METADATA, b.a(c, TBS_METADATA)); instance.commit(); } if (optInt != -1 || z3) { try { String g2 = n.a(c).g(); TbsLog.i(LOGTAG, "[TbsDownloader.sendRequest] postUrl=" + g2); if (z) { try { n = a2; } catch (Throwable th2) { th = th2; } } else { o = a2; } String str = null; if (r.e(c)) { try { int i2 = a2.getInt("FUNCTION"); if (i2 == 0 && !TextUtils.isEmpty(n.a(c).f())) { str = n.a(c).f(); } else if (i2 == 1 && !TextUtils.isEmpty(n.a(c).e())) { str = n.a(c).e(); } else if (i2 == 2 && !TextUtils.isEmpty(n.a(c).d())) { str = n.a(c).d(); } } catch (Throwable unused) { } } if (str == null) { if (z) { return true; } str = f.a(g2, a2.toString().getBytes("utf-8"), new f.a() { /* class com.tencent.smtt.sdk.TbsDownloader.AnonymousClass3 */ @Override // com.tencent.smtt.utils.f.a public void a(int i) { TbsDownloadConfig tbsDownloadConfig; int i2; instance.mSyncMap.put(TbsDownloadConfig.TbsConfigKey.KEY_LAST_CHECK, Long.valueOf(System.currentTimeMillis())); instance.commit(); TbsLog.i(TbsDownloader.LOGTAG, "[TbsDownloader.sendRequest] httpResponseCode=" + i); if (TbsShareManager.isThirdPartyApp(TbsDownloader.c) && i == 200) { instance.mSyncMap.put(TbsDownloadConfig.TbsConfigKey.KEY_LAST_REQUEST_SUCCESS, Long.valueOf(System.currentTimeMillis())); instance.mSyncMap.put(TbsDownloadConfig.TbsConfigKey.KEY_REQUEST_FAIL, 0L); instance.mSyncMap.put(TbsDownloadConfig.TbsConfigKey.KEY_COUNT_REQUEST_FAIL_IN_24HOURS, 0L); instance.commit(); } if (i >= 300) { if (z) { tbsDownloadConfig = instance; i2 = NetError.ERR_SSL_PROTOCOL_ERROR; } else { tbsDownloadConfig = instance; i2 = NetError.ERR_CERT_INVALID; } tbsDownloadConfig.setDownloadInterruptCode(i2); } } }, false); if (str != null && str.contains("HttpError")) { TbsLogReport.TbsLogInfo tbsLogInfo = TbsLogReport.getInstance(c).tbsLogInfo(); tbsLogInfo.setErrorCode(NetError.ERR_SSL_WEAK_SERVER_EPHEMERAL_DH_KEY); tbsLogInfo.setFailDetail(str); TbsLogReport.getInstance(c).eventReport(TbsLogReport.EventType.TYPE_DOWNLOAD, tbsLogInfo); } } z5 = a(str, optInt, z, z2, z4); try { TbsLog.i(LOGTAG, "sendrequest return false #2"); return z5; } catch (Throwable th3) { th = th3; } } catch (Throwable th4) { th = th4; z5 = false; TbsLog.i(LOGTAG, "sendrequest return false " + Log.getStackTraceString(th)); th.printStackTrace(); instance.setDownloadInterruptCode(NetError.ERR_INTERNET_DISCONNECTED); return z5; } } else { instance.setDownloadInterruptCode(NetError.ERR_SSL_VERSION_OR_CIPHER_MISMATCH); return false; } } else { instance.setDownloadInterruptCode(NetError.ERR_CONNECTION_FAILED); TbsLog.i(LOGTAG, "TbsDownloader sendRequest cpu is invalid:" + e); return false; } } else { TbsLog.i(LOGTAG, "[TbsDownloader.sendRequest] -- SET_SENDREQUEST_AND_UPLOAD is false"); instance.setDownloadInterruptCode(NetError.ERR_MANDATORY_PROXY_CONFIGURATION_FAILED); return false; } } private static synchronized void c() { synchronized (TbsDownloader.class) { if (h == null) { h = o.a(); try { g = new m(c); d = new Handler(h.getLooper()) { /* class com.tencent.smtt.sdk.TbsDownloader.AnonymousClass2 */ public void handleMessage(Message message) { FileLock fileLock; int i = message.what; boolean z = true; if (i != 108) { if (i != 109) { switch (i) { case 100: boolean z2 = message.arg1 == 1; boolean b = TbsDownloader.b(true, false, false, message.arg2 == 1); if (message.obj != null && (message.obj instanceof TbsDownloaderCallback)) { TbsLog.i(TbsDownloader.LOGTAG, "needDownload-onNeedDownloadFinish needStartDownload=" + b); String str = (TbsDownloader.c == null || TbsDownloader.c.getApplicationContext() == null || TbsDownloader.c.getApplicationContext().getApplicationInfo() == null) ? "" : TbsDownloader.c.getApplicationContext().getApplicationInfo().packageName; if (b && !z2) { if (TbsConfig.APP_WX.equals(str) || TbsConfig.APP_QQ.equals(str)) { TbsLog.i(TbsDownloader.LOGTAG, "needDownload-onNeedDownloadFinish in mm or QQ callback needStartDownload = " + b); } } ((TbsDownloaderCallback) message.obj).onNeedDownloadFinish(b, TbsDownloadConfig.getInstance(TbsDownloader.c).mPreferences.getInt(TbsDownloadConfig.TbsConfigKey.KEY_TBS_DOWNLOAD_V, 0)); } if (TbsShareManager.isThirdPartyApp(TbsDownloader.c) && b) { TbsDownloader.startDownload(TbsDownloader.c); return; } return; case 101: break; case 102: TbsLog.i(TbsDownloader.LOGTAG, "[TbsDownloader.handleMessage] MSG_REPORT_DOWNLOAD_STAT"); int a = TbsShareManager.isThirdPartyApp(TbsDownloader.c) ? TbsShareManager.a(TbsDownloader.c, false) : p.a().n(TbsDownloader.c); TbsLog.i(TbsDownloader.LOGTAG, "[TbsDownloader.handleMessage] localTbsVersion=" + a); TbsDownloader.g.a(a); TbsLogReport.getInstance(TbsDownloader.c).dailyReport(); return; case 103: TbsLog.i(TbsDownloader.LOGTAG, "[TbsDownloader.handleMessage] MSG_CONTINUEINSTALL_TBSCORE"); if (message.arg1 == 0) { p.a().a((Context) message.obj, true); return; } return; case 104: TbsLog.i(TbsDownloader.LOGTAG, "[TbsDownloader.handleMessage] MSG_UPLOAD_TBSLOG"); TbsLogReport.getInstance(TbsDownloader.c).reportTbsLog(); return; default: return; } } else if (TbsDownloader.g != null) { TbsDownloader.g.f(); return; } else { return; } } TbsDownloadConfig instance = TbsDownloadConfig.getInstance(TbsDownloader.c); if (Apn.getApnType(TbsDownloader.c) == 3 || QbSdk.getDownloadWithoutWifi()) { FileOutputStream fileOutputStream = null; FileLock fileLock2 = null; if (!TbsShareManager.isThirdPartyApp(TbsDownloader.c)) { FileOutputStream b2 = FileUtil.b(TbsDownloader.c, false, "tbs_download_lock_file" + TbsDownloadConfig.getInstance(TbsDownloader.c).mPreferences.getInt(TbsDownloadConfig.TbsConfigKey.KEY_TBS_DOWNLOAD_V, 0) + ".txt"); if (b2 != null) { fileLock2 = FileUtil.a(TbsDownloader.c, b2); if (fileLock2 == null) { instance.setDownloadInterruptCode(NetError.ERR_CERT_CONTAINS_ERRORS); QbSdk.n.onDownloadFinish(177); TbsLog.i(TbsDownloader.LOGTAG, "file lock locked,wx or qq is downloading"); TbsLog.i(TbsDownloader.LOGTAG, "MSG_START_DOWNLOAD_DECOUPLECORE return #1"); return; } } else if (FileUtil.a(TbsDownloader.c)) { instance.setDownloadInterruptCode(NetError.ERR_CERT_NO_REVOCATION_MECHANISM); QbSdk.n.onDownloadFinish(NetError.ERR_CERT_NO_REVOCATION_MECHANISM); TbsLog.i(TbsDownloader.LOGTAG, "MSG_START_DOWNLOAD_DECOUPLECORE return #2"); return; } fileOutputStream = b2; fileLock = fileLock2; } else { fileLock = null; } boolean z3 = message.arg1 == 1; boolean b3 = TbsDownloader.b(false, z3, 108 == message.what, true); StringBuilder sb = new StringBuilder(); sb.append("needStartDownload is "); sb.append(b3); sb.append(" forDecoupleCore is "); sb.append(108 == message.what); TbsLog.i(TbsDownloader.LOGTAG, sb.toString()); TbsLog.i(TbsDownloader.LOGTAG, "idownloadConfig.mPreferences.getBoolean(TbsConfigKey.KEY_NEEDDOWNLOAD, false) is " + instance.mPreferences.getBoolean(TbsDownloadConfig.TbsConfigKey.KEY_NEEDDOWNLOAD, false)); if (b3) { if (z3 && p.a().b(TbsDownloader.c, TbsDownloadConfig.getInstance(TbsDownloader.c).mPreferences.getInt(TbsDownloadConfig.TbsConfigKey.KEY_TBS_DOWNLOAD_V, 0))) { TbsLog.i(TbsDownloader.LOGTAG, "in needStartDownload true #1"); QbSdk.n.onDownloadFinish(122); QbSdk.n.onInstallFinish(TbsListener.ErrorCode.DOWNLOAD_FAILED_FOR_PREINIT_CALLBACK); instance.setDownloadInterruptCode(NetError.ERR_CERT_VALIDITY_TOO_LONG); TbsLog.i(TbsDownloader.LOGTAG, "------freeFileLock called :"); FileUtil.a(fileLock, fileOutputStream); return; } else if (instance.mPreferences.getBoolean(TbsDownloadConfig.TbsConfigKey.KEY_NEEDDOWNLOAD, false)) { TbsDownloadConfig.getInstance(TbsDownloader.c).setDownloadInterruptCode(NetError.ERR_CERT_SYMANTEC_LEGACY); if (108 == message.what) { instance.mSyncMap.put(TbsDownloadConfig.TbsConfigKey.KEY_CPUTYPE_OTHER_STABLE_CORE, 0); instance.commit(); } m mVar = TbsDownloader.g; if (108 != message.what) { z = false; } mVar.b(z3, z); TbsLog.i(TbsDownloader.LOGTAG, "------freeFileLock called :"); FileUtil.a(fileLock, fileOutputStream); return; } else { instance.setDownloadInterruptCode(NetError.ERR_PRECONNECT_MAX_SOCKET_LIMIT); } } QbSdk.n.onDownloadFinish(110); QbSdk.n.onInstallFinish(TbsListener.ErrorCode.DOWNLOAD_FAILED_FOR_PREINIT_CALLBACK); TbsLog.i(TbsDownloader.LOGTAG, "------freeFileLock called :"); FileUtil.a(fileLock, fileOutputStream); return; } TbsLog.i(TbsDownloader.LOGTAG, "not wifi,no need send request"); instance.setDownloadInterruptCode(-220); QbSdk.n.onDownloadFinish(111); } }; } catch (Exception unused) { i = true; TbsLog.e(LOGTAG, "TbsApkDownloader init has Exception"); } } } } /* JADX WARNING: Removed duplicated region for block: B:36:0x00e5 */ /* JADX WARNING: Removed duplicated region for block: B:39:0x00f3 */ /* JADX WARNING: Removed duplicated region for block: B:40:0x00f9 */ /* JADX WARNING: Removed duplicated region for block: B:43:0x01b1 */ /* JADX WARNING: Removed duplicated region for block: B:63:0x0272 */ /* JADX WARNING: Removed duplicated region for block: B:67:? A[RETURN, SYNTHETIC] */ private static void c(int i2) { int i3; int tbsStableCoreVersion; String str; try { TbsLog.i(LOGTAG, "sendRequestForOtherStableCore cpuType is " + i2 + " mJsonDataQuery is " + n + " mJsonDataDownloadUpdate is " + o); if (!r.b(c)) { TbsLog.i(LOGTAG, "sendRequestForOtherStableCore isStableCoreForHostEnable is false and return "); } else if (i2 >= 32) { if (n == null) { n = o; } if (n != null) { long j2 = TbsDownloadConfig.getInstance(c).mPreferences.getLong(TbsDownloadConfig.TbsConfigKey.KEY_LAST_DOWNLOAD_STABLE_CORE_OTHER_CPU, 0); if (System.currentTimeMillis() - j2 < TbsDownloadConfig.getInstance(c).getRetryInterval() * 1000) { TbsLog.i(LOGTAG, "sendRequestForOtherStableCore less than and return "); return; } if (i2 == 64) { n.put("REQUEST_64", 1); } else if (i2 == 32) { n.remove("REQUEST_64"); } n.put("DOWNLOADDECOUPLECORE", 1); if (i2 == 64) { if (n.a(c).c("stable_64_tpatch_fail") == 1) { str = "sendRequestForOtherStableCore stable_64_last_tpatch_fail and set REQUEST_TPATCH 0 "; } i3 = 1; n.put("REQUEST_TPATCH", i3); tbsStableCoreVersion = TbsShareManager.getTbsStableCoreVersion(c, i2); n.put("TBSDV", p.a().j(c) % 10000); n.put("TBSBACKUPV", tbsStableCoreVersion); if (i3 == 0) { n.put("TBSDV", 0); n.put("TBSBACKUPV", 0); } if (tbsStableCoreVersion > 0) { n.put("FUNCTION", 1); } else { n.put("FUNCTION", 0); } n.put("TBSV", 0); String g2 = n.a(c).g(); TbsLog.i(LOGTAG, "[TbsDownloader.sendRequestForOtherStableCore] postUrl=" + g2); TbsLog.i(LOGTAG, "[TbsDownloader.sendRequestForOtherStableCore] mJsonDataQuery=" + n.toString()); JSONObject jSONObject = n; s = jSONObject; String a2 = f.a(g2, jSONObject.toString().getBytes("utf-8"), new f.a() { /* class com.tencent.smtt.sdk.TbsDownloader.AnonymousClass4 */ @Override // com.tencent.smtt.utils.f.a public void a(int i) { } }, false); TbsLog.i(LOGTAG, "[TbsDownloader.sendRequestForOtherStableCore] response=" + a2); JSONObject jSONObject2 = new JSONObject(a2); TbsDownloadConfig.getInstance(c).mSyncMap.put(TbsDownloadConfig.TbsConfigKey.KEY_LAST_DOWNLOAD_STABLE_CORE_OTHER_CPU, Long.valueOf(System.currentTimeMillis())); TbsDownloadConfig.getInstance(c).commit(); String string = jSONObject2.getString("DOWNLOADURL"); long j3 = jSONObject2.getLong("TBSAPKFILESIZE"); String string2 = jSONObject2.getString("PKGMD5"); int i4 = jSONObject2.getInt("TBSAPKSERVERVERSION"); int i5 = jSONObject2.getInt("RESPONSECODE"); p = false; if (r.b(c)) { int tbsStableCoreVersion2 = TbsShareManager.getTbsStableCoreVersion(c, i2); if (tbsStableCoreVersion2 < i4) { if (a(i4, tbsStableCoreVersion2, i2)) { TbsDownloadConfig instance = TbsDownloadConfig.getInstance(c); instance.mSyncMap.put(TbsDownloadConfig.TbsConfigKey.KEY_CPUTYPE_OTHER_STABLE_CORE, Integer.valueOf(i2)); instance.commit(); TbsLog.i(LOGTAG, "sendRequestForOtherStableCore stable core " + i4 + " copy from old backup and return "); return; } TbsDownloadConfig instance2 = TbsDownloadConfig.getInstance(c); instance2.mSyncMap.put(TbsDownloadConfig.TbsConfigKey.KEY_TBSDOWNLOADURL, string); instance2.mSyncMap.put(TbsDownloadConfig.TbsConfigKey.KEY_TBSAPKFILESIZE, Long.valueOf(j3)); instance2.mSyncMap.put(TbsDownloadConfig.TbsConfigKey.KEY_CPUTYPE_OTHER_STABLE_CORE, Integer.valueOf(i2)); Map<String, Object> map = instance2.mSyncMap; if (string2 == null) { string2 = ""; } map.put(TbsDownloadConfig.TbsConfigKey.KEY_TBSAPK_MD5, string2); instance2.mSyncMap.put(TbsDownloadConfig.TbsConfigKey.KEY_DOWNLOADDECOUPLECORE, 1); instance2.mSyncMap.put(TbsDownloadConfig.TbsConfigKey.KEY_TBS_DOWNLOAD_V, Integer.valueOf(i4)); instance2.mSyncMap.put(TbsDownloadConfig.TbsConfigKey.KEY_RESPONSECODE, Integer.valueOf(i5)); instance2.commit(); TbsLog.i(LOGTAG, "sendRequestForOtherStableCore downloadUrl is " + string, true); if (!TextUtils.isEmpty(string)) { g.b(false, true); } } else if (TextUtils.isEmpty(string) && i4 == 0 && j3 > 0) { p = true; } } d(i2); if (p) { int tbsStableCoreVersion3 = TbsShareManager.getTbsStableCoreVersion(c, i2); r = 0; boolean a3 = a(q, tbsStableCoreVersion3, i2); TbsLog.i(LOGTAG, "other cpu stable core is flowed and copyFromOldBackupDone is " + a3 + " tbsDownloadVersion is " + i4 + " oldBackupCoreVersion is " + r + " localStableCore is " + tbsStableCoreVersion3 + " cpuType is " + i2); return; } return; } if (n.a(c).c("stable_32_tpatch_fail") == 1) { str = "sendRequestForOtherStableCore stable_32_last_tpatch_fail and set REQUEST_TPATCH 0 "; } i3 = 1; n.put("REQUEST_TPATCH", i3); tbsStableCoreVersion = TbsShareManager.getTbsStableCoreVersion(c, i2); n.put("TBSDV", p.a().j(c) % 10000); n.put("TBSBACKUPV", tbsStableCoreVersion); if (i3 == 0) { } if (tbsStableCoreVersion > 0) { } n.put("TBSV", 0); String g22 = n.a(c).g(); TbsLog.i(LOGTAG, "[TbsDownloader.sendRequestForOtherStableCore] postUrl=" + g22); TbsLog.i(LOGTAG, "[TbsDownloader.sendRequestForOtherStableCore] mJsonDataQuery=" + n.toString()); JSONObject jSONObject3 = n; s = jSONObject3; String a22 = f.a(g22, jSONObject3.toString().getBytes("utf-8"), new f.a() { /* class com.tencent.smtt.sdk.TbsDownloader.AnonymousClass4 */ @Override // com.tencent.smtt.utils.f.a public void a(int i) { } }, false); TbsLog.i(LOGTAG, "[TbsDownloader.sendRequestForOtherStableCore] response=" + a22); JSONObject jSONObject22 = new JSONObject(a22); TbsDownloadConfig.getInstance(c).mSyncMap.put(TbsDownloadConfig.TbsConfigKey.KEY_LAST_DOWNLOAD_STABLE_CORE_OTHER_CPU, Long.valueOf(System.currentTimeMillis())); TbsDownloadConfig.getInstance(c).commit(); String string3 = jSONObject22.getString("DOWNLOADURL"); long j32 = jSONObject22.getLong("TBSAPKFILESIZE"); String string22 = jSONObject22.getString("PKGMD5"); int i42 = jSONObject22.getInt("TBSAPKSERVERVERSION"); int i52 = jSONObject22.getInt("RESPONSECODE"); p = false; if (r.b(c)) { } d(i2); if (p) { } TbsLog.i(LOGTAG, str); i3 = 0; n.put("REQUEST_TPATCH", i3); tbsStableCoreVersion = TbsShareManager.getTbsStableCoreVersion(c, i2); n.put("TBSDV", p.a().j(c) % 10000); n.put("TBSBACKUPV", tbsStableCoreVersion); if (i3 == 0) { } if (tbsStableCoreVersion > 0) { } n.put("TBSV", 0); String g222 = n.a(c).g(); TbsLog.i(LOGTAG, "[TbsDownloader.sendRequestForOtherStableCore] postUrl=" + g222); TbsLog.i(LOGTAG, "[TbsDownloader.sendRequestForOtherStableCore] mJsonDataQuery=" + n.toString()); JSONObject jSONObject32 = n; s = jSONObject32; String a222 = f.a(g222, jSONObject32.toString().getBytes("utf-8"), new f.a() { /* class com.tencent.smtt.sdk.TbsDownloader.AnonymousClass4 */ @Override // com.tencent.smtt.utils.f.a public void a(int i) { } }, false); TbsLog.i(LOGTAG, "[TbsDownloader.sendRequestForOtherStableCore] response=" + a222); JSONObject jSONObject222 = new JSONObject(a222); TbsDownloadConfig.getInstance(c).mSyncMap.put(TbsDownloadConfig.TbsConfigKey.KEY_LAST_DOWNLOAD_STABLE_CORE_OTHER_CPU, Long.valueOf(System.currentTimeMillis())); TbsDownloadConfig.getInstance(c).commit(); String string32 = jSONObject222.getString("DOWNLOADURL"); long j322 = jSONObject222.getLong("TBSAPKFILESIZE"); String string222 = jSONObject222.getString("PKGMD5"); int i422 = jSONObject222.getInt("TBSAPKSERVERVERSION"); int i522 = jSONObject222.getInt("RESPONSECODE"); p = false; if (r.b(c)) { } d(i2); if (p) { } } } } catch (Throwable unused) { } } static void c(Context context) { TbsDownloadConfig.getInstance(context).clear(); TbsLogReport.getInstance(context).clear(); m.e(context); (Build.VERSION.SDK_INT >= 11 ? context.getSharedPreferences("tbs_extension_config", 4) : context.getSharedPreferences("tbs_extension_config", 0)).edit().clear().commit(); (Build.VERSION.SDK_INT >= 11 ? context.getSharedPreferences("tbs_preloadx5_check_cfg_file", 4) : context.getSharedPreferences("tbs_preloadx5_check_cfg_file", 0)).edit().clear().commit(); } private static void d(int i2) { JSONObject jSONObject = s; if (jSONObject != null) { try { jSONObject.put("FUNCTION", 2); String g2 = n.a(c).g(); TbsLog.i(LOGTAG, "[TbsDownloader.resetOtherCpuStableCore] postUrl=" + g2); TbsLog.i(LOGTAG, "[TbsDownloader.resetOtherCpuStableCore] mJsonDataQueryReset=" + s.toString()); String a2 = f.a(g2, s.toString().getBytes("utf-8"), new f.a() { /* class com.tencent.smtt.sdk.TbsDownloader.AnonymousClass5 */ @Override // com.tencent.smtt.utils.f.a public void a(int i) { } }, false); TbsLog.i(LOGTAG, "[TbsDownloader.resetOtherCpuStableCore] response=" + a2); q = 0; JSONObject jSONObject2 = new JSONObject(a2); if (jSONObject2.getInt("RESETDECOUPLECORE") == 1) { Context packageContext = TbsShareManager.getPackageContext(c, TbsConfig.APP_WX, false); File file = packageContext == null ? new File(FileUtil.a(c, TbsConfig.APP_WX, 4, true)) : new File(FileUtil.a(packageContext, 4)); TbsLog.i(LOGTAG, "[TbsDownloader.resetOtherCpuStableCore] resetDecoupleCore mFilePathStable is " + file.getAbsolutePath(), true); File[] listFiles = file.listFiles(); Pattern compile = Pattern.compile(a.a(false, i2)); for (File file2 : listFiles) { if (compile.matcher(file2.getName()).find() && file2.isFile() && file2.exists()) { TbsLog.i(LOGTAG, "resetOtherCpuStableCore file is " + file2.getAbsolutePath(), true); file2.delete(); } } File file3 = new File(file, getBackupFileName(false, i2)); TbsLog.i(LOGTAG, "resetOtherCpuStableCore file is " + file3.getAbsolutePath(), true); file3.delete(); return; } q = jSONObject2.getInt("DECOUPLECOREVERSION"); } catch (Throwable unused) { } } } private static boolean d() { try { return TbsDownloadConfig.getInstance(c).mPreferences.getString(TbsDownloadConfig.TbsConfigKey.KEY_LAST_THIRDAPP_SENDREQUEST_COREVERSION, "").equals(f().toString()); } catch (Exception unused) { return false; } } private static void e(int i2) { File t2 = p.t(c); File file = new File(t2, "tbs_switch_disable_" + i2); if (!file.exists()) { try { boolean createNewFile = file.createNewFile(); TbsLog.i(LOGTAG, "setTbsCoreDisabledBySwitch status: " + createNewFile); } catch (IOException e2) { e2.printStackTrace(); } } } private static String[] e() { if (QbSdk.getOnlyDownload()) { return new String[]{c.getApplicationContext().getPackageName()}; } String[] coreProviderAppList = TbsShareManager.getCoreProviderAppList(); String packageName = c.getApplicationContext().getPackageName(); if (!packageName.equals(TbsShareManager.f(c))) { return coreProviderAppList; } int length = coreProviderAppList.length; String[] strArr = new String[(length + 1)]; System.arraycopy(coreProviderAppList, 0, strArr, 0, length); strArr[length] = packageName; return strArr; } private static JSONArray f() { if (!TbsShareManager.isThirdPartyApp(c)) { return null; } JSONArray jSONArray = new JSONArray(); int tbsVersion = QbSdk.getTbsVersion(c); if (tbsVersion > 0) { jSONArray.put(tbsVersion); } TbsLog.i(LOGTAG, "getSelfVersion QbSdk.getTbsVersion() is " + jSONArray.toString()); a(jSONArray); TbsLog.i(LOGTAG, "getHostCoreVersions addStableVersionToJsonData is " + jSONArray.toString()); return jSONArray; } private static boolean g() { int i2; TbsDownloadConfig instance = TbsDownloadConfig.getInstance(c); if (instance.mPreferences.getInt(TbsDownloadConfig.TbsConfigKey.KEY_DOWNLOAD_SUCCESS_RETRYTIMES, 0) >= instance.getDownloadSuccessMaxRetrytimes()) { TbsLog.i(LOGTAG, "[TbsDownloader.needStartDownload] out of success retrytimes", true); i2 = NetError.ERR_PROXY_AUTH_UNSUPPORTED; } else if (instance.mPreferences.getInt(TbsDownloadConfig.TbsConfigKey.KEY_DOWNLOAD_FAILED_RETRYTIMES, 0) >= instance.getDownloadFailedMaxRetrytimes()) { TbsLog.i(LOGTAG, "[TbsDownloader.needStartDownload] out of failed retrytimes", true); i2 = NetError.ERR_CERT_ERROR_IN_SSL_RENEGOTIATION; } else if (!FileUtil.b(c)) { TbsLog.i(LOGTAG, "[TbsDownloader.needStartDownload] local rom freespace limit", true); i2 = NetError.ERR_BAD_SSL_CLIENT_AUTH_CERT; } else { if (System.currentTimeMillis() - instance.mPreferences.getLong(TbsDownloadConfig.TbsConfigKey.KEY_TBSDOWNLOAD_STARTTIME, 0) <= 86400000) { long j2 = instance.mPreferences.getLong(TbsDownloadConfig.TbsConfigKey.KEY_TBSDOWNLOAD_FLOW, 0); TbsLog.i(LOGTAG, "[TbsDownloader.needStartDownload] downloadFlow=" + j2); if (j2 >= instance.getDownloadMaxflow()) { TbsLog.i(LOGTAG, "[TbsDownloader.needStartDownload] failed because you exceeded max flow!", true); i2 = NetError.ERR_SOCKS_CONNECTION_FAILED; } } return true; } instance.setDownloadInterruptCode(i2); return false; } public static String getBackupFileName(boolean z) { return getBackupFileName(z, 0); } public static String getBackupFileName(boolean z, int i2) { boolean c2 = i2 == 64 ? true : i2 == 32 ? false : b.c(); return z ? c2 ? "x5.tbs.decouple.64" : "x5.tbs.decouple" : c2 ? "x5.tbs.org.64" : "x5.tbs.org"; } public static int getCoreShareDecoupleCoreVersion() { return p.a().i(c); } public static int getCoreShareDecoupleCoreVersionByContext(Context context) { return p.a().i(context); } public static synchronized boolean getOverSea(Context context) { boolean z; synchronized (TbsDownloader.class) { if (!m) { m = true; TbsDownloadConfig instance = TbsDownloadConfig.getInstance(context); if (instance.mPreferences.contains(TbsDownloadConfig.TbsConfigKey.KEY_IS_OVERSEA)) { l = instance.mPreferences.getBoolean(TbsDownloadConfig.TbsConfigKey.KEY_IS_OVERSEA, false); TbsLog.i(LOGTAG, "[TbsDownloader.getOverSea] first called. sOverSea = " + l); } TbsLog.i(LOGTAG, "[TbsDownloader.getOverSea] sOverSea = " + l); } z = l; } return z; } public static long getRetryIntervalInSeconds() { return t; } public static HandlerThread getsTbsHandlerThread() { return h; } private static void h() { File t2 = p.t(c); if (t2 != null) { File[] listFiles = t2.listFiles(); Pattern compile = Pattern.compile("tbs_switch_disable_(.*)"); for (File file : listFiles) { if (compile.matcher(file.getName()).find() && file.isFile() && file.exists() && file.canRead()) { TbsLog.i(LOGTAG, "clearTbsCoreDisableFlagFiles: " + file.getName() + "; res: " + file.delete()); } } } } private static void i() { File file = new File(p.t(c), "switch_disable_check"); if (!file.exists()) { try { boolean createNewFile = file.createNewFile(); TbsLog.i(LOGTAG, "addSwitchDisableCheckFlag status: " + createNewFile); } catch (IOException e2) { TbsLog.i(LOGTAG, "" + e2); } } } public static boolean isDownloadForeground() { m mVar = g; return mVar != null && mVar.d(); } public static synchronized boolean isDownloading() { boolean z; synchronized (TbsDownloader.class) { TbsLog.i(LOGTAG, "[TbsDownloader.isDownloading] is " + a); z = a; } return z; } public static boolean isTbsCoreDisabledBySwitch(Context context, int i2) { File t2 = p.t(context); return new File(t2, "tbs_switch_disable_" + i2).exists(); } public static boolean needDownload(Context context, boolean z) { return needDownload(context, z, false, true, null); } public static boolean needDownload(Context context, boolean z, boolean z2, TbsDownloaderCallback tbsDownloaderCallback) { return needDownload(context, z, z2, true, tbsDownloaderCallback); } public static boolean needDownload(Context context, boolean z, boolean z2, boolean z3, TbsDownloaderCallback tbsDownloaderCallback) { int i2; int i3; Context applicationContext = context.getApplicationContext(); c = applicationContext; TbsDownloadConfig instance = TbsDownloadConfig.getInstance(applicationContext); instance.setDownloadInterruptCode(-100); r.a(context, "need_download", ""); r.a("1"); TbsLog.initIfNeed(context); TbsLog.i(LOGTAG, "needDownload,process=" + QbSdk.getCurrentProcessName(context) + "stack=" + Log.getStackTraceString(new Throwable())); boolean z4 = true; p.a().b(context, g.a == 0); int b2 = p.a().b(context); TbsLog.i(LOGTAG, "[TbsDownloader.needDownload],renameRet=" + b2); if (b2 != 0) { TbsLogReport.TbsLogInfo tbsLogInfo = TbsLogReport.getInstance(context).tbsLogInfo(); tbsLogInfo.a = 129; tbsLogInfo.setFailDetail("code=2" + b2); } if (b2 < 0) { TbsLog.i(LOGTAG, "[TbsDownloader.needDownload],needReNameFile=" + b2); instance.setDownloadInterruptCode(-128); if (tbsDownloaderCallback != null) { tbsDownloaderCallback.onNeedDownloadFinish(false, 0); } return false; } TbsLog.i(LOGTAG, "[TbsDownloader.needDownload] oversea=" + z + ",isDownloadForeground=" + z2); if (p.b) { TbsLog.i(LOGTAG, "[TbsDownloader.needDownload]#1 Static Installing, return false"); instance.setDownloadInterruptCode(NetError.ERR_PROXY_CONNECTION_FAILED); if (tbsDownloaderCallback != null) { tbsDownloaderCallback.onNeedDownloadFinish(false, 0); } return false; } TbsLog.app_extra(LOGTAG, context); if (!a(c, z)) { TbsLog.i(LOGTAG, "[TbsDownloader.needDownload]#2 Not shouldDoNeedDownload, return false"); if (tbsDownloaderCallback != null) { tbsDownloaderCallback.onNeedDownloadFinish(false, 0); } return false; } c(); if (i) { instance.setDownloadInterruptCode(NetError.ERR_NAME_NOT_RESOLVED); TbsLog.i(LOGTAG, "[TbsDownloader.needDownload]#3 TbsApkDownloader init Exception, return false"); if (tbsDownloaderCallback != null) { tbsDownloaderCallback.onNeedDownloadFinish(false, 0); } return false; } boolean a2 = a(c, z2, false); TbsLog.i(LOGTAG, "[TbsDownloader.needDownload],needSendRequest=" + a2); if (a2) { a(z2, tbsDownloaderCallback, z3); i2 = NetError.ERR_SSL_RENEGOTIATION_REQUESTED; } else { i2 = NetError.ERR_ALPN_NEGOTIATION_FAILED; } instance.setDownloadInterruptCode(i2); d.removeMessages(102); Message.obtain(d, 102).sendToTarget(); boolean contains = instance.mPreferences.contains(TbsDownloadConfig.TbsConfigKey.KEY_NEEDDOWNLOAD); TbsLog.i(LOGTAG, "[TbsDownloader.needDownload] hasNeedDownloadKey=" + contains); if (contains || TbsShareManager.isThirdPartyApp(context)) { z4 = instance.mPreferences.getBoolean(TbsDownloadConfig.TbsConfigKey.KEY_NEEDDOWNLOAD, false); } TbsLog.i(LOGTAG, "[TbsDownloader.needDownload]#4,needDownload=" + z4 + ",hasNeedDownloadKey=" + contains); if (!z4) { int n2 = p.a().n(c); TbsLog.i(LOGTAG, "[TbsDownloader.needDownload]#7,tbsLocalVersion=" + n2 + ",needSendRequest=" + a2); if (a2 || n2 <= 0) { d.removeMessages(103); if (n2 <= 0 && !a2) { Message.obtain(d, 103, 0, 0, c).sendToTarget(); } i3 = NetError.ERR_SOCKS_CONNECTION_HOST_UNREACHABLE; } else { i3 = NetError.ERR_HOST_RESOLVER_QUEUE_TOO_LARGE; } instance.setDownloadInterruptCode(i3); } else if (!g()) { TbsLog.i(LOGTAG, "[TbsDownloader.needDownload]#5,set needDownload = false"); z4 = false; } else { instance.setDownloadInterruptCode(NetError.ERR_CONNECTION_TIMED_OUT); TbsLog.i(LOGTAG, "[TbsDownloader.needDownload]#6"); } if (!a2 && tbsDownloaderCallback != null) { tbsDownloaderCallback.onNeedDownloadFinish(z4, 0); } return z4; } public static boolean needDownloadDecoupleCore() { int i2; if (TbsShareManager.isThirdPartyApp(c) || a(c)) { return false; } return System.currentTimeMillis() - TbsDownloadConfig.getInstance(c).mPreferences.getLong(TbsDownloadConfig.TbsConfigKey.KEY_LAST_DOWNLOAD_DECOUPLE_CORE, 0) >= TbsDownloadConfig.getInstance(c).getRetryInterval() * 1000 && (i2 = TbsDownloadConfig.getInstance(c).mPreferences.getInt(TbsDownloadConfig.TbsConfigKey.KEY_DECOUPLECOREVERSION, 0)) > 0 && i2 != p.a().i(c) && TbsDownloadConfig.getInstance(c).mPreferences.getInt(TbsDownloadConfig.TbsConfigKey.KEY_TBS_DOWNLOAD_V, 0) != i2; } public static boolean needSendRequest(Context context, boolean z) { c = context.getApplicationContext(); TbsLog.initIfNeed(context); boolean z2 = false; if (!a(c, z)) { return false; } int n2 = p.a().n(context); TbsLog.i(LOGTAG, "[TbsDownloader.needSendRequest] localTbsVersion=" + n2); if (n2 > 0) { return false; } if (a(c, false, true)) { return true; } TbsDownloadConfig instance = TbsDownloadConfig.getInstance(c); boolean contains = instance.mPreferences.contains(TbsDownloadConfig.TbsConfigKey.KEY_NEEDDOWNLOAD); TbsLog.i(LOGTAG, "[TbsDownloader.needSendRequest] hasNeedDownloadKey=" + contains); boolean z3 = !contains ? true : instance.mPreferences.getBoolean(TbsDownloadConfig.TbsConfigKey.KEY_NEEDDOWNLOAD, false); TbsLog.i(LOGTAG, "[TbsDownloader.needSendRequest] needDownload=" + z3); if (z3 && g()) { z2 = true; } TbsLog.i(LOGTAG, "[TbsDownloader.needSendRequest] ret=" + z2); return z2; } public static void pauseDownload() { TbsLog.i(LOGTAG, "called pauseDownload,downloader=" + g); m mVar = g; if (mVar != null) { mVar.e(); } } public static void resumeDownload() { TbsLog.i(LOGTAG, "called resumeDownload,downloader=" + g); Handler handler = d; if (handler != null) { handler.removeMessages(109); d.sendEmptyMessage(109); } } public static void setAppContext(Context context) { if (context != null && context.getApplicationContext() != null) { c = context.getApplicationContext(); } } public static void setRetryIntervalInSeconds(Context context, long j2) { if (context != null) { if (context.getApplicationInfo().packageName.equals("com.tencent.qqlive")) { t = j2; } TbsLog.i(LOGTAG, "mRetryIntervalInSeconds is " + t); } } public static boolean startDecoupleCoreIfNeeded() { TbsLog.i(LOGTAG, "startDecoupleCoreIfNeeded closeStableCore "); return false; } public static boolean startDecoupleCoreIfNeededImpl() { String str; TbsLog.i(LOGTAG, "startDecoupleCoreIfNeeded "); if (TbsShareManager.isThirdPartyApp(c)) { return false; } TbsLog.i(LOGTAG, "startDecoupleCoreIfNeeded #1"); m.a(c); m.b(c); if (a(c) || d == null) { return false; } TbsLog.i(LOGTAG, "startDecoupleCoreIfNeeded #2"); if (System.currentTimeMillis() - TbsDownloadConfig.getInstance(c).mPreferences.getLong(TbsDownloadConfig.TbsConfigKey.KEY_LAST_DOWNLOAD_DECOUPLE_CORE, 0) < TbsDownloadConfig.getInstance(c).getRetryInterval() * 1000) { return false; } TbsLog.i(LOGTAG, "startDecoupleCoreIfNeeded #3"); int i2 = TbsDownloadConfig.getInstance(c).mPreferences.getInt(TbsDownloadConfig.TbsConfigKey.KEY_DECOUPLECOREVERSION, 0); int tbsStableCoreVersion = r.b(c) ? TbsShareManager.getTbsStableCoreVersion(c, 0) : p.a().i(c); TbsLog.i(LOGTAG, "startDecoupleCoreIfNeeded coreVersionForThirdApp is " + tbsStableCoreVersion + " deCoupleCoreVersion is " + i2); if (i2 <= 0 || i2 <= tbsStableCoreVersion) { str = "startDecoupleCoreIfNeeded no need, deCoupleCoreVersion is " + i2 + " localStableCoreVersion is " + tbsStableCoreVersion; } else if (a(i2, tbsStableCoreVersion, 0)) { TbsDownloadConfig instance = TbsDownloadConfig.getInstance(c); instance.mSyncMap.put(TbsDownloadConfig.TbsConfigKey.KEY_CPUTYPE_OTHER_STABLE_CORE, 0); instance.commit(); TbsLog.i(LOGTAG, "startDecoupleCoreIfNeededImpl stable core " + i2 + " copy from old backup and return "); return false; } else if (TbsDownloadConfig.getInstance(c).mPreferences.getInt(TbsDownloadConfig.TbsConfigKey.KEY_TBS_DOWNLOAD_V, 0) != i2 || TbsDownloadConfig.getInstance(c).mPreferences.getInt(TbsDownloadConfig.TbsConfigKey.KEY_TBS_DOWNLOAD_V_TYPE, 0) == 1) { TbsLog.i(LOGTAG, "startDecoupleCoreIfNeeded #4"); a = true; d.removeMessages(108); Message obtain = Message.obtain(d, 108, QbSdk.n); obtain.arg1 = 0; obtain.sendToTarget(); TbsDownloadConfig.getInstance(c).mSyncMap.put(TbsDownloadConfig.TbsConfigKey.KEY_LAST_DOWNLOAD_DECOUPLE_CORE, Long.valueOf(System.currentTimeMillis())); return true; } else { str = "startDecoupleCoreIfNeeded no need, KEY_TBS_DOWNLOAD_V is " + TbsDownloadConfig.getInstance(c).mPreferences.getInt(TbsDownloadConfig.TbsConfigKey.KEY_TBS_DOWNLOAD_V, 0) + " deCoupleCoreVersion is " + i2 + " KEY_TBS_DOWNLOAD_V_TYPE is " + TbsDownloadConfig.getInstance(c).mPreferences.getInt(TbsDownloadConfig.TbsConfigKey.KEY_TBS_DOWNLOAD_V_TYPE, 0); } TbsLog.i(LOGTAG, str); return false; } public static void startDownload(Context context) { startDownload(context, false); } public static synchronized void startDownload(Context context, boolean z) { synchronized (TbsDownloader.class) { Context applicationContext = context.getApplicationContext(); c = applicationContext; TbsLog.initIfNeed(applicationContext); TbsDownloadConfig instance = TbsDownloadConfig.getInstance(c); instance.setDownloadInterruptCode(-200); TbsLog.i(LOGTAG, "[TbsDownloader.startDownload] sAppContext=" + c); if (p.b) { instance.setDownloadInterruptCode(NetError.ERR_PROXY_CONNECTION_FAILED); return; } int i2 = 0; p.a().b(context, g.a == 0); int b2 = p.a().b(context); TbsLog.i(LOGTAG, "[TbsDownloader.needDownload],renameRet=" + b2); if (b2 < 0) { instance.setDownloadInterruptCode(-128); TbsLog.i(LOGTAG, "[TbsDownloader.needDownload],needReNameFile=" + b2); return; } a = true; if (Build.VERSION.SDK_INT < 8) { instance.setDownloadInterruptCode(NetError.ERR_CERT_DATE_INVALID); QbSdk.n.onDownloadFinish(110); return; } c(); if (i) { instance.setDownloadInterruptCode(NetError.ERR_CERT_AUTHORITY_INVALID); QbSdk.n.onDownloadFinish(121); return; } if (z) { stopDownload(); } d.removeMessages(101); d.removeMessages(100); Message obtain = Message.obtain(d, 101, QbSdk.n); if (z) { i2 = 1; } obtain.arg1 = i2; obtain.sendToTarget(); } } public static void stopDownload() { if (!i) { TbsLog.i(LOGTAG, "[TbsDownloader.stopDownload]"); m mVar = g; if (mVar != null) { mVar.b(); } Handler handler = d; if (handler != null) { handler.removeMessages(100); d.removeMessages(101); d.removeMessages(108); } } } }