导航菜单

页面标题

页面副标题

jsgt v4.8.1 - a0.java 源代码

正在查看: jsgt v4.8.1 应用的 a0.java JAVA 源代码文件

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


package je;

import android.content.Context;
import android.os.Build;
import android.os.Bundle;
import android.os.Handler;
import android.os.Looper;
import android.os.Message;
import android.text.TextUtils;
import android.util.Log;
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.io.RandomAccessFile;
import java.nio.channels.FileChannel;
import java.nio.channels.FileLock;
import java.util.Properties;
import java.util.concurrent.locks.ReentrantLock;
import java.util.regex.Pattern;

public final class a0 {
    public static a0 e;
    public static final ReentrantLock f = new ReentrantLock();
    public static final ReentrantLock g = new ReentrantLock();
    public static FileLock h = null;
    public static final a i = new a();
    public static c j = null;
    public static final b k = new b();
    public static int l = 0;
    public FileLock b;
    public FileOutputStream c;
    public int a = 0;
    public boolean d = false;

    public static class a extends ThreadLocal<Integer> {
        @Override
        public final Integer initialValue() {
            return 0;
        }
    }

    public static class b implements FileFilter {
        @Override
        public final boolean accept(File file) {
            String name = file.getName();
            if (name == null || name.endsWith(".jar_is_first_load_dex_flag_file")) {
                return false;
            }
            int i = Build.VERSION.SDK_INT;
            if (name.endsWith(".dex")) {
                return false;
            }
            if (i < 26 || !name.endsWith(".prof")) {
                return i < 26 || !name.equals("oat");
            }
            return false;
        }
    }

    public class c extends Handler {
        public c(Looper looper) {
            super(looper);
        }

        @Override
        public final void handleMessage(Message message) {
            boolean z = je.d.a;
            int i = message.what;
            a0 a0Var = a0.this;
            if (i == 1) {
                ne.e.c("TbsInstaller", "TbsInstaller--handleMessage--MSG_INSTALL_TBS_CORE");
                Object[] objArr = (Object[]) message.obj;
                a0Var.k(((Integer) objArr[2]).intValue(), (String) objArr[1], (Context) objArr[0]);
                return;
            }
            if (i == 2) {
                ne.e.c("TbsInstaller", "TbsInstaller--handleMessage--MSG_COPY_TBS_CORE");
                Object[] objArr2 = (Object[]) message.obj;
                a0Var.f((Context) objArr2[0], (Context) objArr2[1], ((Integer) objArr2[2]).intValue());
                return;
            }
            if (i == 3) {
                ne.e.c("TbsInstaller", "TbsInstaller--handleMessage--MSG_INSTALL_TBS_CORE_EX");
                Object[] objArr3 = (Object[]) message.obj;
                a0Var.l((Context) objArr3[0], (Bundle) objArr3[1]);
                return;
            }
            if (i != 4) {
                return;
            }
            ne.e.c("TbsInstaller", "TbsInstaller--handleMessage--MSG_UNZIP_TBS_CORE");
            Object[] objArr4 = (Object[]) message.obj;
            Context context = (Context) objArr4[0];
            File file = (File) objArr4[1];
            int intValue = ((Integer) objArr4[2]).intValue();
            a0Var.getClass();
            FileOutputStream m = ne.b.m(context, "core_unzip.lock");
            FileLock d = ne.b.d(m);
            if (d != null) {
                ne.e.c("TbsInstaller", "unzipTbsCoreToThirdAppTmpInThread #1");
                boolean i2 = a0.i(context, file, false);
                ne.e.c("TbsInstaller", "unzipTbsCoreToThirdAppTmpInThread result is " + i2);
                ne.x.c(context, "copy_host_core_v3", ("coreVersionIs" + intValue) + "_ret=is=" + i2);
                if (i2) {
                    a0.d().getClass();
                    ne.e.c("TbsInstaller", "setTmpFolderCoreToRead call #01 ");
                    a0.u(context, true);
                    y.b(context).getClass();
                    y.i(intValue, 2);
                }
                ne.b.f(d, m);
            } else {
                ne.e.c("TbsInstaller", "can not get Core unzip FileLock,skip!!!");
            }
            super.handleMessage(message);
        }
    }

    public class d implements FileFilter {
        @Override
        public final boolean accept(File file) {
            return file.getName().endsWith(".jar");
        }
    }

