智能工厂.apk(点击下载) / QbSdk.java


package com.tencent.smtt.sdk;

import android.annotation.SuppressLint;
import android.app.AlertDialog;
import android.content.ComponentName;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.SharedPreferences;
import android.content.pm.PackageManager;
import android.content.pm.ProviderInfo;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Color;
import android.graphics.drawable.BitmapDrawable;
import android.graphics.drawable.Drawable;
import android.net.Uri;
import android.os.Build;
import android.os.Bundle;
import android.os.Handler;
import android.os.Looper;
import android.os.Message;
import android.os.Parcelable;
import android.text.TextUtils;
import android.util.Log;
import android.webkit.CookieManager;
import android.webkit.CookieSyncManager;
import android.webkit.ValueCallback;
import android.webkit.WebIconDatabase;
import android.webkit.WebStorage;
import android.webkit.WebView;
import android.webkit.WebViewDatabase;
import androidx.core.os.EnvironmentCompat;
import androidx.core.provider.FontsContractCompat;
import com.baidu.speech.utils.cuid.util.DeviceId;
import com.tencent.smtt.export.external.DexLoader;
import com.tencent.smtt.export.external.interfaces.IX5WebViewBase;
import com.tencent.smtt.sdk.TbsDownloadConfig;
import com.tencent.smtt.sdk.TbsDownloadUpload;
import com.tencent.smtt.sdk.TbsDownloader;
import com.tencent.smtt.sdk.TbsListener;
import com.tencent.smtt.sdk.TbsPrivacyAccess;
import com.tencent.smtt.sdk.stat.MttLoader;
import com.tencent.smtt.sdk.ui.dialog.d;
import com.tencent.smtt.sdk.ui.dialog.e;
import com.tencent.smtt.utils.FileProvider;
import com.tencent.smtt.utils.FileUtil;
import com.tencent.smtt.utils.TbsLog;
import com.tencent.smtt.utils.TbsLogClient;
import com.tencent.smtt.utils.a;
import com.tencent.smtt.utils.b;
import com.tencent.smtt.utils.i;
import com.tencent.smtt.utils.m;
import com.tencent.smtt.utils.q;
import com.tencent.smtt.utils.r;
import java.io.BufferedInputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.lang.reflect.Constructor;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Properties;
import java.util.regex.Pattern;
import org.json.JSONArray;
import org.json.JSONObject;

@SuppressLint({"NewApi"})
public class QbSdk {
    private static String A = null;
    private static String B = null;
    private static boolean C = false;
    public static final int CORE_VER_ENABLE_202112 = 45912;
    private static boolean D = true;
    private static TbsListener E = null;
    public static final int EXTENSION_INIT_FAILURE = -99999;
    private static TbsListener F = null;
    public static final String FILERADER_MENUDATA = "menuData";
    private static boolean G = false;
    private static boolean H = false;
    private static int I = -1;
    public static final String KEY_SET_SENDREQUEST_AND_UPLOAD = "SET_SENDREQUEST_AND_UPLOAD";
    public static final String KEY_THIRD_PARTY_TURING = "turing";
    public static final String LOGIN_TYPE_KEY_PARTNER_CALL_POS = "PosID";
    public static final String LOGIN_TYPE_KEY_PARTNER_ID = "ChannelID";
    public static final String PARAM_KEY_FEATUREID = "param_key_featureid";
    public static final String PARAM_KEY_FUNCTIONID = "param_key_functionid";
    public static final String PARAM_KEY_POSITIONID = "param_key_positionid";
    public static final int QBMODE = 2;
    public static final String SHARE_PREFERENCES_NAME = "tbs_file_open_dialog_config";
    public static final String SVNVERSION = "jnizz";
    public static final int TBSMODE = 1;
    public static final String TID_QQNumber_Prefix = "QQ:";
    @Deprecated
    public static final String USER_ID_FROM_APP_ANDROID_ID = TbsPrivacyAccess.ConfigurablePrivacy.ANDROID_ID.a;
    @Deprecated
    public static final String USER_ID_FROM_APP_ANDROID_VERSION = TbsPrivacyAccess.ConfigurablePrivacy.ANDROID_VERSION.a;
    @Deprecated
    public static final String USER_ID_FROM_APP_DEVICE_MODEL = TbsPrivacyAccess.ConfigurablePrivacy.DEVICE_MODEL.a;
    @Deprecated
    public static final String USER_ID_FROM_APP_IMSI = TbsPrivacyAccess.ConfigurablePrivacy.IMSI.a;
    @Deprecated
    public static final String USER_ID_FROM_APP_MAC = TbsPrivacyAccess.ConfigurablePrivacy.MAC.a;
    public static final String USER_ID_FROM_APP_QIMEI36 = TbsPrivacyAccess.ConfigurablePrivacy.QIMEI36.a;
    public static final int VERSION = 1;
    static boolean a = false;
    static boolean b = false;
    static boolean c = true;
    static String d = null;
    static boolean e = false;
    static long f = 0;
    static long g = 0;
    static Object h = new Object();
    static boolean i = true;
    public static boolean isDefaultDialog = false;
    static boolean j = true;
    static boolean k = false;
    static boolean l = false;
    static volatile boolean m = a;
    public static boolean mDisableUseHostBackupCore = false;
    static TbsListener n = new TbsListener() {
        /* class com.tencent.smtt.sdk.QbSdk.AnonymousClass7 */

        @Override // com.tencent.smtt.sdk.TbsListener
        public void onDownloadFinish(int i) {
            if (TbsDownloader.needDownloadDecoupleCore()) {
                TbsLog.i("QbSdk", "onDownloadFinish needDownloadDecoupleCore is true", true);
                TbsDownloader.a = true;
                return;
            }
            TbsLog.i("QbSdk", "onDownloadFinish needDownloadDecoupleCore is false", true);
            TbsDownloader.a = false;
            if (QbSdk.E != null) {
                QbSdk.E.onDownloadFinish(i);
            }
            if (QbSdk.F != null) {
                QbSdk.F.onDownloadFinish(i);
            }
        }

        @Override // com.tencent.smtt.sdk.TbsListener
        public void onDownloadProgress(int i) {
            if (QbSdk.F != null) {
                QbSdk.F.onDownloadProgress(i);
            }
            if (QbSdk.E != null) {
                QbSdk.E.onDownloadProgress(i);
            }
        }

        @Override // com.tencent.smtt.sdk.TbsListener
        public void onInstallFinish(int i) {
            if (i != 243 || QbSdk.F == null) {
                if (i != 200) {
                }
                TbsLog.i("QbSdk", "onInstallFinish errCode is " + i, true);
                QbSdk.setTBSInstallingStatus(false);
                TbsDownloader.a = false;
                if (TbsDownloader.startDecoupleCoreIfNeeded()) {
                    TbsDownloader.a = true;
                } else {
                    TbsDownloader.a = false;
                }
                if (QbSdk.E != null) {
                    QbSdk.E.onInstallFinish(i);
                }
                if (QbSdk.F != null) {
                    QbSdk.F.onInstallFinish(i);
                    return;
                }
                return;
            }
            QbSdk.F.onInstallFinish(i);
        }
    };
    static Map<String, Object> o = null;
    private static int p = 0;
    private static String q = "";
    private static Class<?> r = null;
    private static Object s = null;
    public static boolean sIsVersionPrinted = false;
    private static boolean t = false;
    private static String[] u = null;
    private static String v = "NULL";
    private static String w = "UNKNOWN";
    private static boolean x = false;
    private static int y = 0;
    private static int z = TbsListener.ErrorCode.NEEDDOWNLOAD_TRUE;

    public interface PreInitCallback {
        void onCoreInitFinished();

        void onViewInitFinished(boolean z);
    }

    static Bundle a(Context context, Bundle bundle) throws Exception {
        TbsLogReport instance;
        String str;
        if (!a(context)) {
            instance = TbsLogReport.getInstance(context);
            str = "initForPatch return false!";
        } else {
            Object a2 = i.a(s, "incrUpdate", new Class[]{Context.class, Bundle.class}, context, bundle);
            if (a2 != null) {
                return (Bundle) a2;
            }
            instance = TbsLogReport.getInstance(context);
            str = "incrUpdate return null!";
        }
        instance.setInstallErrorCode(TbsListener.ErrorCode.INCR_UPDATE_ERROR, str);
        return null;
    }

    private static Bundle a(Context context, Map<String, String> map) {
        if (map == null) {
            return null;
        }
        try {
            Bundle bundle = new Bundle();
            bundle.putString("style", map.get("style") == null ? DeviceId.CUIDInfo.I_EMPTY : map.get("style"));
            try {
                bundle.putInt("topBarBgColor", Color.parseColor(map.get("topBarBgColor")));
            } catch (Exception unused) {
            }
            if (map != null && map.containsKey(FILERADER_MENUDATA)) {
                JSONObject jSONObject = new JSONObject(map.get(FILERADER_MENUDATA));
                JSONArray jSONArray = jSONObject.getJSONArray("menuItems");
                if (jSONArray != null) {
                    ArrayList<? extends Parcelable> arrayList = new ArrayList<>();
                    int i2 = 0;
                    while (i2 < jSONArray.length() && i2 < 5) {
                        try {
                            JSONObject jSONObject2 = (JSONObject) jSONArray.get(i2);
                            arrayList.add(i2, BitmapFactory.decodeResource(context.getResources(), jSONObject2.getInt("iconResId")));
                            jSONObject2.put("iconResId", i2);
                        } catch (Exception unused2) {
                        }
                        i2++;
                    }
                    bundle.putParcelableArrayList("resArray", arrayList);
                }
                bundle.putString(FILERADER_MENUDATA, jSONObject.toString());
            }
            return bundle;
        } catch (Exception e2) {
            e2.printStackTrace();
            return null;
        }
    }

    static Object a(Context context, String str, Bundle bundle) {
        if (!a(context)) {
            return Integer.valueOf((int) EXTENSION_INIT_FAILURE);
        }
        Object a2 = i.a(s, "miscCall", new Class[]{String.class, Bundle.class}, str, bundle);
        if (a2 != null) {
            return a2;
        }
        return null;
    }

    static String a() {
        return q;
    }

    private static void a(Context context, File file, int i2, int i3) {
    }

    static void a(Context context, Integer num, Map<Integer, String> map) {
        if (a(context)) {
            i.a(s, "dispatchEmergencyCommand", new Class[]{Integer.class, Map.class}, num, map);
        }
    }

    static synchronized void a(Context context, String str) {
        synchronized (QbSdk.class) {
            if (!a) {
                a = true;
                w = "forceSysWebViewInner: " + str;
                TbsLog.e("QbSdk", "forceSysWebViewInner", "Reason:" + w);
                TbsLog.e("QbSdk", "forceSysWebViewInner", Log.getStackTraceString(new Throwable("#")));
                TbsCoreLoadStat.getInstance().a(context, TbsListener.ErrorCode.INFO_FORCE_SYSTEM_WEBVIEW_INNER);
            }
        }
    }

    static boolean a(Context context) {
        try {
            if (r != null) {
                return true;
            }
            File r2 = p.a().r(context);
            if (r2 == null) {
                TbsLog.e("QbSdk", "QbSdk initExtension (false) optDir == null");
                return false;
            }
            File file = new File(r2, "tbs_sdk_extension_dex.jar");
            if (!file.exists()) {
                TbsLog.e("QbSdk", "QbSdk initExtension (false) dexFile.exists()=false", true);
                return false;
            }
            TbsLog.i("QbSdk", "new DexLoader #3 dexFile is " + file.getAbsolutePath());
            x.a().b(context);
            m.a(context);
            r = new DexLoader(file.getParent(), context, new String[]{file.getAbsolutePath()}, r2.getAbsolutePath(), getSettings()).loadClass("com.tencent.tbs.sdk.extension.TbsSDKExtension");
            if (isEnableSensitiveApi() || i.a(r, "isSuiteableGetSensitative", (Class<?>[]) new Class[0], new Object[0]) != null) {
                loadTBSSDKExtension(context, file.getParent());
                return true;
            }
            TbsLog.e("QbSdk", "isSuiteableGetSensitative check failed,can not use x5");
            return false;
        } catch (Throwable th) {
            TbsLog.e("QbSdk", "initExtension sys WebView: " + Log.getStackTraceString(th));
            return false;
        }
    }

    static boolean a(Context context, int i2) {
        return a(context, i2, 20000);
    }

