九游游戏中心HD v4.6.8.1版本的 MD5 值为:78c397802cc5ffdcc7f5502ede90502e

以下内容为反编译后的 UCMPackageInfo.java 源代码,内容仅作参考


package com.uc.webview.export.internal.setup;

import android.content.Context;
import android.content.pm.PackageInfo;
import android.util.Pair;
import cn.ninegame.im.push.model.message.MessageInfo;
import com.alibaba.wireless.security.SecExceptionCode;
import com.uc.webview.export.Build;
import com.uc.webview.export.annotations.Api;
import com.uc.webview.export.cyclone.UCCyclone;
import com.uc.webview.export.cyclone.UCKnownException;
import com.uc.webview.export.extension.UCCore;
import com.uc.webview.export.internal.utility.Log;
import com.xiaomi.mipush.sdk.MiPushClient;
import java.io.BufferedReader;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.FileReader;
import java.io.FilenameFilter;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.Iterator;
import java.util.List;
import java.util.concurrent.ConcurrentHashMap;
import org.json.JSONArray;
import org.json.JSONObject;
@Api
public class UCMPackageInfo {
    public static final String CORE_FACTORY_IMPL_CLASS = "com.uc.webkit.sdk.CoreFactoryImpl";
    private static final String[] f4517a = {"WebCore_UC", "webviewuc", "webviewuc.cr"};
    private static final String[] b = {"armeabi-v7a", "armeabi", "x86"};
    public static final int compareVersion = 10027;
    public static final int deleteTempDecFiles = 10039;
    public static final int deleteUCMSDKDir = 10044;
    public static final int expectCreateDirFile2P = 10035;
    public static final int expectDirFile1F = 10032;
    public static final int expectDirFile1S = 10033;
    public static final int getDataDirHash = 10012;
    public static final int getDecompressRoot = 10003;
    public static final int getDir = 10001;
    public static final int getFlagRoot = 10005;
    public static final int getKernalJarCpyRoot = 10009;
    public static final int getKernalJarLnkRoot = 10007;
    public static final int getKernalResCpyRoot = 10010;
    public static final int getKernalResLnkRoot = 10008;
    public static final int getKernelFileIfMultiCoreFromDir = 10028;
    public static final int getKernelFiles = 10022;
    public static final int getKernelResFiles = 10024;
    public static final int getLibFilter = 10023;
    public static final int getOdexRoot = 10004;
    public static final int getRepairRoot = 10006;
    public static final int getUnExistsFilePath = 10021;
    public static final int getUpdateRoot = 10002;
    public static final int getVersion = 10040;
    public static final int hadInstallUCMobile = 10026;
    public static final int initUCMBuildInfo = 10041;
    public static final int isDirShouldBeDeleted = 10043;
    public static final int isThickSDK = 10011;
    public static final int makeDirDeleteFlg = 10042;
    public static final int sortByLastModified = 10025;
    public final Pair<String, String> browserIFModule;
    public final String coreCode;
    public final Pair<String, String> coreImplModule;
    public final String dataDir;
    public final String disabledFilePath;
    public final boolean isSpecified;
    public final String mainLibrary;
    public final String pkgName;
    public final String resDirPath;
    public final Pair<String, String> sdkShellModule;
    public final String soDirPath;

    public UCMPackageInfo(Context context, String str, String str2, String str3, String str4, boolean z, String str5, String str6, String str7, boolean z2) {
        String str8;
        this.pkgName = str;
        this.soDirPath = str2;
        String a2 = z2 ? a(context, str4, str3) : str3;
        if (a2 == null) {
            a2 = null;
        } else if (!a2.endsWith("/")) {
            a2 = a2 + "/";
        }
        this.resDirPath = a2;
        this.isSpecified = z;
        if (str4 != null) {
            File file = (File) invoke(expectCreateDirFile2P, (File) invoke(10004, context), (String) invoke(10012, str4));
            this.dataDir = str4;
            this.disabledFilePath = str4 + "/e1df430e25e9dacb26ead508abb3413f";
            this.sdkShellModule = new Pair<>(z2 ? b(context, str4, str5) : str5, file.getAbsolutePath());
            this.browserIFModule = new Pair<>(z2 ? b(context, str4, str6) : str6, file.getAbsolutePath());
            this.coreImplModule = new Pair<>(z2 ? b(context, str4, str7) : str7, file.getAbsolutePath());
        } else {
            this.dataDir = null;
            this.disabledFilePath = (String) invoke(getUnExistsFilePath, new Object[0]);
            this.sdkShellModule = null;
            this.browserIFModule = null;
            this.coreImplModule = null;
        }
        String str9 = com.uc.webview.export.internal.utility.d.a(str2) ? context.getApplicationInfo().nativeLibraryDir : str2;
        String str10 = null;
        long j = 0;
        String[] strArr = f4517a;
        int length = strArr.length;
        int i = 0;
        while (i < length) {
            String str11 = strArr[i];
            File file2 = new File(str9, "lib" + str11 + ".so");
            if (!file2.exists() || file2.lastModified() <= j) {
                str11 = str10;
            } else {
                j = file2.lastModified();
            }
            i++;
            str10 = str11;
        }
        if (str10 == null && !com.uc.webview.export.internal.utility.d.a(str2)) {
            throw new UCSetupException(3001, String.format("Main so file U3 [%s] or U4 [%s|%s] not exists.", "WebCore_UC", "webviewuc", "webviewuc.cr"));
        }
        this.mainLibrary = str10;
        if ("WebCore_UC".equals(this.mainLibrary)) {
            str8 = "u3";
        } else {
            str8 = "webviewuc".equals(this.mainLibrary) ? "u4" : "webviewuc.cr".equals(this.mainLibrary) ? "u4" : this.mainLibrary == null ? "null" : cn.ninegame.share.core.g.ERROR;
        }
        this.coreCode = str8;
    }