    public class e implements FileFilter {
        @Override
        public final boolean accept(File file) {
            return file.getName().endsWith(".jar");
        }
    }

    public a0() {
        if (j == null) {
            j = new c(z.a().getLooper());
        }
    }

    public static void A(Context context) {
        ne.e.c("TbsInstaller", "TbsInstaller--cleanStatusAndTmpDir");
        y.b(context).getClass();
        y.d("dexopt_retry_num", 0);
        y.b(context).getClass();
        y.d("unzip_retry_num", 0);
        y.b(context).getClass();
        y.d("unlzma_status", 0);
        y.b(context).getClass();
        y.d("incrupdate_retry_num", 0);
        if (f.a(context)) {
            return;
        }
        y.b(context).getClass();
        y.i(0, -1);
        y.b(context).getClass();
        y.e("install_apk_path", "");
        y.b(context).getClass();
        y.d("copy_retry_num", 0);
        y.b(context).getClass();
        y.h(-1);
        y.b(context).getClass();
        y.c(0, -1);
        ne.b.l(t(0, context), true);
        ne.b.l(t(1, context), true);
    }

    public static File B(Context context) {
        File file = new File(je.d.j(context), "core_share");
        if (file.isDirectory() || file.mkdir()) {
            return file;
        }
        ne.e.c("TbsInstaller", "getTbsCoreShareDir,mkdir false");
        return null;
    }

    public static File C(Context context) {
        File file = new File(je.d.j(context), "core_private");
        if (file.isDirectory() || file.mkdir()) {
            return file;
        }
        return null;
    }

    public static int E(Context context) {
        y.b(context).getClass();
        boolean z = y.f("incrupdate_status") == 1;
        boolean a2 = f.a(context);
        return z ? a2 ? 234 : 221 : a2 ? 233 : 200;
    }

    public static boolean F(Context context) {
        String str;
        if (context == null) {
            str = "#1#";
        } else {
            try {
                if (new File(je.d.j(context), "tmp_folder_core_to_read.conf").exists()) {
                    ne.e.d("TbsInstaller", "getTmpFolderCoreToRead", "#2#");
                    return true;
                }
                ne.e.d("TbsInstaller", "getTmpFolderCoreToRead", "#3#");
                return false;
            } catch (Exception unused) {
                str = "#4#";
            }
        }
        ne.e.d("TbsInstaller", "getTmpFolderCoreToRead", str);
        return true;
    }

    public static boolean G(Context context) {
        FileLock fileLock;
        ne.e.c("TbsInstaller", "Tbsinstaller getTbsCoreRenameFileLock #1 ");
        File a2 = ne.b.a(context);
        ne.e.c("FileHelper", "getTbsCoreRenameFileLock #1 " + a2);
        try {
            fileLock = new RandomAccessFile(a2.getAbsolutePath(), "rw").getChannel().tryLock(0L, Long.MAX_VALUE, false);
        } catch (Throwable unused) {
            ne.e.a("FileHelper", "getTbsCoreRenameFileLock -- excpetion: tbs_rename_lock");
            fileLock = null;
        }
        ne.e.c("FileHelper", fileLock == null ? "getTbsCoreRenameFileLock -- failed: tbs_rename_lock" : "getTbsCoreRenameFileLock -- success: tbs_rename_lock");
        h = fileLock;
        if (fileLock == null) {
            ne.e.c("TbsInstaller", "getTbsCoreRenameFileLock## failed!");
            return false;
        }
        ne.e.c("TbsInstaller", "Tbsinstaller getTbsCoreRenameFileLock true ");
        return true;
    }

    public static void H(Context context) {
        ne.e.c("TbsInstaller", "TbsInstaller--generateNewTbsCoreFromTpatch");
        if (!G(context)) {
            ne.e.c("TbsInstaller", "get rename fileLock#4 ## failed!");
            return;
        }
        try {
            ne.e.c("TbsInstaller", "TbsInstaller--deleteOldCore");
            ne.b.l(B(context), false);
            ne.e.c("TbsInstaller", "TbsInstaller--renameTbsTpatchCoreDir");
            File t = t(5, context);
            File B = B(context);
            if (t != null && B != null) {
                t.renameTo(B);
                ne.e.c("TbsInstaller", "setTmpFolderCoreToRead call #09");
                u(context, false);
            }
            y.b(context).getClass();
            y.d("tpatch_ver", 0);
            y.d("tpatch_status", -1);
            y.b(context).getClass();
            y.d("tpatch_num", 0);
            i.set(0);
        } catch (Exception e2) {
            e2.printStackTrace();
            h.h(context).i(242, "exception when renameing from tpatch:" + e2.toString());
        }
        v();
    }