    static boolean a(Context context, int i2, int i3) {
        Map<String, Object> map = o;
        if (map != null && map.containsKey(KEY_SET_SENDREQUEST_AND_UPLOAD) && o.get(KEY_SET_SENDREQUEST_AND_UPLOAD).equals("false")) {
            TbsLog.i("QbSdk", "[QbSdk.isX5Disabled] -- SET_SENDREQUEST_AND_UPLOAD is false");
            return true;
        } else if (isEnableSensitiveApi() || i.a(r, "isSuiteableGetSensitative", (Class<?>[]) new Class[0], new Object[0]) != null) {
            p.a().b(context, g.a == 0);
            if (!c(context)) {
                return true;
            }
            Object a2 = i.a(s, "isX5Disabled", new Class[]{Integer.TYPE, Integer.TYPE, Integer.TYPE}, Integer.valueOf(i2), 44153, Integer.valueOf(i3));
            if (a2 == null && (a2 = i.a(s, "isX5Disabled", new Class[]{Integer.TYPE, Integer.TYPE}, Integer.valueOf(i2), 44153)) == null) {
                return true;
            }
            return ((Boolean) a2).booleanValue();
        } else {
            TbsLog.e("QbSdk", "isSuiteableGetSensitative check failed,can not use x5");
            return false;
        }
    }

    @SuppressLint({"NewApi"})
    private static boolean a(Context context, boolean z2) {
        int i2;
        File file;
        TbsLog.initIfNeed(context);
        if (!sIsVersionPrinted) {
            TbsLog.i("QbSdk", "svn revision: jnizz; SDK_VERSION_CODE: 44153; SDK_VERSION_NAME: 4.3.0.253");
            sIsVersionPrinted = true;
        }
        if (a && !z2) {
            TbsCoreLoadStat.getInstance().a(context, TbsListener.ErrorCode.INFO_SDKINIT_IS_SYS_FORCED);
            TbsLog.e("QbSdk", "init", "Force WebView Inner, " + w);
            return false;
        } else if (b) {
            TbsCoreLoadStat.getInstance().a(context, TbsListener.ErrorCode.INFO_FORCE_SYSTEM_WEBVIEW_OUTER);
            TbsLog.e("QbSdk", "init", "QbSdk init mIsSysWebViewForcedByOuter = true, " + v);
            return false;
        } else {
            if (!D) {
                d(context);
            }
            try {
                File r2 = p.a().r(context);
                if (r2 == null) {
                    TbsCoreLoadStat.getInstance().a(context, TbsListener.ErrorCode.ERROR_TBSCORE_SHARE_DIR, new Throwable("QbSdk.init (false) TbsCoreShareDir is null"));
                    return false;
                }
                if (TbsShareManager.isThirdPartyApp(context)) {
                    if (p == 0 || p == TbsShareManager.d(context)) {
                        i2 = TbsShareManager.d(context);
                    } else {
                        r = null;
                        s = null;
                        TbsCoreLoadStat.getInstance().a(context, TbsListener.ErrorCode.ERROR_UNMATCH_TBSCORE_VER_THIRDPARTY);
                        TbsLog.w("QbSdk", "init", "return false, thirdParty not match TBS core ver, details:sTbsVersion: " + p + "; AvailableTbsCoreVersion: " + TbsShareManager.d(context));
                        return false;
                    }
                } else if (p != 0) {
                    i2 = p.a().a(true, context);
                    if (p != i2) {
                        r = null;
                        s = null;
                        TbsCoreLoadStat instance = TbsCoreLoadStat.getInstance();
                        instance.a(context, TbsListener.ErrorCode.ERROR_UNMATCH_TBSCORE_VER, new Throwable("sTbsVersion: " + p + "; tbsCoreInstalledVer: " + i2));
                        return false;
                    }
                } else {
                    i2 = 0;
                }
                p = i2;
                if (TbsDownloader.a(context, p)) {
                    TbsLog.i("QbSdk", "init", "version " + p + " is in blacklist,can not load! return");
                    return false;
                } else if (r != null && s != null) {
                    return true;
                } else {
                    if (!TbsShareManager.isThirdPartyApp(context)) {
                        file = new File(p.a().r(context), "tbs_sdk_extension_dex.jar");
                    } else if (TbsShareManager.j(context)) {
                        file = new File(TbsShareManager.c(context), "tbs_sdk_extension_dex.jar");
                    } else {
                        TbsCoreLoadStat.getInstance().a(context, TbsListener.ErrorCode.ERROR_HOST_UNAVAILABLE, new Throwable("isShareTbsCoreAvailable false!"));
                        return false;
                    }
                    if (!file.exists()) {
                        try {
                            int j2 = p.a().j(context);
                            File file2 = new File(file.getParentFile(), "tbs_jars_fusion_dex.jar");
                            TbsCoreLoadStat.getInstance().a(context, TbsListener.ErrorCode.INFO_MISS_SDKEXTENSION_JAR);
                            TbsLog.w("QbSdk", "init", "[loadMsg] extension is miss, fusion exist is " + file2.exists() + ", core is " + j2 + ", dexPath is " + file.getPath());
                        } catch (Throwable th) {
                            th.printStackTrace();
                        }
                        return false;
                    }
                    String hostCorePathAppDefined = TbsShareManager.getHostCorePathAppDefined() != null ? TbsShareManager.getHostCorePathAppDefined() : r2.getAbsolutePath();
                    TbsLog.i("QbSdk", "init", "optDirExtension #1 is " + hostCorePathAppDefined);
                    TbsLog.i("QbSdk", "init", "new DexLoader #1 dexFile is " + file.getAbsolutePath());
                    x.a().b(context);
                    m.a(context);
                    r = new DexLoader(file.getParent(), context, new String[]{file.getAbsolutePath()}, hostCorePathAppDefined, getSettings()).loadClass("com.tencent.tbs.sdk.extension.TbsSDKExtension");
                    if (isEnableSensitiveApi() || i.a(r, "isSuiteableGetSensitative", (Class<?>[]) new Class[0], new Object[0]) != null) {
                        loadTBSSDKExtension(context, file.getParent());
                        i.a(s, "setClientVersion", new Class[]{Integer.TYPE}, 1);
                        return true;
                    }
                    TbsLog.e("QbSdk", "init", "isSuiteableGetSensitative check failed, can not use x5");
                    return false;
                }
            } catch (Throwable th2) {
                TbsLog.e("QbSdk", "QbSdk init Throwable: " + Log.getStackTraceString(th2));
                TbsCoreLoadStat.getInstance().a(context, TbsListener.ErrorCode.THROWABLE_QBSDK_INIT, th2);
                return false;
            }
        }
    }

    /* JADX WARNING: Removed duplicated region for block: B:72:0x01d3  */
    /* JADX WARNING: Removed duplicated region for block: B:74:0x01e9 A[ADDED_TO_REGION] */
    static boolean a(Context context, boolean z2, boolean z3) {
        boolean z4;
        TbsCoreLoadStat tbsCoreLoadStat;
        Throwable th;
        int i2;
        int i3;
        String str;
        TbsLog.i("QbSdk", "canLoadX5", "#1# installTbsCoreIfNeeded");
        boolean z5 = true;
        p.a().b(context, g.a == 0);
        int disabledCoreVersion = TbsPVConfig.getInstance(context).getDisabledCoreVersion();
        if (disabledCoreVersion == 0 || disabledCoreVersion != p.a().j(context)) {
            if (TbsShareManager.isThirdPartyApp(context)) {
                TbsLog.i("QbSdk", "canLoadX5", "#2# isThirdPartyApp");
                if (!TbsShareManager.i(context)) {
                    TbsLog.w("QbSdk", "canLoadX5", "#2-3# thirdParty no core available before init");
                    TbsCoreLoadStat.getInstance().a(context, TbsListener.ErrorCode.ERROR_UNMATCH_TBSCORE_VER_THIRDPARTY);
                    return false;
                }
            }
            if (!a(context, z2)) {
                TbsLog.e("QbSdk", "canLoadX5", "#2-4# QbSdk.init failure!");
                return false;
            }
            Object a2 = i.a(s, "canLoadX5Core", new Class[]{Integer.TYPE}, 44153);
            StringBuilder sb = new StringBuilder();
            sb.append("#3# invoke sExtensionObj canLoadX5Core and ret is ");
            sb.append(a2 != null);
            TbsLog.i("QbSdk", "canLoadX5", sb.toString());
            if (a2 == null) {
                Object a3 = i.a(s, "canLoadX5", new Class[]{Integer.TYPE}, Integer.valueOf(a.a()));
                if (a3 == null) {
                    TbsCoreLoadStat.getInstance().a(context, TbsListener.ErrorCode.ERROR_CANLOADX5_RETURN_NULL);
                } else if ((a3 instanceof String) && ((String) a3).equalsIgnoreCase("AuthenticationFail")) {
                    return false;
                } else {
                    if (a3 instanceof Boolean) {
                        p = g.d();
                        boolean a4 = a(context, g.d());
                        Boolean bool = (Boolean) a3;
                        if (!bool.booleanValue() || a4) {
                            z5 = false;
                        }
                        if (!z5) {
                            TbsLog.e(TbsListener.tag_load_error, "318");
                            TbsLog.w(TbsListener.tag_load_error, "isX5Disable:" + a4);
                            TbsLog.w(TbsListener.tag_load_error, "(Boolean) ret:" + bool);
                        }
                        return z5;
                    }
                }
                z4 = false;
            } else if ((a2 instanceof String) && ((String) a2).equalsIgnoreCase("AuthenticationFail")) {
                TbsLog.e("QbSdk", "canLoadX5", "[LoadError] authenticationFail");
                return false;
            } else if (!(a2 instanceof Bundle)) {
                TbsCoreLoadStat instance = TbsCoreLoadStat.getInstance();
                instance.a(context, TbsListener.ErrorCode.ERROR_QBSDK_INIT_ERROR_RET_TYPE_NOT_BUNDLE, new Throwable("" + a2));
                TbsLog.e("QbSdk", "canLoadX5", "[LoadError] ret not instance of bundle, ret:" + a2);
                return false;
            } else {
                Bundle bundle = (Bundle) a2;
                if (bundle.isEmpty()) {
                    TbsCoreLoadStat instance2 = TbsCoreLoadStat.getInstance();
                    instance2.a(context, TbsListener.ErrorCode.ERROR_QBSDK_INIT_ERROR_EMPTY_BUNDLE, new Throwable("" + a2));
                    TbsLog.e("QbSdk", "canLoadX5", "[LoadError] empty bundle" + a2);
                    return false;
                }
                int i4 = -1;
                try {
                    i4 = bundle.getInt(FontsContractCompat.Columns.RESULT_CODE, -1);
                } catch (Exception e2) {
                    TbsLog.e("QbSdk", "bundle.getInt(KEY_RESULT_CODE) error : " + e2.toString());
                }
                z4 = i4 == 0;
                if (TbsShareManager.isThirdPartyApp(context)) {
                    g.a(TbsShareManager.d(context));
                    q = String.valueOf(TbsShareManager.d(context));
                    if (q.length() == 5) {
                        q = DeviceId.CUIDInfo.I_EMPTY + q;
                    }
                    if (q.length() != 6) {
                        q = "";
                    }
                } else {
                    try {
                        if (Build.VERSION.SDK_INT >= 12) {
                            str = bundle.getString("tbs_core_version", DeviceId.CUIDInfo.I_EMPTY);
                        } else {
                            q = bundle.getString("tbs_core_version");
                            if (q == null) {
                                str = DeviceId.CUIDInfo.I_EMPTY;
                            }
                            p = Integer.parseInt(q);
                            g.a(p);
                            i3 = p;
                            if (i3 != 0) {
                                TbsCoreLoadStat.getInstance().a(context, TbsListener.ErrorCode.ERROR_CANLOADX5_RETURN_FALSE, new Throwable("sTbsVersion is 0"));
                                TbsLog.e("QbSdk", "canLoadX5", "[LoadError] sTbsVersion is 0");
                                return false;
                            }
                            if ((i3 <= 0 || i3 > 25442) && p != 25472) {
                                z5 = false;
                            }
                            if (z5) {
                                FileUtil.b(p.a().r(context));
                                TbsCoreLoadStat instance3 = TbsCoreLoadStat.getInstance();
                                instance3.a(context, TbsListener.ErrorCode.ERROR_CANLOADX5_RETURN_FALSE, new Throwable("is_obsolete --> delete old core:" + p));
                                TbsLog.e("QbSdk", "canLoadX5", "is_obsolete --> delete old core:" + p);
                                return false;
                            }
                        }
                        q = str;
                    } catch (Exception unused) {
                        q = DeviceId.CUIDInfo.I_EMPTY;
                    }
                    try {
                        p = Integer.parseInt(q);
                    } catch (NumberFormatException unused2) {
                        p = 0;
                    }
                    g.a(p);
                    i3 = p;
                    if (i3 != 0) {
                    }
                }
                try {
                    u = bundle.getStringArray("tbs_jarfiles");
                    if (!(u instanceof String[])) {
                        TbsCoreLoadStat instance4 = TbsCoreLoadStat.getInstance();
                        instance4.a(context, TbsListener.ErrorCode.ERROR_CANLOADX5_RETURN_FALSE, new Throwable("sJarFiles not instanceof String[]: " + u));
                        TbsLog.e("QbSdk", "canLoadX5", "sJarFiles not instanceof String[]: " + u);
                        return false;
                    }
                    try {
                        d = bundle.getString("tbs_librarypath");
                        Object obj = null;
                        if (i4 != 0) {
                            try {
                                obj = i.a(s, "getErrorCodeForLogReport", new Class[0], new Object[0]);
                            } catch (Exception e3) {
                                e3.printStackTrace();
                            }
                        }
                        switch (i4) {
                            case -2:
                                if (obj instanceof Integer) {
                                    tbsCoreLoadStat = TbsCoreLoadStat.getInstance();
                                    i2 = ((Integer) obj).intValue();
                                    th = new Throwable("detail: " + obj);
                                } else {
                                    tbsCoreLoadStat = TbsCoreLoadStat.getInstance();
                                    i2 = TbsListener.ErrorCode.INFO_DISABLE_X5;
                                    th = new Throwable("detail: " + obj);
                                }
                                tbsCoreLoadStat.a(context, i2, th);
                                break;
                            case -1:
                                if (!(obj instanceof Integer)) {
                                    TbsCoreLoadStat instance5 = TbsCoreLoadStat.getInstance();
                                    instance5.a(context, TbsListener.ErrorCode.ERROR_CANLOADX5_RETURN_FALSE, new Throwable("detail: " + obj));
                                    break;
                                } else {
                                    tbsCoreLoadStat = TbsCoreLoadStat.getInstance();
                                    i2 = ((Integer) obj).intValue();
                                    th = new Throwable("detail: " + obj);
                                    tbsCoreLoadStat.a(context, i2, th);
                                    break;
                                }
                            case 0:
                                break;
                            default:
                                TbsCoreLoadStat instance6 = TbsCoreLoadStat.getInstance();
                                instance6.a(context, TbsListener.ErrorCode.INFO_INITX5_FALSE_DEFAULT, new Throwable("detail: " + obj + "errcode" + i4));
                                break;
                        }
                    } catch (Exception unused3) {
                        return false;
                    }
                } catch (Throwable th2) {
                    TbsCoreLoadStat.getInstance().a(context, TbsListener.ErrorCode.ERROR_GETSTRINGARRAY_JARFILE, th2);
                    return false;
                }
            }
            if (!z4) {
                TbsLog.w("QbSdk", "canLoadX5", "#4# error code: 319");
            }
            return z4;
        }
        TbsLog.e("QbSdk", "canLoadX5", "#2-1# force use sys by remote switch");
        return false;
    }