    public String getDirAlias(Context context) {
        String str;
        if (this.coreImplModule != null && this.coreImplModule.first != null && (str = (String) this.coreImplModule.first) != null) {
            if (str.startsWith(((File) invoke(10003, context)).getAbsolutePath())) {
                return "dec";
            }
            if (str.startsWith(((File) invoke(10002, context)).getAbsolutePath())) {
                return "upd";
            }
            if (str.startsWith(((File) invoke(10007, context)).getAbsolutePath())) {
                return "kjl";
            }
            if (str.startsWith(((File) invoke(10009, context)).getAbsolutePath())) {
                return "kjc";
            }
            if (str.startsWith(((File) invoke(10006, context)).getAbsolutePath())) {
                return "rep";
            }
            return "oth";
        }
        return "nul";
    }

    public static synchronized List<UCMPackageInfo> a(Context context, ConcurrentHashMap<String, Object> concurrentHashMap) {
        List<UCMPackageInfo> list;
        synchronized (UCMPackageInfo.class) {
            List<UCMPackageInfo> arrayList = new ArrayList<>();
            String str = (String) concurrentHashMap.get(UCCore.OPTION_DEX_FILE_PATH);
            if (!com.uc.webview.export.internal.utility.d.a(str)) {
                arrayList = a(context, new File(str), arrayList);
            }
            if (arrayList.size() == 0) {
                UCMPackageInfo a2 = a(context, null, (String) concurrentHashMap.get(UCCore.OPTION_DEX_FILE_PATH), (String) concurrentHashMap.get(UCCore.OPTION_SO_FILE_PATH), (String) concurrentHashMap.get(UCCore.OPTION_RES_FILE_PATH));
                if (a2 != null) {
                    arrayList.add(a2);
                }
                if (((Boolean) invoke(10011, new Object[0])).booleanValue()) {
                    list = arrayList;
                }
            }
            String str2 = (String) concurrentHashMap.get(UCCore.OPTION_UCM_KRL_DIR);
            if (!com.uc.webview.export.internal.utility.d.a(str2)) {
                arrayList = a(context, new File(str2), arrayList);
            }
            String str3 = (String) concurrentHashMap.get(UCCore.OPTION_UCM_LIB_DIR);
            if (!com.uc.webview.export.internal.utility.d.a(str3)) {
                arrayList.add(a(context, str3));
            }
            list = (List) invoke(sortByLastModified, arrayList);
        }
        return list;
    }

