导航菜单

页面标题

页面副标题

多多分期 v4.1.2 - c0.java 源代码

正在查看: 多多分期 v4.1.2 应用的 c0.java JAVA 源代码文件

本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。


package d.s.b.b;

import android.content.Context;
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 com.blankj.utilcode.util.LogUtils;
import com.tencent.smtt.sdk.TbsLogReport;
import dalvik.system.DexClassLoader;
import face.security.device.api.FaceSecCode;
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;

public class c0 {

    public static c0 f9133f;

    public static final ReentrantLock f9134g = new ReentrantLock();

    public static final Lock f9135h = new ReentrantLock();

    public static FileLock f9136i = null;

    public static ThreadLocal<Integer> f9137j = new d0();

    public static Handler f9138k = null;

    public static final Long[][] f9139l = {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}};

    public static boolean f9140m = false;

    public static final FileFilter f9141n = new e0();
    public static int o = 0;
    public static boolean p = false;

    public FileLock f9143b;

    public FileOutputStream f9144c;

    public int f9142a = 0;

    public boolean f9145d = false;

    public boolean f9146e = false;

    public c0() {
        if (f9138k == null) {
            f9138k = new f0(this, b0.a().getLooper());
        }
    }

    public static boolean P(Context context, String str) {
        String str2;
        File file = new File(context.getDir("tbs", 0), str);
        if (!file.exists()) {
            str2 = "TbsInstaller-isPrepareTbsCore, #1";
        } else {
            if (new File(file, "tbs.conf").exists()) {
                d.s.b.c.c.g("TbsInstaller", "TbsInstaller-isPrepareTbsCore, #3");
                return true;
            }
            str2 = "TbsInstaller-isPrepareTbsCore, #2";
        }
        d.s.b.c.c.g("TbsInstaller", str2);
        return false;
    }

    public static synchronized c0 j() {
        c0 c0Var;
        synchronized (c0.class) {
            if (f9133f == null) {
                synchronized (c0.class) {
                    if (f9133f == null) {
                        f9133f = new c0();
                    }
                }
            }
            c0Var = f9133f;
        }
        return c0Var;
    }

    public static void l(Context context) {
        String str;
        if (q0(context)) {
            return;
        }
        if (P(context, "core_unzip_tmp")) {
            e.d().c(context, 417, new Throwable("TMP_TBS_UNZIP_FOLDER_NAME"));
            str = "TbsInstaller-UploadIfTempCoreExistConfError INFO_TEMP_CORE_EXIST_CONF_ERROR TMP_TBS_UNZIP_FOLDER_NAME";
        } else if (P(context, "core_share_backup_tmp")) {
            e.d().c(context, 417, new Throwable("TMP_BACKUP_TBSCORE_FOLDER_NAME"));
            str = "TbsInstaller-UploadIfTempCoreExistConfError INFO_TEMP_CORE_EXIST_CONF_ERROR TMP_BACKUP_TBSCORE_FOLDER_NAME";
        } else {
            if (!P(context, "core_copy_tmp")) {
                return;
            }
            e.d().c(context, 417, new Throwable("TMP_TBS_COPY_FOLDER_NAME"));
            str = "TbsInstaller-UploadIfTempCoreExistConfError INFO_TEMP_CORE_EXIST_CONF_ERROR TMP_TBS_COPY_FOLDER_NAME";
        }
        d.s.b.c.c.d("TbsInstaller", str);
    }

    public static File l0(Context context) {
        File file = new File(context.getDir("tbs", 0), "core_private");
        if (file.isDirectory() || file.mkdir()) {
            return file;
        }
        return null;
    }

    public static boolean q0(Context context) {
        String str;
        if (context == null) {
            str = "TbsInstaller-getTmpFolderCoreToRead, #1";
        } else {
            try {
                if (new File(context.getDir("tbs", 0), "tmp_folder_core_to_read.conf").exists()) {
                    d.s.b.c.c.g("TbsInstaller", "TbsInstaller-getTmpFolderCoreToRead, #2");
                    return true;
                }
                d.s.b.c.c.g("TbsInstaller", "TbsInstaller-getTmpFolderCoreToRead, #3");
                return false;
            } catch (Exception unused) {
                str = "TbsInstaller-getTmpFolderCoreToRead, #4";
            }
        }
        d.s.b.c.c.g("TbsInstaller", str);
        return true;
    }

    public synchronized void A() {
        int i2 = this.f9142a;
        this.f9142a = i2 - 1;
        if (i2 <= 1 && this.f9145d) {
            d.s.b.c.c.g("TbsInstaller", "releaseTbsInstallingFileLock without skip");
            d.s.b.c.n.i(this.f9143b, this.f9144c);
            this.f9145d = false;
            return;
        }
        d.s.b.c.c.g("TbsInstaller", "releaseTbsInstallingFileLock with skip");
    }

    public void B(Context context) {
        Z(context, true);
        y.a(context).k(b0(context), 2);
    }

    public void C(android.content.Context r22, android.os.Bundle r23) {
        throw new UnsupportedOperationException("Method not decompiled: d.s.b.b.c0.C(android.content.Context, android.os.Bundle):void");
    }

    @android.annotation.TargetApi(11)
    public final void D(android.content.Context r17, java.lang.String r18, int r19) {
        throw new UnsupportedOperationException("Method not decompiled: d.s.b.b.c0.D(android.content.Context, java.lang.String, int):void");
    }

    public boolean E(Context context, int i2) {
        if (g.w(context)) {
            return false;
        }
        d.s.b.c.c.g("TbsInstaller", "TbsInstaller-installLocalTbsCore targetTbsCoreVer=" + i2);
        d.s.b.c.c.g("TbsInstaller", "TbsInstaller-continueInstallTbsCore currentProcessName=" + context.getApplicationInfo().processName);
        d.s.b.c.c.g("TbsInstaller", "TbsInstaller-installLocalTbsCore currentProcessId=" + Process.myPid());
        d.s.b.c.c.g("TbsInstaller", "TbsInstaller-installLocalTbsCore currentThreadName=" + Thread.currentThread().getName());
        Context V = V(context, i2);
        if (V == null) {
            d.s.b.c.c.g("TbsInstaller", "TbsInstaller--installLocalTbsCore copy from null");
            return false;
        }
        Object[] objArr = {V, context, Integer.valueOf(i2)};
        Message message = new Message();
        message.what = 2;
        message.obj = objArr;
        f9138k.sendMessage(message);
        return true;
    }

    public final boolean F(Context context, File file) {
        return v(context, file, false);
    }

    public File G(Context context, Context context2) {
        File file = new File(context2.getDir("tbs", 0), "core_share_decouple");
        if (file.isDirectory() || ((context != null && j.C(context)) || file.mkdir())) {
            return file;
        }
        return null;
    }

    public String H(Context context, String str) {
        BufferedInputStream bufferedInputStream;
        BufferedInputStream bufferedInputStream2 = null;
        if (TextUtils.isEmpty(str)) {
            return null;
        }
        try {
            File file = new File(j0(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) {
                    try {
                        bufferedInputStream.close();
                    } catch (IOException unused3) {
                    }
                }
                return null;
            } catch (Throwable th) {
                th = th;
                bufferedInputStream2 = bufferedInputStream;
                if (bufferedInputStream2 != null) {
                    try {
                        bufferedInputStream2.close();
                    } catch (IOException unused4) {
                    }
                }
                throw th;
            }
        } catch (Exception unused5) {
            bufferedInputStream = null;
        } catch (Throwable th2) {
            th = th2;
        }
    }

    public void I(Context context, int i2) {
        int c0;
        d.s.b.c.c.g("TbsInstaller", "TbsInstaller-installTbsCoreForThirdPartyApp");
        if (i2 > 0 && (c0 = c0(context)) != i2) {
            Context j2 = j.j(context);
            if (j2 != null || j.v() != null) {
                d.s.b.c.c.g("TbsInstaller", "TbsInstaller--quickDexOptForThirdPartyApp hostContext != null");
                t(context, j2);
            } else if (c0 <= 0) {
                d.s.b.c.c.g("TbsInstaller", "TbsInstaller--installTbsCoreForThirdPartyApp hostContext == null");
                c.d(context, "TbsInstaller::installTbsCoreForThirdPartyApp forceSysWebViewInner #2");
            }
        }
    }

    public void J(Context context, boolean z) {
        String str;
        File n0;
        if (c.f9125g) {
            return;
        }
        if (Build.VERSION.SDK_INT < 8) {
            d.s.b.c.c.e("TbsInstaller", "android version < 2.1 no need install X5 core", true);
            return;
        }
        try {
            if (!j.C(context) && (n0 = n0(context)) != null && n0.exists()) {
                d.s.b.c.n.g(n0, false);
                new File(l0(context), "x5.tbs").delete();
            }
        } catch (Throwable unused) {
        }
        d.s.b.c.c.g("TbsInstaller", "Tbsinstaller installTbsCoreIfNeeded #1 ");
        if (q0(context)) {
            d.s.b.c.c.g("TbsInstaller", "Tbsinstaller installTbsCoreIfNeeded #2 ");
            if (P(context, "core_unzip_tmp") && U(context, z)) {
                str = "TbsInstaller-installTbsCoreIfNeeded, enableTbsCoreFromUnzip!!";
            } else if (P(context, "core_share_backup_tmp") && X(context, z)) {
                str = "TbsInstaller-installTbsCoreIfNeeded, enableTbsCoreFromBackup!!";
            } else {
                if (!P(context, "core_copy_tmp") || !Q(context, z)) {
                    d.s.b.c.c.h("TbsInstaller", "TbsInstaller-installTbsCoreIfNeeded, error !!", true);
                    return;
                }
                str = "TbsInstaller-installTbsCoreIfNeeded, enableTbsCoreFromCopy!!";
            }
            d.s.b.c.c.h("TbsInstaller", str, true);
        }
    }

    public boolean K(Context context) {
        File file = new File(j0(context), "tbs.conf");
        boolean z = 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);
                boolean booleanValue = Boolean.valueOf(properties.getProperty("tbs_local_installation", "false")).booleanValue();
                if (booleanValue) {
                    try {
                        if (System.currentTimeMillis() - file.lastModified() > 259200000) {
                            z = true;
                        }
                    } catch (Throwable th) {
                        th = th;
                        z = booleanValue;
                        bufferedInputStream = bufferedInputStream2;
                        try {
                            th.printStackTrace();
                            return z;
                        } finally {
                            if (bufferedInputStream != null) {
                                try {
                                    bufferedInputStream.close();
                                } catch (IOException e2) {
                                    e2.printStackTrace();
                                }
                            }
                        }
                    }
                }
                d.s.b.c.c.g("TbsInstaller", "TBS_LOCAL_INSTALLATION is:" + booleanValue + " expired=" + z);
                boolean z2 = booleanValue & (!z);
                try {
                    bufferedInputStream2.close();
                    return z2;
                } catch (IOException e3) {
                    e3.printStackTrace();
                    return z2;
                }
            } catch (Throwable th2) {
                th = th2;
            }
        } catch (Throwable th3) {
            th = th3;
        }
    }

    public final boolean L(Context context, File file) {
        try {
            File[] listFiles = file.listFiles(new k0(this));
            int length = listFiles.length;
            if (Build.VERSION.SDK_INT < 16 && context.getPackageName() != null && context.getPackageName().equalsIgnoreCase("com.tencent.tbs")) {
                try {
                    Thread.sleep(5000L);
                } catch (Exception unused) {
                }
            }
            ClassLoader classLoader = context.getClassLoader();
            for (int i2 = 0; i2 < length; i2++) {
                d.s.b.c.c.g("TbsInstaller", "jarFile: " + listFiles[i2].getAbsolutePath());
                new DexClassLoader(listFiles[i2].getAbsolutePath(), file.getAbsolutePath(), null, classLoader);
            }
            return true;
        } catch (Exception e2) {
            e2.printStackTrace();
            TbsLogReport.b(context).h(209, e2.toString());
            d.s.b.c.c.g("TbsInstaller", "TbsInstaller-doTbsDexOpt done");
            return false;
        }
    }

    public void M(Context context) {
        BufferedInputStream bufferedInputStream;
        try {
            File file = new File(j0(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);
                        try {
                            bufferedOutputStream2.close();
                        } catch (IOException unused) {
                        }
                    } catch (Throwable unused2) {
                        bufferedOutputStream = bufferedOutputStream2;
                        if (bufferedOutputStream != null) {
                            try {
                                bufferedOutputStream.close();
                            } catch (IOException unused3) {
                            }
                        }
                        if (bufferedInputStream == null) {
                            return;
                        }
                        bufferedInputStream.close();
                    }
                } catch (Throwable unused4) {
                }
            } catch (Throwable unused5) {
                bufferedInputStream = null;
            }
            bufferedInputStream.close();
        } catch (Throwable unused6) {
        }
    }

    public boolean N(Context context, int i2) {
        File j0;
        String str;
        try {
            boolean C = j.C(context);
            if (!C) {
                j0 = j0(context);
            } else {
                if (!j.D(context)) {
                    d.s.b.c.c.d("TbsInstaller", "321");
                    return false;
                }
                j0 = new File(j.g(context));
                if (j0.getAbsolutePath().contains("com.tencent.tbs")) {
                    return true;
                }
            }
            if (j0 != null) {
                Long[][] lArr = f9139l;
                int length = lArr.length;
                int i3 = 0;
                while (true) {
                    if (i3 >= length) {
                        break;
                    }
                    Long[] lArr2 = lArr[i3];
                    if (i2 == lArr2[0].intValue()) {
                        File file = new File(j0, "libmttwebview.so");
                        if (file.exists() && file.length() == lArr2[1].longValue()) {
                            d.s.b.c.c.c("TbsInstaller", "check so success: " + i2 + "; file: " + file);
                        } else {
                            if (!C) {
                                d.s.b.c.n.u(context.getDir("tbs", 0));
                            }
                            f9137j.set(0);
                            str = "322";
                        }
                    } else {
                        i3++;
                    }
                }
                return true;
            }
            str = "323";
            d.s.b.c.c.d("TbsInstaller", str);
            return false;
        } catch (Throwable th) {
            d.s.b.c.c.d("TbsInstaller", "ISTBSCORELEGAL exception getMessage is " + th.getMessage());
            d.s.b.c.c.d("TbsInstaller", "ISTBSCORELEGAL exception getCause is " + th.getCause());
            return false;
        }
    }

    public final boolean O(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 = b1.a(context, file3.getAbsolutePath());
            if (TextUtils.isEmpty(a2)) {
                TbsLogReport.b(context).h(226, "can not find oat command");
                return false;
            }
            for (File file4 : file.listFiles(new l0(this))) {
                String substring = file4.getName().substring(0, r5.getName().length() - 4);
                Runtime.getRuntime().exec("/system/bin/dex2oat " + a2.replaceAll("tbs_sdk_extension_dex", substring) + " --dex-location=" + j().j0(context) + File.separator + substring + ".jar").waitFor();
            }
            return true;
        } catch (Exception e2) {
            e2.printStackTrace();
            TbsLogReport.b(context).j(226, e2);
            return false;
        }
    }

    public final synchronized boolean Q(Context context, boolean z) {
        d.s.b.c.c.g("TbsInstaller", "TbsInstaller-enableTbsCoreFromCopy");
        boolean z2 = false;
        try {
        } finally {
            return z2;
        }
        if (!p0(context)) {
            return false;
        }
        boolean tryLock = f9134g.tryLock();
        d.s.b.c.c.g("TbsInstaller", "TbsInstaller-enableTbsCoreFromCopy Locked =" + tryLock);
        if (tryLock) {
            try {
                int i2 = y.a(context).i("copy_status");
                int h2 = h(false, context);
                d.s.b.c.c.g("TbsInstaller", "TbsInstaller-enableTbsCoreFromCopy copyStatus =" + i2);
                d.s.b.c.c.g("TbsInstaller", "TbsInstaller-enableTbsCoreFromCopy tbsCoreInstalledVer =" + h2);
                if (i2 == 1) {
                    if (h2 == 0) {
                        d.s.b.c.c.h("TbsInstaller", "TbsInstaller-enableTbsCoreFromCopy tbsCoreInstalledVer = 0", true);
                    } else if (z) {
                        d.s.b.c.c.h("TbsInstaller", "TbsInstaller-enableTbsCoreFromCopy tbsCoreInstalledVer != 0", true);
                    }
                    b(context);
                    z2 = true;
                }
                f9134g.unlock();
            } catch (Throwable th) {
                f9134g.unlock();
                throw th;
            }
        }
        A();
        return z2;
    }

    public boolean R(Context context) {
        try {
            File file = new File(d.s.b.c.n.b(context, 4), "x5.tbs.decouple");
            File n0 = j().n0(context);
            d.s.b.c.n.k(n0);
            d.s.b.c.n.g(n0, true);
            d.s.b.c.n.l(file, n0);
            for (String str : n0.list()) {
                File file2 = new File(n0, str);
                if (file2.getName().endsWith(".dex")) {
                    file2.delete();
                }
            }
            j().Z(context, true);
            File i0 = i0(context);
            d.s.b.c.n.g(i0, true);
            n0.renameTo(i0);
            j.e(context);
            return true;
        } catch (Exception unused) {
            return false;
        }
    }

    public final boolean S(android.content.Context r8, int r9) {
        throw new UnsupportedOperationException("Method not decompiled: d.s.b.b.c0.S(android.content.Context, int):boolean");
    }

    public final boolean T(Context context, String str) {
        PackageInfo packageInfo;
        try {
            packageInfo = context.getPackageManager().getPackageInfo(str, 0);
        } catch (PackageManager.NameNotFoundException unused) {
            packageInfo = null;
        }
        return packageInfo != null;
    }

    public final synchronized boolean U(Context context, boolean z) {
        if (context != null) {
            if ("com.tencent.mm".equals(context.getApplicationContext().getApplicationInfo().packageName)) {
                TbsLogReport.b(context).h(229, LogUtils.PLACEHOLDER);
            }
        }
        d.s.b.c.c.g("TbsInstaller", "TbsInstaller-enableTbsCoreFromUnzip canRenameTmpDir =" + z);
        d.s.b.c.c.g("TbsInstaller", "Tbsinstaller enableTbsCoreFromUnzip #1 ");
        boolean z2 = false;
        try {
        } catch (Exception e2) {
            c.d(context, "TbsInstaller::enableTbsCoreFromUnzip Exception: " + e2);
            e2.printStackTrace();
        }
        if (!p0(context)) {
            return false;
        }
        d.s.b.c.c.g("TbsInstaller", "Tbsinstaller enableTbsCoreFromUnzip #2 ");
        boolean tryLock = f9134g.tryLock();
        d.s.b.c.c.g("TbsInstaller", "TbsInstaller-enableTbsCoreFromUnzip locked=" + tryLock);
        if (tryLock) {
            try {
                int l2 = y.a(context).l();
                d.s.b.c.c.g("TbsInstaller", "TbsInstaller-enableTbsCoreFromUnzip installStatus=" + l2);
                int h2 = h(false, context);
                if (l2 == 2) {
                    d.s.b.c.c.g("TbsInstaller", "Tbsinstaller enableTbsCoreFromUnzip #4 ");
                    if (h2 == 0) {
                        d.s.b.c.c.h("TbsInstaller", "TbsInstaller-enableTbsCoreFromUnzip tbsCoreInstalledVer = 0", false);
                    } else if (z) {
                        d.s.b.c.c.h("TbsInstaller", "TbsInstaller-enableTbsCoreFromUnzip tbsCoreInstalledVer != 0", false);
                    }
                    a(context);
                    z2 = true;
                }
                f9134g.unlock();
            } catch (Throwable th) {
                f9134g.unlock();
                throw th;
            }
        }
        A();
        return z2;
    }

    public final Context V(Context context, int i2) {
        Context i3;
        d.s.b.c.c.g("TbsInstaller", "TbsInstaller--getTbsCoreHostContext tbsCoreTargetVer=" + i2);
        if (i2 <= 0) {
            return null;
        }
        String[] t = j.t();
        for (int i4 = 0; i4 < t.length; i4++) {
            if (!context.getPackageName().equalsIgnoreCase(t[i4]) && T(context, t[i4]) && (i3 = i(context, t[i4])) != null) {
                if (W(i3)) {
                    int c0 = c0(i3);
                    d.s.b.c.c.g("TbsInstaller", "TbsInstaller-getTbsCoreHostContext hostTbsCoreVer=" + c0);
                    if (c0 != 0 && c0 == i2) {
                        d.s.b.c.c.g("TbsInstaller", "TbsInstaller-getTbsCoreHostContext targetApp=" + t[i4]);
                        return i3;
                    }
                } else {
                    d.s.b.c.c.d("TbsInstaller", "TbsInstaller--getTbsCoreHostContext " + t[i4] + " illegal signature go on next");
                }
            }
        }
        return null;
    }

    public boolean W(Context context) {
        if (j.v() != null) {
            return true;
        }
        try {
            Signature signature = context.getPackageManager().getPackageInfo(context.getPackageName(), 64).signatures[0];
            if (context.getPackageName().equals("com.tencent.mtt")) {
                if (!signature.toCharsString().equals("3082023f308201a8a00302010202044c46914a300d06092a864886f70d01010505003064310b30090603550406130238363110300e060355040813074265696a696e673110300e060355040713074265696a696e673110300e060355040a130754656e63656e74310c300a060355040b13035753443111300f0603550403130873616d75656c6d6f301e170d3130303732313036313835305a170d3430303731333036313835305a3064310b30090603550406130238363110300e060355040813074265696a696e673110300e060355040713074265696a696e673110300e060355040a130754656e63656e74310c300a060355040b13035753443111300f0603550403130873616d75656c6d6f30819f300d06092a864886f70d010101050003818d0030818902818100c209077044bd0d63ea00ede5b839914cabcc912a87f0f8b390877e0f7a2583f0d5933443c40431c35a4433bc4c965800141961adc44c9625b1d321385221fd097e5bdc2f44a1840d643ab59dc070cf6c4b4b4d98bed5cbb8046e0a7078ae134da107cdf2bfc9b440fe5cb2f7549b44b73202cc6f7c2c55b8cfb0d333a021f01f0203010001300d06092a864886f70d010105050003818100b007db9922774ef4ccfee81ba514a8d57c410257e7a2eba64bfa17c9e690da08106d32f637ac41fbc9f205176c71bde238c872c3ee2f8313502bee44c80288ea4ef377a6f2cdfe4d3653c145c4acfedbfbadea23b559d41980cc3cdd35d79a68240693739aabf5c5ed26148756cf88264226de394c8a24ac35b712b120d4d23a")) {
                    return false;
                }
            } else if (context.getPackageName().equals("com.tencent.mm")) {
                if (!signature.toCharsString().equals("308202eb30820254a00302010202044d36f7a4300d06092a864886f70d01010505003081b9310b300906035504061302383631123010060355040813094775616e67646f6e673111300f060355040713085368656e7a68656e31353033060355040a132c54656e63656e7420546563686e6f6c6f6779285368656e7a68656e2920436f6d70616e79204c696d69746564313a3038060355040b133154656e63656e74204775616e677a686f7520526573656172636820616e6420446576656c6f706d656e742043656e7465723110300e0603550403130754656e63656e74301e170d3131303131393134333933325a170d3431303131313134333933325a3081b9310b300906035504061302383631123010060355040813094775616e67646f6e673111300f060355040713085368656e7a68656e31353033060355040a132c54656e63656e7420546563686e6f6c6f6779285368656e7a68656e2920436f6d70616e79204c696d69746564313a3038060355040b133154656e63656e74204775616e677a686f7520526573656172636820616e6420446576656c6f706d656e742043656e7465723110300e0603550403130754656e63656e7430819f300d06092a864886f70d010101050003818d0030818902818100c05f34b231b083fb1323670bfbe7bdab40c0c0a6efc87ef2072a1ff0d60cc67c8edb0d0847f210bea6cbfaa241be70c86daf56be08b723c859e52428a064555d80db448cdcacc1aea2501eba06f8bad12a4fa49d85cacd7abeb68945a5cb5e061629b52e3254c373550ee4e40cb7c8ae6f7a8151ccd8df582d446f39ae0c5e930203010001300d06092a864886f70d0101050500038181009c8d9d7f2f908c42081b4c764c377109a8b2c70582422125ce545842d5f520aea69550b6bd8bfd94e987b75a3077eb04ad341f481aac266e89d3864456e69fba13df018acdc168b9a19dfd7ad9d9cc6f6ace57c746515f71234df3a053e33ba93ece5cd0fc15f3e389a3f365588a9fcb439e069d3629cd7732a13fff7b891499")) {
                    return false;
                }
            } else if (context.getPackageName().equals("com.tencent.mobileqq")) {
                if (!signature.toCharsString().equals("30820253308201bca00302010202044bbb0361300d06092a864886f70d0101050500306d310e300c060355040613054368696e61310f300d06035504080c06e58c97e4baac310f300d06035504070c06e58c97e4baac310f300d060355040a0c06e885bee8aeaf311b3019060355040b0c12e697a0e7babfe4b89ae58aa1e7b3bbe7bb9f310b30090603550403130251513020170d3130303430363039343831375a180f32323834303132303039343831375a306d310e300c060355040613054368696e61310f300d06035504080c06e58c97e4baac310f300d06035504070c06e58c97e4baac310f300d060355040a0c06e885bee8aeaf311b3019060355040b0c12e697a0e7babfe4b89ae58aa1e7b3bbe7bb9f310b300906035504031302515130819f300d06092a864886f70d010101050003818d0030818902818100a15e9756216f694c5915e0b529095254367c4e64faeff07ae13488d946615a58ddc31a415f717d019edc6d30b9603d3e2a7b3de0ab7e0cf52dfee39373bc472fa997027d798d59f81d525a69ecf156e885fd1e2790924386b2230cc90e3b7adc95603ddcf4c40bdc72f22db0f216a99c371d3bf89cba6578c60699e8a0d536950203010001300d06092a864886f70d01010505000381810094a9b80e80691645dd42d6611775a855f71bcd4d77cb60a8e29404035a5e00b21bcc5d4a562482126bd91b6b0e50709377ceb9ef8c2efd12cc8b16afd9a159f350bb270b14204ff065d843832720702e28b41491fbc3a205f5f2f42526d67f17614d8a974de6487b2c866efede3b4e49a0f916baa3c1336fd2ee1b1629652049")) {
                    return false;
                }
            } else if (context.getPackageName().equals("com.tencent.tbs")) {
                if (!signature.toCharsString().equals("3082023f308201a8a00302010202044c46914a300d06092a864886f70d01010505003064310b30090603550406130238363110300e060355040813074265696a696e673110300e060355040713074265696a696e673110300e060355040a130754656e63656e74310c300a060355040b13035753443111300f0603550403130873616d75656c6d6f301e170d3130303732313036313835305a170d3430303731333036313835305a3064310b30090603550406130238363110300e060355040813074265696a696e673110300e060355040713074265696a696e673110300e060355040a130754656e63656e74310c300a060355040b13035753443111300f0603550403130873616d75656c6d6f30819f300d06092a864886f70d010101050003818d0030818902818100c209077044bd0d63ea00ede5b839914cabcc912a87f0f8b390877e0f7a2583f0d5933443c40431c35a4433bc4c965800141961adc44c9625b1d321385221fd097e5bdc2f44a1840d643ab59dc070cf6c4b4b4d98bed5cbb8046e0a7078ae134da107cdf2bfc9b440fe5cb2f7549b44b73202cc6f7c2c55b8cfb0d333a021f01f0203010001300d06092a864886f70d010105050003818100b007db9922774ef4ccfee81ba514a8d57c410257e7a2eba64bfa17c9e690da08106d32f637ac41fbc9f205176c71bde238c872c3ee2f8313502bee44c80288ea4ef377a6f2cdfe4d3653c145c4acfedbfbadea23b559d41980cc3cdd35d79a68240693739aabf5c5ed26148756cf88264226de394c8a24ac35b712b120d4d23a")) {
                    return false;
                }
            } else if (context.getPackageName().equals("com.qzone")) {
                if (!signature.toCharsString().equals("308202ad30820216a00302010202044c26cea2300d06092a864886f70d010105050030819a310b3009060355040613023836311530130603550408130c4265696a696e672043697479311530130603550407130c4265696a696e67204369747931263024060355040a131d515a6f6e65205465616d206f662054656e63656e7420436f6d70616e7931183016060355040b130f54656e63656e7420436f6d70616e79311b301906035504031312416e64726f696420515a6f6e65205465616d301e170d3130303632373034303830325a170d3335303632313034303830325a30819a310b3009060355040613023836311530130603550408130c4265696a696e672043697479311530130603550407130c4265696a696e67204369747931263024060355040a131d515a6f6e65205465616d206f662054656e63656e7420436f6d70616e7931183016060355040b130f54656e63656e7420436f6d70616e79311b301906035504031312416e64726f696420515a6f6e65205465616d30819f300d06092a864886f70d010101050003818d003081890281810082d6aca037a9843fbbe88b6dd19f36e9c24ce174c1b398f3a529e2a7fe02de99c27539602c026edf96ad8d43df32a85458bca1e6fbf11958658a7d6751a1d9b782bf43a8c19bd1c06bdbfd94c0516326ae3cf638ac42bb470580e340c46e6f306a772c1ef98f10a559edf867f3f31fe492808776b7bd953b2cba2d2b2d66a44f0203010001300d06092a864886f70d0101050500038181006003b04a8a8c5be9650f350cda6896e57dd13e6e83e7f891fc70f6a3c2eaf75cfa4fc998365deabbd1b9092159edf4b90df5702a0d101f8840b5d4586eb92a1c3cd19d95fbc1c2ac956309eda8eef3944baf08c4a49d3b9b3ffb06bc13dab94ecb5b8eb74e8789aa0ba21cb567f538bbc59c2a11e6919924a24272eb79251677")) {
                    return false;
                }
            } else if (context.getPackageName().equals("com.tencent.qqpimsecure") && !signature.toCharsString().equals("30820239308201a2a00302010202044c96f48f300d06092a864886f70d01010505003060310b300906035504061302434e310b300906035504081302474431123010060355040713094775616e677a686f753110300e060355040a130754656e63656e74310b3009060355040b130233473111300f0603550403130857696c736f6e57753020170d3130303932303035343334335a180f32303635303632333035343334335a3060310b300906035504061302434e310b300906035504081302474431123010060355040713094775616e677a686f753110300e060355040a130754656e63656e74310b3009060355040b130233473111300f0603550403130857696c736f6e577530819f300d06092a864886f70d010101050003818d0030818902818100b56e79dbb1185a79e52d792bb3d0bb3da8010d9b87da92ec69f7dc5ad66ab6bfdff2a6a1ed285dd2358f28b72a468be7c10a2ce30c4c27323ed4edcc936080e5bedc2cbbca0b7e879c08a631182793f44bb3ea284179b263410c298e5f6831032c9702ba4a74e2ccfc9ef857f12201451602fc8e774ac59d6398511586c83d1d0203010001300d06092a864886f70d0101050500038181002475615bb65b8d8786b890535802948840387d06b1692ff3ea47ef4c435719ba1865b81e6bfa6293ce31747c3cd6b34595b485cc1563fd90107ba5845c28b95c79138f0dec288940395bc10f92f2b69d8dc410999deb38900974ce9984b678030edfba8816582f56160d87e38641288d8588d2a31e20b89f223d788dd35cc9c8")) {
                return false;
            }
            return true;
        } catch (Exception unused) {
            d.s.b.c.c.g("TbsInstaller", "TbsInstaller-installLocalTbsCore getPackageInfo fail");
            return false;
        }
    }

    public final synchronized boolean X(Context context, boolean z) {
        return false;
    }

    public void Y(Context context) {
        boolean z;
        FileLock fileLock;
        try {
            z = f.h().k();
        } catch (Throwable unused) {
            z = true;
        }
        if (z && (fileLock = f9136i) != null) {
            d.s.b.c.n.f(context, fileLock);
        }
    }

    public final void Z(Context context, boolean z) {
        if (context == null) {
            TbsLogReport.b(context).h(225, "setTmpFolderCoreToRead context is null");
            return;
        }
        try {
            File file = new File(context.getDir("tbs", 0), "tmp_folder_core_to_read.conf");
            if (!z) {
                d.s.b.c.n.u(file);
            } else if (!file.exists()) {
                file.createNewFile();
            }
        } catch (Exception e2) {
            TbsLogReport.b(context).h(225, "setTmpFolderCoreToRead Exception message is " + e2.getMessage() + " Exception cause is " + e2.getCause());
        }
    }

    public final void a(Context context) {
        d.s.b.c.c.g("TbsInstaller", "TbsInstaller--generateNewTbsCoreFromUnzip");
        if (!r0(context)) {
            d.s.b.c.c.g("TbsInstaller", "get rename fileLock#4 ## failed!");
            return;
        }
        try {
            c(context);
            d(context);
            d.s.b.c.c.g("TbsInstaller", "after renameTbsCoreShareDir");
            if (j.C(context)) {
                d.s.b.c.c.g("TbsInstaller", "is thirdapp and not chmod");
            } else {
                d.s.b.c.c.g("TbsInstaller", "prepare to shareTbsCore");
                j.c(context);
            }
            y.a(context).c(0);
            y.a(context).j(0);
            y.a(context).q(0);
            y.a(context).f("incrupdate_retry_num", 0);
            y.a(context).k(0, 3);
            y.a(context).e("");
            y.a(context).n(-1);
            if (!j.C(context)) {
                int i2 = f.i(context).f9168b.getInt("tbs_decouplecoreversion", 0);
                if (i2 <= 0 || i2 == j().b0(context) || i2 != j().c0(context)) {
                    d.s.b.c.c.g("TbsInstaller", "TbsInstaller--generateNewTbsCoreFromUnzip #1 deCoupleCoreVersion is " + i2 + " getTbsCoreShareDecoupleCoreVersion is " + j().b0(context) + " getTbsCoreInstalledVerInNolock is " + j().c0(context));
                } else {
                    g0(context);
                }
            }
            if (j.C(context)) {
                j.I(context, f0(context), true);
            }
            f9137j.set(0);
            o = 0;
        } catch (Throwable th) {
            th.printStackTrace();
            TbsLogReport.b(context).h(219, "exception when renameing from unzip:" + th.toString());
            d.s.b.c.c.e("TbsInstaller", "TbsInstaller--generateNewTbsCoreFromUnzip Exception", true);
        }
        Y(context);
    }

    public int a0(Context context) {
        BufferedInputStream bufferedInputStream = null;
        try {
            File m0 = m0(context);
            d.s.b.c.c.g("TbsInstaller", "TbsInstaller--getTmpTbsCoreVersionUnzipDir  tbsShareDir is " + m0);
            File file = new File(m0, "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) {
                    try {
                        bufferedInputStream.close();
                    } catch (IOException unused4) {
                    }
                }
                return 0;
            } catch (Throwable th) {
                th = th;
                bufferedInputStream = bufferedInputStream2;
                if (bufferedInputStream != null) {
                    try {
                        bufferedInputStream.close();
                    } catch (IOException unused5) {
                    }
                }
                throw th;
            }
        } catch (Exception unused6) {
        } catch (Throwable th2) {
            th = th2;
        }
    }

    public final void b(Context context) {
        d.s.b.c.c.g("TbsInstaller", "TbsInstaller--generateNewTbsCoreFromCopy");
        if (!r0(context)) {
            d.s.b.c.c.g("TbsInstaller", "get rename fileLock#4 ## failed!");
            return;
        }
        try {
            c(context);
            e(context);
            j.c(context);
            y.a(context).d(0, 3);
            if (!j.C(context)) {
                int i2 = f.i(context).f9168b.getInt("tbs_decouplecoreversion", 0);
                if (i2 <= 0 || i2 == j().b0(context) || i2 != j().c0(context)) {
                    d.s.b.c.c.g("TbsInstaller", "TbsInstaller--generateNewTbsCoreFromCopy #1 deCoupleCoreVersion is " + i2 + " getTbsCoreShareDecoupleCoreVersion is " + j().b0(context) + " getTbsCoreInstalledVerInNolock is " + j().c0(context));
                } else {
                    g0(context);
                }
            }
            f9137j.set(0);
        } catch (Exception e2) {
            e2.printStackTrace();
            TbsLogReport.b(context).h(219, "exception when renameing from copy:" + e2.toString());
        }
        Y(context);
    }

    public int b0(Context context) {
        BufferedInputStream bufferedInputStream = null;
        try {
            File file = new File(i0(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) {
                    try {
                        bufferedInputStream.close();
                    } catch (IOException unused4) {
                    }
                }
                return 0;
            } catch (Throwable th) {
                th = th;
                bufferedInputStream = bufferedInputStream2;
                if (bufferedInputStream != null) {
                    try {
                        bufferedInputStream.close();
                    } catch (IOException unused5) {
                    }
                }
                throw th;
            }
        } catch (Exception unused6) {
        } catch (Throwable th2) {
            th = th2;
        }
    }

    public final void c(Context context) {
        d.s.b.c.c.g("TbsInstaller", "TbsInstaller--deleteOldCore");
        d.s.b.c.n.g(j0(context), false);
    }

    public int c0(Context context) {
        BufferedInputStream bufferedInputStream = null;
        try {
            try {
                File file = new File(j0(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 e2) {
                            d.s.b.c.c.g("TbsInstaller", "TbsInstaller--getTbsCoreInstalledVerInNolock IOException=" + e2.toString());
                        }
                        return 0;
                    }
                    int parseInt = Integer.parseInt(property);
                    if (o == 0) {
                        o = parseInt;
                    }
                    try {
                        bufferedInputStream2.close();
                    } catch (IOException e3) {
                        d.s.b.c.c.g("TbsInstaller", "TbsInstaller--getTbsCoreInstalledVerInNolock IOException=" + e3.toString());
                    }
                    return parseInt;
                } catch (Exception e4) {
                    e = e4;
                    bufferedInputStream = bufferedInputStream2;
                    d.s.b.c.c.g("TbsInstaller", "TbsInstaller--getTbsCoreInstalledVerInNolock Exception=" + e.toString());
                    if (bufferedInputStream != null) {
                        try {
                            bufferedInputStream.close();
                        } catch (IOException e5) {
                            d.s.b.c.c.g("TbsInstaller", "TbsInstaller--getTbsCoreInstalledVerInNolock IOException=" + e5.toString());
                        }
                    }
                    return 0;
                } catch (Throwable th) {
                    th = th;
                    bufferedInputStream = bufferedInputStream2;
                    if (bufferedInputStream != null) {
                        try {
                            bufferedInputStream.close();
                        } catch (IOException e6) {
                            d.s.b.c.c.g("TbsInstaller", "TbsInstaller--getTbsCoreInstalledVerInNolock IOException=" + e6.toString());
                        }
                    }
                    throw th;
                }
            } catch (Exception e7) {
                e = e7;
            }
        } catch (Throwable th2) {
            th = th2;
        }
    }

    public final void d(Context context) {
        TbsLogReport b2;
        int i2;
        d.s.b.c.c.g("TbsInstaller", "TbsInstaller--renameShareDir");
        File m0 = m0(context);
        File j0 = j0(context);
        if (m0 == null || j0 == null) {
            return;
        }
        boolean renameTo = m0.renameTo(j0);
        if (context != null && "com.tencent.mm".equals(context.getApplicationContext().getApplicationInfo().packageName)) {
            if (renameTo) {
                b2 = TbsLogReport.b(context);
                i2 = 230;
            } else {
                b2 = TbsLogReport.b(context);
                i2 = 231;
            }
            b2.h(i2, LogUtils.PLACEHOLDER);
        }
        Z(context, false);
    }

    public void d0(Context context) {
        if (o != 0) {
            return;
        }
        o = c0(context);
    }

    public final void e(Context context) {
        d.s.b.c.c.g("TbsInstaller", "TbsInstaller--renameTbsCoreCopyDir");
        File o0 = o0(context);
        File j0 = j0(context);
        if (o0 == null || j0 == null) {
            return;
        }
        o0.renameTo(j0);
        Z(context, false);
    }

    public boolean e0(Context context) {
        return new File(j0(context), "tbs.conf").exists();
    }

    public final void f(Context context) {
        d.s.b.c.c.g("TbsInstaller", "TbsInstaller--clearNewTbsCore");
        File m0 = m0(context);
        if (m0 != null) {
            d.s.b.c.n.g(m0, false);
        }
        y.a(context).k(0, 5);
        y.a(context).n(-1);
        c.d(context, "TbsInstaller::clearNewTbsCore forceSysWebViewInner!");
    }

    public int f0(Context context) {
        if (!p0(context)) {
            return -1;
        }
        boolean tryLock = f9134g.tryLock();
        d.s.b.c.c.g("TbsInstaller", "TbsInstaller--getTbsCoreInstalledVer locked=" + tryLock);
        if (!tryLock) {
            A();
            return 0;
        }
        BufferedInputStream bufferedInputStream = null;
        try {
            try {
                File file = new File(j0(context), "tbs.conf");
                if (!file.exists()) {
                    try {
                        if (f9134g.isHeldByCurrentThread()) {
                            f9134g.unlock();
                        }
                    } catch (Throwable th) {
                        d.s.b.c.c.d("TbsInstaller", "TbsRenameLock.unlock exception: " + th);
                    }
                    A();
                    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 e2) {
                            d.s.b.c.c.g("TbsInstaller", "TbsInstaller--getTbsCoreInstalledVer IOException=" + e2.toString());
                        }
                        try {
                            if (f9134g.isHeldByCurrentThread()) {
                                f9134g.unlock();
                            }
                        } catch (Throwable th2) {
                            d.s.b.c.c.d("TbsInstaller", "TbsRenameLock.unlock exception: " + th2);
                        }
                        A();
                        return 0;
                    }
                    f9137j.set(Integer.valueOf(Integer.parseInt(property)));
                    int intValue = f9137j.get().intValue();
                    try {
                        bufferedInputStream2.close();
                    } catch (IOException e3) {
                        d.s.b.c.c.g("TbsInstaller", "TbsInstaller--getTbsCoreInstalledVer IOException=" + e3.toString());
                    }
                    try {
                        if (f9134g.isHeldByCurrentThread()) {
                            f9134g.unlock();
                        }
                    } catch (Throwable th3) {
                        d.s.b.c.c.d("TbsInstaller", "TbsRenameLock.unlock exception: " + th3);
                    }
                    A();
                    return intValue;
                } catch (Exception e4) {
                    e = e4;
                    bufferedInputStream = bufferedInputStream2;
                    d.s.b.c.c.g("TbsInstaller", "TbsInstaller--getTbsCoreInstalledVer Exception=" + e.toString());
                    if (bufferedInputStream != null) {
                        try {
                            bufferedInputStream.close();
                        } catch (IOException e5) {
                            d.s.b.c.c.g("TbsInstaller", "TbsInstaller--getTbsCoreInstalledVer IOException=" + e5.toString());
                        }
                    }
                    try {
                        if (f9134g.isHeldByCurrentThread()) {
                            f9134g.unlock();
                        }
                    } catch (Throwable th4) {
                        d.s.b.c.c.d("TbsInstaller", "TbsRenameLock.unlock exception: " + th4);
                    }
                    A();
                    return 0;
                } catch (Throwable th5) {
                    th = th5;
                    bufferedInputStream = bufferedInputStream2;
                    if (bufferedInputStream != null) {
                        try {
                            bufferedInputStream.close();
                        } catch (IOException e6) {
                            d.s.b.c.c.g("TbsInstaller", "TbsInstaller--getTbsCoreInstalledVer IOException=" + e6.toString());
                        }
                    }
                    try {
                        if (f9134g.isHeldByCurrentThread()) {
                            f9134g.unlock();
                        }
                    } catch (Throwable th6) {
                        d.s.b.c.c.d("TbsInstaller", "TbsRenameLock.unlock exception: " + th6);
                    }
                    A();
                    throw th;
                }
            } catch (Exception e7) {
                e = e7;
            }
        } catch (Throwable th7) {
            th = th7;
        }
    }

    public int g(String str) {
        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) {
                    try {
                        bufferedInputStream.close();
                    } catch (IOException unused4) {
                    }
                }
                return 0;
            } catch (Throwable th) {
                th = th;
                bufferedInputStream = bufferedInputStream2;
                if (bufferedInputStream != null) {
                    try {
                        bufferedInputStream.close();
                    } catch (IOException unused5) {
                    }
                }
                throw th;
            }
        } catch (Exception unused6) {
        } catch (Throwable th2) {
            th = th2;
        }
    }

    public boolean g0(Context context) {
        d.s.b.c.c.g("TbsInstaller", "TbsInstaller--coreShareCopyToDecouple #0");
        File j0 = j0(context);
        File i0 = i0(context);
        try {
            d.s.b.c.n.g(i0, true);
            d.s.b.c.n.m(j0, i0, new j0(this));
            j.e(context);
            d.s.b.c.c.g("TbsInstaller", "TbsInstaller--coreShareCopyToDecouple success!!!");
            return true;
        } catch (Exception unused) {
            return false;
        }
    }

    public int h(boolean z, Context context) {
        if (z || f9137j.get().intValue() <= 0) {
            f9137j.set(Integer.valueOf(c0(context)));
        }
        return f9137j.get().intValue();
    }

    public void h0(Context context) {
        d.s.b.c.c.g("TbsInstaller", "TbsInstaller--cleanStatusAndTmpDir");
        y.a(context).c(0);
        y.a(context).j(0);
        y.a(context).q(0);
        y.a(context).f("incrupdate_retry_num", 0);
        if (f.i(context).f9168b.getInt("tbs_downloaddecouplecore", 0) != 1) {
            y.a(context).k(0, -1);
            y.a(context).e("");
            y.a(context).f("copy_retry_num", 0);
            y.a(context).n(-1);
            y.a(context).d(0, -1);
            d.s.b.c.n.g(m0(context), true);
            d.s.b.c.n.g(o0(context), true);
        }
    }

    public Context i(Context context, String str) {
        try {
            return context.createPackageContext(str, 2);
        } catch (Exception unused) {
            return null;
        }
    }

    public File i0(Context context) {
        File file = new File(context.getDir("tbs", 0), "core_share_decouple");
        if (file.isDirectory() || file.mkdir()) {
            return file;
        }
        return null;
    }

    public File j0(Context context) {
        return z(null, context);
    }

    public final void k(int i2, String str, Context context) {
        BufferedInputStream bufferedInputStream;
        new File(str).delete();
        d.s.b.c.c.h("TbsInstaller", "Local tbs apk(" + str + ") is deleted!", true);
        File file = new File(context.getDir("tbs", 0), "core_unzip_tmp");
        if (file.canRead()) {
            File file2 = new File(file, "tbs.conf");
            Properties properties = new Properties();
            BufferedOutputStream bufferedOutputStream = null;
            try {
                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);
                            d.s.b.c.c.h("TbsInstaller", "TBS_LOCAL_INSTALLATION is set!", true);
                            try {
                                bufferedOutputStream2.close();
                            } catch (IOException e2) {
                                e2.printStackTrace();
                            }
                            bufferedInputStream.close();
                        } catch (Throwable th) {
                            th = th;
                            bufferedOutputStream = bufferedOutputStream2;
                            try {
                                th.printStackTrace();
                                if (bufferedOutputStream != null) {
                                    try {
                                        bufferedOutputStream.close();
                                    } catch (IOException e3) {
                                        e3.printStackTrace();
                                    }
                                }
                                if (bufferedInputStream != null) {
                                    bufferedInputStream.close();
                                }
                            } finally {
                            }
                        }
                    } catch (Throwable th2) {
                        th = th2;
                    }
                } catch (IOException e4) {
                    e4.printStackTrace();
                }
            } catch (Throwable th3) {
                th = th3;
                bufferedInputStream = null;
            }
        }
    }

    public File k0(Context context) {
        File file = new File(context.getDir("tbs", 0), "share");
        if (file.isDirectory() || file.mkdir()) {
            return file;
        }
        return null;
    }

    public void m(Context context, int i2) {
        Z(context, true);
        y.a(context).k(i2, 2);
    }

    public File m0(Context context) {
        File file = new File(context.getDir("tbs", 0), "core_unzip_tmp");
        if (file.isDirectory() || file.mkdir()) {
            return file;
        }
        return null;
    }

    @android.annotation.TargetApi(11)
    public final void n(android.content.Context r22, android.content.Context r23, int r24) {
        throw new UnsupportedOperationException("Method not decompiled: d.s.b.b.c0.n(android.content.Context, android.content.Context, int):void");
    }

    public File n0(Context context) {
        File file = new File(context.getDir("tbs", 0), "core_unzip_tmp_decouple");
        if (file.isDirectory() || file.mkdir()) {
            return file;
        }
        return null;
    }

    public void o(Context context, Bundle bundle) {
        if (bundle == null || context == null) {
            return;
        }
        Object[] objArr = {context, bundle};
        Message message = new Message();
        message.what = 3;
        message.obj = objArr;
        f9138k.sendMessage(message);
    }

    public File o0(Context context) {
        File file = new File(context.getDir("tbs", 0), "core_copy_tmp");
        if (file.isDirectory() || file.mkdir()) {
            return file;
        }
        return null;
    }

    public void p(Context context, String str, int i2) {
        d.s.b.c.c.g("TbsInstaller", "TbsInstaller-installTbsCore tbsApkPath=" + str);
        d.s.b.c.c.g("TbsInstaller", "TbsInstaller-installTbsCore tbsCoreTargetVer=" + i2);
        d.s.b.c.c.g("TbsInstaller", "TbsInstaller-continueInstallTbsCore currentProcessName=" + context.getApplicationInfo().processName);
        d.s.b.c.c.g("TbsInstaller", "TbsInstaller-installTbsCore currentProcessId=" + Process.myPid());
        d.s.b.c.c.g("TbsInstaller", "TbsInstaller-installTbsCore currentThreadName=" + Thread.currentThread().getName());
        Object[] objArr = {context, str, Integer.valueOf(i2)};
        Message message = new Message();
        message.what = 1;
        message.obj = objArr;
        f9138k.sendMessage(message);
    }

    public synchronized boolean p0(Context context) {
        this.f9142a++;
        if (this.f9145d) {
            d.s.b.c.c.g("TbsInstaller", "getTbsInstallingFileLock success,is cached= true");
            return true;
        }
        FileOutputStream t = d.s.b.c.n.t(context, true, "tbslock.txt");
        this.f9144c = t;
        if (t == null) {
            return false;
        }
        FileLock e2 = d.s.b.c.n.e(context, t);
        this.f9143b = e2;
        if (e2 == null) {
            return false;
        }
        d.s.b.c.c.g("TbsInstaller", "getTbsInstallingFileLock success,is cached= false");
        this.f9145d = true;
        return true;
    }

    public void q(Context context, boolean z) {
        int l2;
        int h2;
        String p2;
        int m2;
        int i2;
        boolean z2 = true;
        if (z) {
            this.f9146e = true;
        }
        d.s.b.c.c.g("TbsInstaller", "TbsInstaller-continueInstallTbsCore currentProcessName=" + context.getApplicationInfo().processName);
        d.s.b.c.c.g("TbsInstaller", "TbsInstaller-continueInstallTbsCore currentProcessId=" + Process.myPid());
        d.s.b.c.c.g("TbsInstaller", "TbsInstaller-continueInstallTbsCore currentThreadName=" + Thread.currentThread().getName());
        if (p0(context)) {
            if (f9134g.tryLock()) {
                try {
                    l2 = y.a(context).l();
                    h2 = y.a(context).h();
                    p2 = y.a(context).p("install_apk_path");
                    m2 = y.a(context).m("copy_core_ver");
                    i2 = y.a(context).i("copy_status");
                } finally {
                    f9134g.unlock();
                }
            } else {
                p2 = null;
                l2 = -1;
                h2 = 0;
                m2 = 0;
                i2 = -1;
            }
            A();
            d.s.b.c.c.g("TbsInstaller", "TbsInstaller-continueInstallTbsCore installStatus=" + l2);
            d.s.b.c.c.g("TbsInstaller", "TbsInstaller-continueInstallTbsCore tbsCoreInstallVer=" + h2);
            d.s.b.c.c.g("TbsInstaller", "TbsInstaller-continueInstallTbsCore tbsApkPath=" + p2);
            d.s.b.c.c.g("TbsInstaller", "TbsInstaller-continueInstallTbsCore tbsCoreCopyVer=" + m2);
            d.s.b.c.c.g("TbsInstaller", "TbsInstaller-continueInstallTbsCore copyStatus=" + i2);
            if (j.C(context)) {
                I(context, j.a(context, false));
                return;
            }
            int i3 = f.i(context).f9168b.getInt("tbs_responsecode", 0);
            if (i3 != 1 && i3 != 2 && i3 != 4) {
                z2 = false;
            }
            if (!z2 && i3 != 0) {
                Bundle bundle = new Bundle();
                bundle.putInt("operation", FaceSecCode.SC_NOT_INIT);
                o(context, bundle);
            }
            if (l2 > -1 && l2 < 2) {
                p(context, p2, h2);
            }
            if (i2 == 0) {
                E(context, m2);
            }
        }
    }

    public final boolean r0(Context context) {
        boolean z;
        d.s.b.c.c.g("TbsInstaller", "Tbsinstaller getTbsCoreRenameFileLock #1 ");
        try {
            z = f.h().k();
        } catch (Throwable unused) {
            z = true;
        }
        d.s.b.c.c.g("TbsInstaller", "Tbsinstaller getTbsCoreRenameFileLock #2  enabled is " + z);
        f9136i = !z ? z0.a().d(context) : d.s.b.c.n.E(context);
        if (f9136i == null) {
            d.s.b.c.c.g("TbsInstaller", "getTbsCoreRenameFileLock## failed!");
            return false;
        }
        d.s.b.c.c.g("TbsInstaller", "Tbsinstaller getTbsCoreRenameFileLock true ");
        return true;
    }

    public synchronized boolean t(Context context, Context context2) {
        d.s.b.c.c.g("TbsInstaller", "TbsInstaller--quickDexOptForThirdPartyApp");
        if (p) {
            return true;
        }
        p = true;
        new g0(this, context2, context).start();
        return true;
    }

    public boolean u(Context context, File file) {
        d.s.b.c.c.g("TbsInstaller", "unzipTbsCoreToThirdAppTmp #1");
        boolean v = v(context, file, false);
        d.s.b.c.c.g("TbsInstaller", "unzipTbsCoreToThirdAppTmp result is " + v);
        return v;
    }

    public final boolean v(Context context, File file, boolean z) {
        f i2;
        int i3;
        d.s.b.c.c.g("TbsInstaller", "TbsInstaller-unzipTbs start");
        if (d.s.b.c.n.A(file)) {
            try {
                File dir = context.getDir("tbs", 0);
                File file2 = z ? new File(dir, "core_share_decouple") : new File(dir, "core_unzip_tmp");
                if (file2.exists() && f.i(context).f9168b.getInt("tbs_downloaddecouplecore", 0) != 1) {
                    d.s.b.c.n.u(file2);
                }
            } catch (Throwable th) {
                d.s.b.c.c.d("TbsInstaller", "TbsInstaller-unzipTbs -- delete unzip folder if exists exception" + Log.getStackTraceString(th));
            }
            File n0 = z ? n0(context) : m0(context);
            if (n0 != null) {
                try {
                    d.s.b.c.n.k(n0);
                    if (z) {
                        d.s.b.c.n.g(n0, true);
                    }
                    boolean l2 = d.s.b.c.n.l(file, n0);
                    if (l2) {
                        l2 = x(n0, context);
                    }
                    if (z) {
                        for (String str : n0.list()) {
                            File file3 = new File(n0, str);
                            if (file3.getName().endsWith(".dex")) {
                                file3.delete();
                            }
                        }
                        try {
                            new File(l0(context), "x5.tbs").delete();
                        } catch (Exception unused) {
                        }
                    }
                    if (l2) {
                        Z(context, true);
                        if (z) {
                            File i0 = i0(context);
                            d.s.b.c.n.g(i0, true);
                            n0.renameTo(i0);
                            j.e(context);
                        }
                    } else {
                        d.s.b.c.n.u(n0);
                        f.i(context).m(-522);
                        d.s.b.c.c.d("TbsInstaller", "copyFileIfChanged -- delete tmpTbsCoreUnzipDir#1! exist:" + n0.exists());
                    }
                    return l2;
                } catch (IOException e2) {
                    f.i(context).m(-523);
                    TbsLogReport.b(context).j(206, e2);
                    if ((n0 != null && n0.exists()) && n0 != null) {
                        try {
                            d.s.b.c.n.u(n0);
                            d.s.b.c.c.d("TbsInstaller", "copyFileIfChanged -- delete tmpTbsCoreUnzipDir#2! exist:" + n0.exists());
                        } catch (Throwable th2) {
                            d.s.b.c.c.d("TbsInstaller", "copyFileIfChanged -- delete tmpTbsCoreUnzipDir#2! exception:" + Log.getStackTraceString(th2));
                        }
                    }
                    return false;
                } catch (Exception e3) {
                    f.i(context).m(-523);
                    TbsLogReport.b(context).j(207, e3);
                    if ((n0 != null && n0.exists()) && n0 != null) {
                        try {
                            d.s.b.c.n.u(n0);
                            d.s.b.c.c.d("TbsInstaller", "copyFileIfChanged -- delete tmpTbsCoreUnzipDir#2! exist:" + n0.exists());
                        } catch (Throwable th3) {
                            d.s.b.c.c.d("TbsInstaller", "copyFileIfChanged -- delete tmpTbsCoreUnzipDir#2! exception:" + Log.getStackTraceString(th3));
                        }
                    }
                    return false;
                } finally {
                    d.s.b.c.c.g("TbsInstaller", "TbsInstaller-unzipTbs done");
                }
            }
            TbsLogReport.b(context).h(205, "tmp unzip dir is null!");
            i2 = f.i(context);
            i3 = -521;
        } else {
            TbsLogReport.b(context).h(204, "apk is invalid!");
            i2 = f.i(context);
            i3 = -520;
        }
        i2.m(i3);
        return false;
    }

    public boolean w(Context context, File[] fileArr) {
        return false;
    }

    public final boolean x(java.io.File r13, android.content.Context r14) {
        throw new UnsupportedOperationException("Method not decompiled: d.s.b.b.c0.x(java.io.File, android.content.Context):boolean");
    }

    public int y(Context context, String str) {
        PackageInfo packageArchiveInfo = context.getPackageManager().getPackageArchiveInfo(str, 0);
        if (packageArchiveInfo != null) {
            return packageArchiveInfo.versionCode;
        }
        return 0;
    }

    public File z(Context context, Context context2) {
        File file = new File(context2.getDir("tbs", 0), "core_share");
        if (file.isDirectory() || ((context != null && j.C(context)) || file.mkdir())) {
            return file;
        }
        return null;
    }
}