    protected static String b() {
        Object invokeStaticMethod;
        x a2 = x.a();
        if (a2 == null || !a2.b() || (invokeStaticMethod = a2.c().b().invokeStaticMethod("com.tencent.tbs.tbsshell.WebCoreProxy", "getGUID", new Class[0], new Object[0])) == null || !(invokeStaticMethod instanceof String)) {
            return null;
        }
        return (String) invokeStaticMethod;
    }

    static boolean b(Context context) {
        if (context == null) {
            return false;
        }
        try {
            if (!context.getApplicationInfo().packageName.contains("com.tencent.portfolio")) {
                return true;
            }
            TbsLog.i("QbSdk", "clearPluginConfigFile #1");
            String string = TbsDownloadConfig.getInstance(context).mPreferences.getString(TbsDownloadConfig.TbsConfigKey.KEY_APP_VERSIONNAME, null);
            String str = context.getPackageManager().getPackageInfo("com.tencent.portfolio", 0).versionName;
            TbsLog.i("QbSdk", "clearPluginConfigFile oldAppVersionName is " + string + " newAppVersionName is " + str);
            if (string == null) {
                return true;
            }
            if (string.contains(str)) {
                return true;
            }
            SharedPreferences sharedPreferences = context.getSharedPreferences("plugin_setting", 0);
            if (sharedPreferences == null) {
                return true;
            }
            SharedPreferences.Editor edit = sharedPreferences.edit();
            edit.clear();
            edit.commit();
            TbsLog.i("QbSdk", "clearPluginConfigFile done");
            return true;
        } catch (Throwable th) {
            TbsLog.i("QbSdk", "clearPluginConfigFile error is " + th.getMessage());
            return false;
        }
    }

    private static boolean c(Context context) {
        File file;
        try {
            if (r != null) {
                return true;
            }
            File r2 = p.a().r(context);
            if (r2 == null) {
                TbsLog.e("QbSdk", "QbSdk initForX5DisableConfig (false) optDir == null");
                return false;
            }
            if (!TbsShareManager.isThirdPartyApp(context)) {
                file = new File(p.a().r(context), "tbs_sdk_extension_dex.jar");
            } else if (TbsShareManager.j(context)) {
                file = new File(TbsShareManager.c(context), "tbs_sdk_extension_dex.jar");
            } else {
                TbsCoreLoadStat.getInstance().a(context, TbsListener.ErrorCode.ERROR_HOST_UNAVAILABLE);
                return false;
            }
            if (!file.exists()) {
                TbsCoreLoadStat.getInstance().a(context, TbsListener.ErrorCode.INFO_MISS_SDKEXTENSION_JAR_OLD, new Exception("initForX5DisableConfig failure -- tbs_sdk_extension_dex.jar is not exist!"));
                return false;
            }
            String hostCorePathAppDefined = TbsShareManager.getHostCorePathAppDefined() != null ? TbsShareManager.getHostCorePathAppDefined() : r2.getAbsolutePath();
            TbsLog.i("QbSdk", "QbSdk init optDirExtension #3 is " + hostCorePathAppDefined);
            TbsLog.i("QbSdk", "new DexLoader #4 dexFile is " + file.getAbsolutePath());
            x.a().b(context);
            m.a(context);
            r = new DexLoader(file.getParent(), context, new String[]{file.getAbsolutePath()}, hostCorePathAppDefined, getSettings()).loadClass("com.tencent.tbs.sdk.extension.TbsSDKExtension");
            if (isEnableSensitiveApi() || i.a(r, "isSuiteableGetSensitative", (Class<?>[]) new Class[0], new Object[0]) != null) {
                loadTBSSDKExtension(context, file.getParent());
                i.a(s, "setClientVersion", new Class[]{Integer.TYPE}, 1);
                return true;
            }
            TbsLog.e("QbSdk", "isSuiteableGetSensitative check failed,can not use x5");
            return false;
        } catch (Throwable th) {
            TbsLog.e("QbSdk", "initForX5DisableConfig sys WebView: " + Log.getStackTraceString(th));
            return false;
        }
    }

    @Deprecated
    public static void canGetAndroidId(boolean z2) {
        TbsPrivacyAccess.AndroidId.setEnabled(z2);
    }

    @Deprecated
    public static void canGetDeviceId(boolean z2) {
        TbsPrivacyAccess.DeviceId.setEnabled(z2);
    }

    @Deprecated
    public static void canGetSubscriberId(boolean z2) {
        TbsPrivacyAccess.Imsi.setEnabled(z2);
    }

    /* JADX WARNING: Removed duplicated region for block: B:10:? A[RETURN, SYNTHETIC] */
    /* JADX WARNING: Removed duplicated region for block: B:8:0x0036  */
    public static boolean canLoadVideo(Context context) {
        int i2;
        TbsCoreLoadStat tbsCoreLoadStat;
        Object a2 = i.a(s, "canLoadVideo", new Class[]{Integer.TYPE}, 0);
        if (a2 != null) {
            if (!((Boolean) a2).booleanValue()) {
                tbsCoreLoadStat = TbsCoreLoadStat.getInstance();
                i2 = TbsListener.ErrorCode.ERROR_CANLOADVIDEO_RETURN_FALSE;
            }
            if (a2 != null) {
                return false;
            }
            return ((Boolean) a2).booleanValue();
        }
        tbsCoreLoadStat = TbsCoreLoadStat.getInstance();
        i2 = TbsListener.ErrorCode.ERROR_CANLOADVIDEO_RETURN_NULL;
        tbsCoreLoadStat.a(context, i2);
        if (a2 != null) {
        }
    }

    public static boolean canLoadX5(Context context) {
        return a(context, false, false);
    }

    public static boolean canLoadX5FirstTimeThirdApp(Context context) {
        try {
            if (context.getApplicationInfo().packageName.contains("com.moji.mjweather") && Build.VERSION.SDK_INT == 19) {
                return true;
            }
            if (r == null) {
                File r2 = p.a().r(context);
                if (r2 == null) {
                    TbsLog.e("QbSdk", "QbSdk canLoadX5FirstTimeThirdApp (false) optDir == null");
                    return false;
                }
                File file = new File(TbsShareManager.c(context), "tbs_sdk_extension_dex.jar");
                if (!file.exists()) {
                    TbsLog.e("QbSdk", "QbSdk canLoadX5FirstTimeThirdApp (false) dexFile.exists()=false", true);
                    return false;
                }
                String hostCorePathAppDefined = TbsShareManager.getHostCorePathAppDefined() != null ? TbsShareManager.getHostCorePathAppDefined() : r2.getAbsolutePath();
                TbsLog.i("QbSdk", "QbSdk init optDirExtension #2 is " + hostCorePathAppDefined);
                TbsLog.i("QbSdk", "new DexLoader #2 dexFile is " + file.getAbsolutePath());
                x.a().b(context);
                m.a(context);
                r = new DexLoader(file.getParent(), context, new String[]{file.getAbsolutePath()}, hostCorePathAppDefined, getSettings()).loadClass("com.tencent.tbs.sdk.extension.TbsSDKExtension");
                if (s == null) {
                    if (TbsShareManager.e(context) == null && TbsShareManager.getHostCorePathAppDefined() == null) {
                        TbsLogReport.getInstance(context.getApplicationContext()).setLoadErrorCode(TbsListener.ErrorCode.HOST_CONTEXT_IS_NULL, "host context is null!");
                        return false;
                    } else if (isEnableSensitiveApi() || i.a(r, "isSuiteableGetSensitative", (Class<?>[]) new Class[0], new Object[0]) != null) {
                        loadTBSSDKExtension(context, file.getParent());
                    } else {
                        TbsLog.e("QbSdk", "isSuiteableGetSensitative check failed,can not use x5");
                        return false;
                    }
                }
            }
            Object a2 = i.a(s, "canLoadX5CoreForThirdApp", new Class[0], new Object[0]);
            if (a2 == null || !(a2 instanceof Boolean)) {
                return false;
            }
            return ((Boolean) a2).booleanValue();
        } catch (Throwable th) {
            TbsLog.e("QbSdk", "canLoadX5FirstTimeThirdApp sys WebView: " + Log.getStackTraceString(th));
            return false;
        }
    }

    public static void canOpenFile(final Context context, final String str, final ValueCallback<Boolean> valueCallback) {
        new Thread() {
            /* class com.tencent.smtt.sdk.QbSdk.AnonymousClass1 */

            public void run() {
                x a2 = x.a();
                a2.a(context);
                final boolean a3 = a2.b() ? a2.c().a(context, str) : false;
                new Handler(Looper.getMainLooper()).post(new Runnable() {
                    /* class com.tencent.smtt.sdk.QbSdk.AnonymousClass1.AnonymousClass1 */

                    public void run() {
                        valueCallback.onReceiveValue(Boolean.valueOf(a3));
                    }
                });
            }
        }.start();
    }

    public static boolean canOpenMimeFileType(Context context, String str) {
        if (!a(context, false)) {
        }
        return false;
    }