    public static Object invoke(int i, Object... objArr) {
        BufferedReader bufferedReader;
        File[] fileArr;
        boolean z;
        File file;
        boolean z2;
        while (true) {
            switch (i) {
                case 10001:
                    Context context = (Context) objArr[0];
                    String str = objArr.length >= 2 ? (String) objArr[1] : null;
                    File dir = context.getDir("ucmsdk", 0);
                    return str != null ? UCCyclone.expectCreateDirFile(new File(dir, str)) : dir;
                case 10002:
                    objArr = new Object[]{(Context) objArr[0], "updates"};
                    i = 10001;
                case 10003:
                    objArr = new Object[]{(Context) objArr[0], "decompresses"};
                    i = 10001;
                case 10004:
                    objArr = new Object[]{(Context) objArr[0], "odexs"};
                    i = 10001;
                case 10005:
                    objArr = new Object[]{(Context) objArr[0], "flags"};
                    i = 10001;
                case 10006:
                    objArr = new Object[]{(Context) objArr[0], "repairs"};
                    i = 10001;
                case 10007:
                    objArr = new Object[]{(Context) objArr[0], "kjlinks"};
                    i = 10001;
                case 10008:
                    objArr = new Object[]{(Context) objArr[0], "krlinks"};
                    i = 10001;
                case 10009:
                    objArr = new Object[]{(Context) objArr[0], "kjcopies"};
                    i = 10001;
                case 10010:
                    objArr = new Object[]{(Context) objArr[0], "krcopies"};
                    i = 10001;
                case 10011:
                    try {
                        Class.forName(CORE_FACTORY_IMPL_CLASS);
                        return true;
                    } catch (Throwable th) {
                        return false;
                    }
                case 10012:
                    return String.valueOf(((String) objArr[0]).hashCode()).replace('-', '_');
                case UCAsyncTask.getPriority:
                case UCAsyncTask.getTaskCount:
                case UCAsyncTask.getRootTask:
                case UCAsyncTask.inThread:
                case UCAsyncTask.getPercent:
                case UCAsyncTask.isPaused:
                case 10019:
                case 10020:
                case 10029:
                case 10030:
                case 10031:
                case 10034:
                case 10036:
                case 10037:
                case 10038:
                default:
                    return null;
                case getUnExistsFilePath:
                    return "/unexists/" + System.currentTimeMillis();
                case getKernelFiles:
                    return ((File) objArr[0]).listFiles(new FilenameFilter() {
                        @Override
                        public final boolean accept(File file2, String str2) {
                            return str2.startsWith("libkernel") && str2.endsWith("_uc.so");
                        }
                    });
                case getLibFilter:
                    return new FilenameFilter() {
                        @Override
                        public final boolean accept(File file2, String str2) {
                            return file2 != null && str2 != null && file2.getPath().startsWith("lib") && str2.startsWith("lib") && str2.endsWith(".so") && !str2.startsWith("libkernel");
                        }
                    };
                case getKernelResFiles:
                    return ((File) objArr[0]).list(new FilenameFilter() {
                        @Override
                        public final boolean accept(File file2, String str2) {
                            return str2.startsWith("lib") && str2.endsWith("_kr_uc.so");
                        }
                    });
                case sortByLastModified:
                    List list = (List) objArr[0];
                    if (list != null && list.size() > 1) {
                        Collections.sort(list, new Comparator<UCMPackageInfo>() {
                            @Override
                            public final int compare(UCMPackageInfo uCMPackageInfo, UCMPackageInfo uCMPackageInfo2) {
                                return Long.valueOf(new File((String) uCMPackageInfo2.coreImplModule.first).lastModified() - new File((String) uCMPackageInfo.coreImplModule.first).lastModified()).intValue();
                            }
                        });
                    }
                    return list;
                case hadInstallUCMobile:
                    Iterator<PackageInfo> it = ((Context) objArr[0]).getPackageManager().getInstalledPackages(64).iterator();
                    while (true) {
                        if (it.hasNext()) {
                            PackageInfo next = it.next();
                            if (next.packageName.startsWith("com.UCMobile") && next.applicationInfo.enabled) {
                                z = true;
                            }
                        } else {
                            z = false;
                        }
                    }
                    return Boolean.valueOf(z);
                case compareVersion:
                    String str2 = (String) objArr[2];
                    String[] split = ((String) objArr[0]).split("\\.");
                    String[] split2 = ((String) objArr[1]).split("\\.");
                    if (com.uc.webview.export.internal.utility.d.b(split[0]) < com.uc.webview.export.internal.utility.d.b(split2[0]) || com.uc.webview.export.internal.utility.d.b(split[1]) < com.uc.webview.export.internal.utility.d.b(split2[1]) || com.uc.webview.export.internal.utility.d.b(split[2]) < com.uc.webview.export.internal.utility.d.b(split2[2])) {
                        Log.d("UCMPackageInfo", str2);
                        return false;
                    }
                    return true;
                case getKernelFileIfMultiCoreFromDir:
                    String str3 = (String) objArr[0];
                    if ((Build.PACK_TYPE == 34 || Build.PACK_TYPE == 43) && (fileArr = (File[]) invoke(getKernelFiles, (File) invoke(expectDirFile1S, str3))) != null && fileArr.length > 0) {
                        return fileArr[0];
                    }
                    return null;
                case expectDirFile1F:
                    File file2 = (File) objArr[0];
                    if (file2.exists()) {
                        return file2;
                    }
                    throw new UCSetupException((int) SecExceptionCode.SEC_ERROR_ATLAS_ENC_DATA_FILE_MISMATCH, String.format("Directory [%s] not exists.", file2.getAbsolutePath()));
                case expectDirFile1S:
                    return (File) invoke(expectDirFile1F, new File((String) objArr[0]));
                case expectCreateDirFile2P:
                    return UCCyclone.expectCreateDirFile(new File((File) objArr[0], (String) objArr[1]));
                case deleteTempDecFiles:
                    File[] listFiles = ((Context) objArr[0]).getCacheDir().listFiles(new FilenameFilter() {
                        @Override
                        public final boolean accept(File file3, String str4) {
                            return str4.startsWith("uc_temp_dec_");
                        }
                    });
                    if (listFiles == null || listFiles.length <= 0) {
                        return null;
                    }
                    for (File file3 : listFiles) {
                        UCCyclone.recursiveDelete(file3, false, null);
                    }
                    return null;
                case getVersion:
                    ?? r2 = "curver";
                    ?? file4 = new File((String) objArr[0], "curver");
                    try {
                        if (!file4.exists()) {
                            return null;
                        }
                        try {
                            r2 = new FileReader((File) file4);
                            try {
                                bufferedReader = new BufferedReader(r2);
                                try {
                                    String readLine = bufferedReader.readLine();
                                    if (readLine == null) {
                                        try {
                                            bufferedReader.close();
                                        } catch (Exception e) {
                                        }
                                        try {
                                            r2.close();
                                            return null;
                                        } catch (Exception e2) {
                                            return null;
                                        }
                                    }
                                    String trim = readLine.trim();
                                    if (!trim.startsWith("/")) {
                                        trim = "/" + trim;
                                    }
                                    if (!trim.endsWith("/")) {
                                        trim = trim + "/";
                                    }
                                    try {
                                        bufferedReader.close();
                                    } catch (Exception e3) {
                                    }
                                    try {
                                        r2.close();
                                    } catch (Exception e4) {
                                    }
                                    return trim;
                                } catch (Exception e5) {
                                    e = e5;
                                    Log.i("tag_test_log", "getVersion", e);
                                    try {
                                        bufferedReader.close();
                                    } catch (Exception e6) {
                                    }
                                    try {
                                        r2.close();
                                        return null;
                                    } catch (Exception e7) {
                                        return null;
                                    }
                                }
                            } catch (Exception e8) {
                                e = e8;
                                bufferedReader = null;
                            } catch (Throwable th2) {
                                th = th2;
                                file4 = 0;
                                try {
                                    file4.close();
                                } catch (Exception e9) {
                                }
                                try {
                                    r2.close();
                                } catch (Exception e10) {
                                }
                                throw th;
                            }
                        } catch (Exception e11) {
                            e = e11;
                            bufferedReader = null;
                            r2 = 0;
                        } catch (Throwable th3) {
                            th = th3;
                            file4 = 0;
                            r2 = 0;
                        }
                    } catch (Throwable th4) {
                        th = th4;
                    }
                case initUCMBuildInfo:
                    ClassLoader classLoader = (ClassLoader) objArr[0];
                    try {
                        Class<?> cls = Class.forName("com.uc.webview.browser.shell.Build$Version", false, classLoader);
                        String obj = cls.getField("NAME").get(null).toString();
                        String obj2 = cls.getField("SUPPORT_SDK_MIN").get(null).toString();
                        Build.UCM_VERSION = obj;
                        Build.UCM_SUPPORT_SDK_MIN = obj2;
                        Build.Version.API_LEVEL = cls.getField("API_LEVEL").getInt(null);
                    } catch (Exception e12) {
                        Build.Version.API_LEVEL = 1;
                    }
                    try {
                        Class<?> cls2 = Class.forName("com.uc.webview.browser.shell.Build", false, classLoader);
                        Build.CORE_VERSION = cls2.getField("CORE_VERSION").get(null).toString();
                        Build.CORE_TIME = cls2.getField("TIME").get(null).toString();
                        return null;
                    } catch (Exception e13) {
                        return null;
                    }
                case makeDirDeleteFlg:
                    try {
                        if (new File((File) objArr[1], String.valueOf(System.currentTimeMillis())).createNewFile()) {
                            return null;
                        }
                        throw new Exception("createNewFile return false");
                    } catch (Throwable th5) {
                        throw new UCKnownException((int) SecExceptionCode.SEC_ERROR_ATLAS_ENC_NO_KEY, th5);
                    }
                case isDirShouldBeDeleted:
                    File expectCreateDirFile = UCCyclone.expectCreateDirFile(new File(UCCyclone.expectCreateDirFile(new File((File) invoke(10005, (Context) objArr[0]), "setup_delete")), UCCyclone.getSourceHash(((File) objArr[1]).getAbsolutePath())));
                    if (expectCreateDirFile.list().length < 12) {
                        return expectCreateDirFile;
                    }
                    return null;
                case deleteUCMSDKDir:
                    Context context2 = (Context) objArr[0];
                    File file5 = (File) objArr[1];
                    File file6 = (File) objArr[2];
                    if (file5.isFile()) {
                        file = null;
                        z2 = true;
                    } else if (file5.isDirectory()) {
                        file = (File) invoke(isDirShouldBeDeleted, context2, file5);
                        z2 = file != null;
                    } else {
                        file = null;
                        z2 = false;
                    }
                    if (z2) {
                        UCCyclone.recursiveDelete(file5, false, file6);
                        if (file5.exists() || file == null) {
                            return null;
                        }
                        invoke(makeDirDeleteFlg, context2, file);
                        return null;
                    }
                    return null;
            }
        }
    }

