package com.baidu.techain.i; import android.app.AlarmManager; import android.app.Application; import android.app.PendingIntent; import android.content.BroadcastReceiver; import android.content.ComponentName; import android.content.Context; import android.content.Intent; import android.content.IntentFilter; import android.content.SharedPreferences; import android.content.pm.ApplicationInfo; import android.content.pm.PackageInfo; import android.content.pm.PackageManager; import android.content.pm.ProviderInfo; import android.content.pm.ResolveInfo; import android.content.res.XmlResourceParser; import android.net.ConnectivityManager; import android.net.NetworkInfo; import android.os.Build; import android.os.Looper; import android.os.Message; import android.os.Process; import android.text.TextUtils; import android.util.Base64; import com.baidu.android.common.util.DeviceId; import com.baidu.techain.TechainActivity; import com.baidu.techain.TechainProvider; import com.baidu.techain.TechainReceiver; import com.baidu.techain.TechainService; import com.baidu.techain.a.a; import com.baidu.techain.ac.F; import com.baidu.techain.b; import com.baidu.techain.core.ApkInfo; import com.baidu.techain.core.f; import com.baidu.techain.rp.Report; import com.meizu.cloud.pushsdk.constants.PushConstants; import com.meizu.cloud.pushsdk.notification.model.NotifyType; import com.umeng.analytics.pro.ak; import com.umeng.analytics.pro.d; import com.umeng.commonsdk.framework.UMModuleRegister; import com.xiaomi.mipush.sdk.Constants; import java.io.BufferedReader; import java.io.File; import java.io.FileInputStream; import java.io.FileOutputStream; import java.io.FileReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.lang.reflect.Field; import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; import java.security.PublicKey; import java.util.ArrayList; import java.util.Calendar; import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.Properties; import java.util.TimeZone; import org.json.JSONArray; import org.json.JSONObject; /* compiled from: CommonMethods */ public final class c { public static boolean a = false; public static String b = null; public static String c = null; public static int d = 0; public static String e = "3"; public static String f = "925fc15df8a49bed0b3eca8d2b44cb7b"; public static TechainReceiver g = null; public static HashMap<Integer, ApkInfo> h = null; public static JSONObject i = null; public static long j = 0; private static int k = -1; private static String l = ""; private static String m = ""; private static int n = -1; private static int o = -1; private static int p = -1; public static void a() { b.d(); } /* JADX WARNING: Removed duplicated region for block: B:12:0x001f */ /* JADX WARNING: Removed duplicated region for block: B:14:? A[RETURN, SYNTHETIC] */ private static PublicKey a(PackageInfo packageInfo, String str) { PublicKey publicKey; if (!(packageInfo.signatures == null || packageInfo.signatures.length <= 0 || packageInfo.signatures[0] == null)) { try { publicKey = b.a(packageInfo.signatures[0]); } catch (Throwable unused) { b.d(); } return publicKey != null ? b.a(str) : publicKey; } publicKey = null; if (publicKey != null) { } } public static String a(Class<?> cls) { try { if (cls.getCanonicalName().equals(Integer.TYPE.getCanonicalName())) { return Integer.class.getCanonicalName(); } if (cls.getCanonicalName().equals(Boolean.TYPE.getCanonicalName())) { return Boolean.class.getCanonicalName(); } if (cls.getCanonicalName().equals(Character.TYPE.getCanonicalName())) { return Character.class.getCanonicalName(); } if (cls.getCanonicalName().equals(Byte.TYPE.getCanonicalName())) { return Byte.class.getCanonicalName(); } if (cls.getCanonicalName().equals(Short.TYPE.getCanonicalName())) { return Short.class.getCanonicalName(); } if (cls.getCanonicalName().equals(Long.TYPE.getCanonicalName())) { return Long.class.getCanonicalName(); } if (cls.getCanonicalName().equals(Float.TYPE.getCanonicalName())) { return Float.class.getCanonicalName(); } if (cls.getCanonicalName().equals(Double.TYPE.getCanonicalName())) { return Double.class.getCanonicalName(); } return null; } catch (Throwable unused) { b.d(); return null; } } public static Class<?> a(String str) { try { if (str.contains(Integer.class.getCanonicalName())) { return Integer.TYPE; } if (str.contains(Boolean.class.getCanonicalName())) { return Boolean.TYPE; } if (str.contains(Character.class.getCanonicalName())) { return Character.TYPE; } if (str.contains(Byte.class.getCanonicalName())) { return Byte.TYPE; } if (str.contains(Short.class.getCanonicalName())) { return Short.TYPE; } if (str.contains(Long.class.getCanonicalName())) { return Long.TYPE; } if (str.contains(Float.class.getCanonicalName())) { return Float.TYPE; } if (str.contains(Double.class.getCanonicalName())) { return Double.TYPE; } return null; } catch (Throwable unused) { b.d(); return null; } } private static int q(Context context) { try { String b2 = b(context); if (TextUtils.isEmpty(m)) { m = b(Process.myPid()); } if (TextUtils.isEmpty(m)) { return 0; } return !TextUtils.isEmpty(b2) ? b2.equals(m) ? 1 : 2 : context.getPackageName().equals(m) ? 3 : 4; } catch (Throwable unused) { b.d(); return 0; } } public static int a(Context context) { try { int i2 = 1; if (TechainProvider.a()) { return 1; } if (k == -1) { int q = q(context); if (q != 1) { if (q == 2 || !TechainProvider.a()) { i2 = 0; } } k = i2; } return k; } catch (Throwable unused) { b.d(); return -1; } } public static String b(Context context) { try { if (TextUtils.isEmpty(l)) { if (o != 1) { ProviderInfo resolveContentProvider = context.getPackageManager().resolveContentProvider(context.getPackageName() + ".techain.ac.provider", 0); if (!(resolveContentProvider == null || resolveContentProvider.multiprocess)) { l = resolveContentProvider.processName; } o = 1; return l; } } return l; } catch (Throwable unused) { b.d(); } } /* JADX WARNING: Code restructure failed: missing block: B:10:0x0010, code lost: return false; */ /* JADX WARNING: Code restructure failed: missing block: B:21:?, code lost: com.baidu.techain.b.d(); */ /* JADX WARNING: Code restructure failed: missing block: B:23:0x0035, code lost: return false; */ /* JADX WARNING: Code restructure failed: missing block: B:8:0x000d, code lost: if (r5 != 1) goto L_0x0010; */ /* JADX WARNING: Code restructure failed: missing block: B:9:0x000f, code lost: return true; */ /* JADX WARNING: Exception block dominator not found, dom blocks: [] */ /* JADX WARNING: Missing exception handler attribute for start block: B:20:0x0031 */ public static synchronized boolean a(Context context, boolean z) { boolean z2; synchronized (c.class) { if (n != -1) { int i2 = n; } else { String b2 = b(context); if (TextUtils.isEmpty(b2)) { z2 = a(context, context.getPackageName(), true, z); } else { z2 = a(context, b2, false, z); } if (z2) { n = 1; } else { n = 0; } return z2; } } } /* JADX WARNING: Removed duplicated region for block: B:13:0x0035 */ /* JADX WARNING: Removed duplicated region for block: B:20:0x004a A[Catch:{ all -> 0x008a }] */ /* JADX WARNING: Removed duplicated region for block: B:29:0x006b */ /* JADX WARNING: Removed duplicated region for block: B:30:0x0074 */ /* JADX WARNING: Removed duplicated region for block: B:33:0x007f */ private static boolean a(Context context, String str, boolean z, boolean z2) { ResolveInfo resolveInfo; boolean z3 = false; try { Intent intent = new Intent(); intent.setComponent(new ComponentName(context.getPackageName(), TechainService.class.getCanonicalName())); resolveInfo = context.getPackageManager().resolveService(intent, 0); if (resolveInfo != null) { try { if (str.equals(resolveInfo.serviceInfo.processName)) { z3 = true; } } catch (Throwable unused) { b.d(); if (resolveInfo == null) { } if (TextUtils.isEmpty(m)) { } HashMap hashMap = new HashMap(); if (!z3) { } if (z) { } a(context, "1003140", (Map<String, Object>) hashMap, true); return z3; } } } catch (Throwable unused2) { resolveInfo = null; b.d(); if (resolveInfo == null) { } if (TextUtils.isEmpty(m)) { } HashMap hashMap2 = new HashMap(); if (!z3) { } if (z) { } a(context, "1003140", (Map<String, Object>) hashMap2, true); return z3; } if (resolveInfo == null) { try { if (str.equals(a(context, str, "service"))) { z3 = true; } } catch (Throwable unused3) { b.d(); } } if (TextUtils.isEmpty(m)) { m = b(Process.myPid()); } if (z2 && m.equals(str) && (!z3 || z)) { HashMap hashMap22 = new HashMap(); if (!z3) { hashMap22.put(PushConstants.PUSH_TYPE_NOTIFY, Integer.toString(2)); } else if (!z3) { hashMap22.put(PushConstants.PUSH_TYPE_NOTIFY, Integer.toString(1)); } if (z) { hashMap22.put("1", PushConstants.PUSH_TYPE_NOTIFY); } a(context, "1003140", (Map<String, Object>) hashMap22, true); } return z3; } public static boolean b(String str) { try { if (TextUtils.isEmpty(m)) { m = b(Process.myPid()); } if (!str.equals(m)) { return true; } return false; } catch (Throwable unused) { b.d(); return false; } } public static void a(String str, String str2) { if (!TextUtils.isEmpty(str) && !TextUtils.isEmpty(str2)) { a(new File(str), new File(str2)); } } private static String a(Context context, String str, String str2) { int next; String attributeValue; String str3; String str4; try { XmlResourceParser openXmlResourceParser = context.createPackageContext(context.getPackageName(), 3).getAssets().openXmlResourceParser("AndroidManifest.xml"); if (openXmlResourceParser != null) { do { next = openXmlResourceParser.next(); if (next == 2) { break; } } while (next != 1); if (next == 2 && openXmlResourceParser.getName().equals("manifest") && (attributeValue = openXmlResourceParser.getAttributeValue(null, "package")) != null) { if (attributeValue.length() != 0) { int length = attributeValue.length(); int i2 = 0; boolean z = false; boolean z2 = true; while (true) { if (i2 < length) { char charAt = attributeValue.charAt(i2); if ((charAt < 'a' || charAt > 'z') && (charAt < 'A' || charAt > 'Z')) { if (z2 || ((charAt < '0' || charAt > '9') && charAt != '_')) { if (charAt != '.') { str3 = "bad character '" + charAt + "'"; break; } z = true; z2 = true; } } else { z2 = false; } i2++; } else { str3 = z ? null : "must have at least one '.' separator"; } } if (str3 == null || "android".equals(attributeValue)) { if (str2.equals(d.M)) { str4 = TechainProvider.class.getCanonicalName(); } else if (str2.equals("service")) { str4 = TechainService.class.getCanonicalName(); } else { str4 = str2.equals("receiver") ? TechainReceiver.class.getCanonicalName() : null; } while (true) { int next2 = openXmlResourceParser.next(); if (next2 == 1) { break; } else if (next2 == 2) { String name = openXmlResourceParser.getName(); if (d.M.equals(name)) { try { if (openXmlResourceParser.getAttributeValue("http://schemas.android.com/apk/res/android", "name").equals(str4)) { String attributeValue2 = openXmlResourceParser.getAttributeValue("http://schemas.android.com/apk/res/android", "multiprocess"); if (!TextUtils.isEmpty(attributeValue2) && "true".equals(attributeValue2.toLowerCase())) { return null; } String attributeValue3 = openXmlResourceParser.getAttributeValue("http://schemas.android.com/apk/res/android", "authorities"); if (TextUtils.isEmpty(attributeValue3) || !str.equals(attributeValue3)) { return null; } String attributeValue4 = openXmlResourceParser.getAttributeValue("http://schemas.android.com/apk/res/android", UMModuleRegister.PROCESS); if (TextUtils.isEmpty(attributeValue4)) { return context.getPackageName(); } if (!attributeValue4.startsWith(Constants.COLON_SEPARATOR)) { return attributeValue4; } return context.getPackageName() + attributeValue4; } } catch (Throwable unused) { b.d(); } } else if ("service".equals(name)) { try { String attributeValue5 = openXmlResourceParser.getAttributeValue("http://schemas.android.com/apk/res/android", "name"); if (!TextUtils.isEmpty(attributeValue5) && attributeValue5.equals(str4)) { String attributeValue6 = openXmlResourceParser.getAttributeValue("http://schemas.android.com/apk/res/android", UMModuleRegister.PROCESS); if (TextUtils.isEmpty(attributeValue6)) { return context.getPackageName(); } if (!attributeValue6.startsWith(Constants.COLON_SEPARATOR)) { return attributeValue6; } return context.getPackageName() + attributeValue6; } } catch (Throwable unused2) { b.d(); } } else if ("receiver".equals(name)) { try { String attributeValue7 = openXmlResourceParser.getAttributeValue("http://schemas.android.com/apk/res/android", "name"); if (!TextUtils.isEmpty(attributeValue7) && attributeValue7.equals(str4)) { String attributeValue8 = openXmlResourceParser.getAttributeValue("http://schemas.android.com/apk/res/android", UMModuleRegister.PROCESS); if (TextUtils.isEmpty(attributeValue8)) { return context.getPackageName(); } if (!attributeValue8.startsWith(Constants.COLON_SEPARATOR)) { return attributeValue8; } return context.getPackageName() + attributeValue8; } } catch (Throwable unused3) { b.d(); } } else { continue; } } } } else { return null; } } } return null; } } catch (Throwable unused4) { b.d(); } return null; } /* JADX WARNING: Failed to process nested try/catch */ /* JADX WARNING: Missing exception handler attribute for start block: B:21:0x0035 */ /* JADX WARNING: Removed duplicated region for block: B:33:0x0042 A[SYNTHETIC, Splitter:B:33:0x0042] */ /* JADX WARNING: Removed duplicated region for block: B:37:0x0049 A[SYNTHETIC, Splitter:B:37:0x0049] */ /* JADX WARNING: Removed duplicated region for block: B:55:? A[RETURN, SYNTHETIC] */ public static void a(File file, File file2) { FileOutputStream fileOutputStream; if (file != null && file2 != null && a(file)) { if (file2.exists()) { file2.delete(); } FileInputStream fileInputStream = null; try { FileInputStream fileInputStream2 = new FileInputStream(file); try { fileOutputStream = new FileOutputStream(file2); } catch (Throwable unused) { fileOutputStream = null; fileInputStream = fileInputStream2; try { b.d(); if (fileInputStream != null) { try { fileInputStream.close(); } catch (Throwable unused2) { } } if (fileOutputStream != null) { try { fileOutputStream.close(); return; } catch (Throwable unused3) { return; } } else { return; } } catch (Throwable unused4) { } } try { byte[] bArr = new byte[8192]; while (true) { int read = fileInputStream2.read(bArr); if (read == -1) { break; } fileOutputStream.write(bArr, 0, read); } fileOutputStream.flush(); fileInputStream2.close(); try { fileOutputStream.close(); return; } catch (Throwable unused5) { return; } } catch (Throwable unused6) { fileInputStream = fileInputStream2; b.d(); if (fileInputStream != null) { } if (fileOutputStream != null) { } } } catch (Throwable unused7) { fileOutputStream = null; b.d(); if (fileInputStream != null) { } if (fileOutputStream != null) { } } } else { return; } if (fileOutputStream != null) { fileOutputStream.close(); } throw th; throw th; } public static boolean c(String str) { if (TextUtils.isEmpty(str)) { return false; } return a(new File(str)); } public static boolean a(File file) { return file != null && file.exists() && file.isFile() && file.canRead() && file.length() > 0; } public static void d(String str) { try { if (!TextUtils.isEmpty(str)) { File file = new File(str); if (file.exists()) { File[] listFiles = file.listFiles(); if (listFiles != null && listFiles.length > 0) { for (File file2 : listFiles) { if (file2.isDirectory()) { d(file2.getAbsolutePath()); } else { file2.delete(); } } } file.delete(); } } } catch (Throwable unused) { b.d(); } } public static Object a(Object obj, String str, Class<?>[] clsArr, Object... objArr) throws NoSuchMethodException, InvocationTargetException, IllegalAccessException { if (obj == null || TextUtils.isEmpty(str)) { throw new NoSuchMethodException("object=" + obj + ", methodName=" + str); } else if (clsArr == null || objArr == null || clsArr.length == objArr.length) { Method[] declaredMethods = obj.getClass().getDeclaredMethods(); Method method = null; int length = declaredMethods.length; int i2 = 0; while (true) { if (i2 >= length) { break; } Method method2 = declaredMethods[i2]; if (a(method2, str, clsArr)) { method = method2; break; } i2++; } if (method != null) { return method.invoke(obj, objArr); } throw new NoSuchMethodException("cannot find method in target methodName=" + str); } else { throw new NoSuchMethodException("paramTypes or args fail"); } } private static boolean a(Method method, String str, Class<?>[] clsArr) { if (!str.equals(method.getName())) { return false; } Class<?>[] parameterTypes = method.getParameterTypes(); if ((parameterTypes == null || parameterTypes.length == 0) && (clsArr == null || clsArr.length == 0)) { return true; } if ((clsArr == null || clsArr.length == 0) && parameterTypes != null && parameterTypes.length > 0) { return false; } if (((parameterTypes == null || parameterTypes.length == 0) && clsArr != null && clsArr.length > 0) || parameterTypes == null || clsArr == null || parameterTypes.length != clsArr.length) { return false; } for (int i2 = 0; i2 < parameterTypes.length; i2++) { if (parameterTypes[i2] != clsArr[i2]) { return false; } } return true; } public static void a(String str, boolean z) { c("771", str); if (z) { c("771", new File(str).getParentFile().getAbsolutePath()); } } private static boolean c(String str, String str2) { if (TextUtils.isEmpty(str) || TextUtils.isEmpty(str2) || !new File(str2).exists()) { return false; } try { Runtime runtime = Runtime.getRuntime(); runtime.exec("chmod " + str + " " + str2 + "\n").waitFor(); return true; } catch (Throwable unused) { b.d(); return false; } } public static void c(Context context) { try { Report instance = Report.getInstance(context); JSONObject jSONObject = new JSONObject(); a a2 = a.a(context); Map<Integer, String> b2 = a2.b(); jSONObject.put(PushConstants.PUSH_TYPE_NOTIFY, b2.keySet()); jSONObject.put("1", b2.values()); JSONObject jSONObject2 = new JSONObject(); JSONObject jSONObject3 = new JSONObject(); jSONObject3.put("1003003", jSONObject); jSONObject2.put(PushConstants.PUSH_TYPE_NOTIFY, jSONObject3); Map<Integer, String> c2 = a2.c(); JSONArray jSONArray = new JSONArray(); for (String str : c2.values()) { jSONArray.put(str); } jSONArray.put("com.baidu.techain"); jSONObject2.put(PushConstants.PUSH_TYPE_UPLOAD_LOG, jSONArray); instance.w(jSONObject2.toString()); } catch (Throwable unused) { } } public static void d(Context context) { if (!TextUtils.isEmpty("3.5.9.0.1")) { Report instance = Report.getInstance(context); try { c(context); instance.i("techain", "com.baidu.techain", "3.5.9.0.1", "1003003", "1003002"); } catch (Throwable unused) { } } } public static String b() { try { return new String(F.getInstance().ad(Base64.decode(m.a, 0), "30212102dicudiab".getBytes())); } catch (Throwable unused) { return ""; } } private static String f(String str) { try { int length = str.length(); int i2 = 0; while (i2 < length && (str.charAt(i2) <= ' ' || str.charAt(i2) == 160)) { i2++; } if (i2 > 0) { return str.substring(i2); } return str; } catch (Throwable unused) { b.d(); return ""; } } public static void a(Context context, String str, Map<String, Object> map, boolean z) { String str2; if (!TextUtils.isEmpty(str)) { try { JSONObject jSONObject = new JSONObject(); JSONObject jSONObject2 = new JSONObject(); jSONObject2.put(PushConstants.PUSH_TYPE_NOTIFY, System.currentTimeMillis()); jSONObject2.put("1", ""); jSONObject2.put(PushConstants.PUSH_TYPE_UPLOAD_LOG, ""); String[] g2 = g(context); if (g2 == null || g2.length != 2 || TextUtils.isEmpty(g2[0]) || TextUtils.isEmpty(g2[1])) { str2 = e; } else { str2 = g2[0]; } jSONObject2.put(PushConstants.PUSH_FLYME_3_CHANGE_VERSION_START, str2); jSONObject2.put(PushConstants.PUSH_TYPE_WITHDRAW_NOTIFICATION, 0); jSONObject2.put("5", 0); jSONObject2.put("6", 1); jSONObject2.put("7", 0); jSONObject2.put("8", "techain"); jSONObject2.put("9", "3.5.9.0.1"); jSONObject2.put("10", str); jSONObject.put("Common_section", jSONObject2); if (map.size() > 0) { jSONObject.put("Module_section", new JSONObject(map)); } else { jSONObject.put("Module_section", new JSONObject()); } Report.getInstance(context).s(jSONObject.toString(), z); } catch (Throwable unused) { b.d(); } } } public static void a(Context context, String str, Map<String, Object> map) { String str2; if (!TextUtils.isEmpty(str)) { try { JSONObject jSONObject = new JSONObject(); JSONObject jSONObject2 = new JSONObject(); jSONObject2.put(PushConstants.PUSH_TYPE_NOTIFY, System.currentTimeMillis()); jSONObject2.put("1", ""); jSONObject2.put(PushConstants.PUSH_TYPE_UPLOAD_LOG, ""); String[] g2 = g(context); if (g2 == null || g2.length != 2 || TextUtils.isEmpty(g2[0]) || TextUtils.isEmpty(g2[1])) { str2 = e; } else { str2 = g2[0]; } jSONObject2.put(PushConstants.PUSH_FLYME_3_CHANGE_VERSION_START, str2); jSONObject2.put(PushConstants.PUSH_TYPE_WITHDRAW_NOTIFICATION, 0); jSONObject2.put("5", 0); jSONObject2.put("6", 1); jSONObject2.put("7", 0); jSONObject2.put("8", "techain"); jSONObject2.put("9", "3.5.9.0.1"); jSONObject2.put("10", str); jSONObject.put("Common_section", jSONObject2); if (map.size() > 0) { jSONObject.put("Module_section", new JSONObject(map)); } else { jSONObject.put("Module_section", new JSONObject()); } Report.getInstance(context).sr(jSONObject.toString()); } catch (Throwable unused) { b.d(); } } } /* JADX WARNING: Code restructure failed: missing block: B:16:0x0026, code lost: if (r2 == null) goto L_0x002c; */ /* JADX WARNING: Code restructure failed: missing block: B:6:0x0017, code lost: if (r2 != null) goto L_0x0019; */ /* JADX WARNING: Code restructure failed: missing block: B:8:?, code lost: r2.close(); */ private static String b(Context context, String str, String str2) { String str3 = ""; try { Properties properties = new Properties(); InputStream inputStream = null; try { inputStream = context.getAssets().open(str); properties.load(inputStream); str3 = properties.getProperty(str2); } catch (IOException unused) { } catch (Throwable th) { if (inputStream != null) { try { inputStream.close(); } catch (IOException unused2) { } } throw th; } } catch (Throwable unused3) { b.d(); } return str3; } public static boolean e(Context context) { NetworkInfo activeNetworkInfo = ((ConnectivityManager) context.getSystemService("connectivity")).getActiveNetworkInfo(); if (activeNetworkInfo != null && 1 == activeNetworkInfo.getType()) { return true; } return false; } public static boolean f(Context context) { try { NetworkInfo activeNetworkInfo = ((ConnectivityManager) context.getSystemService("connectivity")).getActiveNetworkInfo(); if (activeNetworkInfo == null) { return false; } return activeNetworkInfo.isConnected(); } catch (Throwable unused) { b.d(); return false; } } public static String[] g(Context context) { String[] split; String[] split2; String str = b; String str2 = c; if (!TextUtils.isEmpty(str) && !TextUtils.isEmpty(str2)) { return new String[]{str, str2}; } if (TextUtils.isEmpty(str) || TextUtils.isEmpty(str2)) { String a2 = com.baidu.techain.h.a.a(context).a(); if (!TextUtils.isEmpty(a2) && (split2 = a2.split(Constants.ACCEPT_TIME_SEPARATOR_SERVER)) != null && split2.length == 2) { return split2; } } if (TextUtils.isEmpty(str) || TextUtils.isEmpty(str2)) { String string = com.baidu.techain.h.a.a(context).a.getString("svi", ""); if (!TextUtils.isEmpty(string) && (split = string.split(Constants.ACCEPT_TIME_SEPARATOR_SERVER)) != null && split.length == 2) { return split; } } if (TextUtils.isEmpty(str) || TextUtils.isEmpty(str2)) { str = e; str2 = f; } return new String[]{str, str2}; } public static boolean a(Context context, int i2) { if (i2 != 1 || e(context)) { return true; } IntentFilter intentFilter = new IntentFilter("android.net.conn.CONNECTIVITY_CHANGE"); if (g == null) { g = new TechainReceiver().a(); } a(context, g, intentFilter); a = true; return false; } private static void a(Context context, byte[] bArr) { try { String[] g2 = g(context); if (g2 != null && g2.length == 2) { if (!(TextUtils.isEmpty(g2[0]) || TextUtils.isEmpty(g2[1]) || !"200080".equals(g2[0]) || !context.getPackageName().equals("com.baidu.BaiduMap") || bArr == null)) { for (int i2 = 0; i2 < bArr.length; i2++) { bArr[i2] = (byte) (bArr[i2] ^ 246); } } } } catch (Throwable unused) { } } public static void h(Context context) { com.baidu.techain.h.a a2 = com.baidu.techain.h.a.a(context); long currentTimeMillis = System.currentTimeMillis(); long j2 = a2.a.getLong("se_ae_fd", 0); if (j2 == 0) { j2 = System.currentTimeMillis(); a2.g(); } if (currentTimeMillis - j2 > 86400000) { HashMap hashMap = new HashMap(); hashMap.put(PushConstants.PUSH_TYPE_NOTIFY, Integer.valueOf(a2.j() + 1)); a2.c(0); a2.g(); a(context, "1003119", (Map<String, Object>) hashMap, false); return; } a2.c(a2.j() + 1); } public static boolean b(String str, String str2) { if (TextUtils.isEmpty(str) || TextUtils.isEmpty(str2) || str.equals(str2)) { return false; } return true; } private static boolean d(String str, String str2) { if (!TextUtils.isEmpty(str) && !TextUtils.isEmpty(str2)) { try { String[] split = str.split("\\."); String[] split2 = str2.split("\\."); int i2 = 0; while (i2 < split.length && i2 < split2.length) { int intValue = Integer.valueOf(split[i2]).intValue() - Integer.valueOf(split2[i2]).intValue(); if (intValue == 0) { i2++; } else if (intValue > 0) { return true; } else { return false; } } if (split.length > split2.length) { return true; } } catch (Throwable unused) { } } return false; } public static boolean i(Context context) { try { if (p < 0 && context != null) { try { String packageName = context.getPackageName(); Field field = Class.forName(packageName + ".BuildConfig").getField("DEBUG"); field.setAccessible(true); p = field.getBoolean(null) ? 1 : 0; } catch (Throwable unused) { if (context.getApplicationInfo() != null) { if ((context.getApplicationInfo().flags & 2) != 0) { p = 1; } else { p = 0; } } } } return p == 1; } catch (Throwable unused2) { b.d(); } } public static void j(Context context) throws UnsupportedOperationException { if (i(context) && !"com.baidu.input".equals(context.getPackageName())) { StringBuilder sb = new StringBuilder("SDK Self Check: "); int length = sb.length(); try { System.loadLibrary("techain"); } catch (Throwable unused) { sb.append("LoadLibrary Error,"); } try { Class.forName("com.baidu.techain.ac.F").getDeclaredMethod("getInstance", new Class[0]); } catch (Exception unused2) { sb.append("Proguard Error,"); } try { boolean z = context.getPackageManager().resolveContentProvider(context.getPackageName() + ".techain.ac.provider", 0).multiprocess; } catch (Throwable unused3) { sb.append("Provider Error,"); } if (!a(context, false)) { sb.append("Service or Receiver Error."); } try { context.getPackageManager().getActivityInfo(new ComponentName(context.getPackageName(), TechainActivity.class.getCanonicalName()), 0); } catch (Throwable unused4) { sb.append("Activity error "); } if (sb.length() > length) { throw new UnsupportedOperationException(sb.toString()); } } } public static int k(Context context) { NetworkInfo activeNetworkInfo; try { ConnectivityManager connectivityManager = (ConnectivityManager) context.getSystemService("connectivity"); if (!(connectivityManager == null || (activeNetworkInfo = connectivityManager.getActiveNetworkInfo()) == null || activeNetworkInfo.getState() != NetworkInfo.State.CONNECTED)) { if (activeNetworkInfo.getType() == 1) { return 4; } if (activeNetworkInfo.getType() != 0) { return -2; } switch (activeNetworkInfo.getSubtype()) { case 1: case 2: return 1; case 3: return 2; case 4: return 1; case 5: case 6: return 2; case 7: return 1; case 8: case 9: case 10: return 2; case 11: return 1; case 12: return 2; case 13: return 3; case 14: case 15: return 2; default: return 5; } } } catch (Throwable unused) { b.d(); } return -1; } public static JSONObject l(Context context) { JSONObject jSONObject = new JSONObject(); try { String str = Build.BOARD; if (str == null) { str = ""; } jSONObject.put(PushConstants.PUSH_TYPE_NOTIFY, str); String str2 = Build.DEVICE; if (str2 == null) { str2 = ""; } jSONObject.put("1", str2); String b2 = e.b(); if (b2 == null) { b2 = ""; } jSONObject.put(PushConstants.PUSH_TYPE_UPLOAD_LOG, b2); String str3 = Build.HOST; if (str3 == null) { str3 = ""; } jSONObject.put(PushConstants.PUSH_FLYME_3_CHANGE_VERSION_START, str3); String a2 = e.a(); if (a2 == null) { a2 = ""; } jSONObject.put(PushConstants.PUSH_TYPE_WITHDRAW_NOTIFICATION, a2); String str4 = Build.PRODUCT; if (str4 == null) { str4 = ""; } jSONObject.put("5", str4); String str5 = Build.VERSION.CODENAME; if (str5 == null) { str5 = ""; } jSONObject.put("6", str5); String str6 = Build.VERSION.INCREMENTAL; if (str6 == null) { str6 = ""; } jSONObject.put("7", str6); jSONObject.put("8", e.b(context)); String c2 = e.c(); if (c2 == null) { c2 = ""; } jSONObject.put("9", c2); String d2 = e.d(); if (d2 == null) { d2 = ""; } jSONObject.put("10", d2); jSONObject.put("11", e.g(context)); String e2 = e.e(); if (e2 == null) { e2 = ""; } jSONObject.put("12", e2); jSONObject.put("13", e.d(context)); jSONObject.put("14", ""); jSONObject.put("17", s.k(context)); jSONObject.put("18", s.l(context)); jSONObject.put("20", Build.VERSION.SDK_INT); TimeZone timeZone = TimeZone.getDefault(); if (timeZone != null) { jSONObject.put("21", timeZone.getID()); } else { jSONObject.put("21", "-1"); } } catch (Throwable unused) { b.d(); } return jSONObject; } public static JSONObject a(Context context, com.baidu.techain.c.a aVar, String str, boolean z) { return a(context, aVar.a, aVar.c, z ? aVar.d : aVar.e, str); } public static int m(Context context) { NetworkInfo networkInfo; try { networkInfo = ((ConnectivityManager) context.getSystemService("connectivity")).getActiveNetworkInfo(); } catch (Throwable unused) { b.d(); networkInfo = null; } if (networkInfo == null) { return 0; } if (1 == networkInfo.getType()) { return 2; } if (networkInfo.getType() == 0) { } return 1; } private static String b(int i2) { String str; String str2 = null; try { if (Build.VERSION.SDK_INT >= 28) { str = Application.getProcessName(); try { if (!TextUtils.isEmpty(str)) { return str.trim(); } } catch (Throwable unused) { str2 = str; b.d(); return str2; } } else { str = null; } try { Method declaredMethod = Class.forName("android.app.ActivityThread", false, Application.class.getClassLoader()).getDeclaredMethod("currentProcessName", new Class[0]); declaredMethod.setAccessible(true); Object invoke = declaredMethod.invoke(null, new Object[0]); if (invoke instanceof String) { str = (String) invoke; } if (!TextUtils.isEmpty(str)) { return str.trim(); } str2 = g(String.format("/proc/%d/cmdline", Integer.valueOf(i2))); if (!TextUtils.isEmpty(str2)) { return str2.trim(); } return str2; } catch (Throwable unused2) { b.d(); } } catch (Throwable unused3) { b.d(); return str2; } } /* JADX WARNING: Can't wrap try/catch for region: R(4:11|12|(2:14|15)|16) */ /* JADX WARNING: Code restructure failed: missing block: B:12:?, code lost: com.baidu.techain.b.d(); */ /* JADX WARNING: Code restructure failed: missing block: B:13:0x0012, code lost: if (r1 != null) goto L_0x0014; */ /* JADX WARNING: Code restructure failed: missing block: B:15:?, code lost: r1.close(); */ /* JADX WARNING: Code restructure failed: missing block: B:16:0x0017, code lost: return null; */ /* JADX WARNING: Code restructure failed: missing block: B:18:0x0018, code lost: r2 = move-exception; */ /* JADX WARNING: Code restructure failed: missing block: B:19:0x0019, code lost: if (r1 != null) goto L_0x001b; */ /* JADX WARNING: Code restructure failed: missing block: B:21:?, code lost: r1.close(); */ /* JADX WARNING: Failed to process nested try/catch */ /* JADX WARNING: Missing exception handler attribute for start block: B:11:0x000f */ private static String g(String str) { FileInputStream fileInputStream; try { fileInputStream = new FileInputStream(str); String a2 = a(fileInputStream); try { fileInputStream.close(); } catch (Throwable unused) { } return a2; } catch (Throwable unused2) { fileInputStream = null; } throw th; } private static String a(InputStream inputStream) throws IOException { BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(inputStream, "UTF-8")); StringBuilder sb = new StringBuilder(); boolean z = true; while (true) { String readLine = bufferedReader.readLine(); if (readLine == null) { return sb.toString(); } if (!z) { sb.append('\n'); } else { z = false; } sb.append(readLine); } } /* JADX WARNING: Can't wrap try/catch for region: R(19:0|(2:1|2)|5|(1:7)(1:8)|9|10|11|12|13|14|(1:16)(1:17)|18|19|20|23|(1:25)|26|(1:28)(1:29)|32) */ /* JADX WARNING: Code restructure failed: missing block: B:30:0x0140, code lost: com.baidu.techain.b.d(); */ /* JADX WARNING: Failed to process nested try/catch */ /* JADX WARNING: Missing exception handler attribute for start block: B:11:0x0056 */ public static JSONObject a(Context context, JSONObject jSONObject) { JSONObject jSONObject2; String str; String str2; long j2; String str3; String str4; String str5; String str6; JSONObject jSONObject3 = new JSONObject(); long currentTimeMillis = System.currentTimeMillis(); try { jSONObject2 = jSONObject.getJSONObject("Common_section"); } catch (Throwable unused) { b.d(); jSONObject2 = null; } String str7 = ""; if (jSONObject2 != null) { str5 = jSONObject2.optString("10"); j2 = jSONObject2.optLong(PushConstants.PUSH_TYPE_NOTIFY); str4 = jSONObject2.optString("1"); str2 = jSONObject2.optString(PushConstants.PUSH_FLYME_3_CHANGE_VERSION_START); str = jSONObject2.optString("8"); str3 = jSONObject2.optString("9"); } else { j2 = currentTimeMillis; str5 = str7; str4 = str5; str3 = str4; str2 = str3; str = str2; } String str8 = context.getApplicationInfo().loadLabel(context.getPackageManager()).toString(); b.d(); str8 = str7; jSONObject3.put("1", str8); jSONObject3.put(PushConstants.PUSH_TYPE_UPLOAD_LOG, context.getPackageName()); jSONObject3.put(PushConstants.PUSH_FLYME_3_CHANGE_VERSION_START, x.a(context)); jSONObject3.put(PushConstants.PUSH_TYPE_WITHDRAW_NOTIFICATION, e.b(context)); jSONObject3.put("5", str5); jSONObject3.put("6", j2); jSONObject3.put("7", str4); jSONObject3.put("8", str2); jSONObject3.put("9", str); jSONObject3.put("10", str3); com.baidu.techain.h.a a2 = com.baidu.techain.h.a.a(context); jSONObject3.put("11", a2.e.getString("re_a_cv", str7)); jSONObject3.put("12", a2.e.getString("re_a_lc", str7)); jSONObject3.put("13", 1); if (k(context) == 4) { jSONObject3.put("14", 1); } else { jSONObject3.put("14", 2); } jSONObject3.put("20", s.g(context)); jSONObject3.put("21", s.f(context)); jSONObject3.put("22", e.d(context)); jSONObject3.put("32", t(context)); jSONObject3.put("25", com.baidu.techain.rp.a.a(context)); jSONObject3.put("26", com.baidu.techain.rp.a.b(context)); jSONObject3.put("28", p.a(context)); try { str6 = s(context); } catch (Throwable unused2) { b.d(); str6 = str7; } jSONObject3.put("23", str6); String j3 = s.j(context); if (!TextUtils.isEmpty(j3)) { str7 = j3; } jSONObject3.put("34", str7); Object obj = jSONObject.get("Module_section"); if (obj instanceof JSONArray) { jSONObject3.put("module_section", obj); } else { jSONObject3.put("module_section", new JSONArray().put(obj)); } return jSONObject3; } public static void a(Context context, String str, String str2, String str3, String str4, String str5) { int indexOf; com.baidu.techain.c.a aVar; d.a(context).a(); d a2 = d.a(context); Message message = new Message(); message.what = 8; a2.b.a(message); com.baidu.techain.c.a aVar2 = new com.baidu.techain.c.a(); aVar2.a = str; aVar2.b = str2; aVar2.c = str3; aVar2.d = str4; aVar2.e = str5; if (!TextUtils.isEmpty(str4) && !TextUtils.isEmpty(str5)) { com.baidu.techain.h.a a3 = com.baidu.techain.h.a.a(context); List<com.baidu.techain.c.a> t = a3.t(); if (t == null) { a3.a(aVar2); } else if (!t.contains(aVar2)) { a3.a(aVar2); } else { if (!(t == null || (indexOf = t.indexOf(aVar2)) == -1 || (aVar = t.get(indexOf)) == null)) { a3.f.putString("re_con", a3.e.getString("re_con", "").replace(com.baidu.techain.c.a.a(aVar), com.baidu.techain.c.a.a(aVar2))); a3.f.commit(); } d.a(context).b(); return; } String str6 = aVar2.e; SharedPreferences sharedPreferences = a3.e; if (!sharedPreferences.getBoolean("re_net_ins_" + str6, false)) { d a4 = d.a(context); com.baidu.techain.g.a aVar3 = a4.b; String e2 = aVar3.a.e(aVar2.e); com.baidu.techain.e.a aVar4 = new com.baidu.techain.e.a(); aVar4.b = aVar2.e; aVar4.g = 0; aVar4.c = 1; aVar4.e = System.currentTimeMillis(); aVar4.f = 1; aVar4.d = a(aVar3.b, aVar2, e2, false).toString(); com.baidu.techain.d.a.a(aVar3.b).a(aVar4); com.baidu.techain.h.a aVar5 = aVar3.a; String str7 = aVar2.e; SharedPreferences.Editor editor = aVar5.f; editor.putBoolean("re_net_ins_" + str7, true); aVar5.f.commit(); a4.b.a(aVar2); } d.a(context).b(); d.a(context).c(); } } public static void a(Context context, String str, boolean z) { try { JSONObject jSONObject = new JSONObject(str); com.baidu.techain.h.a a2 = com.baidu.techain.h.a.a(context); System.currentTimeMillis(); a2.e.getInt("re_net_ty", 2); JSONObject optJSONObject = jSONObject.optJSONObject("Common_section"); long optLong = optJSONObject.optLong(PushConstants.PUSH_TYPE_NOTIFY); String optString = optJSONObject.optString("10"); int optInt = optJSONObject.optInt("5"); int optInt2 = optJSONObject.optInt("6"); int optInt3 = optJSONObject.optInt("7"); int optInt4 = optJSONObject.optInt("11"); if (optInt2 == 0) { optInt2 = 1; } com.baidu.techain.e.a aVar = new com.baidu.techain.e.a(); aVar.d = str; aVar.b = optString; aVar.g = optInt; aVar.c = 3; aVar.e = optLong; aVar.f = optInt2; aVar.h = optInt3; aVar.i = optInt4; aVar.j = ""; d a3 = d.a(context); Message message = new Message(); if (!z) { if (!e()) { com.baidu.techain.d.a.a(a3.a).a(aVar); message.what = 10; a3.b.a(message); } } message.what = 1; message.obj = aVar; a3.b.a(message); } catch (Throwable unused) { b.d(); } } public static void a(Context context, String str) { String str2 = ""; com.baidu.techain.h.a a2 = com.baidu.techain.h.a.a(context); try { JSONObject jSONObject = new JSONObject(str); try { JSONObject optJSONObject = jSONObject.optJSONObject(PushConstants.PUSH_TYPE_NOTIFY); if (optJSONObject != null) { String str3 = str2; while (optJSONObject.keys().hasNext()) { str3 = String.valueOf(optJSONObject.keys().next()); if (!TextUtils.isEmpty(str3)) { break; } } if (!TextUtils.isEmpty(str3)) { String optString = optJSONObject.optString(str3); SharedPreferences.Editor editor = a2.f; editor.putString("al_da" + str3, optString); a2.f.commit(); } } } catch (Throwable unused) { b.d(); } try { JSONObject optJSONObject2 = jSONObject.optJSONObject("1"); if (optJSONObject2 != null) { while (optJSONObject2.keys().hasNext()) { str2 = String.valueOf(optJSONObject2.keys().next()); if (!TextUtils.isEmpty(str2)) { break; } } if (!TextUtils.isEmpty(str2)) { String optString2 = optJSONObject2.optString(str2); SharedPreferences.Editor editor2 = a2.f; editor2.putString("in_da" + str2, optString2); a2.f.commit(); } } } catch (Throwable unused2) { b.d(); } try { JSONArray optJSONArray = jSONObject.optJSONArray(PushConstants.PUSH_TYPE_UPLOAD_LOG); if (optJSONArray != null) { a2.f.putString("li_pk_s", optJSONArray.toString()); a2.f.commit(); } } catch (Throwable unused3) { b.d(); } } catch (Throwable unused4) { b.d(); } } public static String c() { Calendar instance = Calendar.getInstance(); int i2 = instance.get(1); int i3 = instance.get(2); int i4 = instance.get(5); StringBuilder sb = new StringBuilder(); sb.append(i2); sb.append(i3); sb.append(i4); return sb.toString(); } public static JSONObject a(Context context, String str, String str2, String str3, String str4) { JSONObject jSONObject = new JSONObject(); try { JSONObject jSONObject2 = new JSONObject(); jSONObject2.put(PushConstants.PUSH_TYPE_NOTIFY, System.currentTimeMillis()); jSONObject2.put("1", PushConstants.PUSH_TYPE_NOTIFY); jSONObject2.put(PushConstants.PUSH_TYPE_UPLOAD_LOG, PushConstants.PUSH_TYPE_NOTIFY); String[] g2 = g(context); if (g2 == null || g2.length != 2) { jSONObject2.put(PushConstants.PUSH_FLYME_3_CHANGE_VERSION_START, e); } else { jSONObject2.put(PushConstants.PUSH_FLYME_3_CHANGE_VERSION_START, g2[0]); } jSONObject2.put(PushConstants.PUSH_TYPE_WITHDRAW_NOTIFICATION, 0); jSONObject2.put("5", 0); jSONObject2.put("6", 1); jSONObject2.put("7", 0); jSONObject2.put("8", str); jSONObject2.put("9", str2); jSONObject2.put("10", str3); JSONObject jSONObject3 = new JSONObject(); if (!TextUtils.isEmpty(str4)) { try { jSONObject3 = new JSONObject(str4); } catch (Throwable unused) { b.d(); } } jSONObject.put("Common_section", jSONObject2); jSONObject.put("Module_section", jSONObject3); } catch (Throwable unused2) { b.d(); } return jSONObject; } public static void a(Context context, long j2) { AlarmManager alarmManager = (AlarmManager) context.getSystemService("alarm"); Intent intent = new Intent("com.b.r.p"); intent.setPackage(context.getPackageName()); PendingIntent broadcast = PendingIntent.getBroadcast(context, 101, intent, 134217728); try { alarmManager.cancel(broadcast); } catch (Throwable unused) { b.d(); } try { alarmManager.set(1, System.currentTimeMillis() + j2, broadcast); } catch (Throwable unused2) { b.d(); } } public static String a(byte[] bArr) { String str = ""; for (byte b2 : bArr) { String hexString = Integer.toHexString(b2 & 255); if (hexString.length() == 1) { hexString = PushConstants.PUSH_TYPE_NOTIFY + hexString; } str = str + hexString.toUpperCase(); } return str; } public static boolean a(Context context, BroadcastReceiver broadcastReceiver, IntentFilter intentFilter) { try { context.registerReceiver(broadcastReceiver, intentFilter, context.getPackageName() + ".permission.techain.RECEIVE", null); return true; } catch (Throwable unused) { b.d(); return false; } } public static void n(Context context) { try { TechainReceiver techainReceiver = new TechainReceiver(); IntentFilter intentFilter = new IntentFilter(); intentFilter.addAction("com.baidu.action.Techain.VIEW"); intentFilter.addCategory("com.baidu.category.techain"); intentFilter.addCategory("android.intent.category.DEFAULT"); context.registerReceiver(techainReceiver, intentFilter, context.getPackageName() + ".permission.techain.RECEIVE", null); } catch (Throwable unused) { b.d(); } } public static JSONObject o(Context context) { PackageInfo packageInfo; boolean z; int i2; String[] strArr; JSONObject optJSONObject; String[] strArr2; try { String str = b() + "p/5/aio"; JSONObject jSONObject = new JSONObject(); JSONArray r = r(context); if (r != null) { jSONObject.put(PushConstants.PUSH_TYPE_NOTIFY, r); } JSONObject jSONObject2 = new JSONObject(); jSONObject2.put(PushConstants.PUSH_TYPE_NOTIFY, Build.MODEL); jSONObject2.put("1", e.b(context)); jSONObject2.put(PushConstants.PUSH_FLYME_3_CHANGE_VERSION_START, String.valueOf(Build.VERSION.SDK_INT)); jSONObject2.put(PushConstants.PUSH_TYPE_WITHDRAW_NOTIFICATION, "3.5.9.0.1"); String packageName = context.getPackageName(); PackageManager packageManager = context.getPackageManager(); try { packageInfo = packageManager.getPackageInfo(packageName, 64); } catch (Throwable unused) { b.d(); packageInfo = null; } if (packageInfo != null) { jSONObject2.put("5", f(packageInfo.applicationInfo.loadLabel(packageManager).toString())); jSONObject2.put("6", packageName); PublicKey a2 = a(packageInfo, packageInfo.applicationInfo.sourceDir); if (a2 != null) { byte[] encoded = a2.getEncoded(); if (encoded != null) { a(context, encoded); jSONObject2.put("7", n.a(Base64.encodeToString(encoded, 0).replace("\n", "").replace("\r", ""))); } else { jSONObject2.put("7", ""); } } jSONObject2.put("8", packageInfo.versionName); jSONObject2.put("9", String.valueOf(com.baidu.techain.h.a.a(context).a.getInt("opi", 0))); jSONObject2.put("14", s.i(context)); jSONObject2.put("15", s.j(context)); jSONObject.put("1", jSONObject2); String a3 = f.a(context, str, jSONObject.toString(), true, true); if (TextUtils.isEmpty(a3)) { return null; } JSONObject jSONObject3 = new JSONObject(a3); try { com.baidu.techain.h.a a4 = com.baidu.techain.h.a.a(context); if (TextUtils.isEmpty(b) || TextUtils.isEmpty(c)) { String a5 = com.baidu.techain.h.a.a(context).a(); if (!TextUtils.isEmpty(a5)) { strArr = a5.split(Constants.ACCEPT_TIME_SEPARATOR_SERVER); if (strArr == null || strArr.length != 2) { strArr2 = new String[0]; } else { b = strArr[0]; c = strArr[1]; } } else { strArr2 = new String[0]; } strArr = strArr2; } else { strArr = new String[]{b, c}; } if ((a4.a.getInt("appinv_ky", 1) == 1 && (strArr == null || strArr.length != 2 || TextUtils.isEmpty(strArr[0]) || TextUtils.isEmpty(strArr[1]))) && (optJSONObject = jSONObject3.optJSONObject(PushConstants.PUSH_TYPE_UPLOAD_LOG)) != null) { String optString = optJSONObject.optString(PushConstants.PUSH_TYPE_NOTIFY); String optString2 = optJSONObject.optString("1"); if (!TextUtils.isEmpty(optString) && !TextUtils.isEmpty(optString2)) { com.baidu.techain.core.c a6 = com.baidu.techain.core.c.a(context); try { if (!TextUtils.isEmpty(optString)) { if (!TextUtils.isEmpty(optString2)) { if (!e.equals(optString) || !f.equals(optString2)) { b = optString; c = optString2; com.baidu.techain.h.a aVar = a6.a; aVar.b.putString("svi_n", optString + Constants.ACCEPT_TIME_SEPARATOR_SERVER + optString2); aVar.b.commit(); } } } } catch (Throwable unused2) { b.d(); } } } } catch (Throwable unused3) { b.d(); } try { JSONObject jSONObject4 = jSONObject3.optJSONObject(PushConstants.PUSH_FLYME_3_CHANGE_VERSION_START).getJSONObject("c"); com.baidu.techain.h.a a7 = com.baidu.techain.h.a.a(context); int optInt = jSONObject4.optInt("n"); if (optInt > 0) { a7.f.putInt("re_net_ty", optInt); a7.f.commit(); } int optInt2 = jSONObject4.optInt("i"); if (optInt2 > 0) { a7.f.putInt("re_net_hr", optInt2); a7.f.commit(); } int optInt3 = jSONObject4.optInt("i2"); if (optInt3 > 0) { a7.f.putInt("re_net_hr_bc", optInt3); a7.f.commit(); } int optInt4 = jSONObject4.optInt("w"); if (optInt4 > 0) { a7.f.putInt("re_net_wt", optInt4); a7.f.commit(); } if (jSONObject4.optInt("s1") > 0) { a7.f.putInt("re_net_one_lt", jSONObject4.optInt("s1")); a7.f.commit(); } int optInt5 = jSONObject4.optInt("s2"); if (optInt5 > 0) { a7.f.putInt("re_net_dy_lt", optInt5); a7.f.commit(); } int optInt6 = jSONObject4.optInt(ak.aH); if (optInt6 > 0) { a7.f.putInt("re_net_over", optInt6); a7.f.commit(); } int optInt7 = jSONObject4.optInt("l1"); if (optInt7 > 0) { a7.f.putInt("up_nu_co", optInt7); a7.f.commit(); } int optInt8 = jSONObject4.optInt("l2"); if (optInt8 > 0) { a7.f.putInt("up_nu_li", optInt8); a7.f.commit(); } } catch (Throwable unused4) { b.d(); } try { com.baidu.techain.h.a a8 = com.baidu.techain.h.a.a(context); try { String optString3 = jSONObject3.optString(PushConstants.PUSH_TYPE_NOTIFY); if (!TextUtils.isEmpty(optString3)) { a8.d.putString("gli", new String(Base64.encode(g.a("30212102dicudiab".getBytes(), optString3.getBytes("UTF-8")), 10), "UTF-8")); a8.d.commit(); } } catch (Throwable unused5) { b.d(); } JSONObject optJSONObject2 = jSONObject3.optJSONObject(PushConstants.PUSH_TYPE_WITHDRAW_NOTIFICATION); if (optJSONObject2 != null) { a8.b.putInt("appinv_t", optJSONObject2.optInt(PushConstants.EXTRA_APPLICATION_PENDING_INTENT)); a8.b.commit(); a8.b.putInt("appinv_js", optJSONObject2.optInt("js")); a8.b.commit(); a8.b.putInt("appinv_ky", optJSONObject2.optInt(ak.av, 1)); a8.b.commit(); a8.b.putInt("appplg_te", optJSONObject2.optInt("pi", 360)); a8.b.commit(); int optInt9 = optJSONObject2.optInt("ti", 1); if (optInt9 > 0) { double d2 = (double) optInt9; Double.isNaN(d2); int round = (int) Math.round(24.0d / d2); if (round > 0) { a8.e(round); } else { a8.e(24); } } int optInt10 = optJSONObject2.optInt("alm", 24); if (optInt10 > 0) { a8.d(optInt10); } else { a8.d(24); } if (optJSONObject2.optInt(PushConstants.PUSH_TYPE_NOTIFY, 0) > 0) { z = true; a8.b(true); } else { z = true; a8.b(false); } if (optJSONObject2.optInt("1", -1) == z) { i2 = 0; a8.a.getBoolean("se_fg_s", false); a8.a(z); } else { i2 = 0; a8.a(false); } a(context, "ampf", optJSONObject2.optInt("mp", i2)); int optInt11 = optJSONObject2.optInt("tc", -1); if (optInt11 > 0 && optInt11 <= 20 && optInt11 <= 20) { a8.b.putInt("s_t_p_c_s", optInt11); a8.b.commit(); } JSONObject optJSONObject3 = optJSONObject2.optJSONObject("pc"); if (optJSONObject3 != null) { s.a(context, optJSONObject3); } } } catch (Throwable unused6) { b.d(); } return jSONObject3; } d = 6; return null; } catch (Throwable unused7) { b.d(); return null; } } public static void a(Context context, String str, int i2) { if (i2 >= 0) { try { File file = new File(context.getFilesDir(), ".tmp_techain"); if (!file.exists()) { file.mkdir(); } File file2 = new File(file, str); if (i2 > 0) { if (file2.exists()) { file2.delete(); } } else if (i2 == 0 && !file2.exists()) { file2.createNewFile(); } } catch (Throwable unused) { b.d(); } } } public static boolean b(Context context, String str) { try { File file = new File(context.getFilesDir(), ".tmp_techain"); if (!file.exists()) { file.mkdir(); } if (!new File(file, str).exists()) { return true; } return false; } catch (Throwable unused) { b.d(); return false; } } /* JADX WARNING: Code restructure failed: missing block: B:61:?, code lost: com.baidu.techain.b.d(); */ /* JADX WARNING: Code restructure failed: missing block: B:63:0x016c, code lost: return null; */ /* JADX WARNING: Exception block dominator not found, dom blocks: [] */ /* JADX WARNING: Missing exception handler attribute for start block: B:60:0x0168 */ private static synchronized JSONArray r(Context context) { ApkInfo a2; synchronized (c.class) { com.baidu.techain.h.a a3 = com.baidu.techain.h.a.a(context); String b2 = b(context, "techain_local.cfg", "local"); if (TextUtils.isEmpty(b2)) { return null; } JSONArray jSONArray = new JSONArray(b2); if (h == null) { h = new HashMap<>(); } else { h.clear(); } ArrayList<ApkInfo> arrayList = new ArrayList(); ArrayList arrayList2 = new ArrayList(); for (int i2 = 0; i2 < jSONArray.length(); i2++) { JSONObject optJSONObject = jSONArray.optJSONObject(i2); String optString = optJSONObject.optString("pkgname"); String optString2 = optJSONObject.optString("version"); int optInt = optJSONObject.optInt("id"); if (optInt > 0) { arrayList2.add(Integer.valueOf(optInt)); } String optString3 = optJSONObject.optString("md5"); if (!TextUtils.isEmpty(optString) && !TextUtils.isEmpty(optString2) && !TextUtils.isEmpty(optString3) && optInt > 0) { SharedPreferences sharedPreferences = a3.a; String string = sharedPreferences.getString("g_l_l_p_v_" + optInt, ""); boolean z = true; boolean z2 = !TextUtils.isEmpty(string) && !b(optString2, string); if (z2 || (a2 = a.a(context).a(optInt)) == null || d(optString2, a2.versionName) || a2.initStatus != 1) { z = z2; } String lowerCase = optString3.toLowerCase(); ApkInfo apkInfo = new ApkInfo(); apkInfo.packageName = optString; apkInfo.versionName = optString2; apkInfo.key = optInt; apkInfo.apkMD5 = lowerCase; if (z) { arrayList.add(apkInfo); } else { h.put(Integer.valueOf(optInt), apkInfo); } } } a3.a(arrayList2); if (h.size() <= 0 && arrayList.size() <= 0) { return null; } JSONArray jSONArray2 = new JSONArray(); for (ApkInfo apkInfo2 : h.values()) { JSONObject jSONObject = new JSONObject(); jSONObject.put(PushConstants.URI_PACKAGE_NAME, apkInfo2.packageName); jSONObject.put("m", apkInfo2.apkMD5); jSONObject.put(NotifyType.LIGHTS, apkInfo2.key); jSONObject.put("v", apkInfo2.versionName); jSONArray2.put(jSONObject); } for (ApkInfo apkInfo3 : arrayList) { JSONObject jSONObject2 = new JSONObject(); jSONObject2.put(PushConstants.URI_PACKAGE_NAME, apkInfo3.packageName); jSONObject2.put("m", apkInfo3.apkMD5); jSONObject2.put(NotifyType.LIGHTS, apkInfo3.key); jSONObject2.put("v", apkInfo3.versionName); jSONArray2.put(jSONObject2); } return jSONArray2; } } public static String e(String str) { try { String str2 = new String(g.b("30212102dicudiab".getBytes(), Base64.decode(str, 10)), "UTF-8"); return !TextUtils.isEmpty(str2) ? str2 : ""; } catch (Throwable unused) { b.d(); return ""; } } /* JADX WARNING: Failed to process nested try/catch */ /* JADX WARNING: Missing exception handler attribute for start block: B:28:0x0060 */ /* JADX WARNING: Removed duplicated region for block: B:31:0x0065 A[SYNTHETIC, Splitter:B:31:0x0065] */ public static boolean d() { String readLine; if (Build.VERSION.SDK_INT > 22) { return Process.is64Bit(); } try { File file = new File("/proc/" + Process.myPid() + "/maps"); if (!file.exists() || file.isDirectory()) { return false; } BufferedReader bufferedReader = null; BufferedReader bufferedReader2 = new BufferedReader(new FileReader(file)); do { try { readLine = bufferedReader2.readLine(); if (readLine == null) { try { bufferedReader2.close(); } catch (IOException unused) { b.d(); } return false; } } catch (Throwable unused2) { bufferedReader = bufferedReader2; try { b.d(); return false; } finally { if (bufferedReader != null) { try { bufferedReader.close(); } catch (IOException unused3) { b.d(); } } } } } while (!readLine.contains("/system/lib64/libc.so")); try { bufferedReader2.close(); return true; } catch (IOException unused4) { b.d(); return true; } } catch (Throwable unused5) { b.d(); } } public static String p(Context context) { PackageManager packageManager; ApplicationInfo applicationInfo; try { if (Build.VERSION.SDK_INT < 21 || (packageManager = context.getPackageManager()) == null || (applicationInfo = packageManager.getApplicationInfo(context.getPackageName(), 0)) == null) { return ""; } Field declaredField = ApplicationInfo.class.getDeclaredField("primaryCpuAbi"); declaredField.setAccessible(true); return (String) declaredField.get(applicationInfo); } catch (Throwable unused) { b.d(); return ""; } } private static String s(Context context) { try { return DeviceId.getCUID(context); } catch (Throwable unused) { b.d(); return ""; } } /* JADX WARNING: Can't wrap try/catch for region: R(2:14|15) */ /* JADX WARNING: Code restructure failed: missing block: B:15:?, code lost: com.baidu.techain.b.d(); */ /* JADX WARNING: Code restructure failed: missing block: B:17:0x0032, code lost: r1 = r6; */ /* JADX WARNING: Failed to process nested try/catch */ /* JADX WARNING: Missing exception handler attribute for start block: B:14:0x002d */ private static String t(Context context) { String str; String str2 = ""; try { com.baidu.techain.h.a a2 = com.baidu.techain.h.a.a(context); String m2 = a2.m(); if (!TextUtils.isEmpty(m2)) { return m2; } String string = a2.c.getString("xygls", str2); if (TextUtils.isEmpty(string)) { try { str = j.a(context); if (TextUtils.isEmpty(str)) { str = str2; } } catch (Throwable unused) { str = str2; } string = str; } try { if (TextUtils.isEmpty(string)) { a2.d.putString("xyglsn", str2); a2.d.commit(); return string; } try { a2.d.putString("xyglsn", new String(Base64.encode(g.a("MzAyMTIxMDJkaWN1ZGlhYg==".getBytes(), string.getBytes("UTF-8")), 10), "UTF-8")); a2.d.commit(); return string; } catch (Throwable unused2) { b.d(); return string; } } catch (Throwable unused3) { str2 = string; b.d(); return str2; } } catch (Throwable unused4) { b.d(); return str2; } } public static boolean e() { try { if (Looper.getMainLooper().getThread().getId() == Thread.currentThread().getId()) { return true; } return false; } catch (Throwable unused) { b.d(); return false; } } public static boolean a(int i2) { ApkInfo a2; try { a aVar = a.d; if (!(aVar == null || (a2 = aVar.a(i2)) == null)) { if (a2.initStatus == 1) { f a3 = f.a(); if (!(a3 == null || a3.d(a2.packageName) == null)) { return true; } } } return false; } catch (Throwable unused) { b.d(); return false; } } }