    /* JADX WARN: Multi-variable type inference failed */
    /* JADX WARN: Type inference failed for: r5v6, types: [java.io.FileInputStream, java.io.InputStream] */
    /* JADX WARN: Type inference failed for: r0v11, types: [java.util.Properties] */
    /* JADX WARNING: Removed duplicated region for block: B:53:0x00f8 A[SYNTHETIC, Splitter:B:53:0x00f8] */
    /* JADX WARNING: Removed duplicated region for block: B:61:0x0101 A[SYNTHETIC, Splitter:B:61:0x0101] */
    /* JADX WARNING: Removed duplicated region for block: B:79:0x0134 A[SYNTHETIC, Splitter:B:79:0x0134] */
    /* JADX WARNING: Removed duplicated region for block: B:84:0x013a A[SYNTHETIC, Splitter:B:84:0x013a] */
    /* JADX WARNING: Unknown variable types count: 2 */
    public static boolean canOpenWebPlus(Context context) {
        Throwable th;
        Throwable th2;
        Throwable th3;
        BufferedInputStream bufferedInputStream;
        if (y == 0) {
            y = a.a();
        }
        TbsLog.i("QbSdk", "canOpenWebPlus - totalRAM: " + y);
        boolean z2 = false;
        if (Build.VERSION.SDK_INT < 7 || y < z || context == null) {
            return false;
        }
        BufferedInputStream bufferedInputStream2 = null;
        try {
            BufferedInputStream bufferedInputStream3 = new BufferedInputStream(new FileInputStream(new File(p.a().r(context), "tbs.conf")));
            try {
                Properties properties = new Properties();
                properties.load(bufferedInputStream3);
                String property = properties.getProperty("android_sdk_max_supported");
                String property2 = properties.getProperty("android_sdk_min_supported");
                int parseInt = Integer.parseInt(property);
                int parseInt2 = Integer.parseInt(property2);
                int parseInt3 = Integer.parseInt(Build.VERSION.SDK);
                if (parseInt3 <= parseInt) {
                    if (parseInt3 >= parseInt2) {
                        int parseInt4 = Integer.parseInt(properties.getProperty("tbs_core_version"));
                        try {
                            bufferedInputStream3.close();
                        } catch (Exception unused) {
                        }
                        try {
                            ?? fileInputStream = new FileInputStream(new File(p.t(context), "tbs_extension.conf"));
                            try {
                                ?? properties2 = new Properties();
                                properties2.load(fileInputStream);
                                int parseInt5 = Integer.parseInt(properties2.getProperty("tbs_local_version"));
                                int parseInt6 = Integer.parseInt(properties2.getProperty(TbsDownloadConfig.TbsConfigKey.KEY_APP_VERSIONCODE_FOR_SWITCH));
                                if (parseInt4 != 88888888) {
                                    if (parseInt5 != 88888888) {
                                        if (parseInt4 <= parseInt5) {
                                            if (parseInt4 == parseInt5) {
                                                if (parseInt6 <= 0 || parseInt6 == b.e(context)) {
                                                    if (Boolean.parseBoolean(properties2.getProperty("x5_disabled")) && !TbsDownloadConfig.getInstance(context.getApplicationContext()).mPreferences.getBoolean(TbsDownloadConfig.TbsConfigKey.KEY_SWITCH_BACKUPCORE_ENABLE, false)) {
                                                        z2 = true;
                                                    }
                                                }
                                            }
                                        }
                                    }
                                }
                                try {
                                    fileInputStream.close();
                                } catch (Exception unused2) {
                                }
                            } catch (Throwable th4) {
                                th3 = th4;
                                bufferedInputStream = fileInputStream;
                                if (bufferedInputStream != null) {
                                }
                                throw th3;
                            }
                        } catch (Throwable unused3) {
                            TbsLog.i("QbSdk", "canOpenWebPlus - isX5Disabled Exception");
                            if (bufferedInputStream2 != null) {
                            }
                            z2 = true;
                            return !z2;
                        }
                        return !z2;
                    }
                }
                TbsLog.i("QbSdk", "canOpenWebPlus - sdkVersion: " + parseInt3);
                try {
                    bufferedInputStream3.close();
                } catch (Exception unused4) {
                }
                return false;
            } catch (Throwable th5) {
                th = th5;
                if (bufferedInputStream3 != null) {
                }
                throw th;
            }
        } catch (Throwable th6) {
            th2 = th6;
            th2.printStackTrace();
            TbsLog.i("QbSdk", "canOpenWebPlus - canLoadX5 Exception");
            if (bufferedInputStream2 != null) {
                try {
                    bufferedInputStream2.close();
                } catch (Exception unused5) {
                }
            }
            return false;
        }
    }

    public static boolean canUseVideoFeatrue(Context context, int i2) {
        Object a2 = i.a(s, "canUseVideoFeatrue", new Class[]{Integer.TYPE}, Integer.valueOf(i2));
        if (a2 == null || !(a2 instanceof Boolean)) {
            return false;
        }
        return ((Boolean) a2).booleanValue();
    }

    public static boolean checkApkExist(Context context, String str) {
        if (str != null && !"".equals(str)) {
            try {
                context.getPackageManager().getApplicationInfo(str, 8192);
                return true;
            } catch (PackageManager.NameNotFoundException unused) {
            }
        }
        return false;
    }

    public static boolean checkContentProviderPrivilage(Context context) {
        if (context == null || context.getApplicationInfo().targetSdkVersion < 24 || Build.VERSION.SDK_INT < 24 || TbsConfig.APP_QQ.equals(context.getApplicationInfo().packageName)) {
            return true;
        }
        try {
            if (!TextUtils.isEmpty(context.getPackageManager().getProviderInfo(new ComponentName(context.getPackageName(), "androidx.core.content.FileProvider"), 0).authority)) {
                return true;
            }
        } catch (Exception e2) {
            e2.printStackTrace();
        }
        PackageManager packageManager = context.getPackageManager();
        ProviderInfo resolveContentProvider = packageManager.resolveContentProvider(context.getApplicationInfo().packageName + ".provider", 128);
        if (resolveContentProvider == null) {
            Log.e("QbSdk", "Must declare com.tencent.smtt.utils.FileProvider in AndroidManifest above Android 7.0,please view document in x5.tencent.com");
        }
        return resolveContentProvider != null;
    }

    public static void checkTbsValidity(Context context) {
        if (context != null && !m.b(context)) {
            TbsLog.e("QbSdk", "sys WebView: SysWebViewForcedBy checkTbsValidity");
            TbsCoreLoadStat.getInstance().a(context, TbsListener.ErrorCode.INFO_CORE_CHECK_VALIDITY_FALSE);
            forceSysWebView();
        }
    }

    public static void clear(Context context) {
    }

    public static void clearAllDefaultBrowser(Context context) {
        context.getSharedPreferences(SHARE_PREFERENCES_NAME, 0).edit().clear().commit();
    }

    /* JADX WARNING: Removed duplicated region for block: B:17:0x0068  */
    /* JADX WARNING: Removed duplicated region for block: B:19:0x0070 A[SYNTHETIC, Splitter:B:19:0x0070] */
    public static void clearAllWebViewCache(Context context, boolean z2) {
        boolean z3;
        Throwable th;
        TbsLog.i("QbSdk", "clearAllWebViewCache(" + context + ", " + z2 + ")");
        boolean z4 = false;
        try {
            if (new WebView(context).getWebViewClientExtension() != null) {
                try {
                    x a2 = x.a();
                    if (a2 != null && a2.b()) {
                        a2.c().a(context, z2);
                    }
                    z4 = true;
                } catch (Throwable th2) {
                    th = th2;
                    z3 = true;
                    TbsLog.e("QbSdk", "clearAllWebViewCache exception 2 -- " + Log.getStackTraceString(th));
                    z4 = z3;
                    if (z4) {
                    }
                }
            }
        } catch (Throwable th3) {
            th = th3;
            z3 = false;
            TbsLog.e("QbSdk", "clearAllWebViewCache exception 2 -- " + Log.getStackTraceString(th));
            z4 = z3;
            if (z4) {
            }
        }
        if (z4) {
            TbsLog.i("QbSdk", "is_in_x5_mode --> no need to clear system webview!");
            return;
        }
        try {
            WebView webView = new WebView(context);
            if (Build.VERSION.SDK_INT >= 11) {
                webView.removeJavascriptInterface("searchBoxJavaBridge_");
                webView.removeJavascriptInterface("accessibility");
                webView.removeJavascriptInterface("accessibilityTraversal");
            }
            webView.clearCache(true);
            if (z2) {
                CookieSyncManager.createInstance(context);
                CookieManager.getInstance().removeAllCookie();
            }
            WebViewDatabase.getInstance(context).clearUsernamePassword();
            WebViewDatabase.getInstance(context).clearHttpAuthUsernamePassword();
            WebViewDatabase.getInstance(context).clearFormData();
            WebStorage.getInstance().deleteAllData();
            WebIconDatabase.getInstance().removeAllIcons();
        } catch (Throwable th4) {
            TbsLog.e("QbSdk", "clearAllWebViewCache exception 1 -- " + Log.getStackTraceString(th4));
        }
    }

    public static void clearDefaultBrowser(Context context, String str) {
        SharedPreferences sharedPreferences = context.getSharedPreferences(SHARE_PREFERENCES_NAME, 0);
        String d2 = e.d(str);
        if (TextUtils.isEmpty(d2)) {
            d2 = "*/*";
        }
        SharedPreferences.Editor edit = sharedPreferences.edit();
        edit.remove("key_tbs_picked_default_browser_" + d2).commit();
    }

    public static void closeFileReader(Context context) {
        x a2 = x.a();
        a2.a(context);
        if (a2.b()) {
            a2.c().p();
        }
    }

    public static String closeNetLogAndSavaToLocal() {
        x a2 = x.a();
        if (a2 == null || !a2.b()) {
            return "";
        }
        try {
            Object invokeStaticMethod = a2.c().b().invokeStaticMethod("com.tencent.smtt.livelog.NetLogManager", "closeNetLogAndSavaToLocal", new Class[0], new Object[0]);
            return (invokeStaticMethod == null || !(invokeStaticMethod instanceof String)) ? "" : (String) invokeStaticMethod;
        } catch (Exception unused) {
            return "";
        }
    }

    public static void configurePrivacy(Context context, TbsPrivacyAccess.ConfigurablePrivacy configurablePrivacy, String str) {
        TbsPrivacyAccess.configurePrivacy(context, configurablePrivacy, str);
    }

    public static void continueLoadSo(Context context) {
        if (TbsConfig.APP_WX.equals(getCurrentProcessName(context)) && WebView.mWebViewCreated) {
            i.a(s, "continueLoadSo", new Class[0], new Object[0]);
        }
    }

    public static boolean createMiniQBShortCut(Context context, String str, String str2, Drawable drawable) {
        x a2;
        if (!(context == null || TbsDownloader.getOverSea(context) || isMiniQBShortCutExist(context, str, str2) || (a2 = x.a()) == null || !a2.b())) {
            Bitmap bitmap = null;
            if (drawable instanceof BitmapDrawable) {
                bitmap = ((BitmapDrawable) drawable).getBitmap();
            }
            DexLoader b2 = a2.c().b();
            TbsLog.e("QbSdk", "qbsdk createMiniQBShortCut");
            Object invokeStaticMethod = b2.invokeStaticMethod("com.tencent.tbs.tbsshell.WebCoreProxy", "createMiniQBShortCut", new Class[]{Context.class, String.class, String.class, Bitmap.class}, context, str, str2, bitmap);
            TbsLog.e("QbSdk", "qbsdk after createMiniQBShortCut ret: " + invokeStaticMethod);
            if (invokeStaticMethod != null) {
                return true;
            }
        }
        return false;
    }