    private static String a(Context context, String str, String str2) {
        String substring;
        if (com.uc.webview.export.internal.utility.d.a(str2)) {
            return null;
        }
        File file = (File) invoke(expectDirFile1S, str2);
        String[] strArr = (String[]) invoke(getKernelResFiles, file);
        if (strArr == null || strArr.length == 0) {
            return null;
        }
        String str3 = (String) invoke(10012, str);
        File file2 = (File) invoke(expectCreateDirFile2P, (File) invoke(10008, context), str3);
        File file3 = (File) invoke(expectCreateDirFile2P, (File) invoke(10010, context), str3);
        File file4 = (File) invoke(expectCreateDirFile2P, file2, "paks");
        File file5 = (File) invoke(expectCreateDirFile2P, file3, "paks");
        boolean[] zArr = new boolean[strArr.length];
        File[] fileArr = new File[strArr.length];
        File[] fileArr2 = new File[strArr.length];
        File[] fileArr3 = new File[strArr.length];
        boolean z = true;
        for (int i = 0; i < strArr.length; i++) {
            String str4 = strArr[i];
            boolean endsWith = str4.endsWith("_pak_kr_uc.so");
            int lastIndexOf = str4.substring(3, str4.length() - 9).lastIndexOf(95);
            String str5 = substring.substring(0, lastIndexOf) + '.' + substring.substring(lastIndexOf + 1);
            File file6 = new File(file, str4);
            File file7 = new File(endsWith ? file4 : file2, str5);
            File file8 = new File(endsWith ? file5 : file3, str5);
            File a2 = com.uc.webview.export.internal.utility.d.a(file6, file7, file8, false);
            fileArr[i] = file6;
            fileArr2[i] = file7;
            fileArr3[i] = file8;
            boolean z2 = a2 == file7;
            zArr[i] = z2;
            if (!z2) {
                z = false;
            }
        }
        if (!z) {
            for (int i2 = 0; i2 < strArr.length; i2++) {
                if (zArr[i2]) {
                    com.uc.webview.export.internal.utility.d.a(fileArr[i2], fileArr2[i2], fileArr3[i2], true);
                }
            }
            return file3.getAbsolutePath();
        }
        return file2.getAbsolutePath();
    }

