package com.tencent.smtt.utils; import android.content.Context; import android.content.pm.ApplicationInfo; import android.content.pm.PackageInfo; import android.content.pm.PackageManager; import android.os.Build; import android.text.TextUtils; import android.util.DisplayMetrics; import android.view.Display; import android.view.WindowManager; import com.baidu.speech.utils.cuid.util.DeviceId; import com.fasterxml.jackson.core.util.MinimalPrettyPrinter; import com.tencent.smtt.sdk.TbsConfig; import com.tencent.smtt.sdk.TbsListener; import com.tencent.smtt.sdk.WebView; public class k { private static String a = null; private static String b = "GA"; private static String c = "GE"; private static String d = "9422"; private static String e = "0"; private static String f = ""; private static boolean g = false; private static boolean h = false; private static boolean i = false; public static String a(Context context) { return a(context, DeviceId.CUIDInfo.I_EMPTY); } public static String a(Context context, String str) { if (!TextUtils.isEmpty(a)) { return a; } a = a(context, String.valueOf(WebView.getTbsSDKVersion(context)), str, b, c, d, e, f, g); return a; } private static String a(Context context, String str, String str2, String str3, String str4, String str5, String str6, String str7, boolean z) { String str8 = ""; String str9 = ""; String str10 = "PHONE"; StringBuilder sb = new StringBuilder(); String str11 = b(context) + "*" + c(context); try { ApplicationInfo applicationInfo = context.getApplicationContext().getApplicationInfo(); PackageInfo packageInfo = context.getPackageManager().getPackageInfo(applicationInfo.packageName, 0); str8 = applicationInfo.packageName; str9 = !TextUtils.isEmpty(str7) ? str7 : packageInfo.versionName; } catch (PackageManager.NameNotFoundException e2) { e2.printStackTrace(); } String a2 = a(str8); if (!"QB".equals(a2) ? e(context) : z) { str10 = "PAD"; } sb.append("QV"); sb.append("="); sb.append("3"); a(sb, "PL", "ADR"); a(sb, "PR", a2); a(sb, "PP", str8); a(sb, "PPVN", str9); if (!TextUtils.isEmpty(str)) { a(sb, "TBSVC", str); } a(sb, "CO", "SYS"); if (!TextUtils.isEmpty(str2) && !str2.equals(DeviceId.CUIDInfo.I_EMPTY)) { a(sb, "CO", "BK"); } if (!TextUtils.isEmpty(str2)) { a(sb, "COVC", str2); } a(sb, "PB", str4); a(sb, "VE", str3); a(sb, "DE", str10); a(sb, "CHID", TextUtils.isEmpty(str6) ? DeviceId.CUIDInfo.I_EMPTY : str6); a(sb, "LCID", str5); String d2 = d(context); try { d2 = new String(d2.getBytes("UTF-8"), "ISO8859-1"); } catch (Exception unused) { } if (!TextUtils.isEmpty(d2)) { a(sb, "MO", d2); } a(sb, "RL", str11); String str12 = Build.VERSION.RELEASE; try { str12 = new String(str12.getBytes("UTF-8"), "ISO8859-1"); } catch (Exception unused2) { } if (!TextUtils.isEmpty(str12)) { a(sb, "OS", str12); } a(sb, "API", Build.VERSION.SDK_INT + ""); return sb.toString(); } private static String a(String str) { return TbsConfig.APP_WX.equals(str) ? "WX" : TbsConfig.APP_QQ.equals(str) ? "QQ" : TbsConfig.APP_QZONE.equals(str) ? "QZ" : TbsConfig.APP_QB.equals(str) ? "QB" : "TRD"; } private static void a(StringBuilder sb, String str, String str2) { sb.append("&"); sb.append(str); sb.append("="); sb.append(str2); } private static int b(Context context) { Display defaultDisplay = ((WindowManager) context.getSystemService("window")).getDefaultDisplay(); if (defaultDisplay != null) { return defaultDisplay.getWidth(); } return -1; } private static int c(Context context) { Display defaultDisplay = ((WindowManager) context.getSystemService("window")).getDefaultDisplay(); if (defaultDisplay != null) { return defaultDisplay.getHeight(); } return -1; } private static String d(Context context) { String d2 = r.d(context); return MinimalPrettyPrinter.DEFAULT_ROOT_VALUE_SEPARATOR + d2.replaceAll("[ |\\/|\\_|\\&|\\|]", "") + MinimalPrettyPrinter.DEFAULT_ROOT_VALUE_SEPARATOR; } private static boolean e(Context context) { if (h) { return i; } try { i = (Math.min(b(context), c(context)) * TbsListener.ErrorCode.STARTDOWNLOAD_1) / f(context) >= 700; h = true; return i; } catch (Throwable unused) { return false; } } private static int f(Context context) { DisplayMetrics displayMetrics = new DisplayMetrics(); Display defaultDisplay = ((WindowManager) context.getSystemService("window")).getDefaultDisplay(); if (defaultDisplay == null) { return TbsListener.ErrorCode.STARTDOWNLOAD_1; } defaultDisplay.getMetrics(displayMetrics); return displayMetrics.densityDpi; } }