    public static void I(Context context) {
        h h2;
        int i2;
        ne.e.c("TbsInstaller", "TbsInstaller--renameShareDir");
        File t = t(0, context);
        File B = B(context);
        if (t == null || B == null) {
            ne.e.c("TbsInstaller", "renameTbsCoreShareDir return,tmpTbsCoreUnzipDir=" + t + "tbsSharePath=" + B);
            return;
        }
        boolean renameTo = t.renameTo(B);
        ne.e.c("TbsInstaller", "renameTbsCoreShareDir rename success=" + renameTo);
        ne.x.d("8is" + renameTo);
        if (context != null && "com.tencent.mm".equals(context.getApplicationContext().getApplicationInfo().packageName)) {
            if (renameTo) {
                h2 = h.h(context);
                i2 = 230;
            } else {
                h2 = h.h(context);
                i2 = 231;
            }
            h2.i(i2, " ");
        }
        ne.e.c("TbsInstaller", "setTmpFolderCoreToRead call #07");
        u(context, false);
    }

    public static void a(Context context) {
        ne.e.c("TbsInstaller", "TbsInstaller--clearNewTbsCore");
        File t = t(0, context);
        if (t != null) {
            ne.b.l(t, false);
        }
        y.b(context).getClass();
        y.i(0, 5);
        y.b(context).getClass();
        y.h(-1);
        je.d.e("TbsInstaller::clearNewTbsCore forceSysWebViewInner!");
    }

    public static int b(Context context, boolean z) {
        a aVar = i;
        if (z || aVar.get().intValue() <= 0) {
            aVar.set(Integer.valueOf(z(context)));
        }
        return aVar.get().intValue();
    }