    private static String b(Context context, String str, String str2) {
        if (com.uc.webview.export.internal.utility.d.a(str2)) {
            return null;
        }
        File file = new File(str2);
        String name = file.getName();
        if (name.startsWith("lib") && name.endsWith("_jar_kj_uc.so")) {
            String str3 = name.substring(3, name.length() - 13) + ".jar";
            String str4 = (String) invoke(10012, str);
            return com.uc.webview.export.internal.utility.d.a(file, new File((File) invoke(expectCreateDirFile2P, (File) invoke(10007, context), str4), str3), new File((File) invoke(expectCreateDirFile2P, (File) invoke(10009, context), str4), str3), false).getAbsolutePath();
        }
        return str2;
    }

    private static UCMPackageInfo a(Context context, String str) {
        String[] strArr;
        int i;
        String str2;
        String str3 = null;
        loop0: while (true) {
            File file = (File) invoke(expectDirFile1S, str);
            try {
                String absolutePath = UCCyclone.expectFile(file, "libcore_jar_kj_uc.so").getAbsolutePath();
                try {
                    str2 = UCCyclone.expectFile(file, "libsdk_shell_jar_kj_uc.so").getAbsolutePath();
                } catch (Throwable th) {
                    str2 = null;
                }
                try {
                    str3 = UCCyclone.expectFile(file, "libbrowser_if_jar_kj_uc.so").getAbsolutePath();
                } catch (Throwable th2) {
                }
                return new com.uc.webview.export.internal.utility.UCMPackageInfo(context, "specified", file.getAbsolutePath(), file.getAbsolutePath(), file.getAbsolutePath(), true, str2, str3, absolutePath, true);
            } catch (UCKnownException e) {
                File[] listFiles = file.listFiles();
                if (listFiles == null) {
                    break;
                }
                for (String str4 : b) {
                    int length = listFiles.length;
                    for (i = 0; i < length; i = i + 1) {
                        File file2 = listFiles[i];
                        i = (str4.equals(file2.getName()) && file2.isDirectory()) ? 0 : i + 1;
                    }
                }
                break loop0;
                throw e;
            }
        }
        throw e;
    }

