package com.umeng.commonsdk.statistics; import android.content.Context; import android.content.SharedPreferences; import android.os.Build; import android.text.TextUtils; import android.util.Base64; import android.util.Log; import com.efs.sdk.base.core.util.NetworkUtil; import com.kuaishou.weapon.p0.h; import com.umeng.analytics.AnalyticsConfig; import com.umeng.analytics.pro.am; import com.umeng.analytics.pro.be; import com.umeng.analytics.pro.d; import com.umeng.commonsdk.config.FieldManager; import com.umeng.commonsdk.framework.UMEnvelopeBuild; import com.umeng.commonsdk.framework.UMFrUtils; import com.umeng.commonsdk.internal.a; import com.umeng.commonsdk.internal.c; import com.umeng.commonsdk.internal.crash.UMCrashManager; import com.umeng.commonsdk.statistics.common.DataHelper; import com.umeng.commonsdk.statistics.common.DeviceConfig; import com.umeng.commonsdk.statistics.common.ULog; import com.umeng.commonsdk.statistics.idtracking.Envelope; import com.umeng.commonsdk.statistics.idtracking.ImprintHandler; import com.umeng.commonsdk.statistics.idtracking.e; import com.umeng.commonsdk.statistics.internal.PreferenceWrapper; import com.umeng.commonsdk.utils.UMUtils; import java.util.HashMap; import java.util.Iterator; import java.util.Map; import org.json.JSONException; import org.json.JSONObject; /* compiled from: EnvelopeManager */ public class b { public static String a = null; public static String b = ""; private static final String c = "EnvelopeManager"; private static final String d = "debug.umeng.umTaskId"; private static final String e = "debug.umeng.umCaseId"; private static final String f = "empty"; private static String g = ""; private static String h = ""; private static String i; private static Map<String, String> j; private static boolean l; private int k = 0; static { HashMap hashMap = new HashMap(); j = hashMap; hashMap.put("header", "#h"); j.put(am.u, "#sdt"); j.put(am.Q, "#ac"); j.put("device_model", "#dm"); j.put(am.g, "#umid"); j.put(am.x, am.x); j.put("language", "#lang"); j.put(am.ai, "#dt"); j.put(am.z, "#rl"); j.put(am.H, "#dmf"); j.put(am.J, "#dn"); j.put("platform_version", "#pv"); j.put("font_size_setting", "#fss"); j.put(am.y, "#ov"); j.put(am.I, "#did"); j.put("platform_sdk_version", "#psv"); j.put(am.F, "#db"); j.put("appkey", "#ak"); j.put(am.Y, "#itr"); j.put("id_type", "#it"); j.put("uuid", "#ud"); j.put("device_id", "#dd"); j.put(am.X, "#imp"); j.put("sdk_version", "#sv"); j.put("st", "#st"); j.put("analytics", "#a"); j.put("package_name", "#pkg"); j.put(am.p, "#sig"); j.put(am.q, "#sis1"); j.put(am.r, "#sis"); j.put("app_version", "#av"); j.put("version_code", "#vc"); j.put(am.v, "#imd"); j.put(am.B, "#mnc"); j.put(am.E, "#boa"); j.put(am.G, "#mant"); j.put(am.M, "#tz"); j.put(am.O, "#ct"); j.put(am.P, "#car"); j.put(am.s, "#disn"); j.put(am.T, "#nt"); j.put(am.b, "#cv"); j.put(am.d, "#mv"); j.put(am.c, "#cot"); j.put(am.e, "#mod"); j.put(am.aj, "#al"); j.put("session_id", "#sid"); j.put(am.S, "#ip"); j.put(am.U, "#sre"); j.put(am.V, "#fre"); j.put(am.W, "#ret"); j.put("channel", "#chn"); j.put("wrapper_type", "#wt"); j.put("wrapper_version", "#wv"); j.put(am.aV, "#tsv"); j.put(am.aW, "#rps"); j.put(am.aZ, "#mov"); j.put(d.i, "#vt"); j.put("secret", "#sec"); j.put(d.ah, "#prv"); j.put(d.l, "#$prv"); j.put(d.m, "#uda"); j.put(am.a, "#tok"); j.put(am.aN, "#iv"); j.put(am.R, "#ast"); j.put("backstate", "#bst"); j.put("zdata_ver", "#zv"); j.put("zdata_req_ts", "#zrt"); j.put("app_b_v", "#bv"); j.put("zdata", "#zta"); j.put(am.ap, "#mt"); j.put(am.am, "#zsv"); j.put("others_OS", "#oos"); } public static String a(String str) { return j.containsKey(str) ? j.get(str) : str; } public static void a() { if (i != null) { i = null; e.a(); } } public static long a(Context context) { long j2 = DataHelper.ENVELOPE_ENTITY_RAW_LENGTH_MAX - DataHelper.ENVELOPE_EXTRA_LENGTH; if (ULog.DEBUG) { Log.i(c, "free size is " + j2); } return j2; } private JSONObject a(int i2, JSONObject jSONObject) { if (jSONObject != null) { try { jSONObject.put("exception", i2); } catch (Exception unused) { } return jSONObject; } JSONObject jSONObject2 = new JSONObject(); try { jSONObject2.put("exception", i2); } catch (Exception unused2) { } return jSONObject2; } private static boolean b() { g = UMUtils.getSystemProperty(d, ""); h = UMUtils.getSystemProperty(e, ""); return (!TextUtils.isEmpty(g) && !f.equals(g)) && (!TextUtils.isEmpty(h) && !f.equals(h)); } public JSONObject a(Context context, JSONObject jSONObject, JSONObject jSONObject2, String str, String str2, String str3) { JSONObject jSONObject3; Exception e2; String str4; JSONObject jSONObject4; boolean z; String str5; String str6; Envelope envelope; String str7; JSONObject optJSONObject; if (!(!ULog.DEBUG || jSONObject == null || jSONObject2 == null)) { Log.i(c, "headerJSONObject size is " + jSONObject.toString().getBytes().length); Log.i(c, "bodyJSONObject size is " + jSONObject2.toString().getBytes().length); } if (context == null || jSONObject2 == null) { return a(110, (JSONObject) null); } try { if (!jSONObject2.has("analytics") || (optJSONObject = jSONObject2.optJSONObject("analytics")) == null || !optJSONObject.has(d.n)) { str5 = str2; z = false; } else { str5 = str2; z = true; } JSONObject a2 = a(context, str5, z); if (!(a2 == null || jSONObject == null)) { a2 = a(a2, jSONObject); } if (!(a2 == null || jSONObject2 == null)) { Iterator<String> keys = jSONObject2.keys(); while (keys.hasNext()) { String next = keys.next(); if (!(next == null || !(next instanceof String) || (str7 = next) == null || jSONObject2.opt(str7) == null)) { try { a2.put(a(str7), jSONObject2.opt(str7)); } catch (Exception unused) { } } } } String str8 = "1.0.0"; if (TextUtils.isEmpty(str2)) { str5 = "u"; } if (!TextUtils.isEmpty(str3)) { str8 = str3; } if (a2 != null) { String str9 = str5 + "==" + str8 + "&="; if (TextUtils.isEmpty(str9)) { return a(101, a2); } if (str9.endsWith("&=")) { str9 = str9.substring(0, str9.length() - 2); } str6 = str9; } else { str6 = null; } if (a2 != null) { try { e a3 = e.a(context); if (a3 != null) { a3.b(); String encodeToString = Base64.encodeToString(new be().a(a3.c()), 0); if (!TextUtils.isEmpty(encodeToString)) { JSONObject jSONObject5 = a2.getJSONObject(a("header")); jSONObject5.put(a(am.Y), encodeToString); a2.put(a("header"), jSONObject5); } } } catch (Exception unused2) { } } if (a2 == null || !DataHelper.largeThanMaxSize((long) a2.toString().getBytes().length, DataHelper.ENVELOPE_ENTITY_RAW_LENGTH_MAX)) { if (a2 != null) { Envelope a4 = a(context, a2.toString().getBytes()); if (a4 == null) { return a(111, a2); } envelope = a4; } else { envelope = null; } if (envelope != null && DataHelper.largeThanMaxSize((long) envelope.toBinary().length, DataHelper.ENVELOPE_LENGTH_MAX)) { return a(114, a2); } int a5 = a(context, envelope, str6, a2 != null ? a2.optJSONObject(a("header")).optString(a("app_version")) : null, str); if (a5 != 0) { return a(a5, a2); } if (ULog.DEBUG) { Log.i(c, "constructHeader size is " + a2.toString().getBytes().length); } if (!str6.startsWith(am.aD) && !str6.startsWith("i") && !str6.startsWith(am.aI) && !str6.startsWith("a") && !com.umeng.commonsdk.stateless.b.a()) { new com.umeng.commonsdk.stateless.b(context); com.umeng.commonsdk.stateless.b.b(); } return a2; } SharedPreferences sharedPreferences = PreferenceWrapper.getDefault(context); if (sharedPreferences != null) { sharedPreferences.edit().putInt("serial", sharedPreferences.getInt("serial", 1) + 1).commit(); } return a(113, a2); } catch (Throwable th) { UMCrashManager.reportCrash(context, th); if (jSONObject != null) { try { jSONObject4 = new JSONObject(); jSONObject3 = jSONObject4; } catch (Exception e3) { e2 = e3; jSONObject3 = null; UMCrashManager.reportCrash(context, e2); return a(110, jSONObject3); } try { jSONObject4.put("header", jSONObject); } catch (JSONException unused3) { } catch (Exception e4) { e2 = e4; jSONObject3 = jSONObject4; UMCrashManager.reportCrash(context, e2); return a(110, jSONObject3); } } else { jSONObject3 = null; } if (jSONObject2 != null) { if (jSONObject3 == null) { try { jSONObject3 = new JSONObject(); } catch (Exception e5) { e2 = e5; UMCrashManager.reportCrash(context, e2); return a(110, jSONObject3); } } if (jSONObject2 != null) { Iterator<String> keys2 = jSONObject2.keys(); while (keys2.hasNext()) { String next2 = keys2.next(); if (!(next2 == null || !(next2 instanceof String) || (str4 = next2) == null || jSONObject2.opt(str4) == null)) { try { jSONObject3.put(str4, jSONObject2.opt(str4)); } catch (Exception unused4) { } } } } } return a(110, jSONObject3); } } public JSONObject a(Context context, JSONObject jSONObject, JSONObject jSONObject2, String str) { String str2; try { JSONObject jSONObject3 = new JSONObject(); jSONObject3.put(a("header"), new JSONObject()); if (jSONObject != null) { jSONObject3 = a(jSONObject3, jSONObject); } if (!(jSONObject3 == null || jSONObject2 == null)) { Iterator<String> keys = jSONObject2.keys(); while (keys.hasNext()) { String next = keys.next(); if (!(next == null || !(next instanceof String) || (str2 = next) == null || jSONObject2.opt(str2) == null)) { try { jSONObject3.put(str2, jSONObject2.opt(str2)); } catch (Exception unused) { } } } } if (jSONObject3 == null || !DataHelper.largeThanMaxSize((long) jSONObject3.toString().getBytes().length, DataHelper.ENVELOPE_ENTITY_RAW_LENGTH_MAX)) { Envelope envelope = null; if (jSONObject3 != null && (envelope = a(context, jSONObject3.toString().getBytes())) == null) { return a(111, jSONObject3); } if (envelope != null && DataHelper.largeThanMaxSize((long) envelope.toBinary().length, DataHelper.ENVELOPE_LENGTH_MAX)) { return a(114, jSONObject3); } int a2 = a(context, envelope, "h==1.2.0", "", str); if (a2 != 0) { return a(a2, jSONObject3); } if (ULog.DEBUG) { Log.i(c, "constructHeader size is " + jSONObject3.toString().getBytes().length); } return jSONObject3; } SharedPreferences sharedPreferences = PreferenceWrapper.getDefault(context); if (sharedPreferences != null) { sharedPreferences.edit().putInt("serial", sharedPreferences.getInt("serial", 1) + 1).commit(); } return a(113, jSONObject3); } catch (Throwable th) { UMCrashManager.reportCrash(context, th); return a(110, new JSONObject()); } } public JSONObject b(Context context, JSONObject jSONObject, JSONObject jSONObject2, String str) { String str2; try { JSONObject jSONObject3 = new JSONObject(); jSONObject3.put(a("header"), new JSONObject()); try { if (b()) { jSONObject.put("umTaskId", g); jSONObject.put("umCaseId", h); } } catch (Throwable unused) { } if (jSONObject != null) { jSONObject3 = a(jSONObject3, jSONObject); } if (!(jSONObject3 == null || jSONObject2 == null)) { Iterator<String> keys = jSONObject2.keys(); while (keys.hasNext()) { String next = keys.next(); if (!(next == null || !(next instanceof String) || (str2 = next) == null || jSONObject2.opt(str2) == null)) { try { jSONObject3.put(str2, jSONObject2.opt(str2)); } catch (Exception unused2) { } } } } if (jSONObject3 == null || !DataHelper.largeThanMaxSize((long) jSONObject3.toString().getBytes().length, DataHelper.ENVELOPE_ENTITY_RAW_LENGTH_MAX)) { Envelope envelope = null; if (jSONObject3 != null && (envelope = a(context, jSONObject3.toString().getBytes())) == null) { return a(111, jSONObject3); } if (envelope != null && DataHelper.largeThanMaxSize((long) envelope.toBinary().length, DataHelper.ENVELOPE_LENGTH_MAX)) { return a(114, jSONObject3); } int a2 = a(context, envelope, "z==1.2.0", DeviceConfig.getAppVersionName(context), str); if (a2 != 0) { return a(a2, jSONObject3); } if (ULog.DEBUG) { Log.i(c, "constructHeader size is " + jSONObject3.toString().getBytes().length); } return jSONObject3; } SharedPreferences sharedPreferences = PreferenceWrapper.getDefault(context); if (sharedPreferences != null) { sharedPreferences.edit().putInt("serial", sharedPreferences.getInt("serial", 1) + 1).commit(); } return a(113, jSONObject3); } catch (Throwable th) { UMCrashManager.reportCrash(context, th); return a(110, new JSONObject()); } } private static int[] b(Context context) { int[] iArr = new int[3]; try { SharedPreferences sharedPreferences = context.getApplicationContext().getSharedPreferences(c.a, 0); if (sharedPreferences != null) { iArr[0] = sharedPreferences.getInt(c.b, 0); iArr[1] = sharedPreferences.getInt(c.c, 0); iArr[2] = sharedPreferences.getInt("policyGrantResult", 0); } } catch (Throwable unused) { } return iArr; } /* JADX WARNING: Can't wrap try/catch for region: R(66:57|(2:58|59)|60|62|63|(1:65)|66|(1:68)|69|71|72|(1:74)|77|78|(1:80)|83|84|85|86|87|88|(1:90)(1:91)|92|93|(1:95)|96|(2:102|103)|104|105|(4:109|(2:112|110)|178|113)|114|115|(1:117)|118|119|(1:121)|122|(1:124)|125|(1:127)|128|(1:130)|131|(1:133)|134|(1:136)|137|(1:139)|140|(1:142)|143|(1:145)|146|(1:148)|149|(1:151)|152|(1:154)|155|156|157|(1:159)|160|(3:165|166|167)|(2:173|174)|177) */ /* JADX WARNING: Can't wrap try/catch for region: R(67:57|58|59|60|62|63|(1:65)|66|(1:68)|69|71|72|(1:74)|77|78|(1:80)|83|84|85|86|87|88|(1:90)(1:91)|92|93|(1:95)|96|(2:102|103)|104|105|(4:109|(2:112|110)|178|113)|114|115|(1:117)|118|119|(1:121)|122|(1:124)|125|(1:127)|128|(1:130)|131|(1:133)|134|(1:136)|137|(1:139)|140|(1:142)|143|(1:145)|146|(1:148)|149|(1:151)|152|(1:154)|155|156|157|(1:159)|160|(3:165|166|167)|(2:173|174)|177) */ /* JADX WARNING: Failed to process nested try/catch */ /* JADX WARNING: Missing exception handler attribute for start block: B:104:0x0405 */ /* JADX WARNING: Missing exception handler attribute for start block: B:114:0x0443 */ /* JADX WARNING: Missing exception handler attribute for start block: B:118:0x0456 */ /* JADX WARNING: Missing exception handler attribute for start block: B:156:0x0553 */ /* JADX WARNING: Missing exception handler attribute for start block: B:86:0x0383 */ /* JADX WARNING: Missing exception handler attribute for start block: B:92:0x03ad */ /* JADX WARNING: Removed duplicated region for block: B:112:0x0424 A[Catch:{ all -> 0x0443 }, LOOP:0: B:110:0x041e->B:112:0x0424, LOOP_END] */ /* JADX WARNING: Removed duplicated region for block: B:117:0x044d A[Catch:{ all -> 0x0456 }] */ /* JADX WARNING: Removed duplicated region for block: B:121:0x046e A[Catch:{ all -> 0x0553 }] */ /* JADX WARNING: Removed duplicated region for block: B:124:0x0481 A[Catch:{ all -> 0x0553 }] */ /* JADX WARNING: Removed duplicated region for block: B:127:0x0494 A[Catch:{ all -> 0x0553 }] */ /* JADX WARNING: Removed duplicated region for block: B:130:0x04a7 A[Catch:{ all -> 0x0553 }] */ /* JADX WARNING: Removed duplicated region for block: B:133:0x04ba A[Catch:{ all -> 0x0553 }] */ /* JADX WARNING: Removed duplicated region for block: B:136:0x04cd A[Catch:{ all -> 0x0553 }] */ /* JADX WARNING: Removed duplicated region for block: B:139:0x04e0 A[Catch:{ all -> 0x0553 }] */ /* JADX WARNING: Removed duplicated region for block: B:142:0x04f3 A[Catch:{ all -> 0x0553 }] */ /* JADX WARNING: Removed duplicated region for block: B:145:0x0506 A[Catch:{ all -> 0x0553 }] */ /* JADX WARNING: Removed duplicated region for block: B:148:0x0519 A[Catch:{ all -> 0x0553 }] */ /* JADX WARNING: Removed duplicated region for block: B:151:0x052c A[Catch:{ all -> 0x0553 }] */ /* JADX WARNING: Removed duplicated region for block: B:154:0x053f A[Catch:{ all -> 0x0553 }] */ /* JADX WARNING: Removed duplicated region for block: B:159:0x055d A[Catch:{ all -> 0x0566 }] */ /* JADX WARNING: Removed duplicated region for block: B:90:0x039a */ /* JADX WARNING: Removed duplicated region for block: B:91:0x03a4 */ /* JADX WARNING: Removed duplicated region for block: B:95:0x03b3 A[Catch:{ all -> 0x03c1 }] */ private static JSONObject a(Context context, String str, boolean z) { JSONObject jSONObject; try { SharedPreferences sharedPreferences = PreferenceWrapper.getDefault(context); if (!TextUtils.isEmpty(i)) { try { jSONObject = new JSONObject(i); } catch (Exception unused) { jSONObject = null; } } else { UMUtils.saveSDKComponent(); jSONObject = new JSONObject(); jSONObject.put(a(am.p), DeviceConfig.getAppMD5Signature(context)); jSONObject.put(a(am.q), DeviceConfig.getAppSHA1Key(context)); jSONObject.put(a(am.r), DeviceConfig.getAppHashKey(context)); jSONObject.put(a("app_version"), DeviceConfig.getAppVersionName(context)); jSONObject.put(a("version_code"), Integer.parseInt(DeviceConfig.getAppVersionCode(context))); jSONObject.put(a(am.v), DeviceConfig.getDeviceIdUmengMD5(context)); jSONObject.put(a("cpu"), DeviceConfig.getCPU()); String mccmnc = DeviceConfig.getMCCMNC(context); if (!TextUtils.isEmpty(mccmnc)) { jSONObject.put(a(am.B), mccmnc); b = mccmnc; } else { jSONObject.put(a(am.B), ""); } if (FieldManager.allow(com.umeng.commonsdk.utils.c.I)) { String subOSName = DeviceConfig.getSubOSName(context); if (!TextUtils.isEmpty(subOSName)) { jSONObject.put(a(am.f146K), subOSName); } String subOSVersion = DeviceConfig.getSubOSVersion(context); if (!TextUtils.isEmpty(subOSVersion)) { jSONObject.put(a(am.L), subOSVersion); } } String deviceType = DeviceConfig.getDeviceType(context); if (!TextUtils.isEmpty(deviceType)) { jSONObject.put(a(am.ai), deviceType); } jSONObject.put(a("package_name"), DeviceConfig.getPackageName(context)); jSONObject.put(a(am.u), "Android"); jSONObject.put(a("device_id"), DeviceConfig.getDeviceId(context)); jSONObject.put(a("device_model"), Build.MODEL); jSONObject.put(a(am.E), Build.BOARD); jSONObject.put(a(am.F), Build.BRAND); jSONObject.put(a(am.G), Build.TIME); jSONObject.put(a(am.H), Build.MANUFACTURER); jSONObject.put(a(am.I), Build.ID); jSONObject.put(a(am.J), Build.DEVICE); jSONObject.put(a(am.y), Build.VERSION.RELEASE); jSONObject.put(a(am.x), "Android"); int[] resolutionArray = DeviceConfig.getResolutionArray(context); if (resolutionArray != null) { jSONObject.put(a(am.z), resolutionArray[1] + "*" + resolutionArray[0]); } jSONObject.put(a(am.A), DeviceConfig.getMac(context)); jSONObject.put(a(am.M), DeviceConfig.getTimeZone(context)); String[] localeInfo = DeviceConfig.getLocaleInfo(context); jSONObject.put(a(am.O), localeInfo[0]); jSONObject.put(a("language"), localeInfo[1]); jSONObject.put(a(am.P), DeviceConfig.getNetworkOperatorName(context)); jSONObject.put(a(am.s), DeviceConfig.getAppName(context)); String[] networkAccessMode = DeviceConfig.getNetworkAccessMode(context); if ("Wi-Fi".equals(networkAccessMode[0])) { jSONObject.put(a(am.Q), NetworkUtil.NETWORK_TYPE_WIFI); } else if ("2G/3G".equals(networkAccessMode[0])) { jSONObject.put(a(am.Q), "2G/3G"); } else { jSONObject.put(a(am.Q), "unknow"); } if (!"".equals(networkAccessMode[1])) { jSONObject.put(a(am.R), networkAccessMode[1]); } if (DeviceConfig.isHarmony(context)) { jSONObject.put(a("others_OS"), "harmony"); } else { jSONObject.put(a("others_OS"), "Android"); } jSONObject.put(a(am.T), DeviceConfig.getNetworkType(context)); jSONObject.put(a(am.b), "9.5.0"); jSONObject.put(a(am.c), SdkVersion.SDK_TYPE); jSONObject.put(a(am.d), "1"); if (!TextUtils.isEmpty(a)) { jSONObject.put(a(am.e), a); } jSONObject.put(a(am.aj), Build.VERSION.SDK_INT); if (!TextUtils.isEmpty(UMUtils.VALUE_REC_VERSION_NAME)) { jSONObject.put(a(am.af), UMUtils.VALUE_REC_VERSION_NAME); } try { String uUIDForZid = UMUtils.getUUIDForZid(context); if (TextUtils.isEmpty(uUIDForZid)) { UMUtils.setUUIDForZid(context); uUIDForZid = UMUtils.getUUIDForZid(context); } jSONObject.put(a("session_id"), uUIDForZid); } catch (Throwable unused2) { } i = jSONObject.toString(); } if (jSONObject == null) { return null; } try { jSONObject.put(a(am.ak), UMUtils.getOaidRequiredTime(context)); } catch (Exception unused3) { } try { jSONObject.put(a(am.U), sharedPreferences.getInt("successful_request", 0)); jSONObject.put(a(am.V), sharedPreferences.getInt(am.V, 0)); jSONObject.put(a(am.W), sharedPreferences.getInt("last_request_spent_ms", 0)); String zid = UMUtils.getZid(context); if (!TextUtils.isEmpty(zid)) { jSONObject.put(a(am.al), zid); } if (!TextUtils.isEmpty(UMUtils.VALUE_ASMS_VERSION)) { jSONObject.put(a(am.am), UMUtils.VALUE_ASMS_VERSION); } } catch (Exception unused4) { } jSONObject.put(a("channel"), UMUtils.getChannel(context)); jSONObject.put(a("appkey"), UMUtils.getAppkey(context)); try { String deviceToken = UMUtils.getDeviceToken(context); if (!TextUtils.isEmpty(deviceToken)) { jSONObject.put(a(am.a), deviceToken); } } catch (Exception e2) { UMCrashManager.reportCrash(context, e2); } try { String imprintProperty = UMEnvelopeBuild.imprintProperty(context, am.g, null); if (!TextUtils.isEmpty(imprintProperty)) { jSONObject.put(a(am.g), imprintProperty); } } catch (Exception e3) { UMCrashManager.reportCrash(context, e3); } jSONObject.put(a("wrapper_type"), a.a); jSONObject.put(a("wrapper_version"), a.b); int targetSdkVersion = UMUtils.getTargetSdkVersion(context); boolean checkPermission = UMUtils.checkPermission(context, h.c); jSONObject.put(a(am.aV), targetSdkVersion); if (!checkPermission) { jSONObject.put(a(am.aW), "yes"); } else { jSONObject.put(a(am.aW), "no"); } if (b()) { jSONObject.put("umTaskId", g); jSONObject.put("umCaseId", h); } if ((am.aI.equals(str) || "a".equals(str)) && z) { int[] b2 = b(context); jSONObject.put(a(am.bp), String.valueOf(b2[0]) + String.valueOf(b2[1]) + String.valueOf(b2[2])); } Map<String, String> moduleTags = TagHelper.getModuleTags(); if (moduleTags != null && moduleTags.size() > 0) { JSONObject jSONObject2 = new JSONObject(); for (Map.Entry<String, String> entry : moduleTags.entrySet()) { jSONObject2.put(entry.getKey(), entry.getValue()); } jSONObject.put(a(am.ap), jSONObject2); } String realTimeDebugKey = AnalyticsConfig.getRealTimeDebugKey(); if (!TextUtils.isEmpty(realTimeDebugKey)) { jSONObject.put(a(am.bo), realTimeDebugKey); } JSONObject jSONObject3 = new JSONObject(); jSONObject3.put(a(am.ba), a.e); if (!TextUtils.isEmpty(UMUtils.VALUE_ANALYTICS_VERSION)) { jSONObject3.put(a(am.bb), UMUtils.VALUE_ANALYTICS_VERSION); } if (!TextUtils.isEmpty(UMUtils.VALUE_GAME_VERSION)) { jSONObject3.put(a(am.bc), UMUtils.VALUE_GAME_VERSION); } if (!TextUtils.isEmpty(UMUtils.VALUE_PUSH_VERSION)) { jSONObject3.put(a(am.bd), UMUtils.VALUE_PUSH_VERSION); } if (!TextUtils.isEmpty(UMUtils.VALUE_SHARE_VERSION)) { jSONObject3.put(a(am.be), UMUtils.VALUE_SHARE_VERSION); } if (!TextUtils.isEmpty(UMUtils.VALUE_APM_VERSION)) { jSONObject3.put(a(am.bf), UMUtils.VALUE_APM_VERSION); } if (!TextUtils.isEmpty(UMUtils.VALUE_VERIFY_VERSION)) { jSONObject3.put(a(am.bg), UMUtils.VALUE_VERIFY_VERSION); } if (!TextUtils.isEmpty(UMUtils.VALUE_SMS_VERSION)) { jSONObject3.put(a(am.bh), UMUtils.VALUE_SMS_VERSION); } if (!TextUtils.isEmpty(UMUtils.VALUE_REC_VERSION_NAME)) { jSONObject3.put(a(am.bi), UMUtils.VALUE_REC_VERSION_NAME); } if (!TextUtils.isEmpty(UMUtils.VALUE_VISUAL_VERSION)) { jSONObject3.put(a(am.bj), UMUtils.VALUE_VISUAL_VERSION); } if (!TextUtils.isEmpty(UMUtils.VALUE_ASMS_VERSION)) { jSONObject3.put(a(am.bk), UMUtils.VALUE_ASMS_VERSION); } if (!TextUtils.isEmpty(UMUtils.VALUE_LINK_VERSION)) { jSONObject3.put(a(am.bl), UMUtils.VALUE_LINK_VERSION); } if (!TextUtils.isEmpty(UMUtils.VALUE_ABTEST_VERSION)) { jSONObject3.put(a(am.bm), UMUtils.VALUE_ABTEST_VERSION); } jSONObject.put(a(am.aZ), jSONObject3); String apmFlag = UMUtils.getApmFlag(); if (!TextUtils.isEmpty(apmFlag)) { jSONObject.put(a(am.bn), apmFlag); } byte[] a2 = ImprintHandler.getImprintService(context).a(); if (a2 != null && a2.length > 0) { try { jSONObject.put(a(am.X), Base64.encodeToString(a2, 0)); } catch (JSONException e4) { UMCrashManager.reportCrash(context, e4); } } if (jSONObject != null && jSONObject.length() > 0) { return new JSONObject().put(a("header"), jSONObject); } return null; } catch (Throwable th) { UMCrashManager.reportCrash(context, th); } } private JSONObject a(JSONObject jSONObject, JSONObject jSONObject2) { String str; if (!(jSONObject == null || jSONObject2 == null || jSONObject.opt(a("header")) == null || !(jSONObject.opt(a("header")) instanceof JSONObject))) { JSONObject jSONObject3 = (JSONObject) jSONObject.opt(a("header")); Iterator<String> keys = jSONObject2.keys(); while (keys.hasNext()) { String next = keys.next(); if (!(next == null || !(next instanceof String) || (str = next) == null || jSONObject2.opt(str) == null)) { try { jSONObject3.put(str, jSONObject2.opt(str)); if (str.equals(a(d.i)) && (jSONObject2.opt(str) instanceof Integer)) { this.k = ((Integer) jSONObject2.opt(str)).intValue(); } } catch (Exception unused) { } } } } return jSONObject; } private Envelope a(Context context, byte[] bArr) { String imprintProperty = UMEnvelopeBuild.imprintProperty(context, "codex", null); int i2 = -1; try { if (!TextUtils.isEmpty(imprintProperty)) { i2 = Integer.valueOf(imprintProperty).intValue(); } } catch (NumberFormatException e2) { UMCrashManager.reportCrash(context, e2); } if (i2 == 0) { return Envelope.genEnvelope(context, UMUtils.getAppkey(context), bArr); } if (i2 == 1) { return Envelope.genEncryptEnvelope(context, UMUtils.getAppkey(context), bArr); } if (l) { return Envelope.genEncryptEnvelope(context, UMUtils.getAppkey(context), bArr); } return Envelope.genEnvelope(context, UMUtils.getAppkey(context), bArr); } private int a(Context context, Envelope envelope, String str, String str2, String str3) { if (context == null || envelope == null || TextUtils.isEmpty(str)) { return 101; } if (TextUtils.isEmpty(str2)) { str2 = DeviceConfig.getAppVersionName(context); } String b2 = com.umeng.commonsdk.stateless.d.b(str3); StringBuilder sb = new StringBuilder(); sb.append(str); sb.append("&&"); sb.append(str2); sb.append("_"); sb.append(System.currentTimeMillis()); sb.append("_"); sb.append(b2); sb.append(".log"); byte[] binary = envelope.toBinary(); if (com.umeng.commonsdk.utils.b.a()) { if (str.startsWith("h")) { return UMFrUtils.saveEnvelopeFile(context, sb.toString(), binary); } return 122; } else if (str.startsWith("h")) { return 122; } else { if (str.startsWith(am.aD) || str.startsWith("i") || str.startsWith("a") || str.startsWith(am.aI)) { return UMFrUtils.saveEnvelopeFile(context, sb.toString(), binary); } return com.umeng.commonsdk.stateless.d.a(context, com.umeng.commonsdk.stateless.a.f, sb.toString(), binary); } } public static void a(boolean z) { l = z; } }