package com.tencent.smtt.utils; import android.content.Context; import android.content.SharedPreferences; import android.content.pm.PackageInfo; import android.content.pm.Signature; import android.os.Build; import android.provider.Settings; import android.telephony.TelephonyManager; import android.text.TextUtils; import android.util.Log; import androidx.core.view.PointerIconCompat; import com.tencent.smtt.sdk.QbSdk; import com.tencent.smtt.sdk.TbsConfig; import com.tencent.smtt.sdk.TbsDownloadConfig; import com.tencent.smtt.sdk.TbsPrivacyAccess; import com.tencent.smtt.sdk.c; import java.io.BufferedReader; import java.io.File; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.io.RandomAccessFile; import java.lang.reflect.Method; import java.security.cert.Certificate; import java.util.Enumeration; import java.util.jar.JarEntry; import java.util.jar.JarFile; public class b { public static String a = ""; public static String b = ""; public static String c = ""; public static String d = ""; public static String e = ""; public static String f = ""; private static String g = ""; private static boolean h = false; private static boolean i = false; private static boolean j = false; private static boolean k = false; private static boolean l = false; /* JADX WARNING: Can't wrap try/catch for region: R(5:2|(11:3|4|5|6|7|8|(1:10)(1:12)|11|(1:14)|15|16)|17|18|38) */ /* JADX WARNING: Code restructure failed: missing block: B:36:0x0067, code lost: if (r2 == null) goto L_0x006a; */ /* JADX WARNING: Failed to process nested try/catch */ /* JADX WARNING: Missing exception handler attribute for start block: B:17:0x003e */ /* JADX WARNING: Removed duplicated region for block: B:32:0x0060 */ /* JADX WARNING: Removed duplicated region for block: B:34:0x0064 A[SYNTHETIC, Splitter:B:34:0x0064] */ /* JADX WARNING: Removed duplicated region for block: B:42:0x0071 */ /* JADX WARNING: Removed duplicated region for block: B:44:0x0075 A[SYNTHETIC, Splitter:B:44:0x0075] */ /* JADX WARNING: Removed duplicated region for block: B:48:0x007a A[SYNTHETIC, Splitter:B:48:0x007a] */ public static String a() { Throwable th; InputStreamReader inputStreamReader; BufferedReader bufferedReader; Throwable th2; if (!j) { String str = null; try { inputStreamReader = new InputStreamReader(Runtime.getRuntime().exec("getprop ro.product.cpu.abi").getInputStream()); try { bufferedReader = new BufferedReader(inputStreamReader); try { String a2 = a(bufferedReader.readLine().contains("x86") ? "i686" : System.getProperty("os.arch")); if (a2 != null) { c = a2; } bufferedReader.close(); } catch (Throwable th3) { th2 = th3; try { str = a(System.getProperty("os.arch")); th2.printStackTrace(); if (str != null) { } if (bufferedReader != null) { } } catch (Throwable th4) { th = th4; if (str != null) { } if (bufferedReader != null) { } if (inputStreamReader != null) { } throw th; } } } catch (Throwable th5) { th = th5; bufferedReader = null; if (str != null) { c = str; } if (bufferedReader != null) { try { bufferedReader.close(); } catch (IOException unused) { } } if (inputStreamReader != null) { try { inputStreamReader.close(); } catch (IOException unused2) { } } throw th; } } catch (Throwable th6) { th = th6; bufferedReader = null; inputStreamReader = null; if (str != null) { } if (bufferedReader != null) { } if (inputStreamReader != null) { } throw th; } inputStreamReader.close(); j = true; } return c; } public static String a(Context context) { try { return context.getPackageName(); } catch (Exception unused) { return null; } } /* JADX WARNING: Removed duplicated region for block: B:12:0x002a A[Catch:{ Exception -> 0x002f }] */ /* JADX WARNING: Removed duplicated region for block: B:16:? A[RETURN, SYNTHETIC] */ private static String a(Context context, File file) { Signature signature; try { PackageInfo packageArchiveInfo = context.getPackageManager().getPackageArchiveInfo(file.getAbsolutePath(), 65); if (packageArchiveInfo != null) { if (packageArchiveInfo.signatures == null || packageArchiveInfo.signatures.length <= 0) { TbsLog.w("AppUtil", "[getSignatureFromApk] pkgInfo is not null BUT signatures is null!"); } else { signature = packageArchiveInfo.signatures[0]; if (signature == null) { return signature.toCharsString(); } return null; } } signature = null; if (signature == null) { } } catch (Exception unused) { TbsLog.i("AppUtil", "getSign " + file + "failed"); return null; } } public static String a(Context context, String str) { String str2; try { try { return String.valueOf(Integer.toHexString(Integer.parseInt(String.valueOf(context.getPackageManager().getApplicationInfo(context.getPackageName(), 128).metaData.get(str))))); } catch (Exception unused) { return str2; } } catch (Exception unused2) { return null; } } /* JADX WARNING: Removed duplicated region for block: B:37:0x0064 A[Catch:{ Throwable -> 0x0079 }] */ /* JADX WARNING: Removed duplicated region for block: B:45:0x00a3 */ /* JADX WARNING: Removed duplicated region for block: B:47:? A[RETURN, SYNTHETIC] */ public static String a(Context context, boolean z, File file) { String a2; Throwable th; RandomAccessFile randomAccessFile; Exception e2; if (file == null || !file.exists()) { return ""; } if (z) { try { byte[] bArr = new byte[2]; randomAccessFile = new RandomAccessFile(file, "r"); try { randomAccessFile.read(bArr); if (!new String(bArr).equalsIgnoreCase("PK")) { try { randomAccessFile.close(); } catch (IOException e3) { e3.printStackTrace(); } return ""; } try { randomAccessFile.close(); } catch (IOException e4) { e4.printStackTrace(); } } catch (Exception e5) { e2 = e5; try { e2.printStackTrace(); randomAccessFile.close(); if (context.getApplicationContext().getPackageName().contains("com.jd.jrapp")) { } TbsLog.i("AppUtil", "[AppUtil.getSignatureFromApk] #4"); a2 = a(context, file); TbsLog.i("AppUtil", "[AppUtil.getSignatureFromApk] android api signature=" + a2); if (a2 != null) { } } catch (Throwable th2) { th = th2; try { randomAccessFile.close(); } catch (IOException e6) { e6.printStackTrace(); } throw th; } } } catch (Exception e7) { randomAccessFile = null; e2 = e7; e2.printStackTrace(); randomAccessFile.close(); if (context.getApplicationContext().getPackageName().contains("com.jd.jrapp")) { } TbsLog.i("AppUtil", "[AppUtil.getSignatureFromApk] #4"); a2 = a(context, file); TbsLog.i("AppUtil", "[AppUtil.getSignatureFromApk] android api signature=" + a2); if (a2 != null) { } } catch (Throwable th3) { th = th3; randomAccessFile = null; randomAccessFile.close(); throw th; } } try { if (context.getApplicationContext().getPackageName().contains("com.jd.jrapp")) { TbsLog.i("AppUtil", "[AppUtil.getSignatureFromApk] #1"); String a3 = a(file); if (a3 != null) { TbsLog.i("AppUtil", "[AppUtil.getSignatureFromApk] #2"); return a3; } } } catch (Throwable unused) { TbsLog.i("AppUtil", "[AppUtil.getSignatureFromApk] #3"); } TbsLog.i("AppUtil", "[AppUtil.getSignatureFromApk] #4"); a2 = a(context, file); TbsLog.i("AppUtil", "[AppUtil.getSignatureFromApk] android api signature=" + a2); if (a2 != null) { return a2; } String a4 = a(file); TbsLog.i("AppUtil", "[AppUtil.getSignatureFromApk] java get signature=" + a4); return a4; } private static String a(File file) { try { JarFile jarFile = new JarFile(file); byte[] bArr = new byte[8192]; String a2 = a(a(jarFile, jarFile.getJarEntry("AndroidManifest.xml"), bArr)[0].getEncoded()); Enumeration<JarEntry> entries = jarFile.entries(); while (entries.hasMoreElements()) { JarEntry nextElement = entries.nextElement(); String name = nextElement.getName(); if (name != null) { Certificate[] a3 = a(jarFile, nextElement, bArr); String a4 = a3 != null ? a(a3[0].getEncoded()) : null; if (a4 == null) { if (!name.startsWith("META-INF/")) { return null; } } else if (!a4.equals(a2)) { return null; } } } return a2; } catch (Exception e2) { e2.printStackTrace(); return null; } } private static String a(String str) { return str == null ? "" : str; } private static String a(byte[] bArr) { int length = bArr.length; char[] cArr = new char[(length * 2)]; for (int i2 = 0; i2 < length; i2++) { byte b2 = bArr[i2]; int i3 = (b2 >> 4) & 15; int i4 = i2 * 2; cArr[i4] = (char) (i3 >= 10 ? (i3 + 97) - 10 : i3 + 48); int i5 = b2 & 15; cArr[i4 + 1] = (char) (i5 >= 10 ? (i5 + 97) - 10 : i5 + 48); } return new String(cArr); } private static Certificate[] a(JarFile jarFile, JarEntry jarEntry, byte[] bArr) throws Exception { InputStream inputStream = jarFile.getInputStream(jarEntry); do { } while (inputStream.read(bArr, 0, bArr.length) != -1); inputStream.close(); if (jarEntry != null) { return jarEntry.getCertificates(); } return null; } public static int b(Context context) { if (TbsPrivacyAccess.AndroidVersion.isDisabled()) { return 0; } return Build.VERSION.SDK_INT; } public static void b(Context context, String str) { try { TbsDownloadConfig instance = TbsDownloadConfig.getInstance(context); instance.mSyncMap.put(TbsDownloadConfig.TbsConfigKey.KEY_GUID, str); instance.commit(); } catch (Exception unused) { } } public static boolean b() { Class<?> cls; Method declaredMethod; Object invoke; Method declaredMethod2; try { if (Build.VERSION.SDK_INT < 21 || (cls = Class.forName("dalvik.system.VMRuntime")) == null || (declaredMethod = cls.getDeclaredMethod("getRuntime", new Class[0])) == null || (invoke = declaredMethod.invoke(null, new Object[0])) == null || (declaredMethod2 = cls.getDeclaredMethod("is64Bit", new Class[0])) == null) { return false; } Object invoke2 = declaredMethod2.invoke(invoke, new Object[0]); if (invoke2 instanceof Boolean) { return ((Boolean) invoke2).booleanValue(); } return false; } catch (Throwable th) { th.printStackTrace(); } } public static String c(Context context) { if (TbsPrivacyAccess.DeviceModel.isDisabled()) { return ""; } if (!l) { String d2 = r.d(context); try { f = new String(d2.getBytes("UTF-8"), "ISO8859-1"); } catch (Exception unused) { f = d2; } l = true; } return f; } public static String d(Context context) { try { return context.getPackageManager().getPackageInfo(context.getPackageName(), 0).versionName; } catch (Exception unused) { return null; } } public static int e(Context context) { try { return context.getPackageManager().getPackageInfo(context.getPackageName(), 0).versionCode; } catch (Exception unused) { return 0; } } public static String f(Context context) { try { return TbsDownloadConfig.getInstance(context).mPreferences.getString(TbsDownloadConfig.TbsConfigKey.KEY_GUID, ""); } catch (Exception unused) { return ""; } } public static boolean g(final Context context) { boolean z = false; try { z = context.getSharedPreferences("sai", 0).getBoolean("gi", false); TbsLog.i("AppUtil", "getImeiEnable is " + z); c.a().a(context, (Integer) 1001, (c.a) new c.a() { /* class com.tencent.smtt.utils.b.AnonymousClass1 */ @Override // com.tencent.smtt.sdk.c.a public void a(String str) { SharedPreferences.Editor edit = context.getSharedPreferences("sai", 0).edit(); edit.putBoolean("gi", true); edit.commit(); TbsLog.e("TBSEmergency", "Execute command [1001](" + str + ")"); } }); return z; } catch (Throwable th) { TbsLog.i("AppUtil", "stack is " + Log.getStackTraceString(th)); return z; } } public static String h(Context context) { if (!h) { try { a = m(context); if (TextUtils.isEmpty(a)) { a = j.a(context); } } catch (Exception e2) { TbsLog.i(e2); } h = true; } return a; } public static String i(Context context) { String str; String str2; if (!QbSdk.isEnableSensitiveApi()) { str = "AppUtil"; str2 = "getImsi isEnableSensitiveApi = false"; } else if (!QbSdk.isEnableCanGetSubscriberId()) { str = "AppUtil"; str2 = "getImsi isEnableCanGetSubscriberId is false"; } else { if (!i) { try { if (context.getApplicationInfo().packageName.contains(TbsConfig.APP_QQ)) { return ""; } b = ((TelephonyManager) context.getSystemService("phone")).getSubscriberId(); i = true; } catch (Exception e2) { TbsLog.i(e2); } } return b; } TbsLog.i(str, str2); return ""; } public static String j(Context context) { return "02:00:00:00:00:00"; } public static String k(Context context) { if (!QbSdk.isEnableSensitiveApi()) { TbsLog.i("AppUtil", "getAndroidID isEnableSensitiveApi = false"); return ""; } else if (!QbSdk.isEnableGetAndroidID()) { TbsLog.i("AppUtil", "getAndroidID isEnableGetAndroidID is false"); return ""; } else if (!o(context)) { TbsLog.i("AppUtil", "getAndroidID isAndroidIDEnable is false"); return ""; } else { if (!k) { try { e = Settings.Secure.getString(context.getContentResolver(), "android_id"); } catch (Exception e2) { e2.printStackTrace(); } k = true; } TbsLog.i("AppUtil", "getAndroidID mAndroidID is " + e); return e; } } public static boolean l(Context context) { return context != null && context.checkCallingOrSelfPermission("android.permission.READ_EXTERNAL_STORAGE") == 0; } private static String m(Context context) { try { if (!QbSdk.isEnableGetDeviceID()) { TbsLog.i("AppUtil", "getDeviceID isEnableGetDeviceID is false"); return ""; } else if (!n(context)) { TbsLog.i("AppUtil", "getDeviceID isDeviceIDEnable is false"); return ""; } else { g = ((TelephonyManager) context.getSystemService("phone")).getDeviceId(); TbsLog.i("AppUtil", "getDeviceID mDeviceID is " + g); return g; } } catch (Exception e2) { TbsLog.i(e2); } } private static boolean n(final Context context) { boolean z = false; try { z = context.getSharedPreferences("sai", 0).getBoolean("pdi", false); TbsLog.i("AppUtil", "isDeviceIDEnable is " + z); c a2 = c.a(); a2.a(context, (Integer) 1004, (c.a) new c.a() { /* class com.tencent.smtt.utils.b.AnonymousClass2 */ @Override // com.tencent.smtt.sdk.c.a public void a(String str) { SharedPreferences.Editor edit = context.getSharedPreferences("sai", 0).edit(); edit.putBoolean("pdi", false); edit.commit(); TbsLog.e("TBSEmergency", "Execute command [1004](" + str + ")"); } }); a2.a(context, Integer.valueOf((int) PointerIconCompat.TYPE_ALIAS), new c.a() { /* class com.tencent.smtt.utils.b.AnonymousClass3 */ @Override // com.tencent.smtt.sdk.c.a public void a(String str) { SharedPreferences.Editor edit = context.getSharedPreferences("sai", 0).edit(); edit.putBoolean("pdi", true); edit.commit(); TbsLog.e("TBSEmergency", "Execute command [1010](+extra+)"); } }); return z; } catch (Throwable th) { TbsLog.i("AppUtil", "stack is " + Log.getStackTraceString(th)); return z; } } private static boolean o(final Context context) { boolean z = false; try { z = context.getSharedPreferences("sai", 0).getBoolean("gpai", false); TbsLog.i("AppUtil", "isAndroidIDEnable is " + z); c a2 = c.a(); a2.a(context, Integer.valueOf((int) PointerIconCompat.TYPE_NO_DROP), new c.a() { /* class com.tencent.smtt.utils.b.AnonymousClass4 */ @Override // com.tencent.smtt.sdk.c.a public void a(String str) { SharedPreferences.Editor edit = context.getSharedPreferences("sai", 0).edit(); edit.putBoolean("gpai", false); edit.commit(); TbsLog.e("TBSEmergency", "Execute command [1012](+extra+)"); } }); a2.a(context, Integer.valueOf((int) PointerIconCompat.TYPE_COPY), new c.a() { /* class com.tencent.smtt.utils.b.AnonymousClass5 */ @Override // com.tencent.smtt.sdk.c.a public void a(String str) { SharedPreferences.Editor edit = context.getSharedPreferences("sai", 0).edit(); edit.putBoolean("gpai", true); edit.commit(); TbsLog.e("TBSEmergency", "Execute command [1011](+extra+)"); } }); return z; } catch (Throwable th) { TbsLog.i("AppUtil", "stack is " + Log.getStackTraceString(th)); return z; } } }