    private static UCMPackageInfo a(Context context, String str, String str2, String str3, String str4) {
        String str5;
        String str6;
        String str7;
        boolean a2 = com.uc.webview.export.internal.utility.d.a(str2);
        boolean a3 = com.uc.webview.export.internal.utility.d.a(str3);
        boolean a4 = com.uc.webview.export.internal.utility.d.a(str4);
        if (a2 && !((Boolean) invoke(10011, new Object[0])).booleanValue()) {
            if (a3 && a4) {
                return null;
            }
            throw new UCSetupException(3002, "No ucm dex file specified.");
        }
        if (a2) {
            str5 = null;
            str6 = null;
            str7 = null;
        } else {
            File file = (File) invoke(expectDirFile1S, str2);
            str5 = UCCyclone.expectFile(file, "core.jar").getAbsolutePath();
            try {
                str7 = UCCyclone.expectFile(file, "sdk_shell.jar").getAbsolutePath();
            } catch (Throwable th) {
                str7 = null;
            }
            try {
                str6 = UCCyclone.expectFile(file, "browser_if.jar").getAbsolutePath();
            } catch (Throwable th2) {
                str6 = null;
            }
        }
        return new com.uc.webview.export.internal.utility.UCMPackageInfo(context, str == null ? "specified" : str, str3, str4, str2, true, str7, str6, str5, false);
    }

    private static List<UCMPackageInfo> a(Context context, File file, List<UCMPackageInfo> list) {
        if (list == null) {
            list = new ArrayList<>();
        }
        if (file.exists() && file.isDirectory()) {
            File file2 = new File(file, "sdk_shell.jar");
            File file3 = new File(file, "browser_if.jar");
            File file4 = new File(file, "core.jar");
            File file5 = new File(file, "lib");
            boolean z = file4.exists() && (!com.uc.webview.export.internal.d.m || file2.exists()) && ((!com.uc.webview.export.internal.d.m || file3.exists()) && file5.isDirectory());
            if (z) {
                String[] strArr = b;
                int length = strArr.length;
                int i = 0;
                while (true) {
                    if (i >= length) {
                        break;
                    }
                    File file6 = new File(file5, strArr[i]);
                    if (file6.isDirectory()) {
                        file5 = file6;
                        break;
                    }
                    i++;
                }
                File file7 = new File(file, "assets");
                if (z) {
                    list.add(new com.uc.webview.export.internal.utility.UCMPackageInfo(context, "specified", file5.getAbsolutePath(), file7.getAbsolutePath(), file.getAbsolutePath(), true, file2.getAbsolutePath(), file3.getAbsolutePath(), file4.getAbsolutePath(), false));
                }
            }
            File[] listFiles = file.listFiles();
            if (listFiles != null) {
                for (File file8 : listFiles) {
                    if (file8.isDirectory()) {
                        a(context, file8, list);
                    }
                }
            }
        }
        return list;
    }

    public static synchronized List<UCMPackageInfo> a(Context context, String str, boolean z) {
        List<UCMPackageInfo> list;
        synchronized (UCMPackageInfo.class) {
            List<PackageInfo> installedPackages = context.getPackageManager().getInstalledPackages(64);
            List<UCMPackageInfo> a2 = a(context);
            for (PackageInfo packageInfo : installedPackages) {
                if (!packageInfo.packageName.equals(context.getPackageName()) && packageInfo.packageName.startsWith(str) && packageInfo.applicationInfo.enabled && (z || (packageInfo.signatures.length > 0 && packageInfo.signatures[0].toCharsString().equals("308202153082017ea00302010202044d92c9ac300d06092a864886f70d0101050500304e310b300906035504061302636e310b3009060355040813026764310b300906035504071302677a310b3009060355040a13027563310b3009060355040b13027563310b30090603550403130275633020170d3131303333303036313135365a180f32303635313233313036313135365a304e310b300906035504061302636e310b3009060355040813026764310b300906035504071302677a310b3009060355040a13027563310b3009060355040b13027563310b300906035504031302756330819f300d06092a864886f70d010101050003818d0030818902818100aac959f5439f1595907c7fa43a6d628fa6c6e0006470d122ee5edac296e51d24450acf16e3a4aa8b75735e23a8a7cd4925825a9e3311d6c6d4024b4e837d613bb037a25e898380625b042c1cb7eb017f86772b4ae10256f840d75a9b4f646f2fd7a178e58035182358c1eb2b940307107af050384f3b2763b186679e371ea5c90203010001300d06092a864886f70d010105050003818100a635800a51087088b481823651d212253fcc0fa4b97dc872f9f1c47b723e1a31e4c53ddaf8d7f9e0b754f579c01c887fd6f1de1368594f8262a77e95582ad818bcffd02b9e36a1afe462b220acc6ca00bb98a2d07a484257ab43759231c7134e89168048f05bb3ed20438b045b3e5259488a80fe64888cc89202d33c57824fc1")))) {
                    try {
                        String str2 = packageInfo.packageName;
                        String str3 = packageInfo.applicationInfo.dataDir;
                        String.valueOf(str3.hashCode()).replace('-', '_');
                        String str4 = str3 + "/com/sdk_shell";
                        String str5 = (String) invoke(getVersion, str4);
                        File file = new File(str5 != null ? str4 + str5 : str4);
                        invoke(expectDirFile1F, file);
                        File file2 = new File(file, "dex/sdk_shell.jar");
                        UCCyclone.expectFile(file2);
                        String str6 = str3 + "/com/browser_if";
                        String str7 = (String) invoke(getVersion, str6);
                        File file3 = new File(str7 != null ? str6 + str7 : str6);
                        invoke(expectDirFile1F, file3);
                        File file4 = new File(file3, "dex/browser_if.jar");
                        UCCyclone.expectFile(file4);
                        String str8 = str3 + "/com/core";
                        String str9 = (String) invoke(getVersion, str8);
                        File file5 = new File(str9 != null ? str8 + str9 : str8);
                        invoke(expectDirFile1F, file5);
                        File file6 = new File(file5, "dex/core.jar");
                        UCCyclone.expectFile(file6);
                        String str10 = file5.getAbsolutePath() + "/lib";
                        if (!new File(str10, "/libWebCore_UC.so").exists()) {
                            str10 = str3 + "/native";
                            if (!new File(str10, "/libWebCore_UC.so").exists()) {
                                str10 = str3 + "/lib";
                                if (new File(str10, "/libWebCore_UC.so").exists()) {
                                }
                            }
                        }
                        a2.add(new com.uc.webview.export.internal.utility.UCMPackageInfo(context, str2, str10, null, str3, false, file2.getAbsolutePath(), file4.getAbsolutePath(), file6.getAbsolutePath(), false));
                    } catch (Throwable th) {
                    }
                }
            }
            list = (List) invoke(sortByLastModified, a2);
        }
        return list;
    }

