package com.tencent.smtt.sdk; import android.annotation.TargetApi; import android.content.Context; import android.content.SharedPreferences; import android.content.pm.PackageInfo; import android.content.pm.PackageManager; import android.content.pm.Signature; import android.os.Build; import android.os.Bundle; import android.os.Handler; import android.os.Message; import android.os.Process; import android.text.TextUtils; import android.util.Log; import cn.jpush.android.service.WakedResultReceiver; import com.baidu.speech.utils.AsrError; import com.fasterxml.jackson.core.util.MinimalPrettyPrinter; import com.tencent.smtt.sdk.TbsDownloadConfig; import com.tencent.smtt.sdk.TbsListener; import com.tencent.smtt.sdk.TbsLogReport; 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.r; import dalvik.system.DexClassLoader; import java.io.BufferedInputStream; import java.io.BufferedOutputStream; import java.io.File; import java.io.FileFilter; import java.io.FileInputStream; import java.io.FileOutputStream; import java.io.IOException; import java.nio.channels.FileLock; import java.util.Properties; import java.util.concurrent.locks.Lock; import java.util.concurrent.locks.ReentrantLock; import java.util.regex.Pattern; import org.altbeacon.beacon.service.RangedBeacon; /* access modifiers changed from: package-private */ public class p { public static ThreadLocal<Integer> a = new ThreadLocal<Integer>() { /* class com.tencent.smtt.sdk.p.AnonymousClass1 */ /* renamed from: a */ public Integer initialValue() { return 0; } }; static boolean b = false; static final FileFilter c = new FileFilter() { /* class com.tencent.smtt.sdk.p.AnonymousClass2 */ public boolean accept(File file) { String name = file.getName(); if (name == null || name.endsWith(".jar_is_first_load_dex_flag_file")) { return false; } if (Build.VERSION.SDK_INT >= 21 && name.endsWith(".dex")) { return false; } if (Build.VERSION.SDK_INT < 26 || !name.endsWith(".prof")) { return Build.VERSION.SDK_INT < 26 || !name.equals("oat"); } return false; } }; private static p d; private static final ReentrantLock i = new ReentrantLock(); private static final Lock j = new ReentrantLock(); private static FileLock l = null; private static Handler m = null; private static final Long[][] n = {new Long[]{44006L, 39094008L}, new Long[]{44005L, 39094008L}, new Long[]{43910L, 38917816L}, new Long[]{44027L, 39094008L}, new Long[]{44028L, 39094008L}, new Long[]{44029L, 39094008L}, new Long[]{44030L, 39094008L}, new Long[]{44032L, 39094008L}, new Long[]{44033L, 39094008L}, new Long[]{44034L, 39094008L}, new Long[]{43909L, 38917816L}}; private static int o = 0; private static boolean p = false; private int e = 0; private FileLock f; private FileOutputStream g; private boolean h = false; private boolean k = false; private p() { if (m == null) { m = new Handler(o.a().getLooper()) { /* class com.tencent.smtt.sdk.p.AnonymousClass3 */ public void handleMessage(Message message) { QbSdk.setTBSInstallingStatus(true); switch (message.what) { case 1: TbsLog.i("TbsInstaller", "TbsInstaller--handleMessage--MSG_INSTALL_TBS_CORE"); Object[] objArr = (Object[]) message.obj; p.this.b((p) ((Context) objArr[0]), (Context) ((String) objArr[1]), (String) ((Integer) objArr[2]).intValue()); return; case 2: TbsLog.i("TbsInstaller", "TbsInstaller--handleMessage--MSG_COPY_TBS_CORE"); Object[] objArr2 = (Object[]) message.obj; p.this.a((p) ((Context) objArr2[0]), (Context) objArr2[1], (Context) ((Integer) objArr2[2]).intValue()); return; case 3: TbsLog.i("TbsInstaller", "TbsInstaller--handleMessage--MSG_INSTALL_TBS_CORE_EX"); Object[] objArr3 = (Object[]) message.obj; p.this.b((Context) objArr3[0], (Bundle) objArr3[1]); return; case 4: TbsLog.i("TbsInstaller", "TbsInstaller--handleMessage--MSG_UNZIP_TBS_CORE"); Object[] objArr4 = (Object[]) message.obj; p.this.b((Context) objArr4[0], (File) objArr4[1], ((Integer) objArr4[2]).intValue()); QbSdk.setTBSInstallingStatus(false); super.handleMessage(message); return; default: return; } } }; } } private void A(Context context) { TbsLog.i("TbsInstaller", "TbsInstaller--generateNewTbsCoreFromCopy"); if (!x(context)) { TbsLog.i("TbsInstaller", "get rename fileLock#4 ## failed!"); return; } try { B(context); D(context); if (TbsShareManager.isThirdPartyApp(context)) { TbsShareManager.writeCoreInfoForThirdPartyApp(context, n(context), true); } else { TbsShareManager.a(context); } n.a(context).a(0, 3); n.a(context).a("tpatch_num", 0); if (!TbsShareManager.isThirdPartyApp(context)) { int i2 = TbsDownloadConfig.getInstance(context).mPreferences.getInt(TbsDownloadConfig.TbsConfigKey.KEY_DECOUPLECOREVERSION, 0); if (i2 <= 0 || i2 == a().i(context) || i2 != a().j(context)) { TbsLog.i("TbsInstaller", "TbsInstaller--generateNewTbsCoreFromCopy #1 deCoupleCoreVersion is " + i2 + " getTbsCoreShareDecoupleCoreVersion is " + a().i(context) + " getTbsCoreInstalledVerInNolock is " + a().j(context)); } else { o(context); } } a.set(0); } catch (Exception e2) { e2.printStackTrace(); TbsLogReport instance = TbsLogReport.getInstance(context); instance.setInstallErrorCode(TbsListener.ErrorCode.RENAME_EXCEPTION, "exception when renameing from copy:" + e2.toString()); } h(context); } private void B(Context context) { TbsLog.i("TbsInstaller", "TbsInstaller--deleteOldCore"); FileUtil.a(r(context), false); } private void C(Context context) { int i2; TbsLogReport tbsLogReport; TbsLog.i("TbsInstaller", "TbsInstaller--renameShareDir"); File f2 = f(context, 0); File r = r(context); if (f2 == null || r == null) { TbsLog.i("TbsInstaller", "renameTbsCoreShareDir return,tmpTbsCoreUnzipDir=" + f2 + "tbsSharePath=" + r); return; } boolean renameTo = f2.renameTo(r); TbsLog.i("TbsInstaller", "renameTbsCoreShareDir rename success=" + renameTo); r.a("8is" + renameTo); if (context != null && TbsConfig.APP_WX.equals(context.getApplicationContext().getApplicationInfo().packageName)) { if (renameTo) { tbsLogReport = TbsLogReport.getInstance(context); i2 = TbsListener.ErrorCode.RENAME_SUCCESS; } else { tbsLogReport = TbsLogReport.getInstance(context); i2 = TbsListener.ErrorCode.RENAME_FAIL; } tbsLogReport.setInstallErrorCode(i2, MinimalPrettyPrinter.DEFAULT_ROOT_VALUE_SEPARATOR); } TbsLog.i("TbsInstaller", "setTmpFolderCoreToRead call #07"); g(context, false); } private void D(Context context) { TbsLog.i("TbsInstaller", "TbsInstaller--renameTbsCoreCopyDir"); File f2 = f(context, 1); File r = r(context); if (f2 != null && r != null) { f2.renameTo(r); TbsLog.i("TbsInstaller", "setTmpFolderCoreToRead call #08"); g(context, false); } } private void E(Context context) { TbsLog.i("TbsInstaller", "TbsInstaller--renameTbsTpatchCoreDir"); File f2 = f(context, 5); File r = r(context); if (f2 != null && r != null) { f2.renameTo(r); TbsLog.i("TbsInstaller", "setTmpFolderCoreToRead call #09"); g(context, false); } } private void F(Context context) { TbsLog.i("TbsInstaller", "TbsInstaller--clearNewTbsCore"); File f2 = f(context, 0); if (f2 != null) { FileUtil.a(f2, false); } n.a(context).c(0, 5); n.a(context).c(-1); QbSdk.a(context, "TbsInstaller::clearNewTbsCore forceSysWebViewInner!"); } static synchronized p a() { p pVar; synchronized (p.class) { if (d == null) { synchronized (p.class) { if (d == null) { d = new p(); } } } pVar = d; } return pVar; } /* JADX WARNING: Removed duplicated region for block: B:28:0x0088 A[SYNTHETIC, Splitter:B:28:0x0088] */ /* JADX WARNING: Removed duplicated region for block: B:33:0x0092 */ /* JADX WARNING: Removed duplicated region for block: B:38:0x009e A[SYNTHETIC, Splitter:B:38:0x009e] */ /* JADX WARNING: Removed duplicated region for block: B:43:0x00a8 A[SYNTHETIC, Splitter:B:43:0x00a8] */ /* JADX WARNING: Removed duplicated region for block: B:49:? A[RETURN, SYNTHETIC] */ private void a(int i2, String str, Context context) { Throwable th; BufferedInputStream bufferedInputStream; Throwable th2; new File(str).delete(); TbsLog.i("TbsInstaller", "Local tbs apk(" + str + ") is deleted!", true); File file = new File(QbSdk.getTbsFolderDir(context), "core_unzip_tmp"); if (file.canRead()) { File file2 = new File(file, "tbs.conf"); Properties properties = new Properties(); BufferedOutputStream bufferedOutputStream = null; try { bufferedInputStream = new BufferedInputStream(new FileInputStream(file2)); try { properties.load(bufferedInputStream); BufferedOutputStream bufferedOutputStream2 = new BufferedOutputStream(new FileOutputStream(file2)); try { properties.setProperty("tbs_local_installation", "true"); properties.store(bufferedOutputStream2, (String) null); TbsLog.i("TbsInstaller", "TBS_LOCAL_INSTALLATION is set!", true); try { bufferedOutputStream2.close(); } catch (IOException e2) { e2.printStackTrace(); } try { bufferedInputStream.close(); } catch (IOException e3) { e3.printStackTrace(); } } catch (Throwable th3) { th = th3; bufferedOutputStream = bufferedOutputStream2; if (bufferedOutputStream != null) { } if (bufferedInputStream != null) { } throw th; } } catch (Throwable th4) { th2 = th4; th2.printStackTrace(); if (bufferedOutputStream != null) { } if (bufferedInputStream != null) { } } } catch (Throwable th5) { th = th5; bufferedInputStream = null; if (bufferedOutputStream != null) { try { bufferedOutputStream.close(); } catch (IOException e4) { e4.printStackTrace(); } } if (bufferedInputStream != null) { try { bufferedInputStream.close(); } catch (IOException e5) { e5.printStackTrace(); } } throw th; } } } public static void a(Context context) { String str; String str2; if (!w(context)) { if (a(context, "core_unzip_tmp")) { TbsCoreLoadStat.getInstance().a(context, TbsListener.ErrorCode.INFO_TEMP_CORE_EXIST_CONF_ERROR, new Throwable("TMP_TBS_UNZIP_FOLDER_NAME")); str = "TbsInstaller"; str2 = "TbsInstaller-UploadIfTempCoreExistConfError INFO_TEMP_CORE_EXIST_CONF_ERROR TMP_TBS_UNZIP_FOLDER_NAME"; } else if (a(context, "core_share_backup_tmp")) { TbsCoreLoadStat.getInstance().a(context, TbsListener.ErrorCode.INFO_TEMP_CORE_EXIST_CONF_ERROR, new Throwable("TMP_BACKUP_TBSCORE_FOLDER_NAME")); str = "TbsInstaller"; str2 = "TbsInstaller-UploadIfTempCoreExistConfError INFO_TEMP_CORE_EXIST_CONF_ERROR TMP_BACKUP_TBSCORE_FOLDER_NAME"; } else if (a(context, "core_copy_tmp")) { TbsCoreLoadStat.getInstance().a(context, TbsListener.ErrorCode.INFO_TEMP_CORE_EXIST_CONF_ERROR, new Throwable("TMP_TBS_COPY_FOLDER_NAME")); str = "TbsInstaller"; str2 = "TbsInstaller-UploadIfTempCoreExistConfError INFO_TEMP_CORE_EXIST_CONF_ERROR TMP_TBS_COPY_FOLDER_NAME"; } else { return; } TbsLog.e(str, str2); } } /* access modifiers changed from: private */ /* access modifiers changed from: public */ /* JADX WARNING: Code restructure failed: missing block: B:102:0x02eb, code lost: r0 = move-exception; */ /* JADX WARNING: Code restructure failed: missing block: B:103:0x02ec, code lost: r3 = r0; r16 = null; */ /* JADX WARNING: Code restructure failed: missing block: B:104:0x02f1, code lost: r0 = move-exception; */ /* JADX WARNING: Code restructure failed: missing block: B:105:0x02f2, code lost: r4 = r0; r6 = null; */ /* JADX WARNING: Code restructure failed: missing block: B:111:?, code lost: r16.close(); */ /* JADX WARNING: Code restructure failed: missing block: B:112:0x02ff, code lost: r0 = move-exception; */ /* JADX WARNING: Code restructure failed: missing block: B:113:0x0300, code lost: r0.printStackTrace(); */ /* JADX WARNING: Code restructure failed: missing block: B:154:0x047b, code lost: if (r4 == r7) goto L_0x047d; */ /* JADX WARNING: Code restructure failed: missing block: B:174:?, code lost: r16.close(); */ /* JADX WARNING: Code restructure failed: missing block: B:175:0x0511, code lost: r0 = move-exception; */ /* JADX WARNING: Code restructure failed: missing block: B:176:0x0512, code lost: r0.printStackTrace(); */ /* JADX WARNING: Failed to process nested try/catch */ /* JADX WARNING: Removed duplicated region for block: B:102:0x02eb A[ExcHandler: all (r0v9 'th' java.lang.Throwable A[CUSTOM_DECLARE]), Splitter:B:81:0x02ab] */ /* JADX WARNING: Removed duplicated region for block: B:110:0x02fb A[SYNTHETIC, Splitter:B:110:0x02fb] */ /* JADX WARNING: Removed duplicated region for block: B:116:0x0307 */ /* JADX WARNING: Removed duplicated region for block: B:139:0x03db A[ADDED_TO_REGION] */ /* JADX WARNING: Removed duplicated region for block: B:148:0x042c */ /* JADX WARNING: Removed duplicated region for block: B:149:0x042f */ /* JADX WARNING: Removed duplicated region for block: B:152:0x043e */ /* JADX WARNING: Removed duplicated region for block: B:158:0x048b */ /* JADX WARNING: Removed duplicated region for block: B:160:0x0495 */ /* JADX WARNING: Removed duplicated region for block: B:163:0x04c1 */ /* JADX WARNING: Removed duplicated region for block: B:164:0x04ca */ /* JADX WARNING: Removed duplicated region for block: B:173:0x050d A[SYNTHETIC, Splitter:B:173:0x050d] */ @TargetApi(11) private void a(Context context, Context context2, int i2) { File file; Exception exc; BufferedInputStream bufferedInputStream; Throwable th; Properties properties; boolean z; boolean z2; File d2; TbsLogReport instance; String str; int i3; SharedPreferences sharedPreferences; Exception exc2; BufferedInputStream bufferedInputStream2; TbsDownloadConfig.getInstance(context).setInstallInterruptCode(-524); if (!d(context2)) { TbsLog.i("TbsInstaller", "TbsInstaller-copyTbsCoreInThread start! tbsCoreTargetVer is " + i2); if ((Build.VERSION.SDK_INT >= 11 ? context2.getSharedPreferences("tbs_preloadx5_check_cfg_file", 4) : context2.getSharedPreferences("tbs_preloadx5_check_cfg_file", 0)).getInt("tbs_precheck_disable_version", -1) == i2) { TbsLog.e("TbsInstaller", "TbsInstaller-copyTbsCoreInThread -- version:" + i2 + " is disabled by preload_x5_check!"); TbsDownloadConfig.getInstance(context).setInstallInterruptCode(-525); } else if (!u(context2)) { TbsDownloadConfig.getInstance(context).setInstallInterruptCode(-526); } else { boolean tryLock = j.tryLock(); TbsLog.i("TbsInstaller", "TbsInstaller-copyTbsCoreInThread #1 locked is " + tryLock); if (tryLock) { i.lock(); try { int c2 = n.a(context2).c("copy_core_ver"); int b2 = n.a(context2).b("copy_status"); if (c2 == i2) { QbSdk.n.onInstallFinish(TbsListener.ErrorCode.COPY_INSTALL_SUCCESS); TbsDownloadConfig.getInstance(context).setInstallInterruptCode(-528); i.unlock(); j.unlock(); b(); return; } int j2 = j(context2); TbsLog.i("TbsInstaller", "TbsInstaller-copyTbsCoreInThread tbsCoreInstalledVer=" + j2); if (j2 == i2) { QbSdk.n.onInstallFinish(TbsListener.ErrorCode.COPY_INSTALL_SUCCESS); TbsDownloadConfig.getInstance(context).setInstallInterruptCode(-528); TbsLog.i("TbsInstaller", "TbsInstaller-copyTbsCoreInThread return have same version is " + j2); i.unlock(); j.unlock(); b(); return; } int b3 = n.a(context2).b(); if ((b3 > 0 && i2 > b3) || (c2 > 0 && i2 > c2)) { p(context2); } if (b2 == 3 && j2 > 0 && (i2 > j2 || i2 == 88888888)) { p(context2); TbsLog.i("TbsInstaller", "TbsInstaller-copyTbsCoreInThread -- update TBS.....", true); b2 = -1; } if (!FileUtil.b(context2)) { long a2 = r.a(); long downloadMinFreeSpace = TbsDownloadConfig.getInstance(context2).getDownloadMinFreeSpace(); TbsDownloadConfig.getInstance(context).setInstallInterruptCode(-529); TbsLogReport instance2 = TbsLogReport.getInstance(context2); instance2.setInstallErrorCode(TbsListener.ErrorCode.ROM_NOT_ENOUGH, "rom is not enough when copying tbs core! curAvailROM=" + a2 + ",minReqRom=" + downloadMinFreeSpace); i.unlock(); j.unlock(); b(); } else if (b2 <= 0 || (!TbsShareManager.isThirdPartyApp(context2) && TbsDownloader.a(context2) && i2 != i(context2))) { if (b2 == 0) { int c3 = n.a(context2).c("copy_retry_num"); if (c3 > 2) { TbsLogReport.getInstance(context2).setInstallErrorCode(TbsListener.ErrorCode.EXCEED_COPY_RETRY_NUM, "exceed copy retry num!"); TbsDownloadConfig.getInstance(context).setInstallInterruptCode(-530); i.unlock(); j.unlock(); b(); return; } n.a(context2).a("copy_retry_num", c3 + 1); } File r = r(context); file = (TbsShareManager.isThirdPartyApp(context2) || !TbsDownloader.a(context2)) ? f(context2, 1) : q(context2); if (r == null || file == null) { if (r == null) { TbsLogReport.getInstance(context2).setInstallErrorCode(TbsListener.ErrorCode.COPY_SRCDIR_ERROR, "src-dir is null when copying tbs core!"); TbsDownloadConfig.getInstance(context).setInstallInterruptCode(-535); } if (file == null) { TbsLogReport.getInstance(context2).setInstallErrorCode(TbsListener.ErrorCode.COPY_TMPDIR_ERROR, "dst-dir is null when copying tbs core!"); TbsDownloadConfig.getInstance(context).setInstallInterruptCode(-536); } } try { n.a(context2).a(i2, 0); com.tencent.smtt.utils.p pVar = new com.tencent.smtt.utils.p(); pVar.a(r); long currentTimeMillis = System.currentTimeMillis(); TbsDownloadConfig.getInstance(context).setInstallInterruptCode(-551); boolean a3 = FileUtil.a(r, file, c); if (TbsDownloader.a(context2)) { TbsShareManager.b(context2); } TbsLog.i("TbsInstaller", "TbsInstaller-copyTbsCoreInThread time=" + (System.currentTimeMillis() - currentTimeMillis)); if (a3) { pVar.b(r); if (!pVar.a()) { TbsLog.i("TbsInstaller", "TbsInstaller-copyTbsCoreInThread copy-verify fail!"); FileUtil.a(file, true); TbsLogReport.getInstance(context2).setInstallErrorCode(TbsListener.ErrorCode.COPY_SRCDIR_ERROR, "TbsCopy-Verify fail after copying tbs core!"); TbsDownloadConfig.getInstance(context).setInstallInterruptCode(-531); i.unlock(); j.unlock(); b(); return; } try { File file2 = new File(file, WakedResultReceiver.CONTEXT_KEY); properties = new Properties(); if (file2.exists()) { BufferedInputStream bufferedInputStream3 = new BufferedInputStream(new FileInputStream(file2)); try { properties.load(bufferedInputStream3); bufferedInputStream2 = bufferedInputStream3; z = true; } catch (Exception e2) { bufferedInputStream = bufferedInputStream3; exc2 = e2; try { exc2.printStackTrace(); if (bufferedInputStream != null) { } z = true; if (z) { } z2 = true; TbsLog.i("TbsInstaller", "copyTbsCoreInThread - md5_check_success:" + z2); if (z) { } TbsLog.i("TbsInstaller", "TbsInstaller-copyTbsCoreInThread success!"); TbsLog.i("TbsInstaller", "setTmpFolderCoreToRead call #04"); g(context2, true); d2 = m.d(context); File file3 = new File(d2, !TbsDownloader.getOverSea(context2) ? "x5.oversea.tbs.org" : TbsDownloader.getBackupFileName(false)); if (r.b(context2)) { } m.a(file3, context2); n.a(context2).a(i2, 1); if (!this.k) { } instance.setInstallErrorCode(TbsListener.ErrorCode.COPY_INSTALL_SUCCESS, str); TbsDownloadConfig.getInstance(context).setInstallInterruptCode(-533); TbsLog.i("TbsInstaller", "TbsInstaller-copyTbsCoreInThread success -- version:" + i2); if (Build.VERSION.SDK_INT < 11) { } try { SharedPreferences.Editor edit = sharedPreferences.edit(); edit.putInt("tbs_preload_x5_counter", i3); edit.putInt("tbs_preload_x5_recorder", i3); edit.putInt("tbs_preload_x5_version", i2); edit.commit(); } catch (Throwable th2) { TbsLog.e("TbsInstaller", "Init tbs_preload_x5_counter#2 exception:" + Log.getStackTraceString(th2)); } r.a(context2); } catch (Throwable th3) { th = th3; if (bufferedInputStream != null) { } throw th; } } catch (Throwable th4) { th = th4; bufferedInputStream = bufferedInputStream3; if (bufferedInputStream != null) { } throw th; } } else { z = false; bufferedInputStream2 = null; } if (bufferedInputStream2 != null) { try { bufferedInputStream2.close(); } catch (IOException e3) { e3.printStackTrace(); } } } catch (Exception e4) { exc2 = e4; bufferedInputStream = null; exc2.printStackTrace(); if (bufferedInputStream != null) { } z = true; if (z) { } z2 = true; TbsLog.i("TbsInstaller", "copyTbsCoreInThread - md5_check_success:" + z2); if (z) { } TbsLog.i("TbsInstaller", "TbsInstaller-copyTbsCoreInThread success!"); TbsLog.i("TbsInstaller", "setTmpFolderCoreToRead call #04"); g(context2, true); d2 = m.d(context); File file32 = new File(d2, !TbsDownloader.getOverSea(context2) ? "x5.oversea.tbs.org" : TbsDownloader.getBackupFileName(false)); if (r.b(context2)) { } m.a(file32, context2); n.a(context2).a(i2, 1); if (!this.k) { } instance.setInstallErrorCode(TbsListener.ErrorCode.COPY_INSTALL_SUCCESS, str); TbsDownloadConfig.getInstance(context).setInstallInterruptCode(-533); TbsLog.i("TbsInstaller", "TbsInstaller-copyTbsCoreInThread success -- version:" + i2); if (Build.VERSION.SDK_INT < 11) { } SharedPreferences.Editor edit2 = sharedPreferences.edit(); edit2.putInt("tbs_preload_x5_counter", i3); edit2.putInt("tbs_preload_x5_recorder", i3); edit2.putInt("tbs_preload_x5_version", i2); edit2.commit(); r.a(context2); } catch (Throwable th5) { } if (z) { File[] listFiles = file.listFiles(); TbsDownloadConfig.getInstance(context).setInstallInterruptCode(-552); int i4 = 0; while (true) { if (i4 >= listFiles.length) { break; } File file4 = listFiles[i4]; if (!WakedResultReceiver.CONTEXT_KEY.equals(file4.getName()) && !file4.getName().endsWith(".dex") && !"tbs.conf".equals(file4.getName()) && !file4.isDirectory() && !file4.getName().endsWith(".prof")) { String a4 = a.a(file4); String property = properties.getProperty(file4.getName(), ""); if (property.equals("") || !a4.equals(property)) { TbsLog.e("TbsInstaller", "md5_check_failure for (" + file4.getName() + ")" + " targetMd5:" + property + ", realMd5:" + a4); z2 = false; } else { TbsLog.i("TbsInstaller", "md5_check_success for (" + file4.getName() + ")"); } } i4++; } } z2 = true; TbsLog.i("TbsInstaller", "copyTbsCoreInThread - md5_check_success:" + z2); if (z || z2) { TbsLog.i("TbsInstaller", "TbsInstaller-copyTbsCoreInThread success!"); TbsLog.i("TbsInstaller", "setTmpFolderCoreToRead call #04"); g(context2, true); d2 = m.d(context); if (d2 != null && d2.exists()) { File file322 = new File(d2, !TbsDownloader.getOverSea(context2) ? "x5.oversea.tbs.org" : TbsDownloader.getBackupFileName(false)); if (r.b(context2)) { int i5 = TbsDownloadConfig.getInstance(context2).mPreferences.getInt(TbsDownloadConfig.TbsConfigKey.KEY_DECOUPLECOREVERSION, 0); int tbsStableCoreVersion = TbsShareManager.getTbsStableCoreVersion(context2, 0); int b4 = a.b(file322); TbsLog.i("TbsInstaller", "TbsInstaller-copyTbsCoreInThread decoupleCoreVersion is " + i5 + " localStableCoreVersionMyCpu is " + tbsStableCoreVersion + " srcBackupFileCoreVersion is " + b4); if (tbsStableCoreVersion < i5) { } } m.a(file322, context2); } n.a(context2).a(i2, 1); if (!this.k) { instance = TbsLogReport.getInstance(context2); str = "continueInstallWithout core success"; } else { instance = TbsLogReport.getInstance(context2); str = "success"; } instance.setInstallErrorCode(TbsListener.ErrorCode.COPY_INSTALL_SUCCESS, str); TbsDownloadConfig.getInstance(context).setInstallInterruptCode(-533); TbsLog.i("TbsInstaller", "TbsInstaller-copyTbsCoreInThread success -- version:" + i2); if (Build.VERSION.SDK_INT < 11) { sharedPreferences = context2.getSharedPreferences("tbs_preloadx5_check_cfg_file", 4); i3 = 0; } else { i3 = 0; sharedPreferences = context2.getSharedPreferences("tbs_preloadx5_check_cfg_file", 0); } SharedPreferences.Editor edit22 = sharedPreferences.edit(); edit22.putInt("tbs_preload_x5_counter", i3); edit22.putInt("tbs_preload_x5_recorder", i3); edit22.putInt("tbs_preload_x5_version", i2); edit22.commit(); r.a(context2); } else { TbsLog.e("TbsInstaller", "copyTbsCoreInThread - md5 incorrect -> delete destTmpDir!"); FileUtil.a(file, true); TbsLogReport.getInstance(context2).setInstallErrorCode(TbsListener.ErrorCode.COPY_SRCDIR_ERROR, "TbsCopy-Verify md5 fail after copying tbs core!"); TbsDownloadConfig.getInstance(context).setInstallInterruptCode(-532); i.unlock(); j.unlock(); b(); } } else { TbsLog.i("TbsInstaller", "TbsInstaller-copyTbsCoreInThread fail!"); n.a(context2).a(i2, 2); FileUtil.a(file, false); TbsDownloadConfig.getInstance(context).setInstallInterruptCode(-534); TbsLogReport.getInstance(context2).setInstallErrorCode(TbsListener.ErrorCode.COPY_FAIL, "copy fail!"); } } catch (Exception e5) { exc = e5; try { TbsLogReport.getInstance(context2).setInstallErrorCode(TbsListener.ErrorCode.COPY_EXCEPTION, exc.toString()); TbsDownloadConfig.getInstance(context).setInstallInterruptCode(-537); try { FileUtil.a(file, false); n.a(context2).a(0, -1); } catch (Exception e6) { TbsLog.e("TbsInstaller", "[TbsInstaller-copyTbsCoreInThread] delete dstTmpDir throws exception:" + e6.getMessage() + "," + e6.getCause()); } } finally { i.unlock(); j.unlock(); b(); } } } else { TbsLog.i("TbsInstaller", "TbsInstaller-copyTbsCoreInThread return have copied is " + i(context2)); i.unlock(); j.unlock(); b(); } } catch (Exception e7) { exc = e7; file = null; TbsLogReport.getInstance(context2).setInstallErrorCode(TbsListener.ErrorCode.COPY_EXCEPTION, exc.toString()); TbsDownloadConfig.getInstance(context).setInstallInterruptCode(-537); FileUtil.a(file, false); n.a(context2).a(0, -1); } } else { b(); TbsDownloadConfig.getInstance(context).setInstallInterruptCode(-538); } } } } /* JADX WARNING: Code restructure failed: missing block: B:48:0x012c, code lost: r10 = move-exception; */ /* JADX WARNING: Code restructure failed: missing block: B:49:0x012f, code lost: r11 = move-exception; */ /* JADX WARNING: Code restructure failed: missing block: B:51:?, code lost: com.tencent.smtt.sdk.TbsDownloadConfig.getInstance(r10).setInstallInterruptCode(-523); com.tencent.smtt.sdk.TbsLogReport.getInstance(r10).setInstallErrorCode(com.tencent.smtt.sdk.TbsListener.ErrorCode.UNZIP_OTHER_ERROR, r11); */ /* JADX WARNING: Code restructure failed: missing block: B:55:0x0149, code lost: r3 = false; */ /* JADX WARNING: Code restructure failed: missing block: B:59:?, code lost: com.tencent.smtt.utils.FileUtil.b(r0); com.tencent.smtt.utils.TbsLog.e("TbsInstaller", "copyFileIfChanged -- delete tmpTbsCoreUnzipDir#2! exist:" + r0.exists()); */ /* JADX WARNING: Code restructure failed: missing block: B:60:0x016c, code lost: r10 = move-exception; */ /* JADX WARNING: Code restructure failed: missing block: B:61:0x016d, code lost: com.tencent.smtt.utils.TbsLog.e("TbsInstaller", "copyFileIfChanged -- delete tmpTbsCoreUnzipDir#2! exception:" + android.util.Log.getStackTraceString(r10)); */ /* JADX WARNING: Code restructure failed: missing block: B:64:0x0194, code lost: r11 = move-exception; */ /* JADX WARNING: Code restructure failed: missing block: B:65:0x0195, code lost: com.tencent.smtt.sdk.TbsDownloadConfig.getInstance(r10).setInstallInterruptCode(-523); com.tencent.smtt.sdk.TbsLogReport.getInstance(r10).setInstallErrorCode(com.tencent.smtt.sdk.TbsListener.ErrorCode.UNZIP_IO_ERROR, r11); */ /* JADX WARNING: Code restructure failed: missing block: B:69:0x01ae, code lost: r3 = false; */ /* JADX WARNING: Code restructure failed: missing block: B:73:?, code lost: com.tencent.smtt.utils.FileUtil.b(r0); com.tencent.smtt.utils.TbsLog.e("TbsInstaller", "copyFileIfChanged -- delete tmpTbsCoreUnzipDir#2! exist:" + r0.exists()); */ /* JADX WARNING: Code restructure failed: missing block: B:78:0x01f9, code lost: com.tencent.smtt.utils.TbsLog.i("TbsInstaller", "TbsInstaller-unzipTbs done"); com.tencent.smtt.utils.r.a("11"); */ /* JADX WARNING: Code restructure failed: missing block: B:79:0x0205, code lost: throw r10; */ /* JADX WARNING: Failed to process nested try/catch */ /* JADX WARNING: Removed duplicated region for block: B:64:0x0194 A[ExcHandler: IOException (r11v1 'e' java.io.IOException A[CUSTOM_DECLARE]), Splitter:B:23:0x0098] */ private boolean a(Context context, File file, boolean z) { boolean a2; String[] list; TbsLog.i("TbsInstaller", "TbsInstaller-unzipTbs start isDecoupleCore is " + z); if (!FileUtil.c(file)) { TbsLogReport.getInstance(context).setInstallErrorCode(TbsListener.ErrorCode.APK_INVALID, "apk is invalid!"); TbsDownloadConfig.getInstance(context).setInstallInterruptCode(-520); return false; } try { File tbsFolderDir = QbSdk.getTbsFolderDir(context); File file2 = z ? new File(tbsFolderDir, "core_share_decouple") : new File(tbsFolderDir, "core_unzip_tmp"); if (file2.exists() && !TbsDownloader.a(context)) { FileUtil.b(file2); } } catch (Throwable th) { TbsLog.e("TbsInstaller", "TbsInstaller-unzipTbs -- delete unzip folder if exists exception" + Log.getStackTraceString(th)); } File f2 = z ? f(context, 2) : f(context, 0); if (f2 == null) { TbsLogReport.getInstance(context).setInstallErrorCode(TbsListener.ErrorCode.UNZIP_DIR_ERROR, "tmp unzip dir is null!"); TbsDownloadConfig.getInstance(context).setInstallInterruptCode(-521); return false; } boolean z2 = true; try { FileUtil.a(f2); if (z) { FileUtil.a(f2, true); } a2 = FileUtil.a(file, f2); if (a2) { a2 = a(f2, context); } if (z) { for (String str : f2.list()) { File file3 = new File(f2, str); if (file3.getName().endsWith(".dex")) { file3.delete(); } } new File(t(context), "x5.tbs").delete(); } } catch (Exception unused) { } catch (IOException e2) { } catch (Throwable th2) { TbsLog.e("TbsInstaller", "copyFileIfChanged -- delete tmpTbsCoreUnzipDir#2! exception:" + Log.getStackTraceString(th2)); } if (!a2) { FileUtil.b(f2); TbsDownloadConfig.getInstance(context).setInstallInterruptCode(-522); TbsLog.e("TbsInstaller", "copyFileIfChanged -- delete tmpTbsCoreUnzipDir#1! exist:" + f2.exists()); } else { TbsLog.i("TbsInstaller", "setTmpFolderCoreToRead call #05"); g(context, true); if (z) { File q = q(context); FileUtil.a(q, true); f2.renameTo(q); TbsShareManager.b(context); } } TbsLog.i("TbsInstaller", "TbsInstaller-unzipTbs done"); r.a("11"); return a2; TbsLog.i("TbsInstaller", "TbsInstaller-unzipTbs done"); r.a("11"); return false; TbsLog.i("TbsInstaller", "TbsInstaller-unzipTbs done"); r.a("11"); return false; } static boolean a(Context context, String str) { String str2; StringBuilder sb; String str3; File file = new File(QbSdk.getTbsFolderDir(context), str); if (!file.exists()) { str2 = "TbsInstaller"; sb = new StringBuilder(); str3 = "#1# "; } else if (!new File(file, "tbs.conf").exists()) { str2 = "TbsInstaller"; sb = new StringBuilder(); str3 = "#2# "; } else { TbsLog.i("TbsInstaller", "isPrepareTbsCore", "#3# " + str); return true; } sb.append(str3); sb.append(str); TbsLog.i(str2, "isPrepareTbsCore", sb.toString()); return false; } /* JADX WARNING: Removed duplicated region for block: B:27:0x0064 A[SYNTHETIC, Splitter:B:27:0x0064] */ /* JADX WARNING: Removed duplicated region for block: B:34:0x0085 */ /* JADX WARNING: Removed duplicated region for block: B:57:0x0150 A[ADDED_TO_REGION] */ /* JADX WARNING: Removed duplicated region for block: B:63:0x0164 A[SYNTHETIC, Splitter:B:63:0x0164] */ private boolean a(File file, Context context) { Throwable th; Properties properties; boolean z; boolean z2; File file2; String a2; String property; Exception e2; TbsLog.i("TbsInstaller", "finalCheckForTbsCoreValidity - " + file + ", " + context); BufferedInputStream bufferedInputStream = null; try { File file3 = new File(file, WakedResultReceiver.CONTEXT_KEY); properties = new Properties(); try { if (file3.exists()) { BufferedInputStream bufferedInputStream2 = new BufferedInputStream(new FileInputStream(file3)); try { properties.load(bufferedInputStream2); bufferedInputStream = bufferedInputStream2; z = true; } catch (Exception e3) { e2 = e3; bufferedInputStream = bufferedInputStream2; try { e2.printStackTrace(); if (bufferedInputStream != null) { } z = true; TbsLog.i("TbsInstaller", "finalCheckForTbsCoreValidity - need_check:" + z); if (z) { } z2 = true; TbsLog.i("TbsInstaller", "finalCheckForTbsCoreValidity - md5_check_success:" + z2); if (z) { } TbsLog.i("TbsInstaller", "finalCheckForTbsCoreValidity success!"); return true; } catch (Throwable th2) { th = th2; if (bufferedInputStream != null) { } throw th; } } catch (Throwable th3) { th = th3; bufferedInputStream = bufferedInputStream2; if (bufferedInputStream != null) { try { bufferedInputStream.close(); } catch (IOException e4) { e4.printStackTrace(); } } throw th; } } else { z = false; } if (bufferedInputStream != null) { try { bufferedInputStream.close(); } catch (IOException e5) { e5.printStackTrace(); } } } catch (Exception e6) { e2 = e6; e2.printStackTrace(); if (bufferedInputStream != null) { } z = true; TbsLog.i("TbsInstaller", "finalCheckForTbsCoreValidity - need_check:" + z); if (z) { } z2 = true; TbsLog.i("TbsInstaller", "finalCheckForTbsCoreValidity - md5_check_success:" + z2); if (z) { } TbsLog.i("TbsInstaller", "finalCheckForTbsCoreValidity success!"); return true; } } catch (Exception e7) { e2 = e7; properties = null; e2.printStackTrace(); if (bufferedInputStream != null) { try { bufferedInputStream.close(); } catch (IOException e8) { e8.printStackTrace(); } } z = true; TbsLog.i("TbsInstaller", "finalCheckForTbsCoreValidity - need_check:" + z); if (z) { } z2 = true; TbsLog.i("TbsInstaller", "finalCheckForTbsCoreValidity - md5_check_success:" + z2); if (z) { } TbsLog.i("TbsInstaller", "finalCheckForTbsCoreValidity success!"); return true; } TbsLog.i("TbsInstaller", "finalCheckForTbsCoreValidity - need_check:" + z); if (z) { File[] listFiles = file.listFiles(); int i2 = 0; while (true) { if (i2 >= listFiles.length) { break; } file2 = listFiles[i2]; if (!WakedResultReceiver.CONTEXT_KEY.equals(file2.getName()) && !file2.getName().endsWith(".dex") && !"tbs.conf".equals(file2.getName()) && !file2.isDirectory() && !file2.getName().endsWith(".prof")) { a2 = a.a(file2); property = properties.getProperty(file2.getName(), ""); if (property.equals("") || !property.equals(a2)) { TbsLog.e("TbsInstaller", "md5_check_failure for (" + file2.getName() + ")" + " targetMd5:" + property + ", realMd5:" + a2); z2 = false; } else { TbsLog.i("TbsInstaller", "md5_check_success for (" + file2.getName() + ")"); } } i2++; } TbsLog.e("TbsInstaller", "md5_check_failure for (" + file2.getName() + ")" + " targetMd5:" + property + ", realMd5:" + a2); z2 = false; TbsLog.i("TbsInstaller", "finalCheckForTbsCoreValidity - md5_check_success:" + z2); if (z || z2) { TbsLog.i("TbsInstaller", "finalCheckForTbsCoreValidity success!"); return true; } TbsLog.e("TbsInstaller", "finalCheckForTbsCoreValidity - Verify failed after unzipping!"); return false; } z2 = true; TbsLog.i("TbsInstaller", "finalCheckForTbsCoreValidity - md5_check_success:" + z2); if (z) { } TbsLog.i("TbsInstaller", "finalCheckForTbsCoreValidity success!"); return true; } /* access modifiers changed from: private */ /* access modifiers changed from: public */ /* JADX WARNING: Removed duplicated region for block: B:150:0x04f8 A[SYNTHETIC, Splitter:B:150:0x04f8] */ @TargetApi(11) private void b(Context context, String str, int i2) { boolean z; int i3; TbsLogReport instance; int v; String str2; String str3; String str4; String str5; String absolutePath; boolean z2; TbsLogReport instance2; String str6; TbsDownloadConfig.getInstance(context).setInstallInterruptCode(-501); if (d(context)) { TbsLog.i("TbsInstaller", "isTbsLocalInstalled --> no installation!", true); TbsDownloadConfig.getInstance(context).setInstallInterruptCode(-502); QbSdk.n.onInstallFinish(-502); return; } TbsLog.i("TbsInstaller", "TbsInstaller-installTbsCoreInThread tbsApkPath=" + str); TbsLog.i("TbsInstaller", "TbsInstaller-installTbsCoreInThread tbsCoreTargetVer=" + i2); TbsLog.i("TbsInstaller", "TbsInstaller-continueInstallTbsCore currentProcessName=" + context.getApplicationInfo().processName); TbsLog.i("TbsInstaller", "TbsInstaller-installTbsCoreInThread currentProcessId=" + Process.myPid()); TbsLog.i("TbsInstaller", "TbsInstaller-installTbsCoreInThread currentThreadName=" + Thread.currentThread().getName()); if ((Build.VERSION.SDK_INT >= 11 ? context.getSharedPreferences("tbs_preloadx5_check_cfg_file", 4) : context.getSharedPreferences("tbs_preloadx5_check_cfg_file", 0)).getInt("tbs_precheck_disable_version", -1) == i2) { TbsLog.e("TbsInstaller", "TbsInstaller-installTbsCoreInThread -- version:" + i2 + " is disabled by preload_x5_check!"); TbsDownloadConfig.getInstance(context).setInstallInterruptCode(-503); QbSdk.n.onInstallFinish(-503); } else if (!FileUtil.b(context)) { long a2 = r.a(); long downloadMinFreeSpace = TbsDownloadConfig.getInstance(context).getDownloadMinFreeSpace(); TbsDownloadConfig.getInstance(context).setInstallInterruptCode(-504); String str7 = "rom is not enough when installing tbs core! curAvailROM=" + a2 + ",minReqRom=" + downloadMinFreeSpace; TbsLogReport.getInstance(context).setInstallErrorCode(TbsListener.ErrorCode.ROM_NOT_ENOUGH, str7); TbsLog.i("TbsInstaller", str7); QbSdk.n.onInstallFinish(TbsListener.ErrorCode.ROM_NOT_ENOUGH); } else if (!u(context)) { TbsDownloadConfig.getInstance(context).setInstallInterruptCode(-505); TbsLog.i("TbsInstaller", "getInstalling file lock failed,return!"); QbSdk.n.onInstallFinish(-505); } else { boolean tryLock = j.tryLock(); TbsLog.i("TbsInstaller", "TbsInstaller-installTbsCoreInThread locked =" + tryLock); if (tryLock) { TbsDownloadConfig.getInstance(context).setInstallInterruptCode(-507); i.lock(); try { int c2 = n.a(context).c("copy_core_ver"); int b2 = n.a(context).b(); TbsLog.i("TbsInstaller", "TbsInstaller-installTbsCoreInThread tbsCoreCopyVer =" + c2); TbsLog.i("TbsInstaller", "TbsInstaller-installTbsCoreInThread tbsCoreInstallVer =" + b2); TbsLog.i("TbsInstaller", "TbsInstaller-installTbsCoreInThread tbsCoreTargetVer =" + i2); if ((b2 > 0 && i2 > b2) || (c2 > 0 && i2 > c2)) { p(context); } int c3 = n.a(context).c(); int j2 = j(context); TbsLog.i("TbsInstaller", "TbsInstaller-installTbsCoreInThread installStatus1=" + c3); TbsLog.i("TbsInstaller", "TbsInstaller-installTbsCoreInThread tbsCoreInstalledVer=" + j2); if (c3 < 0 || c3 >= 2) { if (c3 == 3 && j2 >= 0 && (i2 > j2 || i2 == 88888888)) { p(context); TbsLog.i("TbsInstaller", "TbsInstaller-installTbsCoreInThread -- update TBS.....", true); c3 = -1; } z = false; } else { TbsLog.i("TbsInstaller", "TbsInstaller-installTbsCoreInThread -- retry.....", true); z = true; } TbsDownloadConfig.getInstance(context).setInstallInterruptCode(-508); TbsLog.i("TbsInstaller", "TbsInstaller-installTbsCoreInThread installStatus2=" + c3); if (c3 < 1) { TbsLog.i("TbsInstaller", "STEP 2/2 begin installation.....", true); TbsDownloadConfig.getInstance(context).setInstallInterruptCode(-509); if (z) { int c4 = n.a(context).c("unzip_retry_num"); if (c4 > 10) { TbsLogReport.getInstance(context).setInstallErrorCode(TbsListener.ErrorCode.EXCEED_UNZIP_RETRY_NUM, "exceed unzip retry num!"); F(context); TbsDownloadConfig.getInstance(context).setInstallInterruptCode(-510); try { return; } catch (Exception e2) { return; } } else { n.a(context).b(c4 + 1); } } if (str == null) { str4 = n.a(context).d("install_apk_path"); if (str4 == null) { TbsLogReport.getInstance(context).setInstallErrorCode(TbsListener.ErrorCode.APK_PATH_ERROR, "apk path is null!"); TbsDownloadConfig.getInstance(context).setInstallInterruptCode(-511); try { i.unlock(); j.unlock(); } catch (Exception e3) { e3.printStackTrace(); } try { b(); return; } catch (Exception e4) { e4.printStackTrace(); return; } } } else { str4 = str; } TbsLog.i("TbsInstaller", "TbsInstaller-installTbsCoreInThread apkPath =" + str4); i3 = c(context, str4); if (i3 == 0) { TbsDownloadConfig.getInstance(context).setInstallInterruptCode(-512); TbsLogReport.getInstance(context).setInstallErrorCode(TbsListener.ErrorCode.APK_VERSION_ERROR, "apk version is 0!"); try { i.unlock(); j.unlock(); } catch (Exception e5) { e5.printStackTrace(); } try { b(); return; } catch (Exception e6) { e6.printStackTrace(); return; } } else { n.a(context).a("install_apk_path", str4); n.a(context).c(i3, 0); TbsDownloadConfig.getInstance(context).setInstallInterruptCode(-548); if (TbsDownloader.a(context)) { if (!a(context, new File(str4), true)) { TbsLogReport.getInstance(context).setInstallErrorCode(TbsListener.ErrorCode.UNZIP_OTHER_ERROR, "unzipTbsApk failed", TbsLogReport.EventType.TYPE_INSTALL_DECOUPLE); try { i.unlock(); j.unlock(); } catch (Exception e7) { e7.printStackTrace(); } try { b(); return; } catch (Exception e8) { e8.printStackTrace(); return; } } } else if (!b(context, new File(str4))) { TbsLogReport.getInstance(context).setInstallErrorCode(TbsListener.ErrorCode.UNZIP_OTHER_ERROR, "unzipTbsApk failed"); try { i.unlock(); j.unlock(); } catch (Exception e9) { e9.printStackTrace(); } try { b(); return; } catch (Exception e10) { e10.printStackTrace(); return; } } if (z) { int b3 = n.a(context).b("unlzma_status"); if (b3 > 5) { TbsLogReport.getInstance(context).setInstallErrorCode(TbsListener.ErrorCode.EXCEED_LZMA_RETRY_NUM, "exceed unlzma retry num!"); TbsDownloadConfig.getInstance(context).setInstallInterruptCode(-553); F(context); m.e(context); TbsDownloadConfig.getInstance(context).mSyncMap.put(TbsDownloadConfig.TbsConfigKey.KEY_NEEDDOWNLOAD, true); TbsDownloadConfig.getInstance(context).mSyncMap.put(TbsDownloadConfig.TbsConfigKey.KEY_FULL_PACKAGE, true); TbsDownloadConfig.getInstance(context).commit(); try { i.unlock(); j.unlock(); } catch (Exception e11) { e11.printStackTrace(); } try { b(); return; } catch (Exception e12) { e12.printStackTrace(); return; } } else { n.a(context).d(b3 + 1); } } TbsLog.i("TbsInstaller", "unlzma begin"); int i4 = TbsDownloadConfig.getInstance().mPreferences.getInt(TbsDownloadConfig.TbsConfigKey.KEY_RESPONSECODE, 0); if (j(context) != 0) { Object a3 = QbSdk.a(context, "can_unlzma", (Bundle) null); if ((a3 == null || !(a3 instanceof Boolean)) ? false : ((Boolean) a3).booleanValue()) { Bundle bundle = new Bundle(); bundle.putInt("responseCode", i4); if (TbsDownloader.a(context)) { str5 = "unzip_temp_path"; absolutePath = q(context).getAbsolutePath(); } else { str5 = "unzip_temp_path"; absolutePath = f(context, 0).getAbsolutePath(); } bundle.putString(str5, absolutePath); Object a4 = QbSdk.a(context, "unlzma", bundle); if (a4 == null) { TbsLog.i("TbsInstaller", "unlzma return null"); instance2 = TbsLogReport.getInstance(context); str6 = "unlzma is null"; } else { if (a4 instanceof Boolean) { if (((Boolean) a4).booleanValue()) { TbsLog.i("TbsInstaller", "unlzma success"); } else { TbsLog.i("TbsInstaller", "unlzma return false"); instance2 = TbsLogReport.getInstance(context); str6 = "unlzma return false"; } } else if (!(a4 instanceof Bundle)) { if (a4 instanceof Throwable) { TbsLog.i("TbsInstaller", "unlzma failure because Throwable" + Log.getStackTraceString((Throwable) a4)); TbsLogReport.getInstance(context).setInstallErrorCode(TbsListener.ErrorCode.UNLZMA_FAIURE, (Throwable) a4); } z2 = false; if (!z2) { try { i.unlock(); j.unlock(); } catch (Exception e13) { e13.printStackTrace(); } try { b(); return; } catch (Exception e14) { e14.printStackTrace(); return; } } } z2 = true; if (!z2) { } } instance2.setInstallErrorCode(TbsListener.ErrorCode.UNLZMA_FAIURE, str6); z2 = false; if (!z2) { } } } TbsLog.i("TbsInstaller", "unlzma finished"); n.a(context).c(i3, 1); } } else { if (TbsDownloader.a(context)) { if (str == null) { str3 = n.a(context).d("install_apk_path"); if (str3 == null) { TbsLogReport.getInstance(context).setInstallErrorCode(TbsListener.ErrorCode.APK_PATH_ERROR, "apk path is null!"); TbsDownloadConfig.getInstance(context).setInstallInterruptCode(-511); try { i.unlock(); j.unlock(); } catch (Exception e15) { e15.printStackTrace(); } try { b(); return; } catch (Exception e16) { e16.printStackTrace(); return; } } } else { str3 = str; } a(context, new File(str3), true); } i3 = 0; } if (c3 < 2) { if (z) { int c5 = n.a(context).c("dexopt_retry_num"); if (c5 > 10) { TbsLogReport.getInstance(context).setInstallErrorCode(TbsListener.ErrorCode.EXCEED_DEXOPT_RETRY_NUM, "exceed dexopt retry num!"); TbsDownloadConfig.getInstance(context).setInstallInterruptCode(-514); F(context); try { i.unlock(); j.unlock(); } catch (Exception e17) { e17.printStackTrace(); } try { b(); return; } catch (Exception e18) { e18.printStackTrace(); return; } } else { n.a(context).a(c5 + 1); } } TbsDownloadConfig.getInstance(context).setInstallInterruptCode(-549); if (!j(context, 0)) { TbsDownloadConfig.getInstance(context).setInstallInterruptCode(-515); try { i.unlock(); j.unlock(); } catch (Exception e19) { e19.printStackTrace(); } try { b(); return; } catch (Exception e20) { e20.printStackTrace(); return; } } else { n.a(context).c(i3, 2); TbsLog.i("TbsInstaller", "STEP 2/2 installation completed! you can restart!", true); m.a(context); m.b(context); TbsLog.i("TbsInstaller", "STEP 2/2 installation completed! you can restart! version:" + i2); TbsDownloadConfig.getInstance(context).setInstallInterruptCode(-516); try { SharedPreferences.Editor edit = (Build.VERSION.SDK_INT >= 11 ? context.getSharedPreferences("tbs_preloadx5_check_cfg_file", 4) : context.getSharedPreferences("tbs_preloadx5_check_cfg_file", 0)).edit(); edit.putInt("tbs_preload_x5_counter", 0); edit.putInt("tbs_preload_x5_recorder", 0); edit.putInt("tbs_preload_x5_version", i2); edit.commit(); TbsDownloadConfig.getInstance(context).setInstallInterruptCode(-517); } catch (Throwable th) { TbsLog.e("TbsInstaller", "Init tbs_preload_x5_counter#1 exception:" + Log.getStackTraceString(th)); TbsDownloadConfig.getInstance(context).setInstallInterruptCode(-518); } if (i2 == 88888888) { a(i2, str, context); } if (this.k) { instance = TbsLogReport.getInstance(context); v = v(context); str2 = "continueInstallWithout core success"; } else { instance = TbsLogReport.getInstance(context); v = v(context); str2 = "success"; } instance.setInstallErrorCode(v, str2); } } else if (c3 == 2) { QbSdk.n.onInstallFinish(200); } try { i.unlock(); j.unlock(); } catch (Exception e21) { e21.printStackTrace(); } try { b(); } catch (Exception e22) { e22.printStackTrace(); } } finally { try { i.unlock(); j.unlock(); } catch (Exception e23) { e23.printStackTrace(); } try { b(); } catch (Exception e24) { e24.printStackTrace(); } } } else { TbsDownloadConfig.getInstance(context).setInstallInterruptCode(-519); b(); } } } private boolean b(Context context, File file) { return a(context, file, false); } private int c(Context context, Bundle bundle) { int i2; int i3; TbsLogReport instance; int i4; String str; try { Bundle a2 = QbSdk.a(context, bundle); TbsLog.i("TbsInstaller", "tpatch finished,ret is" + a2); int i5 = a2.getInt("patch_result"); if (i5 == 0) { String string = bundle.getString("new_apk_location"); int i6 = bundle.getInt("new_core_ver"); try { i2 = bundle.getInt("for_stable_core"); } catch (Throwable unused) { i2 = 0; } if (i2 == 1) { File file = new File(FileUtil.a(context, TbsConfig.APP_WX, 4, true)); TbsDownloadConfig instance2 = TbsDownloadConfig.getInstance(context); int i7 = instance2.mPreferences.getInt(TbsDownloadConfig.TbsConfigKey.KEY_CPUTYPE_OTHER_STABLE_CORE, 0); File[] listFiles = file.listFiles(); Pattern compile = Pattern.compile(a.a(false, i7)); for (File file2 : listFiles) { if (compile.matcher(file2.getName()).find() && file2.isFile() && file2.exists()) { file2.delete(); } } File file3 = new File(file, a.a(false, i7) + "." + instance2.mPreferences.getInt(TbsDownloadConfig.TbsConfigKey.KEY_TBS_DOWNLOAD_V, 0)); if (!file3.exists()) { file3.createNewFile(); } i3 = TbsShareManager.getTbsStableCoreVersion(context, i7); r.b(context, "tpatch_mid_bundle_ok", ("patchVersion=is=" + i3) + "_" + "targetVersion=is=" + i6); } else { i3 = a(new File(string)); if (TbsShareManager.isThirdPartyApp(context)) { r.a(context, "tpatch_mid_bundle_ok", ("patchVersion=is=" + i3) + "_" + "targetVersion=is=" + i6); } } TbsLog.i("TbsInstaller", "doTpatch wholeFile is " + i2 + " version is " + i6 + " patchVersion is " + i3); if (i6 != i3) { TbsLog.i("TbsInstaller", "version not equals!!!" + i6 + "patchVersion:" + i3); TbsLogReport.getInstance(context).setInstallErrorCode(TbsListener.ErrorCode.TPATCH_VERSION_FAILED, "version=" + i6 + ",patchVersion=" + i3); return 1; } if (i2 == 1) { r.b(context, "tpatch_last_bundle_ok", "coreversion=is=" + i3); } if (TbsShareManager.isThirdPartyApp(context)) { r.a(context, "tpatch_last_bundle_ok", "coreversion=is=" + i3); } if (TbsDownloader.a(context)) { TbsLog.i("TbsInstaller", "Tpatch decouple success!"); instance = TbsLogReport.getInstance(context); i4 = TbsListener.ErrorCode.DECOUPLE_TPATCH_INSTALL_SUCCESS; str = ""; } else { TbsLog.i("TbsInstaller", "Tpatch success!"); instance = TbsLogReport.getInstance(context); i4 = TbsListener.ErrorCode.TPATCH_INSTALL_SUCCESS; str = ""; } instance.setInstallErrorCode(i4, str); return 0; } String string2 = bundle.getString("new_apk_location"); if (!TextUtils.isEmpty(string2)) { FileUtil.b(new File(string2)); } TbsLogReport.getInstance(context).setInstallErrorCode(i5, "tpatch fail,patch error_code=" + i5); return 1; } catch (Exception e2) { e2.printStackTrace(); TbsLogReport.getInstance(context).setInstallErrorCode(TbsListener.ErrorCode.DECOUPLE_TPATCH_FAIL, "patch exception" + Log.getStackTraceString(e2)); return 1; } } private boolean c(Context context, File file) { try { File[] listFiles = file.listFiles(new FileFilter() { /* class com.tencent.smtt.sdk.p.AnonymousClass5 */ public boolean accept(File file) { return file.getName().endsWith(".jar"); } }); int length = listFiles.length; if (Build.VERSION.SDK_INT < 16 && context.getPackageName() != null && context.getPackageName().equalsIgnoreCase(TbsConfig.APP_DEMO)) { try { Thread.sleep(RangedBeacon.DEFAULT_MAX_TRACKING_AGE); } catch (Exception unused) { } } ClassLoader classLoader = context.getClassLoader(); for (int i2 = 0; i2 < length; i2++) { TbsLog.i("TbsInstaller", "jarFile: " + listFiles[i2].getAbsolutePath()); new DexClassLoader(listFiles[i2].getAbsolutePath(), file.getAbsolutePath(), null, classLoader); } return true; } catch (Exception e2) { e2.printStackTrace(); TbsLogReport.getInstance(context).setInstallErrorCode(TbsListener.ErrorCode.DEXOPT_EXCEPTION, e2.toString()); TbsLog.i("TbsInstaller", "TbsInstaller-doTbsDexOpt done"); return false; } } private synchronized boolean c(Context context, boolean z) { TbsLog.i("TbsInstaller", "TbsInstaller-enableTbsCoreFromTpatch"); boolean z2 = false; try { if (!u(context)) { return false; } boolean tryLock = i.tryLock(); TbsLog.i("TbsInstaller", "TbsInstaller-enableTbsCoreFromTpatch Locked =" + tryLock); if (tryLock) { try { int b2 = n.a(context).b("tpatch_status"); int a2 = a(false, context); TbsLog.i("TbsInstaller", "TbsInstaller-enableTbsCoreFromTpatch copyStatus =" + b2); TbsLog.i("TbsInstaller", "TbsInstaller-enableTbsCoreFromTpatch tbsCoreInstalledVer =" + a2); if (b2 == 1) { if (a2 == 0) { TbsLog.i("TbsInstaller", "TbsInstaller-enableTbsCoreFromTpatch tbsCoreInstalledVer = 0", true); } else if (z) { TbsLog.i("TbsInstaller", "TbsInstaller-enableTbsCoreFromTpatch tbsCoreInstalledVer != 0", true); } z(context); z2 = true; } } finally { i.unlock(); } } b(); return z2; } catch (Throwable th) { TbsLogReport.getInstance(context).setInstallErrorCode(TbsListener.ErrorCode.COPY_EXCEPTION, th.toString()); QbSdk.a(context, "TbsInstaller::enableTbsCoreFromTpatch exception:" + Log.getStackTraceString(th)); } } private boolean d(Context context, File file) { try { File file2 = new File(file, "tbs_sdk_extension_dex.jar"); File file3 = new File(file, "tbs_sdk_extension_dex.dex"); new DexClassLoader(file2.getAbsolutePath(), file.getAbsolutePath(), null, context.getClassLoader()); String a2 = f.a(context, file3.getAbsolutePath()); if (TextUtils.isEmpty(a2)) { TbsLogReport.getInstance(context).setInstallErrorCode(TbsListener.ErrorCode.DEXOAT_EXCEPTION, "can not find oat command"); return false; } File[] listFiles = file.listFiles(new FileFilter() { /* class com.tencent.smtt.sdk.p.AnonymousClass6 */ public boolean accept(File file) { return file.getName().endsWith(".jar"); } }); for (File file4 : listFiles) { String substring = file4.getName().substring(0, file4.getName().length() - 4); Runtime.getRuntime().exec("/system/bin/dex2oat " + a2.replaceAll("tbs_sdk_extension_dex", substring) + " --dex-location=" + a().r(context) + File.separator + substring + ".jar").waitFor(); } return true; } catch (Exception e2) { e2.printStackTrace(); TbsLogReport.getInstance(context).setInstallErrorCode(TbsListener.ErrorCode.DEXOAT_EXCEPTION, e2); return false; } } private synchronized boolean d(Context context, boolean z) { TbsLog.i("TbsInstaller", "TbsInstaller-enableTbsCoreFromCopy"); boolean z2 = false; try { if (!u(context)) { return false; } boolean tryLock = i.tryLock(); TbsLog.i("TbsInstaller", "TbsInstaller-enableTbsCoreFromCopy Locked =" + tryLock); if (tryLock) { try { int b2 = n.a(context).b("copy_status"); int a2 = a(false, context); TbsLog.i("TbsInstaller", "TbsInstaller-enableTbsCoreFromCopy copyStatus =" + b2); TbsLog.i("TbsInstaller", "TbsInstaller-enableTbsCoreFromCopy tbsCoreInstalledVer =" + a2); if (b2 == 1) { if (a2 == 0) { TbsLog.i("TbsInstaller", "TbsInstaller-enableTbsCoreFromCopy tbsCoreInstalledVer = 0", true); } else if (z) { TbsLog.i("TbsInstaller", "TbsInstaller-enableTbsCoreFromCopy tbsCoreInstalledVer != 0", true); } A(context); z2 = true; } } finally { i.unlock(); } } b(); return z2; } catch (Throwable th) { TbsLogReport.getInstance(context).setInstallErrorCode(TbsListener.ErrorCode.COPY_EXCEPTION, th.toString()); QbSdk.a(context, "TbsInstaller::enableTbsCoreFromCopy exception:" + Log.getStackTraceString(th)); } } private boolean e(Context context, String str) { PackageInfo packageInfo; try { packageInfo = context.getPackageManager().getPackageInfo(str, 0); } catch (PackageManager.NameNotFoundException unused) { packageInfo = null; } return packageInfo != null; } private synchronized boolean e(Context context, boolean z) { if (context != null) { if (TbsConfig.APP_WX.equals(context.getApplicationContext().getApplicationInfo().packageName)) { TbsLogReport.getInstance(context).setInstallErrorCode(TbsListener.ErrorCode.INSTALL_FROM_UNZIP, MinimalPrettyPrinter.DEFAULT_ROOT_VALUE_SEPARATOR); } } TbsLog.i("TbsInstaller", "enableTbsCoreFromUnzip", "canRenameTmpDir =" + z); TbsLog.i("TbsInstaller", "enableTbsCoreFromUnzip", "#1#"); boolean z2 = false; try { if (!u(context)) { return false; } TbsLog.i("TbsInstaller", "enableTbsCoreFromUnzip", "#2# getInstallFileLock Success!!"); boolean tryLock = i.tryLock(); TbsLog.i("TbsInstaller", "enableTbsCoreFromUnzip", "locked=" + tryLock); if (tryLock) { try { int c2 = n.a(context).c(); TbsLog.i("TbsInstaller", "TbsInstaller-enableTbsCoreFromUnzip installStatus=" + c2); int a2 = a(false, context); if (c2 == 2) { TbsLog.i("TbsInstaller", "enableTbsCoreFromUnzip", "#4# In Rename Logic"); if (a2 == 0) { TbsLog.i("TbsInstaller", "TbsInstaller-enableTbsCoreFromUnzip tbsCoreInstalledVer = 0", false); } else if (z) { TbsLog.i("TbsInstaller", "TbsInstaller-enableTbsCoreFromUnzip tbsCoreInstalledVer != 0", false); } y(context); z2 = true; } } finally { i.unlock(); } } b(); return z2; } catch (Exception e2) { QbSdk.a(context, "TbsInstaller::enableTbsCoreFromUnzip Exception: " + e2); e2.printStackTrace(); } } private synchronized boolean f(Context context, boolean z) { return false; } private void g(Context context, boolean z) { if (context == null) { TbsLogReport.getInstance(context).setInstallErrorCode(TbsListener.ErrorCode.CREATE_TEMP_CONF_ERROR, "setTmpFolderCoreToRead context is null"); TbsLog.i("TbsInstaller", "setTmpFolderCoreToRead inner return #01"); return; } try { File file = new File(QbSdk.getTbsFolderDir(context), "tmp_folder_core_to_read.conf"); if (!z) { TbsLog.i("TbsInstaller", "setTmpFolderCoreToRead inner tmp file delete #01"); FileUtil.b(file); } else if (file.exists()) { TbsLog.i("TbsInstaller", "setTmpFolderCoreToRead inner tmp file already exist #01"); } else { TbsLog.i("TbsInstaller", "setTmpFolderCoreToRead inner tmp file create #01"); file.createNewFile(); } } catch (Exception e2) { TbsLogReport instance = TbsLogReport.getInstance(context); instance.setInstallErrorCode(TbsListener.ErrorCode.CREATE_TEMP_CONF_ERROR, "setTmpFolderCoreToRead Exception message is " + e2.getMessage() + " Exception cause is " + e2.getCause()); TbsLog.i("TbsInstaller", "setTmpFolderCoreToRead inner exception #01"); } } private void h(Context context, int i2) { TbsLog.i("TbsInstaller", "proceedTpatchStatus,result=" + i2); switch (i2) { case 0: if (!TbsDownloader.a(context)) { TbsLog.i("TbsInstaller", "setTmpFolderCoreToRead call #03"); g(context, true); n.a(context).b(TbsDownloadConfig.getInstance(context).mPreferences.getInt(TbsDownloadConfig.TbsConfigKey.KEY_TBS_DOWNLOAD_V, 0), 1); break; } else { i(context, 6); break; } } QbSdk.setTBSInstallingStatus(false); } private void i(Context context, int i2) { File f2 = a().f(context, i2); TbsLog.i("TbsInstaller", "setTmpFolderCoreToRead call #06"); a().g(context, true); File q = q(context); FileUtil.a(q, true); f2.renameTo(q); TbsShareManager.b(context); } /* JADX WARNING: Removed duplicated region for block: B:22:0x0057 */ /* JADX WARNING: Removed duplicated region for block: B:23:0x0059 */ /* JADX WARNING: Removed duplicated region for block: B:30:0x006f */ /* JADX WARNING: Removed duplicated region for block: B:35:0x007f */ /* JADX WARNING: Removed duplicated region for block: B:36:0x0087 */ private boolean j(Context context, int i2) { File file; boolean z; TbsLog.i("TbsInstaller", "TbsInstaller-doTbsDexOpt start - dirMode: " + i2); boolean z2 = false; switch (i2) { case 0: if (TbsDownloader.a(context)) { return true; } file = f(context, 0); try { String property = System.getProperty("java.vm.version"); if (property != null && property.startsWith(WakedResultReceiver.WAKE_TYPE_KEY)) { z = true; boolean z3 = Build.VERSION.SDK_INT != 23; boolean z4 = TbsDownloadConfig.getInstance(context).mPreferences.getBoolean(TbsDownloadConfig.TbsConfigKey.KEY_STOP_PRE_OAT, false); if (z && z3 && !z4) { z2 = true; } if (!z2 && d(context, file)) { TbsLog.i("TbsInstaller", "doTbsDexOpt -- doDexoatForArtVm"); return true; } else if (!z) { TbsLog.i("TbsInstaller", "doTbsDexOpt -- is ART mode, skip!"); TbsLog.i("TbsInstaller", "TbsInstaller-doTbsDexOpt done"); return true; } else { TbsLog.i("TbsInstaller", "doTbsDexOpt -- doDexoptForDavlikVM"); return c(context, file); } } } catch (Throwable th) { TbsLogReport.getInstance(context).setInstallErrorCode(TbsListener.ErrorCode.DEXOAT_EXCEPTION, th); } z = false; if (Build.VERSION.SDK_INT != 23) { } boolean z42 = TbsDownloadConfig.getInstance(context).mPreferences.getBoolean(TbsDownloadConfig.TbsConfigKey.KEY_STOP_PRE_OAT, false); z2 = true; if (!z2) { } if (!z) { } case 1: file = f(context, 1); String property2 = System.getProperty("java.vm.version"); z = true; if (Build.VERSION.SDK_INT != 23) { } boolean z422 = TbsDownloadConfig.getInstance(context).mPreferences.getBoolean(TbsDownloadConfig.TbsConfigKey.KEY_STOP_PRE_OAT, false); z2 = true; if (!z2) { } if (!z) { } break; case 2: try { file = r(context); String property22 = System.getProperty("java.vm.version"); z = true; if (Build.VERSION.SDK_INT != 23) { } boolean z4222 = TbsDownloadConfig.getInstance(context).mPreferences.getBoolean(TbsDownloadConfig.TbsConfigKey.KEY_STOP_PRE_OAT, false); z2 = true; if (!z2) { } if (!z) { } break; } catch (Exception e2) { e2.printStackTrace(); TbsLogReport.getInstance(context).setInstallErrorCode(TbsListener.ErrorCode.DEXOPT_EXCEPTION, e2.toString()); break; } default: TbsLog.e("TbsInstaller", "doDexoptOrDexoat mode error: " + i2); return false; } } static File t(Context context) { File file = new File(QbSdk.getTbsFolderDir(context), "core_private"); if (file.isDirectory() || file.mkdir()) { return file; } return null; } private int v(Context context) { boolean z = true; if (n.a(context).d() != 1) { z = false; } boolean a2 = TbsDownloader.a(context); if (z) { return a2 ? TbsListener.ErrorCode.DECOUPLE_INCURUPDATE_SUCCESS : TbsListener.ErrorCode.INCRUPDATE_INSTALL_SUCCESS; } if (a2) { return TbsListener.ErrorCode.DECOUPLE_INSTLL_SUCCESS; } return 200; } private static boolean w(Context context) { String str; String str2; if (context == null) { str = "TbsInstaller"; str2 = "#1#"; } else { try { if (new File(QbSdk.getTbsFolderDir(context), "tmp_folder_core_to_read.conf").exists()) { TbsLog.i("TbsInstaller", "getTmpFolderCoreToRead", "#2#"); return true; } TbsLog.i("TbsInstaller", "getTmpFolderCoreToRead", "#3#"); return false; } catch (Exception unused) { str = "TbsInstaller"; str2 = "#4#"; } } TbsLog.i(str, "getTmpFolderCoreToRead", str2); return true; } private boolean x(Context context) { TbsLog.i("TbsInstaller", "Tbsinstaller getTbsCoreRenameFileLock #1 "); l = FileUtil.f(context); if (l == null) { TbsLog.i("TbsInstaller", "getTbsCoreRenameFileLock## failed!"); return false; } TbsLog.i("TbsInstaller", "Tbsinstaller getTbsCoreRenameFileLock true "); return true; } private void y(Context context) { TbsLog.i("TbsInstaller", "TbsInstaller--generateNewTbsCoreFromUnzip"); if (!x(context)) { TbsLog.i("TbsInstaller", "get rename fileLock#4 ## failed!"); return; } try { B(context); C(context); TbsLog.i("TbsInstaller", "after renameTbsCoreShareDir"); if (!TbsShareManager.isThirdPartyApp(context)) { TbsLog.i("TbsInstaller", "prepare to shareTbsCore"); TbsShareManager.a(context); } else { TbsLog.i("TbsInstaller", "is thirdapp and not chmod"); } n.a(context).a(0); n.a(context).b(0); n.a(context).d(0); n.a(context).a("incrupdate_retry_num", 0); n.a(context).c(0, 3); n.a(context).a(""); n.a(context).a("tpatch_num", 0); n.a(context).c(-1); if (!TbsShareManager.isThirdPartyApp(context)) { int i2 = TbsDownloadConfig.getInstance(context).mPreferences.getInt(TbsDownloadConfig.TbsConfigKey.KEY_DECOUPLECOREVERSION, 0); if (i2 <= 0 || i2 == a().i(context) || i2 != a().j(context)) { TbsLog.i("TbsInstaller", "TbsInstaller--generateNewTbsCoreFromUnzip #1 deCoupleCoreVersion is " + i2 + " getTbsCoreShareDecoupleCoreVersion is " + a().i(context) + " getTbsCoreInstalledVerInNolock is " + a().j(context)); } else { o(context); } } if (TbsShareManager.isThirdPartyApp(context)) { TbsShareManager.writeCoreInfoForThirdPartyApp(context, n(context), true); } a.set(0); o = 0; } catch (Throwable th) { th.printStackTrace(); TbsLogReport instance = TbsLogReport.getInstance(context); instance.setInstallErrorCode(TbsListener.ErrorCode.RENAME_EXCEPTION, "exception when renameing from unzip:" + th.toString()); TbsLog.e("TbsInstaller", "TbsInstaller--generateNewTbsCoreFromUnzip Exception", true); } h(context); } private void z(Context context) { TbsLog.i("TbsInstaller", "TbsInstaller--generateNewTbsCoreFromTpatch"); if (!x(context)) { TbsLog.i("TbsInstaller", "get rename fileLock#4 ## failed!"); return; } try { B(context); E(context); if (TbsShareManager.isThirdPartyApp(context)) { TbsShareManager.writeCoreInfoForThirdPartyApp(context, n(context), true); } else { TbsShareManager.a(context); } n.a(context).b(0, -1); n.a(context).a("tpatch_num", 0); a.set(0); } catch (Exception e2) { e2.printStackTrace(); TbsLogReport instance = TbsLogReport.getInstance(context); instance.setInstallErrorCode(TbsListener.ErrorCode.TPATCH_ENABLE_EXCEPTION, "exception when renameing from tpatch:" + e2.toString()); } h(context); } /* access modifiers changed from: package-private */ /* JADX WARNING: Removed duplicated region for block: B:24:0x0057 A[SYNTHETIC, Splitter:B:24:0x0057] */ /* JADX WARNING: Removed duplicated region for block: B:30:0x005e A[SYNTHETIC, Splitter:B:30:0x005e] */ public int a(File file) { Throwable th; BufferedInputStream bufferedInputStream = null; try { TbsLog.i("TbsInstaller", "TbsInstaller--getTbsVersion tbsShareDir is " + file); File file2 = new File(file, "tbs.conf"); if (!file2.exists()) { return 0; } Properties properties = new Properties(); BufferedInputStream bufferedInputStream2 = new BufferedInputStream(new FileInputStream(file2)); try { properties.load(bufferedInputStream2); bufferedInputStream2.close(); String property = properties.getProperty("tbs_core_version"); if (property == null) { try { bufferedInputStream2.close(); } catch (IOException unused) { } return 0; } int parseInt = Integer.parseInt(property); try { bufferedInputStream2.close(); } catch (IOException unused2) { } return parseInt; } catch (Exception unused3) { bufferedInputStream = bufferedInputStream2; if (bufferedInputStream != null) { } return 0; } catch (Throwable th2) { th = th2; bufferedInputStream = bufferedInputStream2; if (bufferedInputStream != null) { } throw th; } } catch (Exception unused4) { if (bufferedInputStream != null) { try { bufferedInputStream.close(); } catch (IOException unused5) { } } return 0; } catch (Throwable th3) { th = th3; if (bufferedInputStream != null) { try { bufferedInputStream.close(); } catch (IOException unused6) { } } throw th; } } /* access modifiers changed from: package-private */ /* JADX WARNING: Removed duplicated region for block: B:27:0x0049 A[SYNTHETIC, Splitter:B:27:0x0049] */ /* JADX WARNING: Removed duplicated region for block: B:33:0x0050 A[SYNTHETIC, Splitter:B:33:0x0050] */ public int a(String str) { Throwable th; if (str == null) { return 0; } BufferedInputStream bufferedInputStream = null; try { File file = new File(new File(str), "tbs.conf"); if (!file.exists()) { return 0; } Properties properties = new Properties(); BufferedInputStream bufferedInputStream2 = new BufferedInputStream(new FileInputStream(file)); try { properties.load(bufferedInputStream2); bufferedInputStream2.close(); String property = properties.getProperty("tbs_core_version"); if (property == null) { try { bufferedInputStream2.close(); } catch (IOException unused) { } return 0; } int parseInt = Integer.parseInt(property); try { bufferedInputStream2.close(); } catch (IOException unused2) { } return parseInt; } catch (Exception unused3) { bufferedInputStream = bufferedInputStream2; if (bufferedInputStream != null) { } return 0; } catch (Throwable th2) { th = th2; bufferedInputStream = bufferedInputStream2; if (bufferedInputStream != null) { } throw th; } } catch (Exception unused4) { if (bufferedInputStream != null) { try { bufferedInputStream.close(); } catch (IOException unused5) { } } return 0; } catch (Throwable th3) { th = th3; if (bufferedInputStream != null) { try { bufferedInputStream.close(); } catch (IOException unused6) { } } throw th; } } public int a(boolean z, Context context) { if (z || a.get().intValue() <= 0) { a.set(Integer.valueOf(j(context))); } return a.get().intValue(); } /* access modifiers changed from: package-private */ public File a(Context context, int i2, boolean z) { String str; String str2; File tbsFolderDir = QbSdk.getTbsFolderDir(context); String str3 = ""; switch (i2) { case 0: str3 = "core_unzip_tmp"; break; case 1: str3 = "core_copy_tmp"; break; case 2: str3 = "core_unzip_tmp_decouple"; break; case 3: str3 = "core_share_backup"; break; case 4: str3 = "core_share_backup_tmp"; break; case 5: str3 = "tpatch_tmp"; break; case 6: str3 = "tpatch_decouple_tmp"; break; } TbsLog.i("TbsInstaller", "type=" + i2 + "needMakeDir=" + z + "folder=" + str3); File file = new File(tbsFolderDir, str3); if (!file.isDirectory()) { if (!z) { str = "TbsInstaller"; str2 = "getCoreDir,no need mkdir"; } else if (!file.mkdir()) { str = "TbsInstaller"; str2 = "getCoreDir,mkdir false"; } TbsLog.i(str, str2); return null; } return file; } /* access modifiers changed from: package-private */ public File a(Context context, File file) { File file2 = new File(file, "core_share_decouple"); if (file2.isDirectory() || file2.mkdir()) { return file2; } return null; } public void a(Context context, int i2) { TbsLog.i("TbsInstaller", "setTmpFolderCoreToRead call #01 "); g(context, true); n.a(context).c(i2, 2); } /* access modifiers changed from: package-private */ public void a(Context context, Bundle bundle) { if (bundle != null && context != null) { Object[] objArr = {context, bundle}; Message message = new Message(); message.what = 3; message.obj = objArr; m.sendMessage(message); } } /* access modifiers changed from: package-private */ public void a(Context context, File file, int i2) { TbsLog.i("TbsInstaller", "unzipTbsCoreToThirdAppTmp,ctx=" + context + "File=" + file + "coreVersion=" + i2); if (file != null && context != null) { Object[] objArr = {context, file, Integer.valueOf(i2)}; Message message = new Message(); message.what = 4; message.obj = objArr; m.sendMessage(message); } } /* access modifiers changed from: package-private */ public void a(Context context, String str, int i2) { TbsLog.i("TbsInstaller", "TbsInstaller-installTbsCore tbsApkPath=" + str); TbsLog.i("TbsInstaller", "TbsInstaller-installTbsCore tbsCoreTargetVer=" + i2); TbsLog.i("TbsInstaller", "TbsInstaller-continueInstallTbsCore currentProcessName=" + context.getApplicationInfo().processName); TbsLog.i("TbsInstaller", "TbsInstaller-installTbsCore currentProcessId=" + Process.myPid()); TbsLog.i("TbsInstaller", "TbsInstaller-installTbsCore currentThreadName=" + Thread.currentThread().getName()); Object[] objArr = {context, str, Integer.valueOf(i2)}; Message message = new Message(); message.what = 1; message.obj = objArr; m.sendMessage(message); } /* access modifiers changed from: package-private */ public void a(Context context, boolean z) { int i2; int i3; int i4; String str; int i5; boolean z2 = true; if (z) { this.k = true; } TbsLog.i("TbsInstaller", "TbsInstaller-continueInstallTbsCore currentProcessName=" + context.getApplicationInfo().processName); TbsLog.i("TbsInstaller", "TbsInstaller-continueInstallTbsCore currentProcessId=" + Process.myPid()); TbsLog.i("TbsInstaller", "TbsInstaller-continueInstallTbsCore currentThreadName=" + Thread.currentThread().getName()); if (u(context)) { if (i.tryLock()) { try { i2 = n.a(context).c(); i5 = n.a(context).b(); str = n.a(context).d("install_apk_path"); i4 = n.a(context).c("copy_core_ver"); i3 = n.a(context).b("copy_status"); } finally { i.unlock(); } } else { str = null; i2 = -1; i5 = 0; i4 = 0; i3 = -1; } b(); TbsLog.i("TbsInstaller", "TbsInstaller-continueInstallTbsCore installStatus=" + i2); TbsLog.i("TbsInstaller", "TbsInstaller-continueInstallTbsCore tbsCoreInstallVer=" + i5); TbsLog.i("TbsInstaller", "TbsInstaller-continueInstallTbsCore tbsApkPath=" + str); TbsLog.i("TbsInstaller", "TbsInstaller-continueInstallTbsCore tbsCoreCopyVer=" + i4); TbsLog.i("TbsInstaller", "TbsInstaller-continueInstallTbsCore copyStatus=" + i3); if (TbsShareManager.isThirdPartyApp(context)) { c(context, TbsShareManager.a(context, false)); return; } int i6 = TbsDownloadConfig.getInstance(context).mPreferences.getInt(TbsDownloadConfig.TbsConfigKey.KEY_RESPONSECODE, 0); if (!(i6 == 1 || i6 == 2 || i6 == 4)) { z2 = false; } if (!(z2 || i6 == 0 || i6 == 5)) { Bundle bundle = new Bundle(); bundle.putInt("operation", AsrError.ERROR_OFFLINE_EXCEPTION); a(context, bundle); } if (i2 > -1 && i2 < 2) { a(context, str, i5); } if (i3 == 0) { b(context, i4); } } } public synchronized boolean a(final Context context, final Context context2) { TbsLog.i("TbsInstaller", "TbsInstaller--quickDexOptForThirdPartyApp"); if (p) { return true; } p = true; new Thread() { /* class com.tencent.smtt.sdk.p.AnonymousClass4 */ public void run() { File file; p pVar; Context context; TbsLog.i("TbsInstaller", "TbsInstaller--quickDexOptForThirdPartyApp thread start"); try { if (context2 == null) { file = new File(TbsShareManager.getHostCorePathAppDefined()); } else { if (!TbsShareManager.isThirdPartyApp(context)) { pVar = p.this; context = context2; } else if (TbsShareManager.c(context) == null || !TbsShareManager.c(context).contains("decouple")) { pVar = p.this; context = context2; } else { file = p.this.q(context2); } file = pVar.r(context); } File r = p.this.r(context); int i = Build.VERSION.SDK_INT; if (i != 19 && i < 21) { FileUtil.a(file, r, new FileFilter() { /* class com.tencent.smtt.sdk.p.AnonymousClass4.AnonymousClass1 */ public boolean accept(File file) { return file.getName().endsWith(".dex"); } }); } FileUtil.a(file, r, new FileFilter() { /* class com.tencent.smtt.sdk.p.AnonymousClass4.AnonymousClass2 */ public boolean accept(File file) { return file.getName().endsWith("tbs.conf"); } }); TbsLog.i("TbsInstaller", "TbsInstaller--quickDexOptForThirdPartyApp thread done"); } catch (Exception e) { e.printStackTrace(); } } }.start(); return true; } public boolean a(Context context, File[] fileArr) { return false; } public int b(Context context) { if (!w(context)) { return 0; } if (a(context, "core_unzip_tmp")) { return -1; } if (a(context, "core_share_backup_tmp")) { return -2; } if (a(context, "core_copy_tmp")) { return -3; } return a(context, "tpatch_tmp") ? -4 : 1; } /* access modifiers changed from: package-private */ public Context b(Context context, String str) { try { if (context.getPackageName() == str || !TbsPVConfig.getInstance(context).isEnableNoCoreGray()) { return context.createPackageContext(str, 2); } return null; } catch (Exception unused) { return null; } } /* access modifiers changed from: package-private */ public File b(Context context, Context context2) { File file = new File(QbSdk.getTbsFolderDir(context2), "core_share"); if (file.isDirectory() || ((context != null && TbsShareManager.isThirdPartyApp(context)) || file.mkdir())) { return file; } TbsLog.i("TbsInstaller", "getTbsCoreShareDir,mkdir false"); return null; } /* access modifiers changed from: package-private */ public synchronized void b() { if (this.e <= 0) { TbsLog.i("TbsInstaller", "releaseTbsInstallingFileLock currentTbsFileLockStackCount=" + this.e + "call stack:" + Log.getStackTraceString(new Throwable())); } else if (this.e > 1) { TbsLog.i("TbsInstaller", "releaseTbsInstallingFileLock with skip"); this.e--; } else { if (this.e == 1) { TbsLog.i("TbsInstaller", "releaseTbsInstallingFileLock without skip"); FileUtil.a(this.f, this.g); this.e = 0; } } } /* access modifiers changed from: package-private */ /* JADX WARNING: Code restructure failed: missing block: B:154:0x04d8, code lost: r0 = th; */ /* JADX WARNING: Code restructure failed: missing block: B:156:0x04dc, code lost: r0 = e; */ /* JADX WARNING: Code restructure failed: missing block: B:157:0x04dd, code lost: r7 = r4; r4 = null; */ /* JADX WARNING: Failed to process nested try/catch */ /* JADX WARNING: Removed duplicated region for block: B:144:0x0464 */ /* JADX WARNING: Removed duplicated region for block: B:154:0x04d8 A[ExcHandler: all (th java.lang.Throwable), Splitter:B:111:0x033d] */ /* JADX WARNING: Removed duplicated region for block: B:171:0x052a */ /* JADX WARNING: Removed duplicated region for block: B:173:0x052e */ /* JADX WARNING: Removed duplicated region for block: B:183:0x05a0 */ /* JADX WARNING: Removed duplicated region for block: B:185:0x05a4 */ /* JADX WARNING: Removed duplicated region for block: B:195:0x062d */ /* JADX WARNING: Removed duplicated region for block: B:39:0x00fd A[Catch:{ Exception -> 0x0333, all -> 0x032f }] */ /* JADX WARNING: Removed duplicated region for block: B:55:0x017a */ /* JADX WARNING: Removed duplicated region for block: B:79:0x0211 */ /* JADX WARNING: Removed duplicated region for block: B:81:0x0215 */ /* JADX WARNING: Removed duplicated region for block: B:91:0x029e */ public void b(Context context, Bundle bundle) { Bundle bundle2; int i2; Throwable th; int i3; String str; TbsLogReport tbsLogReport; File file; int i4; Bundle bundle3; Exception e2; TbsLogReport instance; String str2; int i5; int i6; String str3; TbsLogReport tbsLogReport2; File file2; String str4; String str5; boolean z; File file3; int c2; TbsDownloadConfig instance2; int i7; TbsLog.i("TbsInstaller", "TbsInstaller installLocalTbsCoreExInThreadthread " + Thread.currentThread().getName() + Log.getStackTraceString(new Throwable())); if (d(context)) { instance2 = TbsDownloadConfig.getInstance(context); i7 = -539; } else { TbsLog.i("TbsInstaller", "TbsInstaller-installLocalTesCoreExInThread"); if (bundle != null && context != null) { if (!FileUtil.b(context)) { long a2 = r.a(); long downloadMinFreeSpace = TbsDownloadConfig.getInstance(context).getDownloadMinFreeSpace(); TbsLogReport.getInstance(context).setInstallErrorCode(TbsListener.ErrorCode.ROM_NOT_ENOUGH, "rom is not enough when patching tbs core! curAvailROM=" + a2 + ",minReqRom=" + downloadMinFreeSpace); instance2 = TbsDownloadConfig.getInstance(context); i7 = -540; } else if (!u(context)) { instance2 = TbsDownloadConfig.getInstance(context); i7 = -541; } else { boolean tryLock = j.tryLock(); TbsLog.i("TbsInstaller", "TbsInstaller-installLocalTesCoreExInThread locked=" + tryLock); if (tryLock) { int i8 = TbsDownloadConfig.getInstance(context).mPreferences.getInt(TbsDownloadConfig.TbsConfigKey.KEY_RESPONSECODE, 0); try { QbSdk.setTBSInstallingStatus(true); if (i8 == 5 || i8 == 3) { i2 = c(context, bundle); try { TbsLog.i("TbsInstaller", "TbsInstaller-installLocalTesCoreExInThread doTpatch result is " + i2); if (i2 == 1) { n.a(context).a("tpatch_num", n.a(context).c("tpatch_num") + 1); String string = bundle.getString("core_type_tpatch"); if (string.equals("stable_core_0")) { if (b.b()) { n.a(context).a("stable_64_tpatch_fail", 1); str4 = "TbsInstaller"; str5 = "TbsInstaller-installLocalTesCoreExInThread doTpatch set result TBS_CORE_STABLE_TPATCH_FAIL_64 is 1"; } else { n.a(context).a("stable_32_tpatch_fail", 1); str4 = "TbsInstaller"; str5 = "TbsInstaller-installLocalTesCoreExInThread doTpatch set result TBS_CORE_STABLE_TPATCH_FAIL_32 is 1"; } } else if (string.equals("stable_core_32")) { n.a(context).a("stable_32_tpatch_fail", 1); str4 = "TbsInstaller"; str5 = "TbsInstaller-installLocalTesCoreExInThread doTpatch set result TBS_CORE_STABLE_TPATCH_FAIL_32 is 1"; } else if (string.equals("stable_core_64")) { n.a(context).a("stable_64_tpatch_fail", 1); str4 = "TbsInstaller"; str5 = "TbsInstaller-installLocalTesCoreExInThread doTpatch set result TBS_CORE_STABLE_TPATCH_FAIL_64 is 1"; } TbsLog.i(str4, str5); } j.unlock(); b(); if (i8 == 5) { h(context, i2); return; } if (i2 == 0) { TbsLog.i("TbsInstaller", "TbsInstaller-installLocalTesCoreExInThread PATCH_SUCCESS"); n.a(context).a("incrupdate_retry_num", 0); TbsDownloadConfig.getInstance(context).setInstallInterruptCode(-544); n.a(context).c(0, -1); n.a(context).c(1); Bundle bundle4 = null; String string2 = bundle4.getString("apk_path"); if (r.b(context)) { int i9 = TbsDownloadConfig.getInstance(context).mPreferences.getInt(TbsDownloadConfig.TbsConfigKey.KEY_DECOUPLECOREVERSION, 0); int i10 = bundle4.getInt("tbs_core_ver"); TbsLog.i("TbsInstaller", "PATCH_SUCCESS tbsCorVer is " + i10 + " stableCoreVersionServer is " + i9); if (i10 == i9) { TbsLog.i(TbsDownloader.LOGTAG, "PATCH_SUCCESS backup"); file2 = new File(string2); } Bundle bundle5 = null; b(context, string2, bundle5.getInt("tbs_core_ver")); if (TbsDownloader.a(context)) { n.a(context).c(-1); } } else { file2 = new File(string2); } m.a(file2, context); Bundle bundle52 = null; b(context, string2, bundle52.getInt("tbs_core_ver")); if (TbsDownloader.a(context)) { } } else if (i2 == 2) { TbsLog.i("TbsInstaller", "TbsInstaller-installLocalTesCoreExInThread PATCH_NONEEDPATCH"); } else { TbsDownloadConfig.getInstance(context).setInstallInterruptCode(-546); TbsLog.i("TbsInstaller", "TbsInstaller-installLocalTesCoreExInThread PATCH_FAIL"); TbsDownloadConfig.getInstance(context).mSyncMap.put(TbsDownloadConfig.TbsConfigKey.KEY_NEEDDOWNLOAD, true); TbsDownloadConfig.getInstance(context).commit(); if (TbsDownloader.a(context)) { tbsLogReport2 = TbsLogReport.getInstance(context); str3 = "decouple incrUpdate fail! patch ret=" + i2; i6 = TbsListener.ErrorCode.DECOUPLE_INCURUPDATE_FAIL; } else { tbsLogReport2 = TbsLogReport.getInstance(context); str3 = "incrUpdate fail! patch ret=" + i2; i6 = TbsListener.ErrorCode.INCR_UPDATE_FAIL; } tbsLogReport2.setInstallErrorCode(i6, str3); } QbSdk.setTBSInstallingStatus(false); return; } catch (Exception e3) { e2 = e3; i4 = i2; bundle3 = null; try { TbsLog.i("TbsInstaller", "installLocalTbsCoreExInThread exception:" + Log.getStackTraceString(e2)); e2.printStackTrace(); } catch (Throwable th2) { th = th2; bundle2 = bundle3; i2 = i4; j.unlock(); b(); if (i8 != 5) { h(context, i2); return; } if (i2 == 0) { TbsLog.i("TbsInstaller", "TbsInstaller-installLocalTesCoreExInThread PATCH_SUCCESS"); n.a(context).a("incrupdate_retry_num", 0); TbsDownloadConfig.getInstance(context).setInstallInterruptCode(-544); n.a(context).c(0, -1); n.a(context).c(1); String string3 = bundle2.getString("apk_path"); if (r.b(context)) { int i11 = TbsDownloadConfig.getInstance(context).mPreferences.getInt(TbsDownloadConfig.TbsConfigKey.KEY_DECOUPLECOREVERSION, 0); int i12 = bundle2.getInt("tbs_core_ver"); TbsLog.i("TbsInstaller", "PATCH_SUCCESS tbsCorVer is " + i12 + " stableCoreVersionServer is " + i11); if (i12 == i11) { TbsLog.i(TbsDownloader.LOGTAG, "PATCH_SUCCESS backup"); file = new File(string3); } b(context, string3, bundle2.getInt("tbs_core_ver")); if (TbsDownloader.a(context)) { n.a(context).c(-1); } } else { file = new File(string3); } m.a(file, context); b(context, string3, bundle2.getInt("tbs_core_ver")); if (TbsDownloader.a(context)) { } } else if (i2 != 2) { TbsDownloadConfig.getInstance(context).setInstallInterruptCode(-546); TbsLog.i("TbsInstaller", "TbsInstaller-installLocalTesCoreExInThread PATCH_FAIL"); TbsDownloadConfig.getInstance(context).mSyncMap.put(TbsDownloadConfig.TbsConfigKey.KEY_NEEDDOWNLOAD, true); TbsDownloadConfig.getInstance(context).commit(); if (TbsDownloader.a(context)) { tbsLogReport = TbsLogReport.getInstance(context); str = "decouple incrUpdate fail! patch ret=" + i2; i3 = TbsListener.ErrorCode.DECOUPLE_INCURUPDATE_FAIL; } else { tbsLogReport = TbsLogReport.getInstance(context); str = "incrUpdate fail! patch ret=" + i2; i3 = TbsListener.ErrorCode.INCR_UPDATE_FAIL; } tbsLogReport.setInstallErrorCode(i3, str); } else { TbsLog.i("TbsInstaller", "TbsInstaller-installLocalTesCoreExInThread PATCH_NONEEDPATCH"); } QbSdk.setTBSInstallingStatus(false); throw th; } try { TbsDownloadConfig.getInstance(context).setInstallInterruptCode(-543); TbsLogReport.getInstance(context).setInstallErrorCode(TbsListener.ErrorCode.INCR_UPDATE_EXCEPTION, e2.toString()); j.unlock(); b(); if (i8 != 5) { } } catch (Throwable th3) { th = th3; bundle2 = bundle3; i2 = 1; j.unlock(); b(); if (i8 != 5) { } } } catch (Throwable th4) { } } else { try { if (j(context) > 0) { if (n.a(context).d() != 1) { if (!(i8 == 1 || i8 == 2)) { if (i8 != 4) { z = false; if (!z && i8 != 0) { c2 = n.a(context).c("incrupdate_retry_num"); if (c2 <= 5) { TbsLog.i("TbsInstaller", "TbsInstaller-installLocalTesCoreExInThread exceed incrupdate num"); String string4 = bundle.getString("old_apk_location"); String string5 = bundle.getString("new_apk_location"); String string6 = bundle.getString("diff_file_location"); if (!TextUtils.isEmpty(string4)) { FileUtil.b(new File(string4)); } if (!TextUtils.isEmpty(string5)) { FileUtil.b(new File(string5)); } if (!TextUtils.isEmpty(string6)) { FileUtil.b(new File(string6)); } TbsDownloadConfig.getInstance(context).mSyncMap.put(TbsDownloadConfig.TbsConfigKey.KEY_NEEDDOWNLOAD, true); TbsDownloadConfig.getInstance(context).commit(); TbsLogReport.getInstance(context).setInstallErrorCode(TbsListener.ErrorCode.EXCEED_INCR_UPDATE, "incrUpdate exceed retry max num"); j.unlock(); b(); if (i8 == 5) { h(context, 2); return; } TbsLog.i("TbsInstaller", "TbsInstaller-installLocalTesCoreExInThread PATCH_NONEEDPATCH"); QbSdk.setTBSInstallingStatus(false); return; } n.a(context).a("incrupdate_retry_num", c2 + 1); File t = t(context); if (t != null && new File(t, "x5.tbs").exists()) { TbsDownloadConfig.getInstance(context).setInstallInterruptCode(-550); bundle3 = QbSdk.a(context, bundle); if (bundle3 == null) { try { TbsLogReport.getInstance(context).setInstallErrorCode(TbsListener.ErrorCode.INCR_ERROR_DETAIL, "result null : " + bundle.getInt("new_core_ver")); i4 = 1; j.unlock(); b(); if (i8 == 5) { h(context, i4); return; } if (i4 == 0) { TbsLog.i("TbsInstaller", "TbsInstaller-installLocalTesCoreExInThread PATCH_SUCCESS"); n.a(context).a("incrupdate_retry_num", 0); TbsDownloadConfig.getInstance(context).setInstallInterruptCode(-544); n.a(context).c(0, -1); n.a(context).c(1); String string7 = bundle3.getString("apk_path"); if (r.b(context)) { int i13 = TbsDownloadConfig.getInstance(context).mPreferences.getInt(TbsDownloadConfig.TbsConfigKey.KEY_DECOUPLECOREVERSION, 0); int i14 = bundle3.getInt("tbs_core_ver"); TbsLog.i("TbsInstaller", "PATCH_SUCCESS tbsCorVer is " + i14 + " stableCoreVersionServer is " + i13); if (i14 == i13) { TbsLog.i(TbsDownloader.LOGTAG, "PATCH_SUCCESS backup"); file3 = new File(string7); } b(context, string7, bundle3.getInt("tbs_core_ver")); if (TbsDownloader.a(context)) { n.a(context).c(-1); } } else { file3 = new File(string7); } m.a(file3, context); b(context, string7, bundle3.getInt("tbs_core_ver")); if (TbsDownloader.a(context)) { } } else if (i4 == 2) { TbsLog.i("TbsInstaller", "TbsInstaller-installLocalTesCoreExInThread PATCH_NONEEDPATCH"); } else { TbsDownloadConfig.getInstance(context).setInstallInterruptCode(-546); TbsLog.i("TbsInstaller", "TbsInstaller-installLocalTesCoreExInThread PATCH_FAIL"); TbsDownloadConfig.getInstance(context).mSyncMap.put(TbsDownloadConfig.TbsConfigKey.KEY_NEEDDOWNLOAD, true); TbsDownloadConfig.getInstance(context).commit(); if (TbsDownloader.a(context)) { instance = TbsLogReport.getInstance(context); str2 = "decouple incrUpdate fail! patch ret=" + i4; i5 = TbsListener.ErrorCode.DECOUPLE_INCURUPDATE_FAIL; } else { instance = TbsLogReport.getInstance(context); str2 = "incrUpdate fail! patch ret=" + i4; i5 = TbsListener.ErrorCode.INCR_UPDATE_FAIL; } instance.setInstallErrorCode(i5, str2); } QbSdk.setTBSInstallingStatus(false); return; } catch (Exception e4) { e2 = e4; i4 = 1; TbsLog.i("TbsInstaller", "installLocalTbsCoreExInThread exception:" + Log.getStackTraceString(e2)); e2.printStackTrace(); TbsDownloadConfig.getInstance(context).setInstallInterruptCode(-543); TbsLogReport.getInstance(context).setInstallErrorCode(TbsListener.ErrorCode.INCR_UPDATE_EXCEPTION, e2.toString()); j.unlock(); b(); if (i8 != 5) { } } } else { try { i4 = bundle3.getInt("patch_result"); if (i4 != 0) { try { TbsLogReport.getInstance(context).setInstallErrorCode(TbsListener.ErrorCode.INCR_ERROR_DETAIL, "result " + i4 + " : " + bundle.getInt("new_core_ver")); } catch (Exception e5) { e2 = e5; } } j.unlock(); b(); if (i8 == 5) { } } catch (Exception e6) { e2 = e6; i4 = 2; TbsLog.i("TbsInstaller", "installLocalTbsCoreExInThread exception:" + Log.getStackTraceString(e2)); e2.printStackTrace(); TbsDownloadConfig.getInstance(context).setInstallInterruptCode(-543); TbsLogReport.getInstance(context).setInstallErrorCode(TbsListener.ErrorCode.INCR_UPDATE_EXCEPTION, e2.toString()); j.unlock(); b(); if (i8 != 5) { } } catch (Throwable th5) { th = th5; bundle2 = bundle3; i2 = 2; j.unlock(); b(); if (i8 != 5) { } } } } } bundle3 = null; i4 = 2; j.unlock(); b(); if (i8 == 5) { } } } z = true; c2 = n.a(context).c("incrupdate_retry_num"); if (c2 <= 5) { } } } QbSdk.setTBSInstallingStatus(false); j.unlock(); b(); if (i8 == 5) { h(context, 2); return; } TbsLog.i("TbsInstaller", "TbsInstaller-installLocalTesCoreExInThread PATCH_NONEEDPATCH"); QbSdk.setTBSInstallingStatus(false); return; } catch (Exception e7) { e2 = e7; bundle3 = null; i4 = 2; TbsLog.i("TbsInstaller", "installLocalTbsCoreExInThread exception:" + Log.getStackTraceString(e2)); e2.printStackTrace(); TbsDownloadConfig.getInstance(context).setInstallInterruptCode(-543); TbsLogReport.getInstance(context).setInstallErrorCode(TbsListener.ErrorCode.INCR_UPDATE_EXCEPTION, e2.toString()); j.unlock(); b(); if (i8 != 5) { } } catch (Throwable th6) { th = th6; i2 = 2; bundle2 = null; j.unlock(); b(); if (i8 != 5) { } } } } catch (Exception e8) { e2 = e8; bundle3 = null; i4 = 2; TbsLog.i("TbsInstaller", "installLocalTbsCoreExInThread exception:" + Log.getStackTraceString(e2)); e2.printStackTrace(); TbsDownloadConfig.getInstance(context).setInstallInterruptCode(-543); TbsLogReport.getInstance(context).setInstallErrorCode(TbsListener.ErrorCode.INCR_UPDATE_EXCEPTION, e2.toString()); j.unlock(); b(); if (i8 != 5) { h(context, 1); return; } TbsDownloadConfig.getInstance(context).setInstallInterruptCode(-546); TbsLog.i("TbsInstaller", "TbsInstaller-installLocalTesCoreExInThread PATCH_FAIL"); TbsDownloadConfig.getInstance(context).mSyncMap.put(TbsDownloadConfig.TbsConfigKey.KEY_NEEDDOWNLOAD, true); TbsDownloadConfig.getInstance(context).commit(); if (TbsDownloader.a(context)) { instance = TbsLogReport.getInstance(context); str2 = "decouple incrUpdate fail! patch ret=" + 1; i5 = TbsListener.ErrorCode.DECOUPLE_INCURUPDATE_FAIL; } else { instance = TbsLogReport.getInstance(context); str2 = "incrUpdate fail! patch ret=" + 1; i5 = TbsListener.ErrorCode.INCR_UPDATE_FAIL; } instance.setInstallErrorCode(i5, str2); QbSdk.setTBSInstallingStatus(false); return; } catch (Throwable th7) { th = th7; bundle2 = null; i2 = 2; j.unlock(); b(); if (i8 != 5) { } } } else { TbsDownloadConfig.getInstance(context).setInstallInterruptCode(-547); b(); return; } } } else { return; } } instance2.setInstallInterruptCode(i7); } public void b(Context context, File file, int i2) { FileOutputStream b2 = FileUtil.b(context, true, "core_unzip.lock"); FileLock a2 = FileUtil.a(context, b2); if (a2 != null) { TbsLog.i("TbsInstaller", "unzipTbsCoreToThirdAppTmpInThread #1"); boolean a3 = a(context, file, false); TbsLog.i("TbsInstaller", "unzipTbsCoreToThirdAppTmpInThread result is " + a3); r.a(context, "copy_host_core_v3", ("coreVersionIs" + i2) + "_" + "ret=is=" + a3); if (a3) { a().a(context, i2); } FileUtil.a(a2, b2); return; } TbsLog.i("TbsInstaller", "can not get Core unzip FileLock,skip!!!"); } /* access modifiers changed from: package-private */ public void b(Context context, boolean z) { String str; if (!QbSdk.b) { if (Build.VERSION.SDK_INT < 8) { TbsLog.e("TbsInstaller", "android version < 2.1 no need install X5 core", true); return; } TbsLog.i("TbsInstaller", "installTbsCoreIfNeeded", "#1# check local x5core prepared to install"); if (TbsShareManager.isThirdPartyApp(context) && n.a(context).b("remove_old_core") == 1 && z) { try { FileUtil.b(a().r(context)); TbsLog.i("TbsInstaller", "installTbsCoreIfNeeded", "thirdAPP success--> delete old core_share Directory"); } catch (Throwable th) { th.printStackTrace(); } n.a(context).a("remove_old_core", 0); } if (w(context)) { if (TbsShareManager.isThirdPartyApp(context)) { r.a(context, "has_tmpfile_torename", ""); } TbsLog.i("TbsInstaller", "installTbsCoreIfNeeded", "#2# try to install tbs core from tmp dir"); if (a(context, "core_unzip_tmp") && e(context, z)) { TbsLog.i("TbsInstaller", "TbsInstaller-installTbsCoreIfNeeded, enableTbsCoreFromUnzip !!", true); if (TbsShareManager.isThirdPartyApp(context)) { str = "enableTbsCoreFromUnzip"; } else { return; } } else if (a(context, "core_share_backup_tmp") && f(context, z)) { TbsLog.i("TbsInstaller", "TbsInstaller-installTbsCoreIfNeeded, enableTbsCoreFromBackup !!", true); if (TbsShareManager.isThirdPartyApp(context)) { str = "enableTbsCoreFromBackup"; } else { return; } } else if (a(context, "core_copy_tmp") && d(context, z)) { TbsLog.i("TbsInstaller", "TbsInstaller-installTbsCoreIfNeeded, enableTbsCoreFromCopy !!", true); if (TbsShareManager.isThirdPartyApp(context)) { str = "enableTbsCoreFromCopy"; } else { return; } } else if (a(context, "tpatch_tmp") && c(context, z)) { TbsLog.i("TbsInstaller", "TbsInstaller-installTbsCoreIfNeeded, enableTbsCoreFromTpatch !!", true); if (TbsShareManager.isThirdPartyApp(context)) { str = "enableTbsCoreFromTpatch"; } else { return; } } else { TbsLog.i("TbsInstaller", "TbsInstaller-installTbsCoreIfNeeded, error !!", true); return; } r.a(context, "rename_ok", str); } } } /* access modifiers changed from: package-private */ public boolean b(Context context, int i2) { if (TbsDownloader.getOverSea(context)) { return false; } TbsLog.i("TbsInstaller", "TbsInstaller-installLocalTbsCore targetTbsCoreVer=" + i2); TbsLog.i("TbsInstaller", "TbsInstaller-continueInstallTbsCore currentProcessName=" + context.getApplicationInfo().processName); TbsLog.i("TbsInstaller", "TbsInstaller-installLocalTbsCore currentProcessId=" + Process.myPid()); TbsLog.i("TbsInstaller", "TbsInstaller-installLocalTbsCore currentThreadName=" + Thread.currentThread().getName()); Context d2 = d(context, i2); if (d2 != null) { Object[] objArr = {d2, context, Integer.valueOf(i2)}; Message message = new Message(); message.what = 2; message.obj = objArr; m.sendMessage(message); return true; } TbsLog.i("TbsInstaller", "TbsInstaller--installLocalTbsCore copy from null"); return false; } /* access modifiers changed from: package-private */ public int c(Context context, String str) { PackageInfo packageArchiveInfo = context.getPackageManager().getPackageArchiveInfo(str, 0); if (packageArchiveInfo != null) { return packageArchiveInfo.versionCode; } return 0; } /* access modifiers changed from: package-private */ public File c(Context context, Context context2) { File file = new File(QbSdk.getTbsFolderDir(context2), "core_share_decouple"); if (file.isDirectory() || ((context != null && TbsShareManager.isThirdPartyApp(context)) || file.mkdir())) { return file; } return null; } public void c(Context context) { TbsLog.i("TbsInstaller", "setTmpFolderCoreToRead call #02"); g(context, true); n.a(context).c(i(context), 2); } /* access modifiers changed from: package-private */ public void c(Context context, int i2) { int j2; TbsLog.i("TbsInstaller", "TbsInstaller-installTbsCoreForThirdPartyApp"); if (i2 > 0 && (j2 = j(context)) < i2) { Context e2 = TbsShareManager.e(context); if (e2 != null || TbsShareManager.getHostCorePathAppDefined() != null) { TbsLog.i("TbsInstaller", "TbsInstaller--quickDexOptForThirdPartyApp hostContext != null"); a(context, e2); } else if (j2 <= 0) { TbsLog.i("TbsInstaller", "TbsInstaller--installTbsCoreForThirdPartyApp hostContext == null"); QbSdk.a(context, "TbsInstaller::installTbsCoreForThirdPartyApp forceSysWebViewInner #2"); } } } public Context d(Context context, int i2) { Context b2; TbsLog.i("TbsInstaller", "TbsInstaller--getTbsCoreHostContext tbsCoreTargetVer=" + i2); if (i2 <= 0) { return null; } String[] coreProviderAppList = TbsShareManager.getCoreProviderAppList(); for (int i3 = 0; i3 < coreProviderAppList.length; i3++) { if (!context.getPackageName().equalsIgnoreCase(coreProviderAppList[i3]) && e(context, coreProviderAppList[i3]) && (b2 = b(context, coreProviderAppList[i3])) != null) { if (!g(b2)) { TbsLog.e("TbsInstaller", "TbsInstaller--getTbsCoreHostContext " + coreProviderAppList[i3] + " illegal signature go on next"); } else { int j2 = j(b2); TbsLog.i("TbsInstaller", "TbsInstaller-getTbsCoreHostContext hostTbsCoreVer=" + j2); if (j2 != 0 && j2 == i2) { TbsLog.i("TbsInstaller", "TbsInstaller-getTbsCoreHostContext targetApp=" + coreProviderAppList[i3]); return b2; } } } } return null; } /* JADX WARNING: Removed duplicated region for block: B:19:0x003f A[SYNTHETIC, Splitter:B:19:0x003f] */ /* JADX WARNING: Removed duplicated region for block: B:26:0x0046 A[SYNTHETIC, Splitter:B:26:0x0046] */ public String d(Context context, String str) { BufferedInputStream bufferedInputStream; Throwable th; BufferedInputStream bufferedInputStream2 = null; if (TextUtils.isEmpty(str)) { return null; } try { File file = new File(r(context), "tbs.conf"); if (!file.exists()) { return null; } Properties properties = new Properties(); bufferedInputStream = new BufferedInputStream(new FileInputStream(file)); try { properties.load(bufferedInputStream); bufferedInputStream.close(); String property = properties.getProperty(str); try { bufferedInputStream.close(); } catch (IOException unused) { } return property; } catch (Exception unused2) { if (bufferedInputStream != null) { } return null; } catch (Throwable th2) { th = th2; bufferedInputStream2 = bufferedInputStream; if (bufferedInputStream2 != null) { } throw th; } } catch (Exception unused3) { bufferedInputStream = null; if (bufferedInputStream != null) { try { bufferedInputStream.close(); } catch (IOException unused4) { } } return null; } catch (Throwable th3) { th = th3; if (bufferedInputStream2 != null) { try { bufferedInputStream2.close(); } catch (IOException unused5) { } } throw th; } } /* access modifiers changed from: package-private */ /* JADX WARNING: Code restructure failed: missing block: B:22:0x0077, code lost: r10 = th; */ /* JADX WARNING: Code restructure failed: missing block: B:23:0x0079, code lost: r0 = th; */ /* JADX WARNING: Code restructure failed: missing block: B:24:0x007a, code lost: r2 = r4; */ /* JADX WARNING: Code restructure failed: missing block: B:32:0x0086, code lost: r2.close(); */ /* JADX WARNING: Code restructure failed: missing block: B:36:?, code lost: r4.close(); */ /* JADX WARNING: Code restructure failed: missing block: B:37:0x0090, code lost: r0 = move-exception; */ /* JADX WARNING: Code restructure failed: missing block: B:38:0x0091, code lost: r0.printStackTrace(); */ /* JADX WARNING: Failed to process nested try/catch */ /* JADX WARNING: Removed duplicated region for block: B:22:0x0077 A[ExcHandler: all (th java.lang.Throwable), Splitter:B:6:0x0023] */ /* JADX WARNING: Removed duplicated region for block: B:32:0x0086 */ /* JADX WARNING: Removed duplicated region for block: B:35:0x008c A[SYNTHETIC, Splitter:B:35:0x008c] */ public boolean d(Context context) { boolean z; Throwable th; File file = new File(r(context), "tbs.conf"); boolean z2 = false; if (!file.exists()) { return false; } Properties properties = new Properties(); BufferedInputStream bufferedInputStream = null; try { BufferedInputStream bufferedInputStream2 = new BufferedInputStream(new FileInputStream(file)); try { properties.load(bufferedInputStream2); z = Boolean.valueOf(properties.getProperty("tbs_local_installation", "false")).booleanValue(); if (z) { if (System.currentTimeMillis() - file.lastModified() > 259200000) { z2 = true; } } TbsLog.i("TbsInstaller", "TBS_LOCAL_INSTALLATION is:" + z + " expired=" + z2); z &= !z2; try { bufferedInputStream2.close(); } catch (IOException e2) { e2.printStackTrace(); } } catch (Throwable th2) { } } catch (Throwable th3) { th = th3; z = false; th.printStackTrace(); if (bufferedInputStream != null) { } return z; } return z; } /* access modifiers changed from: package-private */ public int e(Context context, int i2) { return a(f(context, i2)); } /* JADX WARNING: Can't wrap try/catch for region: R(5:0|(9:1|2|3|4|5|6|7|8|9)|10|11|39) */ /* JADX WARNING: Code restructure failed: missing block: B:37:?, code lost: return; */ /* JADX WARNING: Failed to process nested try/catch */ /* JADX WARNING: Missing exception handler attribute for start block: B:10:0x0035 */ /* JADX WARNING: Removed duplicated region for block: B:21:0x0046 A[SYNTHETIC, Splitter:B:21:0x0046] */ /* JADX WARNING: Removed duplicated region for block: B:25:0x004d A[SYNTHETIC, Splitter:B:25:0x004d] */ /* JADX WARNING: Removed duplicated region for block: B:32:0x0054 A[SYNTHETIC, Splitter:B:32:0x0054] */ /* JADX WARNING: Removed duplicated region for block: B:38:? A[RETURN, SYNTHETIC] */ public void e(Context context) { BufferedInputStream bufferedInputStream; Throwable th; File file = new File(r(context), "tbs.conf"); Properties properties = new Properties(); BufferedOutputStream bufferedOutputStream = null; try { bufferedInputStream = new BufferedInputStream(new FileInputStream(file)); try { properties.load(bufferedInputStream); BufferedOutputStream bufferedOutputStream2 = new BufferedOutputStream(new FileOutputStream(file)); try { properties.setProperty("tbs_local_installation", "false"); properties.store(bufferedOutputStream2, (String) null); bufferedOutputStream2.close(); } catch (Throwable th2) { th = th2; bufferedOutputStream = bufferedOutputStream2; if (bufferedOutputStream != null) { try { bufferedOutputStream.close(); } catch (IOException unused) { } } if (bufferedInputStream != null) { try { bufferedInputStream.close(); } catch (IOException unused2) { } } throw th; } } catch (Throwable th3) { th = th3; if (bufferedOutputStream != null) { } if (bufferedInputStream != null) { } throw th; } } catch (Throwable th4) { th = th4; bufferedInputStream = null; if (bufferedOutputStream != null) { } if (bufferedInputStream != null) { } throw th; } bufferedInputStream.close(); } /* access modifiers changed from: package-private */ public File f(Context context, int i2) { return a(context, i2, true); } public boolean f(Context context) { String[] list; try { File file = new File(FileUtil.a(context, 4), TbsDownloader.getBackupFileName(true)); File f2 = a().f(context, 2); FileUtil.a(f2); FileUtil.a(f2, true); FileUtil.a(file, f2); for (String str : f2.list()) { File file2 = new File(f2, str); if (file2.getName().endsWith(".dex")) { file2.delete(); } } i(context, 2); return true; } catch (Exception unused) { return false; } } /* access modifiers changed from: package-private */ public boolean g(Context context) { if (TbsShareManager.getHostCorePathAppDefined() != null) { return true; } try { Signature signature = context.getPackageManager().getPackageInfo(context.getPackageName(), 64).signatures[0]; if (context.getPackageName().equals(TbsConfig.APP_QB)) { if (!signature.toCharsString().equals("3082023f308201a8a00302010202044c46914a300d06092a864886f70d01010505003064310b30090603550406130238363110300e060355040813074265696a696e673110300e060355040713074265696a696e673110300e060355040a130754656e63656e74310c300a060355040b13035753443111300f0603550403130873616d75656c6d6f301e170d3130303732313036313835305a170d3430303731333036313835305a3064310b30090603550406130238363110300e060355040813074265696a696e673110300e060355040713074265696a696e673110300e060355040a130754656e63656e74310c300a060355040b13035753443111300f0603550403130873616d75656c6d6f30819f300d06092a864886f70d010101050003818d0030818902818100c209077044bd0d63ea00ede5b839914cabcc912a87f0f8b390877e0f7a2583f0d5933443c40431c35a4433bc4c965800141961adc44c9625b1d321385221fd097e5bdc2f44a1840d643ab59dc070cf6c4b4b4d98bed5cbb8046e0a7078ae134da107cdf2bfc9b440fe5cb2f7549b44b73202cc6f7c2c55b8cfb0d333a021f01f0203010001300d06092a864886f70d010105050003818100b007db9922774ef4ccfee81ba514a8d57c410257e7a2eba64bfa17c9e690da08106d32f637ac41fbc9f205176c71bde238c872c3ee2f8313502bee44c80288ea4ef377a6f2cdfe4d3653c145c4acfedbfbadea23b559d41980cc3cdd35d79a68240693739aabf5c5ed26148756cf88264226de394c8a24ac35b712b120d4d23a")) { return false; } } else if (context.getPackageName().equals(TbsConfig.APP_WX)) { if (!signature.toCharsString().equals("308202eb30820254a00302010202044d36f7a4300d06092a864886f70d01010505003081b9310b300906035504061302383631123010060355040813094775616e67646f6e673111300f060355040713085368656e7a68656e31353033060355040a132c54656e63656e7420546563686e6f6c6f6779285368656e7a68656e2920436f6d70616e79204c696d69746564313a3038060355040b133154656e63656e74204775616e677a686f7520526573656172636820616e6420446576656c6f706d656e742043656e7465723110300e0603550403130754656e63656e74301e170d3131303131393134333933325a170d3431303131313134333933325a3081b9310b300906035504061302383631123010060355040813094775616e67646f6e673111300f060355040713085368656e7a68656e31353033060355040a132c54656e63656e7420546563686e6f6c6f6779285368656e7a68656e2920436f6d70616e79204c696d69746564313a3038060355040b133154656e63656e74204775616e677a686f7520526573656172636820616e6420446576656c6f706d656e742043656e7465723110300e0603550403130754656e63656e7430819f300d06092a864886f70d010101050003818d0030818902818100c05f34b231b083fb1323670bfbe7bdab40c0c0a6efc87ef2072a1ff0d60cc67c8edb0d0847f210bea6cbfaa241be70c86daf56be08b723c859e52428a064555d80db448cdcacc1aea2501eba06f8bad12a4fa49d85cacd7abeb68945a5cb5e061629b52e3254c373550ee4e40cb7c8ae6f7a8151ccd8df582d446f39ae0c5e930203010001300d06092a864886f70d0101050500038181009c8d9d7f2f908c42081b4c764c377109a8b2c70582422125ce545842d5f520aea69550b6bd8bfd94e987b75a3077eb04ad341f481aac266e89d3864456e69fba13df018acdc168b9a19dfd7ad9d9cc6f6ace57c746515f71234df3a053e33ba93ece5cd0fc15f3e389a3f365588a9fcb439e069d3629cd7732a13fff7b891499")) { return false; } } else if (context.getPackageName().equals(TbsConfig.APP_QQ)) { if (!signature.toCharsString().equals("30820253308201bca00302010202044bbb0361300d06092a864886f70d0101050500306d310e300c060355040613054368696e61310f300d06035504080c06e58c97e4baac310f300d06035504070c06e58c97e4baac310f300d060355040a0c06e885bee8aeaf311b3019060355040b0c12e697a0e7babfe4b89ae58aa1e7b3bbe7bb9f310b30090603550403130251513020170d3130303430363039343831375a180f32323834303132303039343831375a306d310e300c060355040613054368696e61310f300d06035504080c06e58c97e4baac310f300d06035504070c06e58c97e4baac310f300d060355040a0c06e885bee8aeaf311b3019060355040b0c12e697a0e7babfe4b89ae58aa1e7b3bbe7bb9f310b300906035504031302515130819f300d06092a864886f70d010101050003818d0030818902818100a15e9756216f694c5915e0b529095254367c4e64faeff07ae13488d946615a58ddc31a415f717d019edc6d30b9603d3e2a7b3de0ab7e0cf52dfee39373bc472fa997027d798d59f81d525a69ecf156e885fd1e2790924386b2230cc90e3b7adc95603ddcf4c40bdc72f22db0f216a99c371d3bf89cba6578c60699e8a0d536950203010001300d06092a864886f70d01010505000381810094a9b80e80691645dd42d6611775a855f71bcd4d77cb60a8e29404035a5e00b21bcc5d4a562482126bd91b6b0e50709377ceb9ef8c2efd12cc8b16afd9a159f350bb270b14204ff065d843832720702e28b41491fbc3a205f5f2f42526d67f17614d8a974de6487b2c866efede3b4e49a0f916baa3c1336fd2ee1b1629652049")) { return false; } } else if (context.getPackageName().equals(TbsConfig.APP_DEMO)) { if (!signature.toCharsString().equals("3082023f308201a8a00302010202044c46914a300d06092a864886f70d01010505003064310b30090603550406130238363110300e060355040813074265696a696e673110300e060355040713074265696a696e673110300e060355040a130754656e63656e74310c300a060355040b13035753443111300f0603550403130873616d75656c6d6f301e170d3130303732313036313835305a170d3430303731333036313835305a3064310b30090603550406130238363110300e060355040813074265696a696e673110300e060355040713074265696a696e673110300e060355040a130754656e63656e74310c300a060355040b13035753443111300f0603550403130873616d75656c6d6f30819f300d06092a864886f70d010101050003818d0030818902818100c209077044bd0d63ea00ede5b839914cabcc912a87f0f8b390877e0f7a2583f0d5933443c40431c35a4433bc4c965800141961adc44c9625b1d321385221fd097e5bdc2f44a1840d643ab59dc070cf6c4b4b4d98bed5cbb8046e0a7078ae134da107cdf2bfc9b440fe5cb2f7549b44b73202cc6f7c2c55b8cfb0d333a021f01f0203010001300d06092a864886f70d010105050003818100b007db9922774ef4ccfee81ba514a8d57c410257e7a2eba64bfa17c9e690da08106d32f637ac41fbc9f205176c71bde238c872c3ee2f8313502bee44c80288ea4ef377a6f2cdfe4d3653c145c4acfedbfbadea23b559d41980cc3cdd35d79a68240693739aabf5c5ed26148756cf88264226de394c8a24ac35b712b120d4d23a")) { return false; } } else if (!context.getPackageName().equals(TbsConfig.APP_QZONE)) { return !context.getPackageName().equals("com.tencent.qqpimsecure") || signature.toCharsString().equals("30820239308201a2a00302010202044c96f48f300d06092a864886f70d01010505003060310b300906035504061302434e310b300906035504081302474431123010060355040713094775616e677a686f753110300e060355040a130754656e63656e74310b3009060355040b130233473111300f0603550403130857696c736f6e57753020170d3130303932303035343334335a180f32303635303632333035343334335a3060310b300906035504061302434e310b300906035504081302474431123010060355040713094775616e677a686f753110300e060355040a130754656e63656e74310b3009060355040b130233473111300f0603550403130857696c736f6e577530819f300d06092a864886f70d010101050003818d0030818902818100b56e79dbb1185a79e52d792bb3d0bb3da8010d9b87da92ec69f7dc5ad66ab6bfdff2a6a1ed285dd2358f28b72a468be7c10a2ce30c4c27323ed4edcc936080e5bedc2cbbca0b7e879c08a631182793f44bb3ea284179b263410c298e5f6831032c9702ba4a74e2ccfc9ef857f12201451602fc8e774ac59d6398511586c83d1d0203010001300d06092a864886f70d0101050500038181002475615bb65b8d8786b890535802948840387d06b1692ff3ea47ef4c435719ba1865b81e6bfa6293ce31747c3cd6b34595b485cc1563fd90107ba5845c28b95c79138f0dec288940395bc10f92f2b69d8dc410999deb38900974ce9984b678030edfba8816582f56160d87e38641288d8588d2a31e20b89f223d788dd35cc9c8"); } else { if (!signature.toCharsString().equals("308202ad30820216a00302010202044c26cea2300d06092a864886f70d010105050030819a310b3009060355040613023836311530130603550408130c4265696a696e672043697479311530130603550407130c4265696a696e67204369747931263024060355040a131d515a6f6e65205465616d206f662054656e63656e7420436f6d70616e7931183016060355040b130f54656e63656e7420436f6d70616e79311b301906035504031312416e64726f696420515a6f6e65205465616d301e170d3130303632373034303830325a170d3335303632313034303830325a30819a310b3009060355040613023836311530130603550408130c4265696a696e672043697479311530130603550407130c4265696a696e67204369747931263024060355040a131d515a6f6e65205465616d206f662054656e63656e7420436f6d70616e7931183016060355040b130f54656e63656e7420436f6d70616e79311b301906035504031312416e64726f696420515a6f6e65205465616d30819f300d06092a864886f70d010101050003818d003081890281810082d6aca037a9843fbbe88b6dd19f36e9c24ce174c1b398f3a529e2a7fe02de99c27539602c026edf96ad8d43df32a85458bca1e6fbf11958658a7d6751a1d9b782bf43a8c19bd1c06bdbfd94c0516326ae3cf638ac42bb470580e340c46e6f306a772c1ef98f10a559edf867f3f31fe492808776b7bd953b2cba2d2b2d66a44f0203010001300d06092a864886f70d0101050500038181006003b04a8a8c5be9650f350cda6896e57dd13e6e83e7f891fc70f6a3c2eaf75cfa4fc998365deabbd1b9092159edf4b90df5702a0d101f8840b5d4586eb92a1c3cd19d95fbc1c2ac956309eda8eef3944baf08c4a49d3b9b3ffb06bc13dab94ecb5b8eb74e8789aa0ba21cb567f538bbc59c2a11e6919924a24272eb79251677")) { return false; } } } catch (Exception unused) { TbsLog.i("TbsInstaller", "TbsInstaller-installLocalTbsCore getPackageInfo fail"); return false; } } /* access modifiers changed from: package-private */ public boolean g(Context context, int i2) { File file; String str; String str2; try { boolean isThirdPartyApp = TbsShareManager.isThirdPartyApp(context); if (!isThirdPartyApp) { file = r(context); } else if (TbsShareManager.j(context)) { file = new File(TbsShareManager.c(context)); if (file.getAbsolutePath().contains(TbsConfig.APP_DEMO)) { return true; } } else { TbsLog.e("TbsInstaller", "321"); return false; } if (file != null) { Long[][] lArr = n; int length = lArr.length; int i3 = 0; while (true) { if (i3 >= length) { break; } Long[] lArr2 = lArr[i3]; if (i2 == lArr2[0].intValue()) { File file2 = new File(file, "libmttwebview.so"); if (!file2.exists() || file2.length() != lArr2[1].longValue()) { if (!isThirdPartyApp) { FileUtil.b(QbSdk.getTbsFolderDir(context)); } a.set(0); str = "TbsInstaller"; str2 = "322"; } else { TbsLog.d("TbsInstaller", "check so success: " + i2 + "; file: " + file2); } } else { i3++; } } return true; } str = "TbsInstaller"; str2 = "323"; TbsLog.e(str, str2); return false; } catch (Throwable th) { TbsLog.e("TbsInstaller", "ISTBSCORELEGAL exception getMessage is " + th.getMessage()); TbsLog.e("TbsInstaller", "ISTBSCORELEGAL exception getCause is " + th.getCause()); return false; } } public void h(Context context) { FileLock fileLock = l; if (fileLock != null) { FileUtil.a(context, fileLock); } } /* access modifiers changed from: package-private */ /* JADX WARNING: Removed duplicated region for block: B:24:0x0045 A[SYNTHETIC, Splitter:B:24:0x0045] */ /* JADX WARNING: Removed duplicated region for block: B:30:0x004c A[SYNTHETIC, Splitter:B:30:0x004c] */ public int i(Context context) { Throwable th; BufferedInputStream bufferedInputStream = null; try { File file = new File(q(context), "tbs.conf"); if (!file.exists()) { return 0; } Properties properties = new Properties(); BufferedInputStream bufferedInputStream2 = new BufferedInputStream(new FileInputStream(file)); try { properties.load(bufferedInputStream2); bufferedInputStream2.close(); String property = properties.getProperty("tbs_core_version"); if (property == null) { try { bufferedInputStream2.close(); } catch (IOException unused) { } return 0; } int parseInt = Integer.parseInt(property); try { bufferedInputStream2.close(); } catch (IOException unused2) { } return parseInt; } catch (Exception unused3) { bufferedInputStream = bufferedInputStream2; if (bufferedInputStream != null) { } return 0; } catch (Throwable th2) { th = th2; bufferedInputStream = bufferedInputStream2; if (bufferedInputStream != null) { } throw th; } } catch (Exception unused4) { if (bufferedInputStream != null) { try { bufferedInputStream.close(); } catch (IOException unused5) { } } return 0; } catch (Throwable th3) { th = th3; if (bufferedInputStream != null) { try { bufferedInputStream.close(); } catch (IOException unused6) { } } throw th; } } /* access modifiers changed from: package-private */ /* JADX WARNING: Removed duplicated region for block: B:32:0x00ba A[SYNTHETIC, Splitter:B:32:0x00ba] */ /* JADX WARNING: Removed duplicated region for block: B:38:0x00dc A[SYNTHETIC, Splitter:B:38:0x00dc] */ public int j(Context context) { Throwable th; Exception e2; BufferedInputStream bufferedInputStream = null; try { File file = new File(r(context), "tbs.conf"); if (!file.exists()) { return 0; } TbsLog.i("TbsInstaller", "getTbsCoreInstalledVerInNolock tbsPropFile is " + file.getAbsolutePath()); Properties properties = new Properties(); BufferedInputStream bufferedInputStream2 = new BufferedInputStream(new FileInputStream(file)); try { properties.load(bufferedInputStream2); bufferedInputStream2.close(); String property = properties.getProperty("tbs_core_version"); if (property == null) { try { bufferedInputStream2.close(); } catch (IOException e3) { TbsLog.i("TbsInstaller", "TbsInstaller--getTbsCoreInstalledVerInNolock IOException=" + e3.toString()); } return 0; } int parseInt = Integer.parseInt(property); if (o == 0) { o = parseInt; } try { bufferedInputStream2.close(); } catch (IOException e4) { TbsLog.i("TbsInstaller", "TbsInstaller--getTbsCoreInstalledVerInNolock IOException=" + e4.toString()); } return parseInt; } catch (Exception e5) { e2 = e5; bufferedInputStream = bufferedInputStream2; try { TbsLog.i("TbsInstaller", "TbsInstaller--getTbsCoreInstalledVerInNolock Exception=" + e2.toString()); if (bufferedInputStream != null) { } return 0; } catch (Throwable th2) { th = th2; if (bufferedInputStream != null) { } throw th; } } catch (Throwable th3) { th = th3; bufferedInputStream = bufferedInputStream2; if (bufferedInputStream != null) { try { bufferedInputStream.close(); } catch (IOException e6) { TbsLog.i("TbsInstaller", "TbsInstaller--getTbsCoreInstalledVerInNolock IOException=" + e6.toString()); } } throw th; } } catch (Exception e7) { e2 = e7; TbsLog.i("TbsInstaller", "TbsInstaller--getTbsCoreInstalledVerInNolock Exception=" + e2.toString()); if (bufferedInputStream != null) { try { bufferedInputStream.close(); } catch (IOException e8) { TbsLog.i("TbsInstaller", "TbsInstaller--getTbsCoreInstalledVerInNolock IOException=" + e8.toString()); } } return 0; } } /* access modifiers changed from: package-private */ public int k(Context context) { int i2 = o; return i2 != 0 ? i2 : j(context); } /* access modifiers changed from: package-private */ public void l(Context context) { if (o == 0) { o = j(context); } } /* access modifiers changed from: package-private */ public boolean m(Context context) { return new File(r(context), "tbs.conf").exists(); } /* access modifiers changed from: package-private */ /* JADX WARNING: Removed duplicated region for block: B:56:0x014d A[SYNTHETIC, Splitter:B:56:0x014d] */ /* JADX WARNING: Removed duplicated region for block: B:63:0x0174 A[Catch:{ Throwable -> 0x017a }] */ /* JADX WARNING: Removed duplicated region for block: B:69:0x0197 A[SYNTHETIC, Splitter:B:69:0x0197] */ /* JADX WARNING: Removed duplicated region for block: B:76:0x01be A[Catch:{ Throwable -> 0x01c4 }] */ public int n(Context context) { Throwable th; Exception e2; if (!u(context)) { return -1; } boolean tryLock = i.tryLock(); TbsLog.i("TbsInstaller", "TbsInstaller--getTbsCoreInstalledVerWithLock locked=" + tryLock); if (tryLock) { BufferedInputStream bufferedInputStream = null; try { File file = new File(r(context), "tbs.conf"); if (!file.exists()) { try { if (i.isHeldByCurrentThread()) { i.unlock(); } } catch (Throwable th2) { TbsLog.e("TbsInstaller", "TbsRenameLock.unlock exception: " + th2); } b(); return 0; } Properties properties = new Properties(); BufferedInputStream bufferedInputStream2 = new BufferedInputStream(new FileInputStream(file)); try { properties.load(bufferedInputStream2); bufferedInputStream2.close(); String property = properties.getProperty("tbs_core_version"); if (property == null) { try { bufferedInputStream2.close(); } catch (IOException e3) { TbsLog.i("TbsInstaller", "TbsInstaller--getTbsCoreInstalledVerWithLock IOException=" + e3.toString()); } try { if (i.isHeldByCurrentThread()) { i.unlock(); } } catch (Throwable th3) { TbsLog.e("TbsInstaller", "TbsRenameLock.unlock exception: " + th3); } b(); return 0; } a.set(Integer.valueOf(Integer.parseInt(property))); int intValue = a.get().intValue(); try { bufferedInputStream2.close(); } catch (IOException e4) { TbsLog.i("TbsInstaller", "TbsInstaller--getTbsCoreInstalledVerWithLock IOException=" + e4.toString()); } try { if (i.isHeldByCurrentThread()) { i.unlock(); } } catch (Throwable th4) { TbsLog.e("TbsInstaller", "TbsRenameLock.unlock exception: " + th4); } b(); return intValue; } catch (Exception e5) { e2 = e5; bufferedInputStream = bufferedInputStream2; try { TbsLog.i("TbsInstaller", "TbsInstaller--getTbsCoreInstalledVerWithLock Exception=" + e2.toString()); if (bufferedInputStream != null) { } try { if (i.isHeldByCurrentThread()) { } } catch (Throwable th5) { TbsLog.e("TbsInstaller", "TbsRenameLock.unlock exception: " + th5); } b(); return 0; } catch (Throwable th6) { th = th6; if (bufferedInputStream != null) { } try { if (i.isHeldByCurrentThread()) { } } catch (Throwable th7) { TbsLog.e("TbsInstaller", "TbsRenameLock.unlock exception: " + th7); } b(); throw th; } } catch (Throwable th8) { th = th8; bufferedInputStream = bufferedInputStream2; if (bufferedInputStream != null) { try { bufferedInputStream.close(); } catch (IOException e6) { TbsLog.i("TbsInstaller", "TbsInstaller--getTbsCoreInstalledVerWithLock IOException=" + e6.toString()); } } if (i.isHeldByCurrentThread()) { i.unlock(); } b(); throw th; } } catch (Exception e7) { e2 = e7; TbsLog.i("TbsInstaller", "TbsInstaller--getTbsCoreInstalledVerWithLock Exception=" + e2.toString()); if (bufferedInputStream != null) { try { bufferedInputStream.close(); } catch (IOException e8) { TbsLog.i("TbsInstaller", "TbsInstaller--getTbsCoreInstalledVerWithLock IOException=" + e8.toString()); } } if (i.isHeldByCurrentThread()) { i.unlock(); } b(); return 0; } } else { b(); return 0; } } public boolean o(Context context) { return true; } /* access modifiers changed from: package-private */ public void p(Context context) { TbsLog.i("TbsInstaller", "TbsInstaller--cleanStatusAndTmpDir"); n.a(context).a(0); n.a(context).b(0); n.a(context).d(0); n.a(context).a("incrupdate_retry_num", 0); if (!TbsDownloader.a(context)) { n.a(context).c(0, -1); n.a(context).a(""); n.a(context).a("copy_retry_num", 0); n.a(context).c(-1); n.a(context).a(0, -1); FileUtil.a(f(context, 0), true); FileUtil.a(f(context, 1), true); } } /* access modifiers changed from: package-private */ public File q(Context context) { File file = new File(QbSdk.getTbsFolderDir(context), "core_share_decouple"); if (file.isDirectory() || file.mkdir()) { return file; } return null; } /* access modifiers changed from: package-private */ public File r(Context context) { return b((Context) null, context); } /* access modifiers changed from: package-private */ public File s(Context context) { File file = new File(QbSdk.getTbsFolderDir(context), "share"); if (file.isDirectory() || file.mkdir()) { return file; } return null; } /* access modifiers changed from: package-private */ public synchronized boolean u(Context context) { if (this.e > 0) { TbsLog.i("TbsInstaller", "getTbsInstallingFileLock success,is cached= true"); this.e++; return true; } this.g = FileUtil.b(context, true, "tbslock.txt"); if (this.g != null) { this.f = FileUtil.a(context, this.g); if (this.f == null) { TbsLog.i("TbsInstaller", "getTbsInstallingFileLock tbsFileLockFileLock == null"); return false; } TbsLog.i("TbsInstaller", "getTbsInstallingFileLock success,is cached= false"); this.e++; return true; } TbsLog.i("TbsInstaller", "getTbsInstallingFileLock get install fos failed"); return false; } }