    public static int c(File file) {
        BufferedInputStream bufferedInputStream = null;
        try {
            ne.e.c("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) {
                    try {
                        bufferedInputStream.close();
                    } catch (IOException unused4) {
                    }
                }
                return 0;
            } catch (Throwable th2) {
                th = th2;
                bufferedInputStream = bufferedInputStream2;
                if (bufferedInputStream != null) {
                    try {
                        bufferedInputStream.close();
                    } catch (IOException unused5) {
                    }
                }
                throw th;
            }
        } catch (Exception unused6) {
        } catch (Throwable th3) {
            th = th3;
        }
    }

    public static synchronized a0 d() {
        a0 a0Var;
        synchronized (a0.class) {
            if (e == null) {
                synchronized (a0.class) {
                    if (e == null) {
                        e = new a0();
                    }
                }
            }
            a0Var = e;
        }
        return a0Var;
    }

    public static void e(Context context) {
        String str;
        if (F(context)) {
            return;
        }
        if (j(context, "core_unzip_tmp")) {
            ne.c.i0().z(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 (j(context, "core_share_backup_tmp")) {
            ne.c.i0().z(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 (!j(context, "core_copy_tmp")) {
                return;
            }
            ne.c.i0().z(context, 417, new Throwable("TMP_TBS_COPY_FOLDER_NAME"));
            str = "TbsInstaller-UploadIfTempCoreExistConfError INFO_TEMP_CORE_EXIST_CONF_ERROR TMP_TBS_COPY_FOLDER_NAME";
        }
        ne.e.a("TbsInstaller", str);
    }

    public static void g(String str, Context context) {
        Throwable th2;
        BufferedInputStream bufferedInputStream;
        BufferedOutputStream bufferedOutputStream;
        new File(str).delete();
        ne.e.c("TbsInstaller", "Local tbs apk(" + str + ") is deleted!");
        File file = new File(je.d.j(context), "core_unzip_tmp");
        if (file.canRead()) {
            File file2 = new File(file, "tbs.conf");
            Properties properties = new Properties();
            BufferedOutputStream bufferedOutputStream2 = null;
            try {
                bufferedInputStream = new BufferedInputStream(new FileInputStream(file2));
                try {
                    properties.load(bufferedInputStream);
                    bufferedOutputStream = new BufferedOutputStream(new FileOutputStream(file2));
                } catch (Throwable th3) {
                    th2 = th3;
                }
            } catch (Throwable th4) {
                th2 = th4;
                bufferedInputStream = null;
            }
            try {
                try {
                    properties.setProperty("tbs_local_installation", "true");
                    properties.store(bufferedOutputStream, (String) null);
                    ne.e.c("TbsInstaller", "TBS_LOCAL_INSTALLATION is set!");
                    try {
                        bufferedOutputStream.close();
                    } catch (IOException e2) {
                        e2.printStackTrace();
                    }
                } catch (Throwable th5) {
                    th2 = th5;
                    bufferedOutputStream2 = bufferedOutputStream;
                    try {
                        th2.printStackTrace();
                        if (bufferedOutputStream2 != null) {
                            try {
                                bufferedOutputStream2.close();
                            } catch (IOException e3) {
                                e3.printStackTrace();
                            }
                        }
                        if (bufferedInputStream == null) {
                            return;
                        }
                        bufferedInputStream.close();
                    } finally {
                    }
                }
                bufferedInputStream.close();
            } catch (IOException e4) {
                e4.printStackTrace();
            }
        }
    }

    public static boolean h(android.content.Context r11, java.io.File r12) {
        throw new UnsupportedOperationException("Method not decompiled: je.a0.h(android.content.Context, java.io.File):boolean");
    }

    public static boolean i(Context context, File file, boolean z) {
        ne.e.c("TbsInstaller", "TbsInstaller-unzipTbs start isDecoupleCore is " + z);
        if (!(file != null && file.exists() && file.isFile() && file.length() > 0)) {
            h.h(context).i(204, "apk is invalid!");
            je.e.d(context).e(-520);
            return false;
        }
        try {
            File j2 = je.d.j(context);
            File file2 = z ? new File(j2, "core_share_decouple") : new File(j2, "core_unzip_tmp");
            if (file2.exists() && !f.a(context)) {
                ne.b.l(file2, false);
            }
        } catch (Throwable th2) {
            ne.e.a("TbsInstaller", "TbsInstaller-unzipTbs -- delete unzip folder if exists exception" + Log.getStackTraceString(th2));
        }
        File t = z ? t(2, context) : t(0, context);
        if (t == null) {
            h.h(context).i(205, "tmp unzip dir is null!");
            je.e.d(context).e(-521);
            return false;
        }
        try {
            try {
                if (!t.exists() || !t.isDirectory()) {
                    ne.b.l(t, false);
                    t.mkdirs();
                }
                if (z) {
                    ne.b.l(t, true);
                }
                boolean h2 = ne.b.h(file, t);
                if (h2) {
                    h2 = h(context, t);
                }
                if (z) {
                    for (String str : t.list()) {
                        File file3 = new File(t, str);
                        if (file3.getName().endsWith(".dex")) {
                            file3.delete();
                        }
                    }
                    try {
                        new File(C(context), "x5.tbs").delete();
                    } catch (Exception unused) {
                    }
                }
                if (h2) {
                    ne.e.c("TbsInstaller", "setTmpFolderCoreToRead call #05");
                    u(context, true);
                } else {
                    ne.b.l(t, false);
                    je.e.d(context).e(-522);
                    ne.e.a("TbsInstaller", "copyFileIfChanged -- delete tmpTbsCoreUnzipDir#1! exist:" + t.exists());
                }
                ne.e.c("TbsInstaller", "TbsInstaller-unzipTbs done");
                ne.x.d("11");
                return h2;
            } catch (Throwable th3) {
                ne.e.c("TbsInstaller", "TbsInstaller-unzipTbs done");
                ne.x.d("11");
                throw th3;
            }
        } catch (IOException e2) {
            je.e.d(context).e(-523);
            h.h(context).j(206, e2);
            if (t.exists()) {
                try {
                    ne.b.l(t, false);
                    ne.e.a("TbsInstaller", "copyFileIfChanged -- delete tmpTbsCoreUnzipDir#2! exist:" + t.exists());
                } catch (Throwable th4) {
                    ne.e.a("TbsInstaller", "copyFileIfChanged -- delete tmpTbsCoreUnzipDir#2! exception:" + Log.getStackTraceString(th4));
                }
            }
            ne.e.c("TbsInstaller", "TbsInstaller-unzipTbs done");
            ne.x.d("11");
            return false;
        } catch (Exception e3) {
            je.e.d(context).e(-523);
            h.h(context).j(207, e3);
            if (t.exists()) {
                try {
                    ne.b.l(t, false);
                    ne.e.a("TbsInstaller", "copyFileIfChanged -- delete tmpTbsCoreUnzipDir#2! exist:" + t.exists());
                } catch (Throwable th5) {
                    ne.e.a("TbsInstaller", "copyFileIfChanged -- delete tmpTbsCoreUnzipDir#2! exception:" + Log.getStackTraceString(th5));
                }
            }
            ne.e.c("TbsInstaller", "TbsInstaller-unzipTbs done");
            ne.x.d("11");
            return false;
        }
    }

    public static boolean j(Context context, String str) {
        StringBuilder sb;
        File file = new File(je.d.j(context), str);
        if (!file.exists()) {
            sb = new StringBuilder("#1# ");
        } else {
            if (new File(file, "tbs.conf").exists()) {
                ne.e.d("TbsInstaller", "isPrepareTbsCore", "#3# ".concat(str));
                return true;
            }
            sb = new StringBuilder("#2# ");
        }
        sb.append(str);
        ne.e.d("TbsInstaller", "isPrepareTbsCore", sb.toString());
        return false;
    }

    public static int n(Context context, Bundle bundle) {
        int i2;
        int c2;
        try {
            Bundle a2 = je.d.a(context, bundle);
            ne.e.c("TbsInstaller", "tpatch finished,ret is" + a2);
            int i3 = a2.getInt("patch_result");
            if (i3 != 0) {
                String string = bundle.getString("new_apk_location");
                if (!TextUtils.isEmpty(string)) {
                    ne.b.l(new File(string), false);
                }
                h.h(context).i(i3, "tpatch fail,patch error_code=" + i3);
                return 1;
            }
            String string2 = bundle.getString("new_apk_location");
            int i4 = bundle.getInt("new_core_ver");
            try {
                i2 = bundle.getInt("for_stable_core");
            } catch (Throwable unused) {
                i2 = 0;
            }
            if (i2 == 1) {
                File file = new File(ne.b.c(context, "com.tencent.mm", 4));
                je.e d2 = je.e.d(context);
                int i5 = d2.b.getInt("tbs_cpu_type_other_stable_core", 0);
                File[] listFiles = file.listFiles();
                Pattern compile = Pattern.compile(ne.g.d(i5, false));
                for (File file2 : listFiles) {
                    if (compile.matcher(file2.getName()).find() && file2.isFile() && file2.exists()) {
                        file2.delete();
                    }
                }
                File file3 = new File(file, ne.g.d(i5, false) + "." + d2.b.getInt("tbs_download_version", 0));
                if (!file3.exists()) {
                    file3.createNewFile();
                }
                c2 = j.b(i5, context);
            } else {
                c2 = c(new File(string2));
            }
            ne.e.c("TbsInstaller", "doTpatch wholeFile is " + i2 + " version is " + i4 + " patchVersion is " + c2);
            if (i4 == c2) {
                if (f.a(context)) {
                    ne.e.c("TbsInstaller", "Tpatch decouple success!");
                    h.h(context).i(237, "");
                } else {
                    ne.e.c("TbsInstaller", "Tpatch success!");
                    h.h(context).i(236, "");
                }
                return 0;
            }
            ne.e.c("TbsInstaller", "version not equals!!!" + i4 + "patchVersion:" + c2);
            h.h(context).i(240, "version=" + i4 + ",patchVersion=" + c2);
            return 1;
        } catch (Exception e2) {
            e2.printStackTrace();
            h.h(context).i(239, "patch exception" + Log.getStackTraceString(e2));
            return 1;
        }
    }

    public static boolean o(Context context, File file) {
        try {
            File[] listFiles = file.listFiles(new d());
            int length = listFiles.length;
            ClassLoader classLoader = context.getClassLoader();
            for (int i2 = 0; i2 < length; i2++) {
                ne.e.c("TbsInstaller", "jarFile: " + listFiles[i2].getAbsolutePath());
                new DexClassLoader(listFiles[i2].getAbsolutePath(), file.getAbsolutePath(), null, classLoader);
            }
            return true;
        } catch (Exception e2) {
            e2.printStackTrace();
            h.h(context).i(209, e2.toString());
            ne.e.c("TbsInstaller", "TbsInstaller-doTbsDexOpt done");
            return false;
        }
    }

    public static boolean r(Context context) {
        Throwable th2;
        BufferedInputStream bufferedInputStream;
        File file = new File(B(context), "tbs.conf");
        boolean z = false;
        if (!file.exists()) {
            return false;
        }
        Properties properties = new Properties();
        try {
            bufferedInputStream = new BufferedInputStream(new FileInputStream(file));
            try {
                properties.load(bufferedInputStream);
                boolean booleanValue = Boolean.valueOf(properties.getProperty("tbs_local_installation", "false")).booleanValue();
                if (booleanValue) {
                    try {
                        if (System.currentTimeMillis() - file.lastModified() > 259200000) {
                            z = true;
                        }
                    } catch (Throwable th3) {
                        th2 = th3;
                        z = booleanValue;
                        try {
                            th2.printStackTrace();
                            return z;
                        } finally {
                            if (bufferedInputStream != null) {
                                try {
                                    bufferedInputStream.close();
                                } catch (IOException e2) {
                                    e2.printStackTrace();
                                }
                            }
                        }
                    }
                }
                ne.e.c("TbsInstaller", "TBS_LOCAL_INSTALLATION is:" + booleanValue + " expired=" + z);
                boolean z2 = booleanValue & (!z);
                try {
                    bufferedInputStream.close();
                    return z2;
                } catch (IOException e3) {
                    e3.printStackTrace();
                    return z2;
                }
            } catch (Throwable th4) {
                th2 = th4;
            }
        } catch (Throwable th5) {
            th2 = th5;
            bufferedInputStream = null;
        }
    }

    public static boolean s(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 = u.a(file3.getAbsolutePath());
            if (TextUtils.isEmpty(a2)) {
                h.h(context).i(226, "can not find oat command");
                return false;
            }
            for (File file4 : file.listFiles(new e())) {
                String substring = file4.getName().substring(0, r5.getName().length() - 4);
                String replaceAll = a2.replaceAll("tbs_sdk_extension_dex", substring);
                StringBuilder sb = new StringBuilder();
                sb.append("/system/bin/dex2oat ");
                sb.append(replaceAll);
                sb.append(" --dex-location=");
                d().getClass();
                sb.append(B(context));
                sb.append(File.separator);
                sb.append(substring);
                sb.append(".jar");
                Runtime.getRuntime().exec(sb.toString()).waitFor();
            }
            return true;
        } catch (Exception e2) {
            e2.printStackTrace();
            h.h(context).j(226, e2);
            return false;
        }
    }

    public static File t(int i2, Context context) {
        String str;
        File j2 = je.d.j(context);
        switch (i2) {
            case 0:
                str = "core_unzip_tmp";
                break;
            case 1:
                str = "core_copy_tmp";
                break;
            case 2:
                str = "core_unzip_tmp_decouple";
                break;
            case 3:
                str = "core_share_backup";
                break;
            case 4:
                str = "core_share_backup_tmp";
                break;
            case 5:
                str = "tpatch_tmp";
                break;
            case 6:
                str = "tpatch_decouple_tmp";
                break;
            default:
                str = "";
                break;
        }
        ne.e.c("TbsInstaller", "type=" + i2 + "needMakeDir=truefolder=" + str);
        File file = new File(j2, str);
        if (file.isDirectory() || file.mkdir()) {
            return file;
        }
        ne.e.c("TbsInstaller", "getCoreDir,mkdir false");
        return null;
    }

    public static void u(Context context, boolean z) {
        if (context == null) {
            h.h(context).i(225, "setTmpFolderCoreToRead context is null");
            ne.e.c("TbsInstaller", "setTmpFolderCoreToRead inner return #01");
            return;
        }
        try {
            File file = new File(je.d.j(context), "tmp_folder_core_to_read.conf");
            if (!z) {
                ne.e.c("TbsInstaller", "setTmpFolderCoreToRead inner tmp file delete #01");
                ne.b.l(file, false);
            } else if (file.exists()) {
                ne.e.c("TbsInstaller", "setTmpFolderCoreToRead inner tmp file already exist #01");
            } else {
                ne.e.c("TbsInstaller", "setTmpFolderCoreToRead inner tmp file create #01");
                file.createNewFile();
            }
        } catch (Exception e2) {
            h.h(context).i(225, "setTmpFolderCoreToRead Exception message is " + e2.getMessage() + " Exception cause is " + e2.getCause());
            ne.e.c("TbsInstaller", "setTmpFolderCoreToRead inner exception #01");
        }
    }

    public static void v() {
        FileLock fileLock = h;
        if (fileLock != null) {
            synchronized (ne.b.class) {
                ne.e.c("FileHelper", "releaseTbsCoreRenameFileLock -- lock: " + fileLock);
                FileChannel channel = fileLock.channel();
                if (channel != null && channel.isOpen()) {
                    try {
                        fileLock.release();
                        channel.close();
                    } catch (IOException e2) {
                        e2.printStackTrace();
                    }
                }
            }
        }
    }

    public static void w(int i2, Context context) {
        ne.e.c("TbsInstaller", "proceedTpatchStatus,result=" + i2);
        if (i2 == 0) {
            ne.e.c("TbsInstaller", "setTmpFolderCoreToRead call #03");
            u(context, true);
            int i3 = je.e.d(context).b.getInt("tbs_download_version", 0);
            y.b(context).getClass();
            y.d("tpatch_ver", i3);
            y.d("tpatch_status", 1);
        }
        boolean z = je.d.a;
    }

    public static int x(Context context) {
        Throwable th2;
        BufferedInputStream bufferedInputStream = null;
        try {
            File file = new File(je.d.j(context), "core_share_decouple");
            if (!file.isDirectory() && !file.mkdir()) {
                file = null;
            }
            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) {
                    try {
                        bufferedInputStream.close();
                    } catch (IOException unused4) {
                    }
                }
                return 0;
            } catch (Throwable th3) {
                th2 = th3;
                bufferedInputStream = bufferedInputStream2;
                if (bufferedInputStream == null) {
                    throw th2;
                }
                try {
                    bufferedInputStream.close();
                    throw th2;
                } catch (IOException unused5) {
                    throw th2;
                }
            }
        } catch (Exception unused6) {
        } catch (Throwable th4) {
            th2 = th4;
        }
    }

    public static boolean y(android.content.Context r8) {
        throw new UnsupportedOperationException("Method not decompiled: je.a0.y(android.content.Context):boolean");
    }

    public static int z(Context context) {
        BufferedInputStream bufferedInputStream;
        BufferedInputStream bufferedInputStream2 = null;
        try {
            try {
                File file = new File(B(context), "tbs.conf");
                if (!file.exists()) {
                    return 0;
                }
                ne.e.c("TbsInstaller", "getTbsCoreInstalledVerInNolock tbsPropFile is " + file.getAbsolutePath());
                Properties properties = new Properties();
                bufferedInputStream = new BufferedInputStream(new FileInputStream(file));
                try {
                    properties.load(bufferedInputStream);
                    bufferedInputStream.close();
                    String property = properties.getProperty("tbs_core_version");
                    if (property == null) {
                        try {
                            bufferedInputStream.close();
                        } catch (IOException e2) {
                            ne.e.c("TbsInstaller", "TbsInstaller--getTbsCoreInstalledVerInNolock IOException=" + e2.toString());
                        }
                        return 0;
                    }
                    int parseInt = Integer.parseInt(property);
                    if (l == 0) {
                        l = parseInt;
                    }
                    try {
                        bufferedInputStream.close();
                    } catch (IOException e3) {
                        ne.e.c("TbsInstaller", "TbsInstaller--getTbsCoreInstalledVerInNolock IOException=" + e3.toString());
                    }
                    return parseInt;
                } catch (Exception e4) {
                    e = e4;
                    bufferedInputStream2 = bufferedInputStream;
                    ne.e.c("TbsInstaller", "TbsInstaller--getTbsCoreInstalledVerInNolock Exception=" + e.toString());
                    if (bufferedInputStream2 != null) {
                        try {
                            bufferedInputStream2.close();
                        } catch (IOException e5) {
                            ne.e.c("TbsInstaller", "TbsInstaller--getTbsCoreInstalledVerInNolock IOException=" + e5.toString());
                        }
                    }
                    return 0;
                } catch (Throwable th2) {
                    th = th2;
                    if (bufferedInputStream != null) {
                        try {
                            bufferedInputStream.close();
                        } catch (IOException e6) {
                            ne.e.c("TbsInstaller", "TbsInstaller--getTbsCoreInstalledVerInNolock IOException=" + e6.toString());
                        }
                    }
                    throw th;
                }
            } catch (Exception e7) {
                e = e7;
            }
        } catch (Throwable th3) {
            th = th3;
            bufferedInputStream = bufferedInputStream2;
        }
    }

    public final synchronized boolean D(Context context) {
        if (this.a > 0) {
            ne.e.c("TbsInstaller", "getTbsInstallingFileLock success,is cached= true");
            this.a++;
            return true;
        }
        FileOutputStream m = ne.b.m(context, "tbslock.txt");
        this.c = m;
        if (m == null) {
            ne.e.c("TbsInstaller", "getTbsInstallingFileLock get install fos failed");
            return false;
        }
        FileLock d2 = ne.b.d(m);
        this.b = d2;
        if (d2 == null) {
            ne.e.c("TbsInstaller", "getTbsInstallingFileLock tbsFileLockFileLock == null");
            return false;
        }
        ne.e.c("TbsInstaller", "getTbsInstallingFileLock success,is cached= false");
        this.a++;
        return true;
    }

    @android.annotation.TargetApi(11)
    public final void f(android.content.Context r24, android.content.Context r25, int r26) {
        throw new UnsupportedOperationException("Method not decompiled: je.a0.f(android.content.Context, android.content.Context, int):void");
    }

    @android.annotation.TargetApi(11)
    public final void k(int r20, java.lang.String r21, android.content.Context r22) {
        throw new UnsupportedOperationException("Method not decompiled: je.a0.k(int, java.lang.String, android.content.Context):void");
    }

    public final void l(android.content.Context r30, android.os.Bundle r31) {
        throw new UnsupportedOperationException("Method not decompiled: je.a0.l(android.content.Context, android.os.Bundle):void");
    }

    public final void m(android.content.Context r11, boolean r12) {
        throw new UnsupportedOperationException("Method not decompiled: je.a0.m(android.content.Context, boolean):void");
    }

    public final synchronized boolean p(Context context, boolean z) {
        String str;
        String str2;
        ne.e.c("TbsInstaller", "TbsInstaller-enableTbsCoreFromTpatch");
        boolean z2 = false;
        try {
        } catch (Throwable th2) {
            h.h(context).i(215, th2.toString());
            je.d.e("TbsInstaller::enableTbsCoreFromTpatch exception:" + Log.getStackTraceString(th2));
        }
        if (!D(context)) {
            return false;
        }
        ReentrantLock reentrantLock = f;
        boolean tryLock = reentrantLock.tryLock();
        ne.e.c("TbsInstaller", "TbsInstaller-enableTbsCoreFromTpatch Locked =" + tryLock);
        if (tryLock) {
            try {
                y.b(context).getClass();
                int f2 = y.f("tpatch_status");
                int b2 = b(context, false);
                ne.e.c("TbsInstaller", "TbsInstaller-enableTbsCoreFromTpatch copyStatus =" + f2);
                ne.e.c("TbsInstaller", "TbsInstaller-enableTbsCoreFromTpatch tbsCoreInstalledVer =" + b2);
                if (f2 == 1) {
                    if (b2 == 0) {
                        str = "TbsInstaller";
                        str2 = "TbsInstaller-enableTbsCoreFromTpatch tbsCoreInstalledVer = 0";
                    } else if (z) {
                        str = "TbsInstaller";
                        str2 = "TbsInstaller-enableTbsCoreFromTpatch tbsCoreInstalledVer != 0";
                    }
                    ne.e.c(str, str2);
                    H(context);
                    z2 = true;
                }
                reentrantLock.unlock();
            } catch (Throwable th3) {
                f.unlock();
                throw th3;
            }
        }
        q();
        return z2;
    }

    public final synchronized void q() {
        int i2 = this.a;
        if (i2 <= 0) {
            ne.e.c("TbsInstaller", "releaseTbsInstallingFileLock currentTbsFileLockStackCount=" + this.a + "call stack:" + Log.getStackTraceString(new Throwable()));
            return;
        }
        if (i2 > 1) {
            ne.e.c("TbsInstaller", "releaseTbsInstallingFileLock with skip");
            this.a--;
        } else {
            if (i2 == 1) {
                ne.e.c("TbsInstaller", "releaseTbsInstallingFileLock without skip");
                ne.b.f(this.b, this.c);
                this.a = 0;
            }
        }
    }
}