    private static List<UCMPackageInfo> a(Context context) {
        String[] strArr = {"com.UCMobile", "com.taobao.taobao"};
        new ArrayList();
        if (((Boolean) com.uc.webview.export.internal.d.a(10007, "shareapps")).booleanValue()) {
            String str = (String) com.uc.webview.export.internal.d.a(10005, "shareapps");
            if ("NAN".equals(str)) {
                strArr = new String[0];
            } else {
                strArr = str.split(MiPushClient.ACCEPT_TIME_SEPARATOR);
            }
        }
        ArrayList arrayList = new ArrayList();
        for (String str2 : strArr) {
            try {
                if (!str2.equals(context.getPackageName())) {
                    for (a aVar : a.a(new File("/data/data/" + str2 + "/app_ucmsdk", "config.json"))) {
                        if (!com.uc.webview.export.internal.utility.d.a(aVar.c)) {
                            File file = new File(aVar.c);
                            File file2 = new File(aVar.d);
                            String str3 = aVar.f4518a;
                            String str4 = aVar.b;
                            if (!((Boolean) invoke(compareVersion, str3, Build.Version.SUPPORT_UCM_MIN, "最小内核版本不通过")).booleanValue() || !((Boolean) invoke(compareVersion, Build.Version.NAME, str4, "最小SDK版本不通过")).booleanValue()) {
                                Log.d("UCMPackageInfo", "版本校验不通过>>config ucmVersion:" + str3 + ",SUPPORT_UCM_MIN=" + Build.Version.SUPPORT_UCM_MIN);
                                Log.d("UCMPackageInfo", "版本校验不通过>>config ucmSuportSDKMin:" + str4 + ",NAME=" + Build.Version.NAME);
                            } else if (file.exists() && file2.exists()) {
                                arrayList.add(a(context, str2, file.getAbsolutePath(), file2.getAbsolutePath(), null));
                            } else {
                                Log.i("UCMPackageInfo", file.getAbsolutePath() + " or " + file2.getAbsolutePath() + " not exist");
                            }
                        }
                    }
                }
            } catch (Exception e) {
                Log.e("UCMPackageInfo", "getAppUCMPackageInfo", e);
            }
        }
        return arrayList;
    }

    public static final class a {
        public String f4518a;
        public String b;
        public String c;
        public String d;
        public String e;
        public String f;