    /* JADX WARNING: Removed duplicated region for block: B:32:0x0080  */
    /* JADX WARNING: Removed duplicated region for block: B:45:0x0101  */
    private static void d(Context context) {
        int i2;
        int i3;
        int i4;
        String str;
        String str2;
        Throwable th;
        D = true;
        int i5 = 0;
        SharedPreferences sharedPreferences = null;
        try {
            sharedPreferences = Build.VERSION.SDK_INT >= 11 ? context.getSharedPreferences("tbs_preloadx5_check_cfg_file", 4) : context.getSharedPreferences("tbs_preloadx5_check_cfg_file", 0);
            int i6 = sharedPreferences.getInt("tbs_preload_x5_recorder", -1);
            if (i6 >= 0) {
                i6++;
                if (i6 <= 4) {
                    i3 = i6;
                } else {
                    return;
                }
            } else {
                i3 = -1;
            }
            try {
                i2 = p.a().j(context);
                if (i2 > 0) {
                    if (i6 <= 4) {
                        try {
                            sharedPreferences.edit().putInt("tbs_preload_x5_recorder", i6).commit();
                        } catch (Throwable th2) {
                            th = th2;
                            TbsLog.e("QbSdk", "tbs_preload_x5_counter Inc exception:" + Log.getStackTraceString(th));
                            i4 = -1;
                            if (i4 > 3) {
                            }
                        }
                    }
                    int i7 = sharedPreferences.getInt("tbs_preload_x5_counter", -1);
                    if (i7 >= 0) {
                        i4 = i7 + 1;
                        sharedPreferences.edit().putInt("tbs_preload_x5_counter", i4).commit();
                        if (i4 > 3) {
                            try {
                                int i8 = sharedPreferences.getInt("tbs_preload_x5_version", -1);
                                SharedPreferences.Editor edit = sharedPreferences.edit();
                                if (i8 == i2) {
                                    FileUtil.a(p.a().r(context), false);
                                    File a2 = n.a(context).a();
                                    if (a2 != null) {
                                        FileUtil.a(a2, false);
                                    }
                                    str = "QbSdk";
                                    str2 = "QbSdk - preload_x5_check: tbs core " + i2 + " is deleted!";
                                } else {
                                    str = "QbSdk";
                                    str2 = "QbSdk - preload_x5_check -- reset exception core_ver:" + i2 + "; value:" + i8;
                                }
                                TbsLog.e(str, str2);
                                edit.putInt("tbs_precheck_disable_version", i8);
                                edit.commit();
                                return;
                            } catch (Throwable th3) {
                                TbsLog.e("QbSdk", "tbs_preload_x5_counter disable version exception:" + Log.getStackTraceString(th3));
                                return;
                            }
                        } else {
                            if (i3 <= 0 || i3 > 3) {
                                i5 = -1;
                            } else {
                                TbsLog.i("QbSdk", "QbSdk - preload_x5_check -- before creation!");
                                x.a().a(context);
                                TbsLog.i("QbSdk", "QbSdk - preload_x5_check -- after creation!");
                            }
                            try {
                                int i9 = sharedPreferences.getInt("tbs_preload_x5_counter", -1);
                                if (i9 > 0) {
                                    sharedPreferences.edit().putInt("tbs_preload_x5_counter", i9 - 1).commit();
                                }
                            } catch (Throwable th4) {
                                TbsLog.e("QbSdk", "tbs_preload_x5_counter Dec exception:" + Log.getStackTraceString(th4));
                            }
                            TbsLog.i("QbSdk", "QbSdk -- preload_x5_check result:" + i5);
                            return;
                        }
                    }
                    i4 = -1;
                    if (i4 > 3) {
                    }
                }
            } catch (Throwable th5) {
                th = th5;
                i2 = -1;
                TbsLog.e("QbSdk", "tbs_preload_x5_counter Inc exception:" + Log.getStackTraceString(th));
                i4 = -1;
                if (i4 > 3) {
                }
            }
        } catch (Throwable th6) {
            th = th6;
            i3 = -1;
            i2 = -1;
            TbsLog.e("QbSdk", "tbs_preload_x5_counter Inc exception:" + Log.getStackTraceString(th));
            i4 = -1;
            if (i4 > 3) {
            }
        }
    }

    public static boolean deleteMiniQBShortCut(Context context, String str, String str2) {
        x a2;
        if (context != null && !TbsDownloader.getOverSea(context) && (a2 = x.a()) != null && a2.b()) {
            if (a2.c().b().invokeStaticMethod("com.tencent.tbs.tbsshell.WebCoreProxy", "deleteMiniQBShortCut", new Class[]{Context.class, String.class, String.class}, context, str, str2) != null) {
                return true;
            }
        }
        return false;
    }

    public static void deleteStableCore(Context context, int i2) {
        try {
            TbsLog.i("QbSdk", "QbSdk deleteStableCore #00");
            if (!r.b(context)) {
                TbsLog.i("QbSdk", "QbSdk deleteStableCore switch stable core close");
            } else if (context.getApplicationInfo().packageName.contains(TbsConfig.APP_WX)) {
                Context packageContext = TbsShareManager.getPackageContext(context, TbsConfig.APP_WX, false);
                File file = packageContext == null ? new File(FileUtil.a(context, TbsConfig.APP_WX, 4, true)) : new File(FileUtil.a(packageContext, 4));
                TbsLog.i("QbSdk", "QbSdk deleteStableCore mFilePathStable is " + file.getAbsolutePath());
                if (TbsShareManager.getTbsStableCoreVersion(context, 32) == i2) {
                    a(context, file, 32, i2);
                }
                if (TbsShareManager.getTbsStableCoreVersion(context, 64) == i2) {
                    a(context, file, 64, i2);
                }
            }
        } catch (Throwable unused) {
        }
    }

    public static void disAllowThirdAppDownload() {
        c = false;
    }

    public static void disableAutoCreateX5Webview() {
        j = false;
    }

    @Deprecated
    public static void disableSensitiveApi() {
        TbsPrivacyAccess.disableSensitiveApi();
    }

    public static void fileInfoDetect(Context context, String str, ValueCallback<String> valueCallback) {
        x a2 = x.a();
        if (a2 != null && a2.b()) {
            try {
                a2.c().b().invokeStaticMethod("com.tencent.tbs.tbsshell.WebCoreProxy", "fileInfoDetect", new Class[]{Context.class, String.class, ValueCallback.class}, context, str, valueCallback);
            } catch (Throwable th) {
                th.printStackTrace();
            }
        }
    }

    public static void forceSysWebView() {
        b = true;
        v = "SysWebViewForcedByOuter: " + Log.getStackTraceString(new Throwable());
        TbsLog.e("QbSdk", "sys WebView: SysWebViewForcedByOuter");
    }

    public static long getApkFileSize(Context context) {
        if (context != null) {
            return TbsDownloadConfig.getInstance(context.getApplicationContext()).mPreferences.getLong(TbsDownloadConfig.TbsConfigKey.KEY_TBSAPKFILESIZE, 0);
        }
        return 0;
    }

    public static int getCoreMinVersion() {
        return I;
    }

    /* JADX WARNING: Removed duplicated region for block: B:12:0x0020 A[Catch:{ Throwable -> 0x0034 }] */
    /* JADX WARNING: Removed duplicated region for block: B:18:0x0030 A[SYNTHETIC, Splitter:B:18:0x0030] */
    /* JADX WARNING: Removed duplicated region for block: B:28:0x0041  */
    /* JADX WARNING: Removed duplicated region for block: B:34:0x004d A[SYNTHETIC, Splitter:B:34:0x004d] */
    public static String getCurrentProcessName(Context context) {
        Throwable th;
        FileInputStream fileInputStream;
        Throwable th2;
        try {
            fileInputStream = new FileInputStream("/proc/self/cmdline");
            try {
                byte[] bArr = new byte[256];
                int i2 = 0;
                while (true) {
                    int read = fileInputStream.read();
                    if (read > 0 && i2 < bArr.length) {
                        bArr[i2] = (byte) read;
                        i2++;
                    } else if (i2 <= 0) {
                        String str = new String(bArr, 0, i2, "UTF-8");
                        try {
                            fileInputStream.close();
                        } catch (IOException e2) {
                            e2.printStackTrace();
                        }
                        return str;
                    } else {
                        try {
                            fileInputStream.close();
                        } catch (IOException e3) {
                            e3.printStackTrace();
                        }
                        return null;
                    }
                }
                if (i2 <= 0) {
                }
            } catch (Throwable th3) {
                th2 = th3;
                try {
                    th2.printStackTrace();
                    if (fileInputStream != null) {
                    }
                    return null;
                } catch (Throwable th4) {
                    th = th4;
                    if (fileInputStream != null) {
                    }
                    throw th;
                }
            }
        } catch (Throwable th5) {
            fileInputStream = null;
            th = th5;
            if (fileInputStream != null) {
                try {
                    fileInputStream.close();
                } catch (IOException e4) {
                    e4.printStackTrace();
                }
            }
            throw th;
        }
    }

    public static String[] getDexLoaderFileList(Context context, Context context2, String str) {
        String[] strArr = u;
        if (strArr instanceof String[]) {
            int length = strArr.length;
            String[] strArr2 = new String[length];
            for (int i2 = 0; i2 < length; i2++) {
                strArr2[i2] = str + u[i2];
            }
            return strArr2;
        }
        Object a2 = i.a(s, "getJarFiles", new Class[]{Context.class, Context.class, String.class}, context, context2, str);
        if (!(a2 instanceof String[])) {
            a2 = new String[]{""};
        }
        return (String[]) a2;
    }

    public static boolean getDownloadWithoutWifi() {
        return G;
    }

    public static boolean getIsInitX5Environment() {
        return k;
    }

    public static boolean getIsSysWebViewForcedByOuter() {
        return b;
    }

    public static boolean getJarFilesAndLibraryPath(Context context) {
        Object obj = s;
        if (obj == null) {
            TbsLog.i("QbSdk", "getJarFilesAndLibraryPath sExtensionObj is null");
            return false;
        }
        Bundle bundle = (Bundle) i.a(obj, "canLoadX5CoreAndNotLoadSo", new Class[]{Integer.TYPE}, 44153);
        if (bundle == null) {
            TbsLog.i("QbSdk", "getJarFilesAndLibraryPath bundle is null and coreverison is " + p.a().a(true, context));
            return false;
        }
        u = bundle.getStringArray("tbs_jarfiles");
        d = bundle.getString("tbs_librarypath");
        return true;
    }

    public static String getMiniQBVersion(Context context) {
        x a2 = x.a();
        a2.a(context);
        if (a2 == null || !a2.b()) {
            return null;
        }
        return a2.c().f();
    }

    public static boolean getOnlyDownload() {
        return l;
    }

    public static String getQQBuildNumber() {
        return B;
    }

    public static Map<String, Object> getSettings() {
        return o;
    }

    public static boolean getTBSInstalling() {
        return H;
    }

    public static String getTID() {
        return A;
    }

    public static File getTbsFolderDir(Context context) {
        if (context == null) {
            return null;
        }
        try {
            if (b.b()) {
                return context.getDir("tbs_64", 0);
            }
        } catch (Exception e2) {
            e2.printStackTrace();
        }
        return context.getDir("tbs", 0);
    }

    public static String getTbsResourcesPath(Context context) {
        return TbsShareManager.g(context);
    }

    public static int getTbsSdkVersion() {
        return 44153;
    }

    public static int getTbsVersion(Context context) {
        return TbsShareManager.isThirdPartyApp(context) ? TbsShareManager.a(context, false) : p.a().j(context);
    }

    public static int getTbsVersionForCrash(Context context) {
        if (TbsShareManager.isThirdPartyApp(context)) {
            return TbsShareManager.a(context, false);
        }
        int k2 = p.a().k(context);
        if (k2 == 0 && n.a(context).c() == 3) {
            reset(context);
        }
        return k2;
    }

    public static int getTmpDirTbsVersion(Context context) {
        if (n.a(context).c() == 2) {
            return p.a().e(context, 0);
        }
        if (n.a(context).b("copy_status") == 1) {
            return p.a().e(context, 1);
        }
        return 0;
    }

    public static void initBuglyAsync(boolean z2) {
        i = z2;
    }

    public static void initForinitAndNotLoadSo(Context context) {
        String str;
        String str2;
        if (r == null) {
            File r2 = p.a().r(context);
            if (r2 == null) {
                str = "QbSdk";
                str2 = "QbSdk initForinitAndNotLoadSo optDir == null";
            } else {
                File file = new File(r2, "tbs_sdk_extension_dex.jar");
                if (!file.exists()) {
                    str = "QbSdk";
                    str2 = "QbSdk initForinitAndNotLoadSo dexFile.exists()=false";
                } else {
                    String absolutePath = r2.getAbsolutePath();
                    x.a().b(context);
                    m.a(context);
                    r = new DexLoader(file.getParent(), context, new String[]{file.getAbsolutePath()}, absolutePath, getSettings()).loadClass("com.tencent.tbs.sdk.extension.TbsSDKExtension");
                    return;
                }
            }
            Log.e(str, str2);
        }
    }

    public static void initTbsSettings(Map<String, Object> map) {
        Map<String, Object> map2 = o;
        if (map2 == null) {
            o = map;
            return;
        }
        try {
            map2.putAll(map);
        } catch (Exception e2) {
            e2.printStackTrace();
        }
    }

