QQ浏览器 v12.2.3.7053版本的 MD5 值为:8285ab3059e5c8b521a264dfbc5c3685
以下内容为反编译后的 XWalkEnvironment.java 源代码,内容仅作参考
package org.xwalk.core;
import android.app.Activity;
import android.content.ContentResolver;
import android.content.Context;
import android.content.ContextWrapper;
import android.content.SharedPreferences;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.os.Build;
import android.os.Looper;
import android.os.Process;
import android.telephony.TelephonyManager;
import android.text.TextUtils;
import com.facebook.common.util.UriUtil;
import com.huawei.hms.framework.common.ContainerUtils;
import com.tencent.luggage.wxa.dc.j;
import com.tencent.mtt.compliance.MethodDelegate;
import com.tencent.qqlive.module.videoreport.inject.webview.dtwebview.DtWebView;
import com.tencent.xweb.ISharedPreferenceProvider;
import com.tencent.xweb.WebView;
import com.tencent.xweb.ag;
import com.tencent.xweb.b;
import com.tencent.xweb.internal.l;
import com.tencent.xweb.util.c;
import com.tencent.xweb.util.f;
import com.tencent.xweb.util.h;
import com.tencent.xweb.v;
import com.xiaomi.mipush.sdk.Constants;
import java.io.BufferedReader;
import java.io.Closeable;
import java.io.File;
import java.io.InputStreamReader;
import java.lang.reflect.Method;
import java.net.URI;
import java.security.MessageDigest;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.Locale;
import java.util.Random;
import java.util.Set;
import kotlin.jvm.internal.ByteCompanionObject;
import tmsdk.common.gourd.vine.IActionReportService;
public class XWalkEnvironment {
private static final String APK_DIR = "apk";
public static final String DOWNLOAD_CONFIG_URL = "https://dldir1.qq.com/weixin/android/wxweb/updateConfig.xml";
public static final String DOWNLOAD_CONFIG_URL_THIRD_PARD = "https://dldir1.qq.com/weixin/android/wxweb/updateConfig_public.xml";
public static final String DOWNLOAD_PLUGIN_UPDATE_CONFIG_URL = "https://dldir1.qq.com/weixin/android/wxweb/plugin/pluginUpdateConfig.xml";
public static final String DOWNLOAD_PLUGIN_UPDATE_CONFIG_URL_THIRD_PARD = "https://dldir1.qq.com/weixin/android/wxweb/plugin/pluginUpdateConfig_public.xml";
public static final String DOWNLOAD_PLUGIN_UPDATE_TEST_CONFIG_DEFAULT_URL = "https://dldir1.qq.com/weixin/android/wxweb/plugin/pluginUpdateConfig_test.xml";
public static final String DOWNLOAD_X86_CONFIG_URL = "https://dldir1.qq.com/weixin/android/wxweb/updateConfig_x86.xml";
public static final String LOCAL_TEST_ZIP_NAME = "runtime_package.zip";
private static final String META_XWALK_DOWNCONFIG_URL = "xwalk_downconfig_url";
public static final String MM_PACKAGE_NAME = "com.tencent.mm";
private static final String OPTIMIZED_DEX_DIR = "dex";
private static final String PACKAGE_RE = "[a-z]+\\.[a-z0-9]+\\.[a-z0-9]+.*";
private static final String PATCH_ZIP_TEMP_DECOMPRESS_DIR = "patch_temp_decompress";
public static final String RUNTIME_ABI_ARM32_STR = "armeabi-v7a";
public static final String RUNTIME_ABI_ARM64_STR = "arm64-v8a";
public static final int SDK_SUPPORT_INVOKE_NOTIFY_MIN_APKVERSION = 153;
public static final int SDK_SUPPORT_INVOKE_RUNTIME_MIN_APKVERSION = 255;
public static final int SDK_SUPPORT_MIN_APKVERSION = 2000;
public static final int SDK_VERSION = 20210601;
private static final int SPECIAL_TEST_USER_ID = 10001;
public static final String SP_KEY_DEVICE_RD = "sNDeviceRd";
public static final String SP_KEY_FILE_READER_POSTFIX_COUNT = "_count";
public static final String SP_KEY_FILE_READER_POSTFIX_REPORT_UV_DATE = "_report_uv_date";
public static final String SP_KEY_FILE_READER_POSTFIX_TIME = "_time";
private static final String SP_KEY_GRAY_VALUE = "GRAY_VALUE";
private static final String SP_KEY_GRAY_VALUE_TEST = "TEST_GRAY_VALUE";
private static final String SP_KEY_IP_TYPE = "IP_TYPE";
public static final String SP_KEY_PLUGIN_AVAILABLE_VERSION = "availableVersion";
public static final String SP_KEY_PLUGIN_LAST_ENV_INFO = "lastEnvInfo";
public static final String SP_KEY_PLUGIN_LAST_REPORT_DATE = "lastReportDate";
public static final String SP_KEY_PLUGIN_LAST_REPORT_VERSION = "lastReportVersion";
public static final String SP_KEY_PLUGIN_PATCH_DOWNLOAD_COUNT_PREFIX = "patchDownloadCount_";
public static final String SP_KEY_PLUGIN_SUPPORT_FORMATS = "supportFormats";
private static final String SP_KEY_PLUGIN_TEST_CONFIG_URL = "XWEB_PLUGIN_TEST_CONFIG_URL";
public static final String SP_KEY_PLUGIN_UPDATE_CONFIG_LAST_FETCH_TIME = "nLastFetchPluginConfigTime";
public static final String SP_KEY_PLUGIN_UPDATE_PROCESS_ID = "nUpdatingProcessId";
public static final String SP_NAME_FILE_READER_RECORD = "xwalk_reader_record";
private static final String SP_NAME_PLUGIN_UPDATE_INFO = "xwalk_plugin_update_info";
private static final String SP_NAME_PLUGIN_VERSION_INFO_PREFIX = "xwalk_plugin_version_info_";
public static final String SP_NAME_VERSION_INFO = "XWALKINFOS";
private static final String TAG = "XWalkEnvironment";
public static final int TEST_APK_START_VERSION = 100000000;
public static String UPDATEINFOTAG = "xwalk_update_info";
public static final String XWALK_CORE_APK_NAME = "base.apk";
public static final String XWALK_CORE_CLASSES_DEX = "classes.dex";
private static final String XWALK_CORE_EXTRACTED_DIR = "extracted_xwalkcore";
public static final String XWALK_CORE_FILELIST_CONFIG_NAME = "filelist.config";
private static final String XWALK_CORE_NAME_PREFIX = "xwalk_";
private static final String XWALK_CORE_PATCH_CONFIG_NAME = "patch.config";
private static final String XWALK_CORE_PATCH_NAME = "patch.zip";
private static final String XWALK_CORE_RES_FILELIST_CONFIG_NAME = "reslist.config";
private static final String XWALK_CORE_ZIP_NAME = "base.zip";
public static final String XWALK_ENV_MAP_KEY_ISGPVERSION = "isgpversion";
public static final String XWALK_ENV_MAP_KEY_PROCESSNAME = "processname";
public static final int XWALK_GET_FROM_PROVIDER_MAX_COUNT = 2;
private static final String XWALK_PLUGIN_BASE_DIR = "xwalkplugin";
public static final String XWALK_PLUGIN_NAME_EXCEL = "XFilesExcelReader";
public static final String XWALK_PLUGIN_NAME_FULL_SCREEN_VIDEO = "FullScreenVideo";
public static final String XWALK_PLUGIN_NAME_OFFICE = "XFilesOfficeReader";
public static final String XWALK_PLUGIN_NAME_PDF = "XFilesPDFReader";
public static final String XWALK_PLUGIN_NAME_PPT = "XFilesPPTReader";
public static final String XWALK_PLUGIN_NAME_WORD = "XFilesWordReader";
private static final String XWALK_PLUGIN_UPDATE_CONFIG_NAME = "pluginUpdateConfig.xml";
public static final int XWALK_PLUGIN_UPDATE_PERIOD_DEFAULT = 90000000;
private static final String XWALK_UPDATE_CONFIG_DIR = "xwalkconfig";
private static final String ZIP_DIR = "zip";
private static Context sApplicationContext;
private static String sApplicationName;
private static String sDeviceAbi;
private static Boolean sIsXWalkVerify;
private static String sLocaleString;
static Method sMMKVMethod;
private static String sRuntimeAbi;
static String sStrCurentProcessName;
private static String sStrTempPluginUpdateConfigUrl;
private static String sStrTempUpdateConfigUrl;
private static String sXWalkApkUrl;
private static String sXWalkDownConfigUrl;
static HashMap<String, Object> sXWebArgs;
private static XWebCoreInfo sXWebCoreInfo;
public static final String[] XWALK_CORE_PROVIDER_LIST = {"com.tencent.mm"};
private static boolean sIsPluginInited = false;
private static Boolean sIsDownloadMode = true;
private static Boolean sIsDownloadModeUpdate = true;
private static int sTempPluginUpdatePeriod = -1;
private static boolean sUsingCustomContext = false;
private static boolean sIsForceDarkMode = false;
private static int sForceDarkBehavior = 2;
private static boolean isTurnOnKVLog = false;
static boolean sBHasInitedSafePsProvider = false;
static ISharedPreferenceProvider sSPProvider = null;
static int sPid = Process.myPid();
static int s_grayValue = 0;
static int s_todayGrayValue = 0;
static String s_todayDate = "";
static int sNChromiuVersion = -1;
public static int sNDeviceRd = 0;
static boolean sBIsIpTypeChanged = false;
static String sStrDeviceId = null;
public static final String[] DEFAULT_MANDATORY_RESOURCES = {"classes.dex", "icudtl.dat", "xwalk.pak", "xwalk_100_percent.pak", "xweb_fullscreen_video.js"};
static long sConfigPerios = 0;
private static Set<String> sAppInfos = new HashSet();
private static int sAppClientVersion = 0;
static class AnonymousClass1 {
static final int[] $SwitchMap$org$xwalk$core$XWalkEnvironment$ForceDarkBehavior = new int[ForceDarkBehavior.values().length];
static {
try {
$SwitchMap$org$xwalk$core$XWalkEnvironment$ForceDarkBehavior[ForceDarkBehavior.FORCE_DARK_ONLY.ordinal()] = 1;
} catch (NoSuchFieldError unused) {
}
try {
$SwitchMap$org$xwalk$core$XWalkEnvironment$ForceDarkBehavior[ForceDarkBehavior.MEDIA_QUERY_ONLY.ordinal()] = 2;
} catch (NoSuchFieldError unused2) {
}
try {
$SwitchMap$org$xwalk$core$XWalkEnvironment$ForceDarkBehavior[ForceDarkBehavior.PREFER_MEDIA_QUERY_OVER_FORCE_DARK.ordinal()] = 3;
} catch (NoSuchFieldError unused3) {
}
}
}
public enum ForceDarkBehavior {
FORCE_DARK_ONLY,
MEDIA_QUERY_ONLY,
PREFER_MEDIA_QUERY_OVER_FORCE_DARK
}
static int _getChromiunVersion() {
String[] split;
try {
PackageInfo packageInfo = getApplicationContext().getPackageManager().getPackageInfo("com.google.android.webview", 0);
if (packageInfo != null) {
int verFromVersionName = getVerFromVersionName(packageInfo.versionName);
if (verFromVersionName > 0) {
return verFromVersionName;
}
}
} catch (Exception unused) {
Log.e(TAG, "Android System WebView is not found");
}
try {
if (!runnintOnUiThread()) {
Log.e(TAG, "_getChromiunVersion NOT IN UI THREAD");
return 0;
}
String userAgentString = new DtWebView(getApplicationContext()).getSettings().getUserAgentString();
if (userAgentString != null && (split = userAgentString.split("Chrome/")) != null && split.length != 0 && (split.length != 1 || split[0].length() != userAgentString.length())) {
return getVerFromVersionName(split[1]);
}
return 0;
} catch (Exception e) {
Log.e(TAG, "Android System WebView is not found " + e.getMessage());
}
return 0;
}
public static Activity activityFromContext(Context context) {
Context baseContext;
if (context instanceof Activity) {
return (Activity) context;
}
if (!(context instanceof ContextWrapper) || (baseContext = ((ContextWrapper) context).getBaseContext()) == context) {
return null;
}
return activityFromContext(baseContext);
}
public static void addXWalkInitializeLog(String str) {
if (str == null || str.isEmpty()) {
return;
}
Log.i("XWalkUpdater", str);
if (isTurnOnKVLog) {
String str2 = sPid + getModuleName() + Constants.COLON_SEPARATOR + new SimpleDateFormat("MM-dd hh:mm:ss").format(new Date()) + " : " + str;
SharedPreferences sharedPreferencesForLog = getSharedPreferencesForLog();
String str3 = str2 + "\n" + sharedPreferencesForLog.getString(j.NAME, "");
if (str3.length() > 10240) {
str3 = str3.substring(0, 5120);
}
sharedPreferencesForLog.edit().putString(j.NAME, str3).apply();
}
}
public static void addXWalkInitializeLog(String str, String str2) {
addXWalkInitializeLog(str + ": " + str2);
}
public static synchronized void appendAppInfo(String str) {
synchronized (XWalkEnvironment.class) {
if (!sAppInfos.contains(str)) {
sAppInfos.add(str);
}
}
}
public static boolean checkApiVersionBaseApkExist(int i) {
return new File(getDownloadApkPath(i)).exists();
}
public static void clearAllVersion(Context context) {
File[] listFiles;
if (context == null || context.getApplicationInfo() == null || context.getApplicationInfo().dataDir == null || (listFiles = new File(context.getApplicationInfo().dataDir).listFiles()) == null) {
return;
}
for (File file : listFiles) {
if (file.getName().startsWith("app_xwalk_") && file.isDirectory()) {
c.b(file.getAbsolutePath());
}
}
setAvailableVersion(-1, "", RUNTIME_ABI_ARM32_STR);
setAvailableVersion(-1, "", RUNTIME_ABI_ARM64_STR);
}
public static synchronized boolean containsAppInfo(String str) {
synchronized (XWalkEnvironment.class) {
String[] split = str.split(ContainerUtils.FIELD_DELIMITER);
if (split != null && split.length != 0) {
for (String str2 : split) {
if (!TextUtils.isEmpty(str2) && !sAppInfos.contains(str2.trim())) {
return false;
}
}
return true;
}
return true;
}
}
public static boolean delApiVersion(int i) {
return c.b(getVesionDir(i));
}
public static String dumpAppInfo() {
Iterator<String> it = sAppInfos.iterator();
String str = "";
while (it.hasNext()) {
str = str + it.next() + IActionReportService.COMMON_SEPARATOR;
}
return str;
}
public static synchronized int getAppClientVersion() {
int i;
synchronized (XWalkEnvironment.class) {
i = sAppClientVersion;
}
return i;
}
public static Context getApplicationContext() {
return sApplicationContext;
}
private static String getApplicationMetaData(String str) {
try {
return sApplicationContext.getPackageManager().getApplicationInfo(sApplicationContext.getPackageName(), 128).metaData.get(str).toString();
} catch (PackageManager.NameNotFoundException | NullPointerException unused) {
return null;
}
}
public static String getApplicationName() {
if (sApplicationName == null) {
try {
PackageManager packageManager = sApplicationContext.getPackageManager();
sApplicationName = (String) packageManager.getApplicationLabel(packageManager.getApplicationInfo(sApplicationContext.getPackageName(), 0));
} catch (PackageManager.NameNotFoundException unused) {
}
String str = sApplicationName;
if (str == null || str.isEmpty() || sApplicationName.matches(PACKAGE_RE)) {
sApplicationName = "this application";
}
Log.d(TAG, "Crosswalk application name: " + sApplicationName);
}
return sApplicationName;
}
public static int getAvailableVersion() {
XWebCoreInfo xWebCoreInfo = sXWebCoreInfo;
if (xWebCoreInfo == null) {
return -1;
}
return xWebCoreInfo.ver;
}
public static String getAvailableVersionDetail() {
XWebCoreInfo xWebCoreInfo = sXWebCoreInfo;
return xWebCoreInfo != null ? xWebCoreInfo.verDetail : "";
}
public static int getChromiunVersion() {
if (sNChromiuVersion < 0) {
sNChromiuVersion = _getChromiunVersion();
}
return sNChromiuVersion;
}
public static String getClassDexFilePath(int i) {
return getExtractedCoreDir(i) + File.separator + "classes.dex";
}
public static long getConfigFetchPeriod() {
return sConfigPerios;
}
public static ContentResolver getContentResolver() {
Context context = sApplicationContext;
if (context != null) {
return context.getContentResolver();
}
Log.e(TAG, "getContentResolver sApplicationContext is null");
return null;
}
public static String getDeviceAbi() {
StringBuilder sb;
String message;
BufferedReader bufferedReader;
BufferedReader bufferedReader2;
if (sDeviceAbi == null) {
try {
if (Build.VERSION.SDK_INT >= 21) {
sDeviceAbi = Build.SUPPORTED_ABIS[0].toLowerCase();
}
} catch (Exception e) {
sb = new StringBuilder();
sb.append("Build.SUPPORTED_ABIS excpet ");
message = e.getMessage();
sb.append(message);
Log.e(TAG, sb.toString());
if (sDeviceAbi == null) {
}
Log.d(TAG, "Device ABI: " + sDeviceAbi);
String str = sDeviceAbi;
if (str != null) {
}
} catch (NoSuchFieldError e2) {
sb = new StringBuilder();
sb.append("Build.SUPPORTED_ABIS NoSuchFieldError ");
message = e2.getMessage();
sb.append(message);
Log.e(TAG, sb.toString());
if (sDeviceAbi == null) {
}
Log.d(TAG, "Device ABI: " + sDeviceAbi);
String str2 = sDeviceAbi;
if (str2 != null) {
}
}
if (sDeviceAbi == null) {
InputStreamReader inputStreamReader = null;
try {
InputStreamReader inputStreamReader2 = new InputStreamReader(Runtime.getRuntime().exec("getprop ro.product.cpu.abi").getInputStream());
try {
bufferedReader2 = new BufferedReader(inputStreamReader2);
} catch (Exception e3) {
e = e3;
bufferedReader = null;
inputStreamReader = inputStreamReader2;
} catch (Throwable th) {
th = th;
bufferedReader = null;
inputStreamReader = inputStreamReader2;
}
try {
sDeviceAbi = bufferedReader2.readLine().toLowerCase();
tryClose(inputStreamReader2);
tryClose(bufferedReader2);
} catch (Exception e4) {
e = e4;
inputStreamReader = inputStreamReader2;
bufferedReader = bufferedReader2;
try {
Log.e(TAG, "Device ABI: " + e.getMessage());
tryClose(inputStreamReader);
tryClose(bufferedReader);
Log.d(TAG, "Device ABI: " + sDeviceAbi);
String str22 = sDeviceAbi;
if (str22 != null) {
}
} catch (Throwable th2) {
th = th2;
tryClose(inputStreamReader);
tryClose(bufferedReader);
throw th;
}
} catch (Throwable th3) {
th = th3;
inputStreamReader = inputStreamReader2;
bufferedReader = bufferedReader2;
tryClose(inputStreamReader);
tryClose(bufferedReader);
throw th;
}
} catch (Exception e5) {
e = e5;
bufferedReader = null;
} catch (Throwable th4) {
th = th4;
bufferedReader = null;
}
}
Log.d(TAG, "Device ABI: " + sDeviceAbi);
}
String str222 = sDeviceAbi;
return str222 != null ? "" : str222;
}
public static String getDeviceId() {
if (sStrDeviceId == null) {
try {
TelephonyManager telephonyManager = (TelephonyManager) getApplicationContext().getSystemService("phone");
if (telephonyManager == null) {
sStrDeviceId = "";
} else {
sStrDeviceId = MethodDelegate.getImei(telephonyManager);
}
} catch (Exception e) {
sStrDeviceId = "";
Log.e(TAG, "getDeviceId failed " + e.getMessage());
}
}
return sStrDeviceId;
}
public static int getDeviceRd() {
if (sNDeviceRd <= 0) {
sNDeviceRd = getSharedPreferences().getInt(SP_KEY_DEVICE_RD, -1);
if (sNDeviceRd <= 0) {
sNDeviceRd = new Random().nextInt(10000000) + 1;
getSharedPreferences().edit().putInt(SP_KEY_DEVICE_RD, sNDeviceRd).apply();
}
}
return (sNDeviceRd % 10000) + 1;
}
public static String getDownloadApkDir(int i) {
String str = getVesionDir(i) + File.separator + APK_DIR;
File file = new File(str);
if (!file.exists()) {
file.mkdirs();
}
return str;
}
public static String getDownloadApkPath(int i) {
String str = getVesionDir(i) + File.separator + APK_DIR;
File file = new File(str);
if (!file.exists()) {
file.mkdirs();
}
return str + File.separator + XWALK_CORE_APK_NAME;
}
public static String getDownloadApkPath(Context context, int i) {
String str;
if (context == null) {
str = "getDownloadApkPath with context, context is null";
} else {
String vesionDir = getVesionDir(context, i);
if (!vesionDir.isEmpty()) {
return vesionDir + File.separator + APK_DIR + File.separator + XWALK_CORE_APK_NAME;
}
str = "getDownloadApkPath with context, versionDir is empty";
}
Log.e(TAG, str);
return "";
}
public static String getDownloadPatchPath(int i) {
String str = getVesionDir(i) + File.separator + APK_DIR;
File file = new File(str);
if (!file.exists()) {
file.mkdirs();
}
return str + File.separator + XWALK_CORE_PATCH_NAME;
}
public static String getDownloadResFileListConfig(int i) {
return getExtractedCoreFile(i, XWALK_CORE_RES_FILELIST_CONFIG_NAME);
}
public static String getDownloadZipDir(int i) {
String str = getVesionDir(i) + File.separator + ZIP_DIR;
File file = new File(str);
if (!file.exists()) {
file.mkdirs();
}
return str + File.separator + XWALK_CORE_ZIP_NAME;
}
public static String getDownloadZipFileListConfig(int i) {
return getExtractedCoreFile(i, XWALK_CORE_FILELIST_CONFIG_NAME);
}
public static String getDownloadZipFileListConfig(Context context, int i) {
return getExtractedCoreFile(context, i, XWALK_CORE_FILELIST_CONFIG_NAME);
}
public static String getExtractedCoreDir(int i) {
String str = getVesionDir(i) + File.separator + XWALK_CORE_EXTRACTED_DIR;
File file = new File(str);
if (!file.exists()) {
file.mkdirs();
}
return str;
}
public static String getExtractedCoreFile(int i, String str) {
String str2 = getVesionDir(i) + File.separator + XWALK_CORE_EXTRACTED_DIR;
File file = new File(str2);
if (!file.exists()) {
file.mkdirs();
}
return str2 + File.separator + str;
}
public static String getExtractedCoreFile(Context context, int i, String str) {
String str2;
if (context == null) {
str2 = "getExtractedCoreFile with context, context is null";
} else {
String vesionDir = getVesionDir(context, i);
if (!vesionDir.isEmpty()) {
return vesionDir + File.separator + XWALK_CORE_EXTRACTED_DIR + File.separator + str;
}
str2 = "getExtractedCoreFile with context, versionDir is empty";
}
Log.e(TAG, str2);
return "";
}
private static boolean getFeatureSupport(int i) {
return ((Boolean) l.a(WebView.c.WV_KIND_CW).excute("STR_CMD_FEATURE_SUPPORT", new Object[]{Integer.valueOf(i)})).booleanValue();
}
public static int getForceDarkBehavior() {
return sForceDarkBehavior;
}
public static boolean getForceDarkMode() {
return sIsForceDarkMode;
}
public static int getGrayValue() {
int i = s_grayValue;
if (i != 0) {
return i;
}
try {
s_grayValue = getSharedPreferences().getInt(SP_KEY_GRAY_VALUE_TEST, -1);
if (s_grayValue <= 0) {
s_grayValue = getSharedPreferences().getInt(SP_KEY_GRAY_VALUE, -1);
}
if (s_grayValue <= 0) {
s_grayValue = getDeviceRd();
}
} catch (Exception e) {
Log.e(TAG, "match gray rate exception: " + e.getMessage());
}
return s_grayValue;
}
public static int getInstalledNewstVersion(Context context) {
if (context == null) {
return 0;
}
return XWebCoreInfo.getCurAbiInstalledNewestVersion(context);
}
public static int getInstalledNewstVersion(String str) {
return XWebCoreInfo.getBackupCoreInfo(str).ver;
}
public static int getInstalledNewstVersionForCurAbi() {
return getInstalledNewstVersion(getRuntimeAbi());
}
public static int getInstalledNewstVersionForPredownAbi() {
String runtimeAbi = getRuntimeAbi();
String str = RUNTIME_ABI_ARM32_STR;
if (RUNTIME_ABI_ARM32_STR.equalsIgnoreCase(runtimeAbi)) {
str = RUNTIME_ABI_ARM64_STR;
}
return getInstalledNewstVersion(str);
}
public static int getInstalledPluginVersion(Context context, String str) {
if (context == null) {
Log.e(TAG, "getInstalledPluginVersion, context is null");
return -2;
}
SharedPreferences sharedPreferences = context.getSharedPreferences(SP_NAME_PLUGIN_VERSION_INFO_PREFIX + str, 4);
if (sharedPreferences != null) {
return sharedPreferences.getInt(SP_KEY_PLUGIN_AVAILABLE_VERSION, -1);
}
Log.e(TAG, "getInstalledPluginVersion, sp is null");
return -3;
}
public static int getIpType() {
return getSharedPreferences().getInt(SP_KEY_IP_TYPE, -2);
}
public static Locale getLocale() {
String str = sLocaleString;
if (str == null || str.isEmpty()) {
return null;
}
return Locale.forLanguageTag(sLocaleString);
}
public static String getLocaleString() {
return sLocaleString;
}
public static SharedPreferences getMMKVSharedPreferences(String str) {
return getMMKVSharedPreferencesEx(str, 4, false);
}
public static SharedPreferences getMMKVSharedPreferencesEx(String str, int i, boolean z) {
SharedPreferences sharedPreferences;
long j;
ISharedPreferenceProvider iSharedPreferenceProvider = sSPProvider;
if (iSharedPreferenceProvider != null) {
try {
sharedPreferences = iSharedPreferenceProvider.a(getApplicationContext(), str, i, z);
} catch (Exception e) {
Log.e(TAG, "got sp from mmkv callback failed " + e.getMessage());
sharedPreferences = null;
}
if (sharedPreferences != null) {
return sharedPreferences;
}
Log.e(TAG, "got sp from mmkv callback retSp == null ");
j = 176;
} else {
j = 177;
}
h.a(j, 1);
initSafePsProvider();
Method method = sMMKVMethod;
if (method != null) {
try {
Object invoke = method.invoke(null, getApplicationContext(), str, Integer.valueOf(i), Boolean.valueOf(z));
if (invoke != null && (invoke instanceof SharedPreferences)) {
return (SharedPreferences) invoke;
}
Log.e(TAG, "get mmmkv from reflection failed");
} catch (Exception unused) {
}
h.a(179L, 1);
}
return sApplicationContext.getSharedPreferences(str, i);
}
public static SharedPreferences getMMKVSharedTransportOld(String str) {
return getMMKVSharedPreferencesEx(str, 4, true);
}
public static String getModuleName() {
String processName = getProcessName();
if (processName == null) {
return "";
}
String str = Constants.COLON_SEPARATOR;
if (!processName.contains(Constants.COLON_SEPARATOR)) {
str = ".";
if (!processName.contains(".")) {
return processName;
}
}
return processName.substring(processName.lastIndexOf(str) + 1).toLowerCase();
}
public static String getOptimizedDexDir(int i) {
String str = getVesionDir(i) + File.separator + "dex";
File file = new File(str);
if (!file.exists()) {
file.mkdirs();
}
return str;
}
public static Context getPackageContext(String str) {
Context context = sApplicationContext;
if (context == null) {
Log.e(TAG, "getTargetPackageContext sApplicationContext is null");
return null;
}
try {
return context.createPackageContext(str, 2);
} catch (Exception e) {
Log.e(TAG, e.getMessage());
return null;
}
}
public static String getPackageName() {
Context context = sApplicationContext;
if (context != null) {
return context.getPackageName();
}
Log.e(TAG, "getPackageName sApplicationContext is null");
return "";
}
public static String getPatchConfig(int i) {
return getPatchZipTempDecompressFilePath(i, XWALK_CORE_PATCH_CONFIG_NAME);
}
public static String getPatchFileListConfig(int i) {
return getPatchZipTempDecompressFilePath(i, XWALK_CORE_FILELIST_CONFIG_NAME);
}
public static String getPatchFileListConfig(Context context, int i) {
return getPatchZipTempDecompressFilePath(context, i, XWALK_CORE_FILELIST_CONFIG_NAME);
}
public static String getPatchZipTempDecompressFilePath(int i, String str) {
String str2 = getVesionDir(i) + File.separator + PATCH_ZIP_TEMP_DECOMPRESS_DIR;
File file = new File(str2);
if (!file.exists()) {
file.mkdirs();
}
return str2 + File.separator + str;
}
public static String getPatchZipTempDecompressFilePath(Context context, int i, String str) {
String str2;
if (context == null) {
str2 = "getPatchZipTempDecompressFilePath with context, context is null";
} else {
String vesionDir = getVesionDir(context, i);
if (!vesionDir.isEmpty()) {
return vesionDir + File.separator + PATCH_ZIP_TEMP_DECOMPRESS_DIR + File.separator + str;
}
str2 = "getPatchZipTempDecompressFilePath with context, versionDir is empty";
}
Log.e(TAG, str2);
return "";
}
public static String getPatchZipTempDecompressPath(int i) {
String str = getVesionDir(i) + File.separator + PATCH_ZIP_TEMP_DECOMPRESS_DIR;
File file = new File(str);
if (!file.exists()) {
file.mkdirs();
}
return str;
}
public static String getPluginBaseDir() {
Context context = sApplicationContext;
return context == null ? "" : context.getDir(XWALK_PLUGIN_BASE_DIR, 0).getAbsolutePath();
}
public static String getPluginConfigUrl() {
StringBuilder sb;
String str;
String pluginTestConfigUrl = getPluginTestConfigUrl();
if (isValidConfigHost(pluginTestConfigUrl)) {
sb = new StringBuilder();
str = "plugin use test config url: ";
} else {
pluginTestConfigUrl = getTempPluginUpdateConfigUrl();
if (isValidConfigHost(pluginTestConfigUrl)) {
sb = new StringBuilder();
str = "plugin use temp config url: ";
} else {
pluginTestConfigUrl = DOWNLOAD_PLUGIN_UPDATE_CONFIG_URL_THIRD_PARD;
sb = new StringBuilder();
str = "plugin use release config url: ";
}
}
sb.append(str);
sb.append(pluginTestConfigUrl);
addXWalkInitializeLog(sb.toString());
return pluginTestConfigUrl;
}
public static String getPluginTestConfigUrl() {
SharedPreferences sharedPreferencesForTestXWeb = getSharedPreferencesForTestXWeb();
if (sharedPreferencesForTestXWeb == null) {
Log.e(TAG, "hasPluginTestConfigUrl sp is null");
return "";
}
String string = sharedPreferencesForTestXWeb.getString(SP_KEY_PLUGIN_TEST_CONFIG_URL, "");
if (string == null) {
return "";
}
String trim = string.trim();
return trim.isEmpty() ? "" : trim;
}
public static String getPluginUpdateConfigFilePath() {
if (sApplicationContext == null) {
return "";
}
return getUpdateConfigDir() + File.separator + XWALK_PLUGIN_UPDATE_CONFIG_NAME;
}
public static int getPluginUpdatePeriod() {
int tempPluginUpdatePeriod = getTempPluginUpdatePeriod();
if (tempPluginUpdatePeriod > 0) {
addXWalkInitializeLog("getPluginUpdatePeriod use tempPeriod = " + tempPluginUpdatePeriod);
return tempPluginUpdatePeriod;
}
int o = b.o();
if (o <= 0) {
addXWalkInitializeLog("getPluginUpdatePeriod use defaultPeriod = 90000000");
return XWALK_PLUGIN_UPDATE_PERIOD_DEFAULT;
}
addXWalkInitializeLog("getPluginUpdatePeriod use cmdPeriod = " + o);
return o;
}
public static String getProcessName() {
if (!TextUtils.isEmpty(sStrCurentProcessName)) {
return sStrCurentProcessName;
}
Object xWebInitArgs = getXWebInitArgs(XWALK_ENV_MAP_KEY_PROCESSNAME);
sStrCurentProcessName = xWebInitArgs != null ? xWebInitArgs.toString() : f.a(getApplicationContext());
return sStrCurentProcessName;
}
public static SharedPreferences getProcessSafePreferences(String str, int i) {
return sApplicationContext.getSharedPreferences(str, i);
}
public static String getRuntimeAbi() {
char c2;
if (sRuntimeAbi == null) {
char c3 = 0;
try {
String lowerCase = Build.CPU_ABI.toLowerCase();
switch (lowerCase.hashCode()) {
case -806050265:
if (lowerCase.equals("x86_64")) {
c2 = 4;
break;
}
c2 = 65535;
break;
case -738963905:
if (lowerCase.equals("armeabi")) {
c2 = 0;
break;
}
c2 = 65535;
break;
case 117110:
if (lowerCase.equals("x86")) {
c2 = 3;
break;
}
c2 = 65535;
break;
case 145444210:
if (lowerCase.equals(RUNTIME_ABI_ARM32_STR)) {
c2 = 1;
break;
}
c2 = 65535;
break;
case 1431565292:
if (lowerCase.equals(RUNTIME_ABI_ARM64_STR)) {
c2 = 2;
break;
}
c2 = 65535;
break;
default:
c2 = 65535;
break;
}
if (c2 == 0 || c2 == 1) {
sRuntimeAbi = RUNTIME_ABI_ARM32_STR;
} else if (c2 == 2) {
sRuntimeAbi = RUNTIME_ABI_ARM64_STR;
} else if (c2 == 3) {
sRuntimeAbi = "x86";
} else if (c2 != 4) {
sRuntimeAbi = lowerCase;
} else {
sRuntimeAbi = "x86_64";
}
} catch (Exception e) {
Log.e(TAG, "get abi from cpu_abi failed , err = " + e.getMessage());
}
if (TextUtils.isEmpty(sRuntimeAbi)) {
try {
String lowerCase2 = System.getProperty("os.arch").toLowerCase();
switch (lowerCase2.hashCode()) {
case -1409295825:
if (lowerCase2.equals("armv7l")) {
c3 = 6;
break;
}
c3 = 65535;
break;
case -1221096139:
if (lowerCase2.equals("aarch64")) {
c3 = '\t';
break;
}
c3 = 65535;
break;
case -806050265:
if (lowerCase2.equals("x86_64")) {
c3 = 5;
break;
}
c3 = 65535;
break;
case -738963905:
if (lowerCase2.equals("armeabi")) {
c3 = 7;
break;
}
c3 = 65535;
break;
case 117046:
if (lowerCase2.equals("x64")) {
c3 = 4;
break;
}
c3 = 65535;
break;
case 117110:
if (lowerCase2.equals("x86")) {
break;
}
c3 = 65535;
break;
case 3178856:
if (lowerCase2.equals("i386")) {
c3 = 2;
break;
}
c3 = 65535;
break;
case 3181739:
if (lowerCase2.equals("i686")) {
c3 = 1;
break;
}
c3 = 65535;
break;
case 3222903:
if (lowerCase2.equals("ia32")) {
c3 = 3;
break;
}
c3 = 65535;
break;
case 93084186:
if (lowerCase2.equals(com.tencent.mtt.BuildConfig.FLAVOR)) {
c3 = 11;
break;
}
c3 = 65535;
break;
case 93086174:
if (lowerCase2.equals("armv8")) {
c3 = '\n';
break;
}
c3 = 65535;
break;
case 145444210:
if (lowerCase2.equals(RUNTIME_ABI_ARM32_STR)) {
c3 = '\b';
break;
}
c3 = 65535;
break;
default:
c3 = 65535;
break;
}
switch (c3) {
case 4:
case 5:
if (is64bitDevice()) {
sRuntimeAbi = "x86_64";
break;
}
case 0:
case 1:
case 2:
case 3:
sRuntimeAbi = "x86";
break;
case '\t':
case '\n':
case 11:
if (is64bitDevice()) {
sRuntimeAbi = RUNTIME_ABI_ARM64_STR;
break;
}
case 6:
case 7:
case '\b':
sRuntimeAbi = RUNTIME_ABI_ARM32_STR;
break;
default:
sRuntimeAbi = "arch:" + lowerCase2;
break;
}
} catch (Exception e2) {
Log.e(TAG, "get abi from os.arch failed , err = " + e2.getMessage());
}
}
if (sRuntimeAbi.equals(RUNTIME_ABI_ARM32_STR)) {
if (isIaDevice()) {
sRuntimeAbi = "x86";
}
} else if (sRuntimeAbi.equals(RUNTIME_ABI_ARM64_STR) && isIaDevice()) {
sRuntimeAbi = "x86_64";
}
Log.i(TAG, "Runtime ABI: " + sRuntimeAbi);
}
return sRuntimeAbi;
}
public static String getSafeModuleForCommand(String str) {
try {
String moduleName = getModuleName();
if (!"tools".equalsIgnoreCase(moduleName) && !"toolsmp".equalsIgnoreCase(moduleName) && !"mm".equalsIgnoreCase(moduleName) && !"support".equalsIgnoreCase(moduleName)) {
if (moduleName.startsWith("appbrand")) {
Log.i(TAG, "getSafeModuleForCommand appbrand");
return "appbrand";
}
Log.i(TAG, "getSafeModuleForCommand unknown " + moduleName + ", use defaultVal " + str);
return str;
}
Log.i(TAG, "getSafeModuleForCommand " + moduleName);
return moduleName;
} catch (Exception e) {
Log.e(TAG, "getSafeModuleForCommand error, use defaultVal " + str + ", error info: ", e);
return str;
}
}
public static SharedPreferences getSharedPreferences() {
return getProcessSafePreferences("libxwalkcore", 4);
}
public static SharedPreferences getSharedPreferencesForFileReaderRecord() {
if (sApplicationContext == null) {
return null;
}
return getProcessSafePreferences(SP_NAME_FILE_READER_RECORD, 4);
}
public static SharedPreferences getSharedPreferencesForLog() {
if (sApplicationContext == null) {
return null;
}
return getMMKVSharedPreferencesEx("UPDATELOG", 4, true);
}
public static SharedPreferences getSharedPreferencesForPluginUpdateInfo() {
if (sApplicationContext == null) {
return null;
}
return getProcessSafePreferences(SP_NAME_PLUGIN_UPDATE_INFO, 4);
}
public static SharedPreferences getSharedPreferencesForPluginVersionInfo(String str) {
if (sApplicationContext == null) {
return null;
}
return getProcessSafePreferences(SP_NAME_PLUGIN_VERSION_INFO_PREFIX + str, 4);
}
public static SharedPreferences getSharedPreferencesForTestXWeb() {
Context context = sApplicationContext;
if (context != null) {
return context.getSharedPreferences("TESTXWEB", 4);
}
Log.e(TAG, "getSharedPreferencesForTestXWeb context is null");
return null;
}
public static SharedPreferences getSharedPreferencesForUpdateConfig() {
return getProcessSafePreferences("UPDATEINFOTAG", 4);
}
public static SharedPreferences getSharedPreferencesForVersionInfo() {
return getProcessSafePreferences(SP_NAME_VERSION_INFO, 4);
}
public static SharedPreferences getSharedPreferencesForXWEBUpdater() {
return getMMKVSharedPreferencesEx("XWEB_UPDATER", 4, false);
}
public static synchronized String getTempPluginUpdateConfigUrl() {
String str;
synchronized (XWalkEnvironment.class) {
str = sStrTempPluginUpdateConfigUrl;
}
return str;
}
public static synchronized int getTempPluginUpdatePeriod() {
int i;
synchronized (XWalkEnvironment.class) {
i = sTempPluginUpdatePeriod;
}
return i;
}
public static synchronized String getTempUpdateConfigUrl() {
String str;
synchronized (XWalkEnvironment.class) {
str = sStrTempUpdateConfigUrl;
}
return str;
}
public static String getTestDownLoadUrl(Context context) {
return getMMKVSharedTransportOld("TESTXWEB").getString("XWEB_TEST_CONFIG_URL", "");
}
public static int getTodayGrayValue() {
byte[] digest;
String format = new SimpleDateFormat("yyyyMMdd").format(new Date());
if (s_todayGrayValue != 0 && format.equals(s_todayDate)) {
return s_todayGrayValue;
}
s_todayDate = format;
int userId = getUserId();
if (userId == 0) {
userId = getGrayValue();
}
try {
digest = MessageDigest.getInstance("MD5").digest(((4294967295L & userId) + "@" + format).getBytes());
} catch (Exception unused) {
s_todayGrayValue = userId;
}
if (digest != null && digest.length > 3) {
int i = ((digest[0] & ByteCompanionObject.MAX_VALUE) << 24) | (digest[3] & 255) | ((digest[2] & 255) << 8) | ((digest[1] & 255) << 16);
if (i == 0) {
s_todayGrayValue = userId;
return userId;
}
s_todayGrayValue = (i % 10000) + 1;
return s_todayGrayValue;
}
s_todayGrayValue = userId;
return userId;
}
public static int getTodayGrayValueByKey(String str) {
String format = new SimpleDateFormat("yyyyMMdd").format(new Date());
int userId = getUserId();
if (userId == 0) {
userId = getGrayValue();
}
try {
byte[] digest = MessageDigest.getInstance("MD5").digest(((userId & 4294967295L) + "@" + format + "key=" + str).getBytes());
if (digest != null && digest.length > 3) {
int i = ((digest[0] & ByteCompanionObject.MAX_VALUE) << 24) | (digest[3] & 255) | ((digest[2] & 255) << 8) | ((digest[1] & 255) << 16);
return i == 0 ? s_todayGrayValue : (i % 10000) + 1;
}
return s_todayGrayValue;
} catch (Exception unused) {
return s_todayGrayValue;
}
}
public static String getUpdateConfigDir() {
return sApplicationContext.getDir(XWALK_UPDATE_CONFIG_DIR, 0).getAbsolutePath();
}
public static String getUpdateConfigFullPath() {
return getUpdateConfigDir() + File.separator + "updateConfg.xml";
}
public static int getUserId() {
return getMMKVSharedPreferences("XWEB_USER_INFO").getInt("USER_ID", 0);
}
public static int getUserType() {
return getIpType();
}
public static boolean getUsingCustomContext() {
return sUsingCustomContext;
}
static int getVerFromVersionName(String str) {
if (str != null && !str.isEmpty()) {
try {
return Integer.parseInt(str.split("\\.")[0]);
} catch (Exception unused) {
Log.e(TAG, "parse to int error str is :" + str);
}
}
return 0;
}
public static String getVesionDir(int i) {
String absolutePath = sApplicationContext.getDir(XWALK_CORE_NAME_PREFIX + i, 0).getAbsolutePath();
File file = new File(absolutePath);
if (!file.exists()) {
file.mkdirs();
}
return absolutePath;
}
public static String getVesionDir(Context context, int i) {
if (context == null) {
Log.e(TAG, "getVersionDir with context, context is null");
return "";
}
return context.getDir(XWALK_CORE_NAME_PREFIX + i, 0).getAbsolutePath();
}
public static String getXWalkInitializeLog() {
SharedPreferences sharedPreferencesForLog = getSharedPreferencesForLog();
return sharedPreferencesForLog == null ? "" : sharedPreferencesForLog.getString(j.NAME, "");
}
public static String getXWalkUpdateConfigUrl() {
StringBuilder sb;
String str;
sXWalkDownConfigUrl = getTestDownLoadUrl(getApplicationContext());
if (isValidConfigHost(sXWalkDownConfigUrl)) {
sb = new StringBuilder();
str = "use test config url : ";
} else {
sXWalkDownConfigUrl = getTempUpdateConfigUrl();
if (!isValidConfigHost(sXWalkDownConfigUrl)) {
sXWalkDownConfigUrl = isIaDevice() ? DOWNLOAD_X86_CONFIG_URL : DOWNLOAD_CONFIG_URL_THIRD_PARD;
Log.i(TAG, "use update config url = " + sXWalkDownConfigUrl);
return sXWalkDownConfigUrl;
}
sb = new StringBuilder();
str = "use temp config url : ";
}
sb.append(str);
sb.append(sXWalkDownConfigUrl);
addXWalkInitializeLog(sb.toString());
Log.i(TAG, "use update config url = " + sXWalkDownConfigUrl);
return sXWalkDownConfigUrl;
}
public static synchronized Object getXWebInitArgs(String str) {
synchronized (XWalkEnvironment.class) {
if (sXWebArgs != null && sXWebArgs.containsKey(str)) {
return sXWebArgs.get(str);
}
return null;
}
}
public static synchronized String getXWebInitArgs(String str, String str2) {
synchronized (XWalkEnvironment.class) {
Object xWebInitArgs = getXWebInitArgs(str);
if (xWebInitArgs != null && (xWebInitArgs instanceof String)) {
return (String) xWebInitArgs;
}
return str2;
}
}
public static synchronized boolean getXWebInitArgs(String str, boolean z) {
synchronized (XWalkEnvironment.class) {
Object xWebInitArgs = getXWebInitArgs(str);
if (xWebInitArgs == null) {
return z;
}
try {
return Boolean.valueOf(xWebInitArgs.toString()).booleanValue();
} catch (Exception unused) {
Log.e(TAG, "getXWebInitArgs boolean parse failed");
return z;
}
}
}
public static boolean hasAvailableVersion() {
return 2000 <= getAvailableVersion();
}
public static boolean hasInstalledAvailableVersion() {
return 2000 <= getInstalledNewstVersionForCurAbi();
}
public static synchronized void init(Context context) {
synchronized (XWalkEnvironment.class) {
if (context != null) {
if (sApplicationContext == null) {
sApplicationContext = context.getApplicationContext();
String runtimeAbi = getRuntimeAbi();
Log.i(TAG, "current abi is " + runtimeAbi);
XWebCoreInfo backupCoreInfo = XWebCoreInfo.getBackupCoreInfo(runtimeAbi);
if (backupCoreInfo.ver <= 0) {
if (!getSharedPreferencesForVersionInfo().getBoolean("transported_version", false)) {
int i = getSharedPreferencesForVersionInfo().getInt(SP_KEY_PLUGIN_AVAILABLE_VERSION, -1);
String string = getSharedPreferencesForVersionInfo().getString("versionDetail", "");
backupCoreInfo.strAbi = runtimeAbi;
backupCoreInfo.ver = i;
backupCoreInfo.verDetail = string;
}
if (XWebCoreInfo.setVersionForAbi(backupCoreInfo)) {
getSharedPreferencesForVersionInfo().edit().putBoolean("transported_version", true).commit();
}
}
sXWebCoreInfo = backupCoreInfo;
if (!sIsPluginInited) {
sIsPluginInited = initXWalkPlugins();
}
v.a(context);
initTurnOnKVLog();
}
}
}
}
static void initSafePsProvider() {
if (sBHasInitedSafePsProvider) {
return;
}
try {
sMMKVMethod = Class.forName("com.tencent.mm.xwebutil.XWebMMkvWrapper").getMethod("getMMKV", Context.class, String.class, Integer.TYPE, Boolean.TYPE);
} catch (Exception unused) {
}
if (sMMKVMethod == null) {
h.a(178L, 1);
Log.e(TAG, "initSafePsProvider failed");
} else {
Log.i(TAG, "initSafePsProvider suscsess");
}
sBHasInitedSafePsProvider = true;
}
public static void initTurnOnKVLog() {
try {
isTurnOnKVLog = v.a().n();
} catch (Exception unused) {
Log.e(TAG, "init log failed");
}
}
private static boolean initXWalkPlugins() {
return com.tencent.luggage.wxa.ud.h.a();
}
public static boolean is64BitRuntime() {
String runtimeAbi = getRuntimeAbi();
return RUNTIME_ABI_ARM64_STR.equalsIgnoreCase(runtimeAbi) || "x86_64".equalsIgnoreCase(runtimeAbi) || "mips64".equalsIgnoreCase(runtimeAbi);
}
public static boolean is64bitApp() {
String runtimeAbi = getRuntimeAbi();
return runtimeAbi.equals(RUNTIME_ABI_ARM64_STR) || runtimeAbi.equals("x86_64");
}
public static boolean is64bitDevice() {
String deviceAbi = getDeviceAbi();
return deviceAbi.equals(RUNTIME_ABI_ARM64_STR) || deviceAbi.equals("x86_64");
}
public static boolean isCurrentVersionSupportCustomContext() {
return hasAvailableVersion() && getFeatureSupport(1020);
}
public static boolean isCurrentVersionSupportCustomInputForAppbrand() {
return hasAvailableVersion() && getFeatureSupport(XWalkFeature.INTERFACE_EXTEND_PLUGIN_INPUT);
}
public static boolean isCurrentVersionSupportCustomTextAreaForAppbrand() {
return hasAvailableVersion() && getFeatureSupport(1012);
}
public static boolean isCurrentVersionSupportExtendPluginForAppbrand() {
return hasAvailableVersion() && getAvailableVersion() >= 300;
}
public static boolean isCurrentVersionSupportForceDarkMode() {
return hasAvailableVersion() && getFeatureSupport(1021);
}
public static boolean isCurrentVersionSupportMapExtendPluginForAppbrand() {
return hasAvailableVersion() && getFeatureSupport(1011);
}
public static boolean isCurrentVersionSupportNativeView() {
return hasAvailableVersion() && getFeatureSupport(1013);
}
public static boolean isCurrentVersionSupportScreenshotForSameLayer() {
return hasAvailableVersion() && getFeatureSupport(2010);
}
public static boolean isCurrentVersionSupportSetWebContentsSize() {
return hasAvailableVersion() && getFeatureSupport(1042);
}
public static boolean isDownloadMode() {
return sIsDownloadMode.booleanValue();
}
public static boolean isDownloadModeUpdate() {
return sIsDownloadModeUpdate.booleanValue();
}
public static boolean isForbidDownloadCode() {
return ag.a();
}
public static boolean isIaDevice() {
String deviceAbi = getDeviceAbi();
return deviceAbi.equals("x86") || deviceAbi.equals("x86_64");
}
public static boolean isInTestMode() {
String testDownLoadUrl = getTestDownLoadUrl(getApplicationContext());
return (testDownLoadUrl == null || testDownLoadUrl.isEmpty()) ? false : true;
}
public static boolean isProvider(String str) {
if (str == null || str.isEmpty()) {
Log.e(TAG, "isProvider packageName is null or empty");
return false;
}
for (String str2 : XWALK_CORE_PROVIDER_LIST) {
if (str2.equals(str)) {
return true;
}
}
return false;
}
public static boolean isSelfProvider() {
Context context = sApplicationContext;
if (context != null) {
return isProvider(context.getPackageName());
}
Log.e(TAG, "isSelfProvider sApplicationContext is null");
return true;
}
public static boolean isTestVersion(int i) {
return i >= 100000000;
}
public static boolean isValidConfigHost(String str) {
if (str != null && !TextUtils.isEmpty(str) && !TextUtils.isEmpty(str.trim())) {
try {
URI uri = new URI(str.trim());
if (uri.getScheme().equals(UriUtil.HTTPS_SCHEME)) {
return uri.getHost().equals("dldir1.qq.com");
}
return false;
} catch (Exception unused) {
Log.e(TAG, "java.net.URI new crashed ");
}
}
return false;
}
public static int readAvailableVersionFromSP(Context context) {
if (context != null) {
return XWebCoreInfo.getCurAbiInstalledNewestVersion(context);
}
Log.e(TAG, "readAvailableVersionFromSP context is null");
return -1;
}
public static void refreshAvailableVersion() {
sXWebCoreInfo = XWebCoreInfo.getBackupCoreInfo(getRuntimeAbi());
if (sXWebCoreInfo.ver != -1) {
getSharedPreferences().edit().putString("XWALK_CORE_EXTRACTED_DIR", getExtractedCoreDir(sXWebCoreInfo.ver)).commit();
}
}
public static void refreshVerInfo() {
sXWebCoreInfo = XWebCoreInfo.getBackupCoreInfo(getRuntimeAbi());
}
public static void resetForDebug() {
sApplicationContext = null;
sXWebCoreInfo = null;
sIsPluginInited = false;
}
static boolean runnintOnUiThread() {
return Looper.getMainLooper() == Looper.myLooper();
}
public static int safeGetChromiunVersion() {
int verFromVersionName;
if (sNChromiuVersion < 0) {
try {
PackageInfo packageInfo = getApplicationContext().getPackageManager().getPackageInfo("com.google.android.webview", 0);
if (packageInfo != null && (verFromVersionName = getVerFromVersionName(packageInfo.versionName)) > 0) {
sNChromiuVersion = verFromVersionName;
return verFromVersionName;
}
} catch (Exception unused) {
Log.e(TAG, "Android System WebView is not found");
}
}
return sNChromiuVersion;
}
public static synchronized void setAppClientVersion(int i) {
synchronized (XWalkEnvironment.class) {
sAppClientVersion = i;
}
}
public static boolean setAvailableVersion(int i, String str, String str2) {
return XWebCoreInfo.setVersionForAbi(i, str, str2);
}
public static void setConfigFetchPeriod(long j) {
sConfigPerios = j;
}
public static void setForceDarkBehavior(ForceDarkBehavior forceDarkBehavior) {
int i = AnonymousClass1.$SwitchMap$org$xwalk$core$XWalkEnvironment$ForceDarkBehavior[forceDarkBehavior.ordinal()];
if (i == 1) {
sForceDarkBehavior = 0;
} else if (i == 2) {
sForceDarkBehavior = 1;
} else if (i == 3) {
sForceDarkBehavior = 2;
}
Log.i(TAG, "setForceDarkMode forceDarkBehavior:" + forceDarkBehavior);
l.a(WebView.c.WV_KIND_CW).excute("STR_CMD_FORCE_DARK_MODE_BEHAVIOR_COMMAND", new Object[]{Integer.valueOf(sForceDarkBehavior)});
}
public static void setForceDarkMode(boolean z) {
sIsForceDarkMode = z;
Log.i(TAG, "setForceDarkMode forceDarkMode:" + z);
l.a(WebView.c.WV_KIND_CW).excute("STR_CMD_FORCE_DARK_MODE_COMMAND", new Object[]{Boolean.valueOf(sIsForceDarkMode)});
}
public static void setGrayValueByUserId(int i) {
byte[] digest;
if (i == 0) {
return;
}
setUserId(i);
try {
digest = MessageDigest.getInstance("MD5").digest(("xweb_gray_value" + (4294967295L & i)).getBytes());
} catch (Exception unused) {
s_grayValue = 0;
}
if (digest != null && digest.length > 3) {
int i2 = ((digest[0] & ByteCompanionObject.MAX_VALUE) << 24) | (digest[3] & 255) | ((digest[2] & 255) << 8) | ((digest[1] & 255) << 16);
if (i2 == 0) {
return;
}
s_grayValue = (i2 % 10000) + 1;
int i3 = getSharedPreferences().getInt(SP_KEY_GRAY_VALUE, -1);
getSharedPreferences().edit().putInt(SP_KEY_GRAY_VALUE, s_grayValue).commit();
if (i3 != s_grayValue) {
Log.i(TAG, "gray value changed to " + s_grayValue);
l.a(WebView.c.WV_KIND_CW).excute("STR_CMD_SET_RECHECK_COMMAND", null);
}
}
}
public static void setGrayValueForTest(int i) {
if (i != 10001) {
s_grayValue = i % 10000;
}
getSharedPreferences().edit().putInt(SP_KEY_GRAY_VALUE_TEST, s_grayValue).commit();
}
public static void setIpType(int i) {
long j;
int ipType = getIpType();
if (i != ipType) {
getSharedPreferences().edit().putInt(SP_KEY_IP_TYPE, i).commit();
addXWalkInitializeLog("setIpType", " to " + i);
if (ipType != 0 || i != 1) {
j = (ipType == 1 && i == 0) ? 198L : 197L;
if (ipType <= 0 || i > 0) {
sBIsIpTypeChanged = true;
l.a(WebView.c.WV_KIND_CW).excute("STR_CMD_SET_RECHECK_COMMAND", null);
}
return;
}
h.a(j, 1);
if (ipType <= 0) {
}
sBIsIpTypeChanged = true;
l.a(WebView.c.WV_KIND_CW).excute("STR_CMD_SET_RECHECK_COMMAND", null);
}
}
public static void setIsForbidDownloadCode(boolean z) {
ag.a(z);
}
public static void setLocale(Locale locale) {
if (locale == null) {
Log.w(TAG, "[setLocale] customize locale not set");
return;
}
Log.i(TAG, "[setLocale] customize locale:" + locale.toLanguageTag());
setLocaleString(locale.toLanguageTag());
}
private static void setLocaleString(String str) {
sLocaleString = str;
}
public static boolean setPluginTestConfigUrl(String str) {
SharedPreferences sharedPreferencesForTestXWeb = getSharedPreferencesForTestXWeb();
if (sharedPreferencesForTestXWeb == null) {
Log.e(TAG, "setPluginTestConfigUrl sp is null");
return false;
}
SharedPreferences.Editor edit = sharedPreferencesForTestXWeb.edit();
if (str == null || str.trim().isEmpty()) {
edit.remove(SP_KEY_PLUGIN_TEST_CONFIG_URL);
} else {
edit.putString(SP_KEY_PLUGIN_TEST_CONFIG_URL, str.trim());
}
return edit.commit();
}
public static synchronized void setSharedPreferenceProvider(ISharedPreferenceProvider iSharedPreferenceProvider) {
synchronized (XWalkEnvironment.class) {
if (iSharedPreferenceProvider != null) {
sSPProvider = iSharedPreferenceProvider;
}
}
}
public static synchronized void setTempPluginUpdateConfigUrl(String str) {
synchronized (XWalkEnvironment.class) {
sStrTempPluginUpdateConfigUrl = str;
}
}
public static synchronized boolean setTempPluginUpdateConfigUrl(String str, String str2) {
synchronized (XWalkEnvironment.class) {
if (!TextUtils.isEmpty(str2)) {
try {
if (new Date().after(new SimpleDateFormat("yyyyMMdd").parse(str2))) {
Log.i(TAG, "today is after enddate set tempConfig failed ");
return false;
}
} catch (Exception unused) {
Log.e(TAG, "parse strEndDate failed , set url failed ");
return false;
}
}
sStrTempPluginUpdateConfigUrl = str;
return true;
}
}
public static synchronized void setTempPluginUpdatePeriod(int i) {
synchronized (XWalkEnvironment.class) {
sTempPluginUpdatePeriod = i;
}
}
public static synchronized void setTempUpdateConfigUrl(String str) {
synchronized (XWalkEnvironment.class) {
sStrTempUpdateConfigUrl = str;
}
}
public static synchronized boolean setTempUpdateConfigUrl(String str, String str2) {
synchronized (XWalkEnvironment.class) {
if (!TextUtils.isEmpty(str2)) {
try {
if (new Date().after(new SimpleDateFormat("yyyyMMdd").parse(str2))) {
Log.i(TAG, "today is after enddate set tempConfig failed ");
return false;
}
} catch (Exception unused) {
Log.e(TAG, "parse strEndDate failed , set url failed ");
return false;
}
}
sStrTempUpdateConfigUrl = str;
return true;
}
}
public static void setTestDownLoadUrl(Context context, String str) {
sXWalkDownConfigUrl = null;
((str == null || str.isEmpty()) ? getMMKVSharedTransportOld("TESTXWEB").edit().putString("XWEB_TEST_CONFIG_URL", "") : getMMKVSharedTransportOld("TESTXWEB").edit().putString("XWEB_TEST_CONFIG_URL", str)).commit();
getXWalkUpdateConfigUrl();
}
public static void setTodayGrayValueForTest(int i) {
s_todayGrayValue = i;
s_todayDate = new SimpleDateFormat("yyyyMMdd").format(new Date());
}
public static void setUserId(int i) {
getMMKVSharedPreferences("XWEB_USER_INFO").edit().putInt("USER_ID", i).commit();
}
public static void setUsingCustomContext(boolean z) {
sUsingCustomContext = z;
Log.i(TAG, "setUsingCustomContext usingCustomContext:" + z);
}
public static synchronized void setXWebInitArgs(HashMap hashMap) {
synchronized (XWalkEnvironment.class) {
sXWebArgs = hashMap;
}
}
static void tryClose(Closeable closeable) {
if (closeable == null || closeable == null) {
return;
}
try {
closeable.close();
} catch (Exception e) {
Log.e(TAG, "closeable close failed " + e.getMessage());
}
}
}