        public static List<a> a(File file) {
            ByteArrayOutputStream byteArrayOutputStream;
            FileInputStream fileInputStream;
            FileInputStream fileInputStream2 = null;
            ArrayList arrayList = new ArrayList();
            if (file == null || !file.exists()) {
                Log.i("Config", "configFile:" + file + " not exist");
                return arrayList;
            }
            try {
                fileInputStream = new FileInputStream(file);
                try {
                    byteArrayOutputStream = new ByteArrayOutputStream();
                } catch (Exception e) {
                    e = e;
                    byteArrayOutputStream = null;
                    fileInputStream2 = fileInputStream;
                } catch (Throwable th) {
                    th = th;
                    byteArrayOutputStream = null;
                }
                try {
                    byte[] bArr = new byte[MessageInfo.FLAG_STATE_UNREAD];
                    while (true) {
                        int read = fileInputStream.read(bArr);
                        if (read <= 0) {
                            break;
                        }
                        byteArrayOutputStream.write(bArr, 0, read);
                    }
                    JSONArray jSONArray = new JSONArray(new String(byteArrayOutputStream.toByteArray()));
                    for (int i = 0; i < jSONArray.length(); i++) {
                        JSONObject jSONObject = jSONArray.getJSONObject(i);
                        a aVar = new a();
                        aVar.f4518a = jSONObject.getString("ucmver");
                        aVar.b = jSONObject.getString("sdkMin");
                        if (jSONObject.has("dex")) {
                            aVar.c = jSONObject.getJSONObject("dex").getString("path");
                        }
                        if (jSONObject.has("so")) {
                            aVar.d = jSONObject.getJSONObject("so").getString("path");
                        }
                        if (jSONObject.has("archive")) {
                            JSONObject jSONObject2 = jSONObject.getJSONObject("archive");
                            aVar.e = jSONObject2.getString("path");
                            aVar.f = jSONObject2.getString("algorithm");
                        }
                        arrayList.add(aVar);
                    }
                    UCCyclone.close(fileInputStream);
                    UCCyclone.close(byteArrayOutputStream);
                    return arrayList;
                } catch (Exception e2) {
                    e = e2;
                    fileInputStream2 = fileInputStream;
                    try {
                        Log.e("Config", "getConfig", e);
                        UCCyclone.close(fileInputStream2);
                        UCCyclone.close(byteArrayOutputStream);
                        return new ArrayList();
                    } catch (Throwable th2) {
                        th = th2;
                        fileInputStream = fileInputStream2;
                        UCCyclone.close(fileInputStream);
                        UCCyclone.close(byteArrayOutputStream);
                        throw th;
                    }
                } catch (Throwable th3) {
                    th = th3;
                    UCCyclone.close(fileInputStream);
                    UCCyclone.close(byteArrayOutputStream);
                    throw th;
                }
            } catch (Exception e3) {
                e = e3;
                byteArrayOutputStream = null;
            } catch (Throwable th4) {
                th = th4;
                byteArrayOutputStream = null;
                fileInputStream = null;
            }
        }

        public static boolean a(List<a> list, File file) {
            JSONArray jSONArray;
            FileOutputStream fileOutputStream;
            if (list.size() == 0) {
                Log.i("Config", "configs:" + list + " is empty or configFile:" + file);
                return false;
            }
            FileOutputStream fileOutputStream2 = null;
            try {
                try {
                    jSONArray = new JSONArray();
                    for (a aVar : list) {
                        JSONObject jSONObject = new JSONObject();
                        jSONArray.put(jSONObject);
                        jSONObject.put("ucmver", aVar.f4518a);
                        jSONObject.put("sdkMin", aVar.b);
                        if (!com.uc.webview.export.internal.utility.d.a(aVar.c)) {
                            JSONObject jSONObject2 = new JSONObject();
                            jSONObject.put("dex", jSONObject2);
                            jSONObject2.put("path", aVar.c);
                        }
                        if (!com.uc.webview.export.internal.utility.d.a(aVar.d)) {
                            JSONObject jSONObject3 = new JSONObject();
                            jSONObject.put("so", jSONObject3);
                            jSONObject3.put("path", aVar.d);
                        }
                        if (!com.uc.webview.export.internal.utility.d.a(aVar.e)) {
                            JSONObject jSONObject4 = new JSONObject();
                            jSONObject.put("archive", jSONObject4);
                            jSONObject4.put("path", aVar.e);
                            jSONObject4.put("algorithm", com.uc.webview.export.internal.utility.d.a(aVar.f) ? "zip" : aVar.f);
                        }
                    }
                    fileOutputStream = new FileOutputStream(file);
                } catch (Exception e) {
                    e = e;
                }
            } catch (Throwable th) {
                th = th;
            }
            try {
                fileOutputStream.write(jSONArray.toString().getBytes());
                UCCyclone.close(fileOutputStream);
                return true;
            } catch (Exception e2) {
                e = e2;
                fileOutputStream2 = fileOutputStream;
                Log.e("Config", "saveConfig", e);
                UCCyclone.close(fileOutputStream2);
                return false;
            } catch (Throwable th2) {
                th = th2;
                fileOutputStream2 = fileOutputStream;
                UCCyclone.close(fileOutputStream2);
                throw th;
            }
        }
    }
}