    public static void initX5Environment(final Context context, final PreInitCallback preInitCallback) {
        q.a().a("init_tbs_Start");
        TbsLog.initIfNeed(context);
        if (context == null) {
            TbsLog.e("QbSdk", "initX5Environment,context=null");
            return;
        }
        b(context);
        F = new TbsListener() {
            /* class com.tencent.smtt.sdk.QbSdk.AnonymousClass5 */

            @Override // com.tencent.smtt.sdk.TbsListener
            public void onDownloadFinish(int i) {
            }

            @Override // com.tencent.smtt.sdk.TbsListener
            public void onDownloadProgress(int i) {
            }

            @Override // com.tencent.smtt.sdk.TbsListener
            public void onInstallFinish(int i) {
                QbSdk.preInit(context, preInitCallback);
            }
        };
        if (TbsShareManager.isThirdPartyApp(context)) {
            p.a().b(context, g.a == 0);
        }
        TbsDownloader.needDownload(context, false, false, true, new TbsDownloader.TbsDownloaderCallback() {
            /* class com.tencent.smtt.sdk.QbSdk.AnonymousClass6 */

            @Override // com.tencent.smtt.sdk.TbsDownloader.TbsDownloaderCallback
            public void onNeedDownloadFinish(boolean z, int i) {
                if (TbsShareManager.findCoreForThirdPartyApp(context) == 0 && !TbsShareManager.getCoreDisabled()) {
                    TbsShareManager.forceToLoadX5ForThirdApp(context, false);
                }
                if (QbSdk.i && TbsShareManager.isThirdPartyApp(context)) {
                    TbsExtensionFunctionManager.getInstance().initTbsBuglyIfNeed(context);
                }
                QbSdk.preInit(context, preInitCallback);
            }
        });
        k = true;
    }

    public static boolean installLocalQbApk(Context context, String str, String str2, Bundle bundle) {
        g a2 = g.a(true);
        a2.a(context, false, false);
        if (a2 == null || !a2.b()) {
            return false;
        }
        return a2.a().a(context, str, str2, bundle);
    }

    public static void installLocalTbsCore(Context context, int i2, String str) {
        p.a().a(context, str, i2);
    }

    public static boolean intentDispatch(WebView webView, Intent intent, String str, String str2) {
        if (webView == null) {
            return false;
        }
        if (str.startsWith("mttbrowser://miniqb/ch=icon?")) {
            Context context = webView.getContext();
            int indexOf = str.indexOf("url=");
            str = indexOf > 0 ? str.substring(indexOf + 4) : null;
            HashMap hashMap = new HashMap();
            String str3 = EnvironmentCompat.MEDIA_UNKNOWN;
            try {
                str3 = context.getApplicationInfo().packageName;
            } catch (Exception e2) {
                e2.printStackTrace();
            }
            hashMap.put("ChannelID", str3);
            hashMap.put("PosID", "14004");
            if (MttLoader.loadUrl(context, "miniqb://home".equals(str) ? "qb://navicard/addCard?cardId=168&cardName=168" : str, hashMap, "QbSdk.startMiniQBToLoadUrl", null) != 0) {
                x a2 = x.a();
                if (a2 != null && a2.b() && a2.c().a(context, str, null, str2, null) == 0) {
                    return true;
                }
            }
            return false;
        }
        webView.loadUrl(str);
        return false;
    }

    public static boolean isCoreVerEnabled(Context context, int i2) {
        if (i2 >= I || i2 == 0 || !r.p(context)) {
            return true;
        }
        TbsCoreLoadStat.getInstance().a(context, TbsListener.ErrorCode.APP_SET_MIN_CORE_VER, new Throwable("QbSdk.setCoreMinVerison"));
        return false;
    }

    @Deprecated
    public static boolean isEnableCanGetSubscriberId() {
        return TbsPrivacyAccess.Imsi.isEnabled();
    }

    @Deprecated
    public static boolean isEnableGetAndroidID() {
        return TbsPrivacyAccess.AndroidId.isEnabled();
    }

    @Deprecated
    public static boolean isEnableGetDeviceID() {
        return TbsPrivacyAccess.DeviceId.isEnabled();
    }

    @Deprecated
    public static boolean isEnableSensitiveApi() {
        return TbsPrivacyAccess.isEnableSensitiveApi();
    }

    public static boolean isInDefaultBrowser(Context context, String str) {
        SharedPreferences sharedPreferences = context.getSharedPreferences(SHARE_PREFERENCES_NAME, 0);
        String d2 = e.d(str);
        if (TextUtils.isEmpty(d2)) {
            d2 = "*/*";
        }
        return sharedPreferences.contains("key_tbs_picked_default_browser_" + d2);
    }

    public static boolean isMiniQBShortCutExist(Context context, String str, String str2) {
        x a2;
        Object invokeStaticMethod;
        if (context == null || TbsDownloader.getOverSea(context) || (a2 = x.a()) == null || !a2.b() || (invokeStaticMethod = a2.c().b().invokeStaticMethod("com.tencent.tbs.tbsshell.WebCoreProxy", "isMiniQBShortCutExist", new Class[]{Context.class, String.class}, context, str)) == null) {
            return false;
        }
        Boolean bool = false;
        if (invokeStaticMethod instanceof Boolean) {
            bool = (Boolean) invokeStaticMethod;
        }
        return bool.booleanValue();
    }

    public static boolean isNeedInitX5FirstTime() {
        return x;
    }

    public static boolean isSuportOpenFile(String str, int i2) {
        List asList;
        if (TextUtils.isEmpty(str)) {
            return false;
        }
        String[] strArr = {"rar", "zip", "tar", "bz2", "gz", "7z", "doc", "docx", "ppt", "pptx", "xls", "xlsx", "txt", "pdf", "epub", "chm", "html", "htm", "xml", "mht", "url", "ini", "log", "bat", "php", "js", "lrc", "jpg", "jpeg", "png", "gif", "bmp", "tiff", "webp", "mp3", "m4a", "aac", "amr", "wav", "ogg", "mid", "ra", "wma", "mpga", "ape", "flac", "RTSP", "RTP", "SDP", "RTMP", "mp4", "flv", "avi", "3gp", "3gpp", "webm", "ts", "ogv", "m3u8", "asf", "wmv", "rmvb", "rm", "f4v", "dat", "mov", "mpg", "mkv", "mpeg", "mpeg1", "mpeg2", "xvid", "dvd", "vcd", "vob", "divx"};
        String[] strArr2 = {"doc", "docx", "ppt", "pptx", "xls", "xlsx", "txt", "pdf", "epub"};
        switch (i2) {
            case 1:
                asList = Arrays.asList(strArr2);
                break;
            case 2:
                asList = Arrays.asList(strArr);
                break;
            default:
                return false;
        }
        return asList.contains(str.toLowerCase());
    }

    public static boolean isTbsCoreInited() {
        g a2 = g.a(false);
        return a2 != null && a2.g();
    }

    public static boolean isX5DisabledSync(Context context) {
        if (n.a(context).c() == 2) {
            return false;
        }
        if (!c(context)) {
            return true;
        }
        Object a2 = i.a(s, "isX5DisabledSync", new Class[]{Integer.TYPE, Integer.TYPE}, Integer.valueOf(p.a().j(context)), 44153);
        if (a2 != null) {
            return ((Boolean) a2).booleanValue();
        }
        return true;
    }

    public static void loadTBSSDKExtension(Context context, String str) {
        Constructor<?> constructor;
        boolean z2;
        Object newInstance;
        if (s == null) {
            synchronized (QbSdk.class) {
                if (s == null) {
                    if (r == null) {
                        TbsLog.i("QbSdk", "QbSdk loadTBSSDKExtension sExtensionClass is null");
                    }
                    try {
                        constructor = r.getConstructor(Context.class, Context.class, String.class, String.class, String.class);
                        z2 = true;
                    } catch (Throwable unused) {
                        constructor = null;
                        z2 = false;
                    }
                    try {
                        if (TbsShareManager.isThirdPartyApp(context)) {
                            Context e2 = TbsShareManager.e(context);
                            if (e2 == null && TbsShareManager.getHostCorePathAppDefined() == null) {
                                TbsCoreLoadStat.getInstance().a(context, TbsListener.ErrorCode.HOST_CONTEXT_IS_NULL);
                                TbsLog.w("QbSdk", "loadTBSSDKExtension", "[LoadWarn] host is context is null.");
                                return;
                            }
                            if (context.getApplicationContext() != null) {
                                context = context.getApplicationContext();
                            }
                            newInstance = !z2 ? e2 == null ? r.getConstructor(Context.class, Context.class, String.class).newInstance(context, e2, TbsShareManager.getHostCorePathAppDefined(), str, null) : r.getConstructor(Context.class, Context.class).newInstance(context, e2) : constructor.newInstance(context, e2, TbsShareManager.getHostCorePathAppDefined(), str, null);
                        } else if (!z2) {
                            Constructor<?> constructor2 = r.getConstructor(Context.class, Context.class);
                            if (context.getApplicationContext() != null) {
                                context = context.getApplicationContext();
                            }
                            newInstance = constructor2.newInstance(context, context);
                        } else {
                            String str2 = (!TbsConfig.APP_WX.equals(getCurrentProcessName(context)) || WebView.mWebViewCreated) ? null : "notLoadSo";
                            if (context.getApplicationContext() != null) {
                                context = context.getApplicationContext();
                            }
                            newInstance = constructor.newInstance(context, context, null, str, str2);
                        }
                        s = newInstance;
                    } catch (Throwable th) {
                        TbsLog.e("QbSdk", "throwable" + Log.getStackTraceString(th));
                    }
                }
            }
        }
    }

    public static void openBrowserList(Context context, String str, Bundle bundle, final ValueCallback<String> valueCallback) {
        String str2;
        if (context != null) {
            String str3 = "";
            if (bundle != null) {
                str3 = bundle.getString("ChannelId");
            }
            Intent intent = new Intent("android.intent.action.VIEW");
            intent.addCategory("android.intent.category.DEFAULT");
            intent.setData(Uri.parse(str));
            String d2 = e.d(str);
            isDefaultDialog = false;
            d dVar = new d(context, "选择其它应用打开", intent, bundle, valueCallback, d2, str3);
            String a2 = dVar.a();
            if (a2 != null && !TextUtils.isEmpty(a2)) {
                if (TbsConfig.APP_QB.equals(a2)) {
                    intent.putExtra("ChannelID", context.getApplicationContext().getPackageName());
                    intent.putExtra("PosID", "4");
                }
                intent.setPackage(a2);
                intent.putExtra("big_brother_source_key", str3);
                context.startActivity(intent);
                if (valueCallback != null) {
                    str2 = "default browser:" + a2;
                } else {
                    return;
                }
            } else if (isDefaultDialog) {
                new AlertDialog.Builder(context).setTitle("提示").setMessage("此文件无法打开").setPositiveButton("确定", new DialogInterface.OnClickListener() {
                    /* class com.tencent.smtt.sdk.QbSdk.AnonymousClass10 */

                    public void onClick(DialogInterface dialogInterface, int i) {
                    }
                }).show();
                if (valueCallback != null) {
                    str2 = "can not open";
                } else {
                    return;
                }
            } else {
                dVar.show();
                dVar.setOnDismissListener(new DialogInterface.OnDismissListener() {
                    /* class com.tencent.smtt.sdk.QbSdk.AnonymousClass2 */

                    public void onDismiss(DialogInterface dialogInterface) {
                        ValueCallback valueCallback = valueCallback;
                        if (valueCallback != null) {
                            valueCallback.onReceiveValue("TbsReaderDialogClosed");
                        }
                    }
                });
                return;
            }
            valueCallback.onReceiveValue(str2);
        }
    }

    public static void openBrowserList(Context context, String str, ValueCallback<String> valueCallback) {
        openBrowserList(context, str, null, valueCallback);
    }

    public static int openFileReader(Context context, String str, HashMap<String, String> hashMap, ValueCallback<String> valueCallback) {
        if (hashMap == null) {
            hashMap = new HashMap<>();
        }
        TbsCoreLoadStat.getInstance().a(context, TbsListener.ErrorCode.INFO_CODE_FILEREADER_OPENFILEREADER_COUNTS);
        if (!checkContentProviderPrivilage(context)) {
            TbsLog.e("QbSdk", "Got an unexpected result when check content provider privilege above api 24");
            return -5;
        } else if (!TextUtils.isEmpty(str)) {
            String lowerCase = str.substring(str.lastIndexOf(".") + 1).toLowerCase();
            String str2 = hashMap.get("fileext");
            String str3 = !TextUtils.isEmpty(str2) ? str2 : lowerCase;
            if (str3 == null) {
                TbsLog.e("QbSdk", "open openFileReader null file type");
            }
            if ("apk".equalsIgnoreCase(str3)) {
                Intent intent = new Intent("android.intent.action.VIEW");
                if (context != null && context.getApplicationInfo().targetSdkVersion >= 24 && Build.VERSION.SDK_INT >= 24) {
                    intent.addFlags(1);
                }
                Uri a2 = FileProvider.a(context, str);
                if (a2 == null) {
                    valueCallback.onReceiveValue("uri failed");
                    return -6;
                }
                intent.setDataAndType(a2, "application/vnd.android.package-archive");
                context.startActivity(intent);
                TbsCoreLoadStat.getInstance().a(context, TbsListener.ErrorCode.INFO_CODE_FILEREADER_OPENFILEREADER_APKFILE);
                TbsLog.e("QbSdk", "open openFileReader ret = 4");
                return 4;
            }
            if (MttLoader.isBrowserInstalled(context)) {
                if (!isSuportOpenFile(str3, 2)) {
                    TbsLog.e("QbSdk", "Open file reader in qq browser, isQBSupport: false  ret = 3");
                    openFileReaderListWithQBDownload(context, str, valueCallback);
                    TbsCoreLoadStat.getInstance().a(context, TbsListener.ErrorCode.INFO_CODE_FILEREADER_OPENFILEREADER_NOTSUPPORT);
                    return 3;
                } else if (startQBForDoc(context, str, 4, 0, str3, a(context, hashMap))) {
                    if (valueCallback != null) {
                        valueCallback.onReceiveValue("open QB");
                    }
                    TbsCoreLoadStat.getInstance().a(context, TbsListener.ErrorCode.INFO_CODE_FILEREADER_OPENFILEREADER_NOTSUPPORT);
                    TbsLog.e("QbSdk", "open openFileReader open QB ret = 1");
                    return 1;
                }
            }
            hashMap.put("local", "true");
            TbsLog.setWriteLogJIT(true);
            int startMiniQBToLoadUrl = startMiniQBToLoadUrl(context, str, hashMap, valueCallback);
            if (startMiniQBToLoadUrl != 0) {
                openFileReaderListWithQBDownload(context, str, valueCallback);
                TbsLogReport instance = TbsLogReport.getInstance(context);
                instance.setLoadErrorCode(511, "" + startMiniQBToLoadUrl);
                return 3;
            }
            TbsCoreLoadStat.getInstance().a(context, TbsListener.ErrorCode.INFO_CODE_FILEREADER_OPENFILEREADER_MINIQBSUCCESS);
            return 2;
        } else {
            if (valueCallback != null) {
                valueCallback.onReceiveValue("filepath error");
            }
            TbsCoreLoadStat.getInstance().a(context, TbsListener.ErrorCode.INFO_CODE_FILEREADER_OPENFILEREADER_FILEPATHISNULL);
            TbsLog.e("QbSdk", "open openFileReader filepath error ret -1");
            return -1;
        }
    }

    public static void openFileReaderListWithQBDownload(Context context, String str, Bundle bundle, final ValueCallback<String> valueCallback) {
        String str2;
        if (context != null && !context.getApplicationInfo().packageName.equals("com.tencent.qim") && !context.getApplicationInfo().packageName.equals("com.tencent.androidqqmail")) {
            String str3 = "";
            if (bundle != null) {
                str3 = bundle.getString("ChannelId");
            }
            Intent intent = new Intent("android.intent.action.VIEW");
            intent.addCategory("android.intent.category.DEFAULT");
            String d2 = e.d(str);
            if (context != null && context.getApplicationInfo().targetSdkVersion >= 24 && Build.VERSION.SDK_INT >= 24) {
                intent.addFlags(1);
            }
            Uri a2 = FileProvider.a(context, str);
            if (a2 == null) {
                TbsLog.i("QbSdk", "openFileReaderListWithQBDownload,uri failed");
                valueCallback.onReceiveValue("uri failed");
                return;
            }
            TbsLog.i("QbSdk", "openFileReaderListWithQBDownload,fileUri:" + str + ",mimeType:" + d2);
            intent.setDataAndType(a2, d2);
            isDefaultDialog = false;
            d dVar = new d(context, "选择其它应用打开", intent, bundle, valueCallback, d2, str3);
            String a3 = dVar.a();
            TbsLog.i("QbSdk", "openFileReaderListWithQBDownload,defaultBrowser:" + a3);
            if (a3 != null && !TextUtils.isEmpty(a3) && a3.startsWith("extraMenuEvent:")) {
                TbsLog.i("QbSdk", "openFileReaderListWithQBDownload, is default extra menu action");
                valueCallback.onReceiveValue(a3);
            } else if (a3 != null && !TextUtils.isEmpty(a3) && checkApkExist(context, a3)) {
                TbsLog.i("QbSdk", "openFileReaderListWithQBDownload, is default normal menu action");
                if (TbsConfig.APP_QB.equals(a3)) {
                    intent.putExtra("ChannelID", context.getApplicationContext().getPackageName());
                    intent.putExtra("PosID", "4");
                }
                if (!TextUtils.isEmpty(str3)) {
                    intent.putExtra("big_brother_source_key", str3);
                }
                intent.setPackage(a3);
                context.startActivity(intent);
                if (valueCallback != null) {
                    valueCallback.onReceiveValue("default browser:" + a3);
                }
            } else if (!"com.tencent.rtxlite".equalsIgnoreCase(context.getApplicationContext().getPackageName()) || !isDefaultDialog) {
                if (isDefaultDialog) {
                    TbsLog.i("QbSdk", "isDefaultDialog=true");
                    if (valueCallback != null) {
                        TbsLog.i("QbSdk", "isDefaultDialog=true, can not open");
                        str2 = "can not open";
                    }
                    TbsLog.i("QbSdk", "unexpected return, dialogBuilder not show!");
                }
                try {
                    TbsLog.i("QbSdk", "isDefaultDialog=false,try to open dialog");
                    dVar.show();
                    dVar.setOnDismissListener(new DialogInterface.OnDismissListener() {
                        /* class com.tencent.smtt.sdk.QbSdk.AnonymousClass9 */

                        public void onDismiss(DialogInterface dialogInterface) {
                            ValueCallback valueCallback = valueCallback;
                            if (valueCallback != null) {
                                valueCallback.onReceiveValue("TbsReaderDialogClosed");
                            }
                        }
                    });
                } catch (Exception e2) {
                    e2.printStackTrace();
                    TbsLog.i("QbSdk", "isDefaultDialog=false,try to open dialog, but failed");
                    str2 = "TbsReaderDialogClosed";
                }
                TbsLog.i("QbSdk", "unexpected return, dialogBuilder not show!");
                valueCallback.onReceiveValue(str2);
                TbsLog.i("QbSdk", "unexpected return, dialogBuilder not show!");
            } else {
                new AlertDialog.Builder(context).setTitle("提示").setMessage("此文件无法打开").setPositiveButton("确定", new DialogInterface.OnClickListener() {
                    /* class com.tencent.smtt.sdk.QbSdk.AnonymousClass8 */

                    public void onClick(DialogInterface dialogInterface, int i) {
                    }
                }).show();
            }
        }
    }

    public static void openFileReaderListWithQBDownload(Context context, String str, ValueCallback<String> valueCallback) {
        openFileReaderListWithQBDownload(context, str, null, valueCallback);
    }

    public static int openFileWithQB(Context context, String str, String str2) {
        TbsLog.i("QbSdk", "open openFileReader startMiniQBToLoadUrl filepath = " + str);
        if (!checkContentProviderPrivilage(context)) {
            return -1;
        }
        if (str != null) {
            String lowerCase = str.substring(str.lastIndexOf(".") + 1).toLowerCase();
            if (!MttLoader.isBrowserInstalled(context)) {
                TbsLog.i("QbSdk", "openFileReader QQ browser not installed");
                return -4;
            } else if (!isSuportOpenFile(lowerCase, 2)) {
                TbsLog.i("QbSdk", "openFileReader open in QB isQBSupport: false");
                return -2;
            } else {
                HashMap hashMap = new HashMap();
                hashMap.put("ChannelID", context.getApplicationContext().getApplicationInfo().processName);
                hashMap.put("PosID", Integer.toString(4));
                if (MttLoader.openDocWithQb(context, str, 0, lowerCase, str2, hashMap, null)) {
                    return 0;
                }
                TbsLog.i("QbSdk", "openFileReader startQBForDoc return false");
                return -3;
            }
        } else {
            TbsLog.i("QbSdk", "open openFileReader filepath error");
            return -5;
        }
    }

    public static void openNetLog(String str) {
        x a2 = x.a();
        if (a2 != null && a2.b()) {
            try {
                a2.c().b().invokeStaticMethod("com.tencent.smtt.livelog.NetLogManager", "openNetLog", new Class[]{String.class}, str);
            } catch (Exception unused) {
            }
        }
    }

    public static void pauseDownload() {
        TbsDownloader.pauseDownload();
    }

    public static synchronized void preInit(Context context) {
        synchronized (QbSdk.class) {
            preInit(context, null);
        }
    }

    public static synchronized void preInit(final Context context, final PreInitCallback preInitCallback) {
        synchronized (QbSdk.class) {
            q.a().a("preinit_start");
            TbsLog.initIfNeed(context);
            TbsLog.i("QbSdk", "preInit", "processName: " + getCurrentProcessName(context));
            TbsLog.i("QbSdk", "preInit", "stack trace: " + Log.getStackTraceString(new Throwable("PreInit Detect:")));
            m = a;
            if (!t) {
                TbsLog.i("QbSdk", "preInit", "#1# Start new thread to preInit");
                final AnonymousClass3 r1 = new Handler(Looper.getMainLooper()) {
                    /* class com.tencent.smtt.sdk.QbSdk.AnonymousClass3 */

                    public void handleMessage(Message message) {
                        switch (message.what) {
                            case 1:
                                q.a().a("preinit_finish");
                                boolean unused = QbSdk.C = TbsExtensionFunctionManager.getInstance().canUseFunction(context, TbsExtensionFunctionManager.DISABLE_UNPREINIT);
                                if (QbSdk.j) {
                                    q.a().a("create_webview_start");
                                    y c = x.a().c();
                                    if (c != null) {
                                        c.a(context);
                                    }
                                    q.a().a("create_webview_end");
                                }
                                PreInitCallback preInitCallback = preInitCallback;
                                if (preInitCallback != null) {
                                    preInitCallback.onViewInitFinished(true);
                                    q.a().a("init_tbs_end");
                                }
                                q.a().a(context);
                                TbsLog.writeLogToDisk();
                                return;
                            case 2:
                                q.a().a("preinit_finish");
                                PreInitCallback preInitCallback2 = preInitCallback;
                                if (preInitCallback2 != null) {
                                    preInitCallback2.onViewInitFinished(false);
                                    q.a().a("init_tbs_end");
                                }
                                TbsLog.writeLogToDisk();
                                q.a().a(context);
                                return;
                            case 3:
                                PreInitCallback preInitCallback3 = preInitCallback;
                                if (preInitCallback3 != null) {
                                    preInitCallback3.onCoreInitFinished();
                                    return;
                                }
                                return;
                            default:
                                return;
                        }
                    }
                };
                AnonymousClass4 r7 = new Thread() {
                    /* class com.tencent.smtt.sdk.QbSdk.AnonymousClass4 */

                    public void run() {
                        int a2 = p.a().a(true, context);
                        TbsDownloader.setAppContext(context);
                        TbsLog.i("QbSdk", "QbSdk preinit ver is " + a2);
                        p.a().b(context, g.a == 0);
                        TbsLog.i("QbSdk", "preInit", "#2-1# prepare initAndLoadSo");
                        g.a(true).a(context, false, false);
                        TbsLog.i("QbSdk", "preInit", "#2-2# SDKEngine init finish");
                        x a3 = x.a();
                        a3.a(context);
                        TbsLog.i("QbSdk", "preInit", "#2-3# X5CoreEngine init finish");
                        boolean b2 = a3.b();
                        r1.sendEmptyMessage(3);
                        if (!b2) {
                            r1.sendEmptyMessage(2);
                        } else {
                            r1.sendEmptyMessage(1);
                        }
                    }
                };
                r7.setName("tbs_preinit");
                r7.setPriority(10);
                r7.start();
                t = true;
            }
        }
    }

    public static void reset(Context context) {
        reset(context, false);
    }

    /* JADX WARNING: Removed duplicated region for block: B:13:0x005b A[Catch:{ Throwable -> 0x007b }] */
    /* JADX WARNING: Removed duplicated region for block: B:15:0x0060 A[Catch:{ Throwable -> 0x007b }] */
    /* JADX WARNING: Removed duplicated region for block: B:19:? A[RETURN, SYNTHETIC] */
    public static void reset(Context context, boolean z2) {
        boolean z3;
        File file;
        TbsLog.e("QbSdk", "QbSdk reset!", true);
        try {
            TbsDownloader.stopDownload();
            if (z2 && !TbsShareManager.isThirdPartyApp(context)) {
                int i2 = p.a().i(context);
                int j2 = p.a().j(context);
                if (i2 > 43300 && i2 != j2) {
                    z3 = true;
                    TbsDownloader.c(context);
                    FileUtil.a(getTbsFolderDir(context), false, "core_share_decouple");
                    TbsLog.i("QbSdk", "delete downloaded apk success", true);
                    p.a.set(0);
                    file = new File(context.getFilesDir(), TbsExtensionFunctionManager.BUGLY_SWITCH_FILE_NAME);
                    if (file.exists()) {
                        file.delete();
                    }
                    if (!z3) {
                        FileUtil.b(p.a().q(context), p.a().f(context, 0));
                        p.a().c(context);
                        return;
                    }
                    return;
                }
            }
            z3 = false;
            TbsDownloader.c(context);
            FileUtil.a(getTbsFolderDir(context), false, "core_share_decouple");
            TbsLog.i("QbSdk", "delete downloaded apk success", true);
            p.a.set(0);
            file = new File(context.getFilesDir(), TbsExtensionFunctionManager.BUGLY_SWITCH_FILE_NAME);
            if (file.exists()) {
            }
            if (!z3) {
            }
        } catch (Throwable th) {
            TbsLog.e("QbSdk", "QbSdk reset exception:" + Log.getStackTraceString(th));
        }
    }

    public static void resetDecoupleCore(Context context) {
        TbsLog.e("QbSdk", "QbSdk resetDecoupleCore!", true);
        try {
            if (r.b(context)) {
                Context packageContext = TbsShareManager.getPackageContext(context, TbsConfig.APP_WX, false);
                File file = packageContext == null ? new File(FileUtil.a(context, TbsConfig.APP_WX, 4, true)) : new File(FileUtil.a(packageContext, 4));
                TbsLog.e("QbSdk", "QbSdk resetDecoupleCore! mFilePathStable is " + file.getAbsolutePath(), true);
                File[] listFiles = file.listFiles();
                Pattern compile = Pattern.compile(a.a(false));
                for (File file2 : listFiles) {
                    if (compile.matcher(file2.getName()).find() && file2.isFile() && file2.exists()) {
                        TbsLog.i(TbsDownloader.LOGTAG, "QbSdk resetDecoupleCore file is " + file2.getAbsolutePath(), true);
                        file2.delete();
                    }
                }
                File file3 = new File(file, TbsDownloader.getBackupFileName(false));
                TbsLog.i(TbsDownloader.LOGTAG, "QbSdk resetDecoupleCore file is " + file3.getAbsolutePath(), true);
                file3.delete();
                return;
            }
            FileUtil.b(p.a().q(context));
        } catch (Throwable th) {
            TbsLog.e("QbSdk", "QbSdk resetDecoupleCore exception:" + Log.getStackTraceString(th));
        }
    }

    public static void resumeDownload() {
        TbsDownloader.resumeDownload();
    }

    public static void setAppList(Context context, List<String> list) {
        if (list != null) {
            TbsPrivacyAccess.configureAllPrivacy(context, TextUtils.join(",", list));
        }
    }

    public static void setCoreMinVersion(int i2) {
        TbsLog.i("QbSdk", "setCoreMinVersion: " + i2);
        I = i2;
    }

    public static void setCurrentID(String str) {
        if (str != null && str.startsWith(TID_QQNumber_Prefix)) {
            String substring = str.substring(3);
            A = "0000000000000000".substring(substring.length()) + substring;
        }
    }

    public static void setDisableUnpreinitBySwitch(boolean z2) {
        C = z2;
        TbsLog.i("QbSdk", "setDisableUnpreinitBySwitch -- mDisableUnpreinitBySwitch is " + C);
    }

    public static void setDisableUseHostBackupCoreBySwitch(boolean z2) {
        mDisableUseHostBackupCore = z2;
        TbsLog.i("QbSdk", "setDisableUseHostBackupCoreBySwitch -- mDisableUseHostBackupCore is " + mDisableUseHostBackupCore);
    }

    public static void setDownloadWithoutWifi(boolean z2) {
        G = z2;
    }

    public static void setEnableForThirdParty(Context context, Bundle bundle) {
        r.a(context, bundle);
    }

    public static void setNeedInitX5FirstTime(boolean z2) {
        x = z2;
    }

    public static void setNetLogEncryptionKey(String str) {
        x a2 = x.a();
        if (a2 != null && a2.b()) {
            try {
                a2.c().b().invokeStaticMethod("com.tencent.smtt.livelog.NetLogManager", "setNetLogEncryptionKey", new Class[]{String.class}, str);
            } catch (Exception unused) {
            }
        }
    }

    public static void setNewDnsHostList(String str) {
        x a2 = x.a();
        if (a2 != null && a2.b()) {
            try {
                a2.c().b().invokeStaticMethod("com.tencent.tbs.tbsshell.WebCoreProxy", "setNewDnsHostList", new Class[]{String.class}, str);
            } catch (Exception unused) {
            }
        }
    }

    public static void setOnlyDownload(boolean z2) {
        l = z2;
    }

    public static void setQQBuildNumber(String str) {
        B = str;
    }

    public static void setTBSInstallingStatus(boolean z2) {
        H = z2;
    }

    public static void setTbsListener(TbsListener tbsListener) {
        E = tbsListener;
    }

    public static void setTbsLogClient(TbsLogClient tbsLogClient) {
        TbsLog.setTbsLogClient(tbsLogClient);
    }

    public static void setUploadCode(Context context, int i2) {
        TbsDownloadUpload instance;
        Map<String, Object> map;
        String str;
        if (i2 >= 130 && i2 <= 139) {
            instance = TbsDownloadUpload.getInstance(context);
            map = instance.a;
            str = TbsDownloadUpload.TbsUploadKey.KEY_NEEDDOWNLOAD_CODE;
        } else if (i2 >= 150 && i2 <= 159) {
            instance = TbsDownloadUpload.getInstance(context);
            map = instance.a;
            str = TbsDownloadUpload.TbsUploadKey.KEY_STARTDOWNLOAD_CODE;
        } else {
            return;
        }
        map.put(str, Integer.valueOf(i2));
        instance.commit();
    }

    public static void setUserID(Context context, Bundle bundle) {
        TbsPrivacyAccess.configureAllPrivacy(context, bundle);
    }

    public static int startMiniQBToLoadUrl(Context context, String str, HashMap<String, String> hashMap, ValueCallback<String> valueCallback) {
        TbsCoreLoadStat.getInstance().a(context, TbsListener.ErrorCode.INFO_CODE_MINIQB_STARTMINIQBTOLOADURL_COUNTS);
        if (context == null) {
            return -100;
        }
        x a2 = x.a();
        a2.a(context);
        if (!a2.b()) {
            TbsCoreLoadStat.getInstance().a(context, TbsListener.ErrorCode.INFO_CODE_MINIQB_STARTMINIQBTOLOADURL_ISNOTX5CORE);
            Log.e("QbSdk", "startMiniQBToLoadUrl  ret = -102");
            return -102;
        } else if (context != null && context.getApplicationInfo().packageName.equals("com.nd.android.pandahome2") && getTbsVersion(context) < 25487) {
            return -101;
        } else {
            int a3 = a2.c().a(context, str, hashMap, null, valueCallback);
            if (a3 == 0) {
                TbsCoreLoadStat.getInstance().a(context, TbsListener.ErrorCode.INFO_CODE_MINIQB_STARTMINIQBTOLOADURL_SUCCESS);
            } else {
                TbsLogReport instance = TbsLogReport.getInstance(context);
                instance.setLoadErrorCode(TbsListener.ErrorCode.INFO_CODE_MINIQB_STARTMINIQBTOLOADURL_FAILED, "" + a3);
            }
            Log.e("QbSdk", "startMiniQBToLoadUrl  ret = " + a3);
            return a3;
        }
    }

    public static boolean startQBForDoc(Context context, String str, int i2, int i3, String str2, Bundle bundle) {
        HashMap hashMap = new HashMap();
        hashMap.put("ChannelID", context.getApplicationContext().getApplicationInfo().processName);
        hashMap.put("PosID", Integer.toString(i2));
        return MttLoader.openDocWithQb(context, str, i3, str2, hashMap, bundle);
    }

    public static boolean startQBForVideo(Context context, String str, int i2) {
        HashMap hashMap = new HashMap();
        hashMap.put("ChannelID", context.getApplicationInfo().processName);
        hashMap.put("PosID", Integer.toString(i2));
        return MttLoader.openVideoWithQb(context, str, hashMap);
    }

    public static boolean startQBToLoadurl(Context context, String str, int i2, WebView webView) {
        x a2;
        Object invokeStaticMethod;
        IX5WebViewBase iX5WebViewBase;
        HashMap hashMap = new HashMap();
        hashMap.put("ChannelID", context.getApplicationInfo().processName);
        hashMap.put("PosID", Integer.toString(i2));
        if (webView == null) {
            try {
                String str2 = context.getPackageManager().getPackageInfo(context.getPackageName(), 0).packageName;
                if (!((str2 != TbsConfig.APP_WX && str2 != TbsConfig.APP_QQ) || (a2 = x.a()) == null || !a2.b() || (invokeStaticMethod = a2.c().b().invokeStaticMethod("com.tencent.smtt.webkit.WebViewList", "getCurrentMainWebviewJustForQQandWechat", new Class[0], new Object[0])) == null || (iX5WebViewBase = (IX5WebViewBase) invokeStaticMethod) == null)) {
                    webView = (WebView) iX5WebViewBase.getView().getParent();
                }
            } catch (Exception unused) {
            }
        }
        return MttLoader.loadUrl(context, str, hashMap, "QbSdk.startQBToLoadurl", webView) == 0;
    }

    public static boolean startQBWithBrowserlist(Context context, String str, int i2) {
        boolean startQBToLoadurl = startQBToLoadurl(context, str, i2, null);
        if (!startQBToLoadurl) {
            openBrowserList(context, str, null);
        }
        return startQBToLoadurl;
    }

    public static boolean startQbOrMiniQBToLoadUrl(Context context, String str, HashMap<String, String> hashMap, ValueCallback<String> valueCallback) {
        if (context == null) {
            return false;
        }
        x a2 = x.a();
        a2.a(context);
        if (hashMap != null && "5".equals(hashMap.get("PosID")) && a2.b()) {
            Bundle bundle = (Bundle) a2.c().b().invokeStaticMethod("com.tencent.tbs.tbsshell.WebCoreProxy", "getAdWebViewInfoFromX5Core", new Class[0], new Object[0]);
        }
        if (MttLoader.loadUrl(context, str, hashMap, "QbSdk.startMiniQBToLoadUrl", null) != 0) {
            return a2.b() && (context == null || !context.getApplicationInfo().packageName.equals("com.nd.android.pandahome2") || getTbsVersion(context) >= 25487) && a2.c().a(context, str, hashMap, null, valueCallback) == 0;
        }
        return true;
    }

    public static void unForceSysWebView() {
        b = false;
        TbsLog.e("QbSdk", "sys WebView: unForceSysWebView called");
    }

    public static synchronized boolean unPreInit(Context context) {
        synchronized (QbSdk.class) {
        }
        return true;
    }

    public static void uploadNetLog(String str) {
        x a2 = x.a();
        if (a2 != null && a2.b()) {
            try {
                a2.c().b().invokeStaticMethod("com.tencent.smtt.livelog.NetLogManager", "uploadNetLog", new Class[]{String.class}, str);
            } catch (Exception unused) {
            }
        }
    }

    public static boolean useSoftWare() {
        Object obj = s;
        if (obj == null) {
            return false;
        }
        Object a2 = i.a(obj, "useSoftWare", new Class[0], new Object[0]);
        if (a2 == null) {
            a2 = i.a(s, "useSoftWare", new Class[]{Integer.TYPE}, Integer.valueOf(a.a()));
        }
        if (a2 == null) {
            return false;
        }
        return ((Boolean) a2).booleanValue();
    }
}