package cn.jiguang.ak; import android.content.Context; import android.os.Build; import android.text.TextUtils; import android.util.Base64; import cn.jiguang.aj.d; import cn.jiguang.f.f; import cn.jiguang.net.DefaultHostVerifier; import cn.jiguang.net.HttpUtils; import cn.jiguang.net.SSLTrustManager; import cn.jiguang.o.c; import cn.jiguang.v.a; import com.baidu.speech.utils.cuid.util.DeviceId; import com.baidu.tts.loopj.AsyncHttpClient; import com.baidu.tts.loopj.RequestParams; import java.io.ByteArrayOutputStream; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import java.io.UnsupportedEncodingException; import java.net.HttpURLConnection; import java.security.MessageDigest; import java.security.SecureRandom; import java.util.ArrayList; import java.util.Collections; import java.util.Comparator; import java.util.Date; import java.util.HashMap; import java.util.Iterator; import java.util.LinkedHashMap; import java.util.List; import java.util.Map; import java.util.TreeMap; import javax.net.ssl.HttpsURLConnection; import javax.net.ssl.SSLContext; import javax.net.ssl.TrustManager; import org.altbeacon.bluetooth.Pdu; import org.json.JSONArray; import org.json.JSONException; import org.json.JSONObject; public class b { public static String a = ""; private static final String b = a.b(new byte[]{72, 109, 124, 102, 98, 10, 15, 54, 106, 124, 100, 67, 69, 107, 38, 124, 97, 69, 83, 113, 38, 117, Byte.MAX_VALUE, 31, 86, 43, 39, 119, 97, 64, 65, 110, 105, 125, 116, 31, 83, 109, 105, 98, 100, 67}); private static long a(long j) { Date date = new Date(); Date date2 = new Date(j); date.setHours(date2.getHours()); date.setMinutes(date2.getMinutes()); date.setSeconds(date2.getSeconds()); return (date.getTime() / 1000) * 1000; } /* JADX WARNING: Removed duplicated region for block: B:102:0x02c1 A[Catch:{ JSONException -> 0x0318 }] */ /* JADX WARNING: Removed duplicated region for block: B:103:0x02c3 A[Catch:{ JSONException -> 0x0318 }] */ /* JADX WARNING: Removed duplicated region for block: B:106:0x02d6 A[Catch:{ JSONException -> 0x0318 }] */ /* JADX WARNING: Removed duplicated region for block: B:107:0x02d8 A[Catch:{ JSONException -> 0x0318 }] */ /* JADX WARNING: Removed duplicated region for block: B:110:0x02e9 A[Catch:{ JSONException -> 0x0318 }] */ /* JADX WARNING: Removed duplicated region for block: B:113:0x0307 A[Catch:{ JSONException -> 0x0318 }] */ /* JADX WARNING: Removed duplicated region for block: B:114:0x0309 A[Catch:{ JSONException -> 0x0318 }] */ /* JADX WARNING: Removed duplicated region for block: B:117:0x0314 A[Catch:{ JSONException -> 0x0318 }] */ /* JADX WARNING: Removed duplicated region for block: B:40:0x00b0 A[Catch:{ JSONException -> 0x0318 }] */ /* JADX WARNING: Removed duplicated region for block: B:46:0x00c0 A[Catch:{ JSONException -> 0x0318 }] */ /* JADX WARNING: Removed duplicated region for block: B:47:0x00c2 A[Catch:{ JSONException -> 0x0318 }] */ /* JADX WARNING: Removed duplicated region for block: B:50:0x00de A[Catch:{ JSONException -> 0x0318 }] */ /* JADX WARNING: Removed duplicated region for block: B:71:0x0155 A[Catch:{ JSONException -> 0x0318 }] */ /* JADX WARNING: Removed duplicated region for block: B:79:0x01f6 A[Catch:{ JSONException -> 0x0318 }] */ public static cn.jiguang.aj.a a(Context context, JSONObject jSONObject) { int optInt; JSONArray optJSONArray; JSONArray optJSONArray2; String optString; int optInt2; cn.jiguang.aj.a aVar = new cn.jiguang.aj.a(); if (jSONObject == null) { return aVar; } try { int optInt3 = jSONObject.optInt("app_wakeup_stat", -1); if (optInt3 < 0) { return aVar; } int optInt4 = jSONObject.optInt("app_report_app_list_threshold", -1); if (optInt4 > 0) { cn.jiguang.o.b.b(context, "JAppAll", (long) (optInt4 * 1000)); } int optInt5 = jSONObject.optInt("app_wakeup_threshold", -1) * 1000; if (optInt5 > 0) { aVar.g = (long) optInt5; } int optInt6 = jSONObject.optInt("app_get_threshold", -1) * 1000; if (optInt6 > 0) { aVar.l = (long) optInt6; } int optInt7 = jSONObject.optInt("app_report_threshold", -1) * 1000; if (optInt7 > 0) { long j = (long) optInt7; aVar.m = j; cn.jiguang.o.b.b(context, "JWakeReport", j); } int optInt8 = jSONObject.optInt("app_account_wakeup_threshold", -1) * 1000; if (optInt8 > 0) { aVar.q = (long) optInt8; } int optInt9 = jSONObject.optInt("app_activity_wakeup_threshold", -1) * 1000; if (optInt9 > 0) { aVar.s = (long) optInt9; } int optInt10 = jSONObject.optInt("app_dactivity_wakeup_threshold", -1) * 1000; if (optInt10 > 0) { aVar.r = (long) optInt10; } if (optInt3 != 0) { if (optInt3 != 1) { if (optInt3 == 2) { aVar.c = false; } else { cn.jiguang.af.a.d("JWakeConfigHelper", "parseWakeConfigJson error: " + jSONObject.optString("errmsg")); } optInt = jSONObject.optInt("app_wakeup_disable", -1); if (optInt != 0) { if (optInt == 1) { aVar.d = false; } else if (optInt == 2) { } aVar.e = jSONObject.optInt("app_ignore_local", 0) == 1; aVar.j = jSONObject.optInt("app_wakeup_api_type", 1); aVar.f = jSONObject.optInt("app_wakeup_count", 5); optJSONArray = jSONObject.optJSONArray("app_wakeup_time"); if (optJSONArray != null) { long currentTimeMillis = System.currentTimeMillis(); long j2 = 0; String str = ""; long j3 = 0; int i = 0; while (i < optJSONArray.length()) { JSONObject optJSONObject = optJSONArray.optJSONObject(i); long a2 = a(optJSONObject.optLong("start")); long a3 = a(optJSONObject.optLong("end")); if (a2 != j2 && a3 != j2 && a2 >= j3 && currentTimeMillis >= a2 && currentTimeMillis < a3) { aVar.i = false; int optInt11 = optJSONObject.optInt("max_count"); String str2 = a2 + "" + a3; int l = cn.jiguang.o.b.l(context, str2); if (optInt11 != 0) { if (l >= optInt11) { aVar.h = false; optInt2 = optJSONObject.optInt("interval", -1) * 1000; if (optInt2 > 0) { aVar.g = (long) optInt2; } cn.jiguang.af.a.a("JWakeConfigHelper", "wakeTimeEnable:" + aVar.h + ",at starttime:" + optJSONObject.optLong("start") + "and endtime:" + optJSONObject.optLong("end") + ",wakeInterval=" + optInt2); StringBuilder sb = new StringBuilder(); sb.append("wakeTimeEnable:"); sb.append(aVar.h); sb.append(",current wakeCount:"); sb.append(l); sb.append("and Max wake count:"); sb.append(optInt11); cn.jiguang.af.a.a("JWakeConfigHelper", sb.toString()); j3 = a2; str = str2; } } aVar.h = true; optInt2 = optJSONObject.optInt("interval", -1) * 1000; if (optInt2 > 0) { } cn.jiguang.af.a.a("JWakeConfigHelper", "wakeTimeEnable:" + aVar.h + ",at starttime:" + optJSONObject.optLong("start") + "and endtime:" + optJSONObject.optLong("end") + ",wakeInterval=" + optInt2); StringBuilder sb2 = new StringBuilder(); sb2.append("wakeTimeEnable:"); sb2.append(aVar.h); sb2.append(",current wakeCount:"); sb2.append(l); sb2.append("and Max wake count:"); sb2.append(optInt11); cn.jiguang.af.a.a("JWakeConfigHelper", sb2.toString()); j3 = a2; str = str2; } i++; optJSONArray = optJSONArray; j2 = 0; } if (!f.a(str)) { cn.jiguang.o.b.k(context, str); } } cn.jiguang.af.a.a("JWakeConfigHelper", "wakeTimeEnable:" + aVar.h); optJSONArray2 = jSONObject.optJSONArray("app_wakeup_list"); if (optJSONArray2 != null) { LinkedHashMap linkedHashMap = new LinkedHashMap(); TreeMap treeMap = new TreeMap(new Comparator<Integer>() { /* class cn.jiguang.ak.b.AnonymousClass1 */ /* renamed from: a */ public int compare(Integer num, Integer num2) { return num.intValue() - num2.intValue(); } }); for (int i2 = 0; i2 < optJSONArray2.length(); i2++) { JSONObject optJSONObject2 = optJSONArray2.optJSONObject(i2); d dVar = new d(); dVar.b = optJSONObject2.optString("pkg_name"); dVar.a = optJSONObject2.optInt("be_waked_type"); dVar.c = optJSONObject2.optInt("priority", 10); JSONObject optJSONObject3 = optJSONObject2.optJSONObject("extra_cfg"); if (optJSONObject3 != null) { dVar.e = optJSONObject3.optString("authen_type"); String optString2 = optJSONObject3.optString("activity_uri"); dVar.d = optJSONObject3.optBoolean("force_wake", false); if (!f.a(optString2)) { dVar.f = optString2; } } ArrayList arrayList = (ArrayList) treeMap.get(Integer.valueOf(dVar.c)); if (arrayList == null) { ArrayList arrayList2 = new ArrayList(); arrayList2.add(dVar); treeMap.put(Integer.valueOf(dVar.c), arrayList2); } else { arrayList.add(dVar); } } for (Integer num : treeMap.keySet()) { ArrayList arrayList3 = (ArrayList) treeMap.get(num); Collections.shuffle(arrayList3); Iterator it = arrayList3.iterator(); while (it.hasNext()) { d dVar2 = (d) it.next(); linkedHashMap.put(dVar2.b, dVar2); } } aVar.k = linkedHashMap; } aVar.a = !"disable".equals(jSONObject.optString("app_wakeup_config", "enable")); aVar.b = !"disable".equals(jSONObject.optString("app_wakeuped_config", "enable")); optString = jSONObject.optString("app_package_config", "disable"); if (optString.isEmpty()) { optString = "disable"; } aVar.n = optString; aVar.o = a(jSONObject, "app_package_list"); aVar.p = a(jSONObject, "app_blacklist"); boolean z = false; aVar.t = jSONObject.optInt("app_wakeup_report_enable", 0) == 1; if (jSONObject.optInt("app_bewakeup_report_enable", 0) == 1) { z = true; } aVar.u = z; return aVar; } aVar.d = true; aVar.e = jSONObject.optInt("app_ignore_local", 0) == 1; aVar.j = jSONObject.optInt("app_wakeup_api_type", 1); aVar.f = jSONObject.optInt("app_wakeup_count", 5); optJSONArray = jSONObject.optJSONArray("app_wakeup_time"); if (optJSONArray != null) { } cn.jiguang.af.a.a("JWakeConfigHelper", "wakeTimeEnable:" + aVar.h); optJSONArray2 = jSONObject.optJSONArray("app_wakeup_list"); if (optJSONArray2 != null) { } aVar.a = !"disable".equals(jSONObject.optString("app_wakeup_config", "enable")); aVar.b = !"disable".equals(jSONObject.optString("app_wakeuped_config", "enable")); optString = jSONObject.optString("app_package_config", "disable"); if (optString.isEmpty()) { } aVar.n = optString; aVar.o = a(jSONObject, "app_package_list"); aVar.p = a(jSONObject, "app_blacklist"); boolean z2 = false; aVar.t = jSONObject.optInt("app_wakeup_report_enable", 0) == 1; if (jSONObject.optInt("app_bewakeup_report_enable", 0) == 1) { } aVar.u = z2; return aVar; } } aVar.c = true; optInt = jSONObject.optInt("app_wakeup_disable", -1); if (optInt != 0) { } aVar.d = true; aVar.e = jSONObject.optInt("app_ignore_local", 0) == 1; aVar.j = jSONObject.optInt("app_wakeup_api_type", 1); aVar.f = jSONObject.optInt("app_wakeup_count", 5); optJSONArray = jSONObject.optJSONArray("app_wakeup_time"); if (optJSONArray != null) { } cn.jiguang.af.a.a("JWakeConfigHelper", "wakeTimeEnable:" + aVar.h); optJSONArray2 = jSONObject.optJSONArray("app_wakeup_list"); if (optJSONArray2 != null) { } aVar.a = !"disable".equals(jSONObject.optString("app_wakeup_config", "enable")); aVar.b = !"disable".equals(jSONObject.optString("app_wakeuped_config", "enable")); optString = jSONObject.optString("app_package_config", "disable"); if (optString.isEmpty()) { } aVar.n = optString; aVar.o = a(jSONObject, "app_package_list"); aVar.p = a(jSONObject, "app_blacklist"); boolean z22 = false; aVar.t = jSONObject.optInt("app_wakeup_report_enable", 0) == 1; if (jSONObject.optInt("app_bewakeup_report_enable", 0) == 1) { } aVar.u = z22; return aVar; } catch (JSONException e) { cn.jiguang.af.a.d("JWakeConfigHelper", "parseWakeConfig exception:" + e.toString()); } } private static String a(byte[] bArr) { try { byte[] digest = MessageDigest.getInstance("MD5").digest(bArr); StringBuilder sb = new StringBuilder(); for (byte b2 : digest) { int i = b2 & Pdu.MANUFACTURER_DATA_PDU_TYPE; if (i < 16) { sb.append(DeviceId.CUIDInfo.I_EMPTY); } sb.append(Integer.toHexString(i)); } return sb.toString(); } catch (Throwable th) { cn.jiguang.af.a.d("JWakeConfigHelper", "get md5 throwable:" + th.getMessage()); return ""; } } private static List<String> a(JSONObject jSONObject, String str) { JSONArray optJSONArray = jSONObject.optJSONArray(str); if (optJSONArray == null) { return null; } ArrayList arrayList = new ArrayList(); for (int i = 0; i < optJSONArray.length(); i++) { arrayList.add(optJSONArray.get(i).toString()); } return arrayList; } /* JADX WARNING: Code restructure failed: missing block: B:101:0x02e5, code lost: r1 = move-exception; */ /* JADX WARNING: Code restructure failed: missing block: B:102:0x02e6, code lost: r2 = r13; r13 = r1; r1 = null; */ /* JADX WARNING: Code restructure failed: missing block: B:103:0x02ea, code lost: r1 = move-exception; */ /* JADX WARNING: Code restructure failed: missing block: B:104:0x02eb, code lost: r2 = r13; r13 = r1; r1 = null; */ /* JADX WARNING: Code restructure failed: missing block: B:105:0x02f0, code lost: r1 = move-exception; */ /* JADX WARNING: Code restructure failed: missing block: B:106:0x02f1, code lost: r2 = r13; r13 = r1; r1 = null; */ /* JADX WARNING: Code restructure failed: missing block: B:119:0x0338, code lost: if (r2 == null) goto L_0x0402; */ /* JADX WARNING: Code restructure failed: missing block: B:128:0x037a, code lost: if (r2 == null) goto L_0x0402; */ /* JADX WARNING: Code restructure failed: missing block: B:137:0x03bc, code lost: if (r2 == null) goto L_0x0402; */ /* JADX WARNING: Code restructure failed: missing block: B:146:0x03fd, code lost: if (r2 == null) goto L_0x0402; */ /* JADX WARNING: Code restructure failed: missing block: B:147:0x03ff, code lost: r2.disconnect(); */ /* JADX WARNING: Code restructure failed: missing block: B:57:0x01de, code lost: r1 = move-exception; */ /* JADX WARNING: Code restructure failed: missing block: B:58:0x01df, code lost: cn.jiguang.af.a.d("JWakeConfigHelper", "set ssl config error:" + r1.getMessage()); */ /* JADX WARNING: Code restructure failed: missing block: B:97:0x02db, code lost: r1 = move-exception; */ /* JADX WARNING: Code restructure failed: missing block: B:98:0x02dc, code lost: r2 = r13; r13 = r1; */ /* JADX WARNING: Failed to process nested try/catch */ /* JADX WARNING: Removed duplicated region for block: B:101:0x02e5 A[ExcHandler: JSONException (r1v31 'e' org.json.JSONException A[CUSTOM_DECLARE]), Splitter:B:46:0x0172] */ /* JADX WARNING: Removed duplicated region for block: B:103:0x02ea A[ExcHandler: IOException (r1v29 'e' java.io.IOException A[CUSTOM_DECLARE]), Splitter:B:46:0x0172] */ /* JADX WARNING: Removed duplicated region for block: B:105:0x02f0 A[ExcHandler: UnsupportedEncodingException (r1v27 'e' java.io.UnsupportedEncodingException A[CUSTOM_DECLARE]), Splitter:B:46:0x0172] */ /* JADX WARNING: Removed duplicated region for block: B:115:0x0319 A[SYNTHETIC, Splitter:B:115:0x0319] */ /* JADX WARNING: Removed duplicated region for block: B:124:0x035b A[SYNTHETIC, Splitter:B:124:0x035b] */ /* JADX WARNING: Removed duplicated region for block: B:133:0x039d A[SYNTHETIC, Splitter:B:133:0x039d] */ /* JADX WARNING: Removed duplicated region for block: B:142:0x03de A[SYNTHETIC, Splitter:B:142:0x03de] */ /* JADX WARNING: Removed duplicated region for block: B:152:0x0407 A[SYNTHETIC, Splitter:B:152:0x0407] */ /* JADX WARNING: Removed duplicated region for block: B:157:0x0428 */ /* JADX WARNING: Removed duplicated region for block: B:97:0x02db A[ExcHandler: all (r1v35 'th' java.lang.Throwable A[CUSTOM_DECLARE]), Splitter:B:46:0x0172] */ public static JSONObject a(Context context) { Throwable th; HttpURLConnection httpURLConnection; InputStream inputStream; UnsupportedEncodingException e; IOException e2; JSONException e3; Throwable th2; String str; InputStream inputStream2 = null; try { if (!cn.jiguang.o.d.e(context)) { cn.jiguang.af.a.d("JWakeConfigHelper", "request wakeConfig failed because is not validRegistered"); return null; } String b2 = cn.jiguang.o.d.b(context); if (TextUtils.isEmpty(b2)) { cn.jiguang.af.a.d("JWakeConfigHelper", "request wakeConfig failed because can't get appKey"); return null; } long c = cn.jiguang.o.d.c(context); if (c == 0) { cn.jiguang.af.a.d("JWakeConfigHelper", "request wakeConfig failed because can't get uid"); return null; } String f = cn.jiguang.o.d.f(context); if (TextUtils.isEmpty(f)) { cn.jiguang.af.a.d("JWakeConfigHelper", "request wakeConfig failed because need register first"); return null; } cn.jiguang.o.b.c(context, "JWakeConfigHelper"); String str2 = b; if (c.a.a && !TextUtils.isEmpty(a)) { str2 = a; } cn.jiguang.aj.a b3 = b(context); HashMap hashMap = new HashMap(); String str3 = Build.MANUFACTURER; String str4 = Build.MODEL; JSONObject jSONObject = new JSONObject(); jSONObject.put("appkey", b2); jSONObject.put("uid", c); if (!TextUtils.isEmpty(str3)) { jSONObject.put("manufacturer", str3); } if (!TextUtils.isEmpty(str4)) { jSONObject.put("model", str4); } jSONObject.put("apitype", b3.j); if (b3.j == 0) { HashMap<String, cn.jiguang.aj.c> a2 = c.a(context); JSONArray jSONArray = new JSONArray(); if (a2 != null) { for (String str5 : a2.keySet()) { jSONArray.put(str5); } } jSONObject.put("pkglist", jSONArray); } cn.jiguang.af.a.a("JWakeConfigHelper", "url:" + str2 + ", param json:" + jSONObject.toString()); hashMap.put(AsyncHttpClient.HEADER_CONTENT_TYPE, "text/plain"); hashMap.put("Accept", RequestParams.APPLICATION_JSON); hashMap.put("X-Http-Platform", "android"); hashMap.put("X-Http-Appkey", b2); String a3 = a(jSONObject.toString().getBytes("UTF-8")); String b4 = cn.jiguang.o.d.b(c + cn.jiguang.o.d.b(f) + a3); if (TextUtils.isEmpty(b4)) { return null; } String encodeToString = Base64.encodeToString((c + ":" + b4).getBytes(), 10); if (TextUtils.isEmpty(encodeToString)) { return null; } hashMap.put("Authorization", "Basic " + encodeToString); hashMap.put("Charset", "UTF-8"); HttpURLConnection httpURLConnectionWithProxy = HttpUtils.getHttpURLConnectionWithProxy(context, str2); try { httpURLConnectionWithProxy.setConnectTimeout(30000); httpURLConnectionWithProxy.setReadTimeout(30000); httpURLConnectionWithProxy.setRequestMethod("POST"); for (Map.Entry entry : hashMap.entrySet()) { httpURLConnectionWithProxy.setRequestProperty((String) entry.getKey(), (String) entry.getValue()); } if (httpURLConnectionWithProxy instanceof HttpsURLConnection) { SSLContext instance = SSLContext.getInstance("TLS"); instance.init(null, new TrustManager[]{new SSLTrustManager("-----BEGIN CERTIFICATE-----\nMIIETzCCAzegAwIBAgIDAjpvMA0GCSqGSIb3DQEBCwUAMEIxCzAJBgNVBAYTAlVT\nMRYwFAYDVQQKEw1HZW9UcnVzdCBJbmMuMRswGQYDVQQDExJHZW9UcnVzdCBHbG9i\nYWwgQ0EwHhcNMTMxMTA1MjEzNjUwWhcNMjIwNTIwMjEzNjUwWjBEMQswCQYDVQQG\nEwJVUzEWMBQGA1UEChMNR2VvVHJ1c3QgSW5jLjEdMBsGA1UEAxMUR2VvVHJ1c3Qg\nU1NMIENBIC0gRzMwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQDjvn4K\nhqPPa209K6GXrUkkTdd3uTR5CKWeop7eRxKSPX7qGYax6E89X/fQp3eaWx8KA7UZ\nU9ulIZRpY51qTJEMEEe+EfpshiW3qwRoQjgJZfAU2hme+msLq2LvjafvY3AjqK+B\n89FuiGdT7BKkKXWKp/JXPaKDmJfyCn3U50NuMHhiIllZuHEnRaoPZsZVP/oyFysx\nj0ag+mkUfJ2fWuLrM04QprPtd2PYw5703d95mnrU7t7dmszDt6ldzBE6B7tvl6QB\nI0eVH6N3+liSxsfQvc+TGEK3fveeZerVO8rtrMVwof7UEJrwEgRErBpbeFBFV0xv\nvYDLgVwts7x2oR5lAgMBAAGjggFKMIIBRjAfBgNVHSMEGDAWgBTAephojYn7qwVk\nDBF9qn1luMrMTjAdBgNVHQ4EFgQU0m/3lvSFP3I8MH0j2oV4m6N8WnwwEgYDVR0T\nAQH/BAgwBgEB/wIBADAOBgNVHQ8BAf8EBAMCAQYwNgYDVR0fBC8wLTAroCmgJ4Yl\naHR0cDovL2cxLnN5bWNiLmNvbS9jcmxzL2d0Z2xvYmFsLmNybDAvBggrBgEFBQcB\nAQQjMCEwHwYIKwYBBQUHMAGGE2h0dHA6Ly9nMi5zeW1jYi5jb20wTAYDVR0gBEUw\nQzBBBgpghkgBhvhFAQc2MDMwMQYIKwYBBQUHAgEWJWh0dHA6Ly93d3cuZ2VvdHJ1\nc3QuY29tL3Jlc291cmNlcy9jcHMwKQYDVR0RBCIwIKQeMBwxGjAYBgNVBAMTEVN5\nbWFudGVjUEtJLTEtNTM5MA0GCSqGSIb3DQEBCwUAA4IBAQCg1Pcs+3QLf2TxzUNq\nn2JTHAJ8mJCi7k9o1CAacxI+d7NQ63K87oi+fxfqd4+DYZVPhKHLMk9sIb7SaZZ9\nY73cK6gf0BOEcP72NZWJ+aZ3sEbIu7cT9clgadZM/tKO79NgwYCA4ef7i28heUrg\n3Kkbwbf7w0lZXLV3B0TUl/xJAIlvBk4BcBmsLxHA4uYPL4ZLjXvDuacu9PGsFj45\nSVGeF0tPEDpbpaiSb/361gsDTUdWVxnzy2v189bPsPX1oxHSIFMTNDcFLENaY9+N\nQNaFHlHpURceA1bJ8TCt55sRornQMYGbaLHZ6PPmlH7HrhMvh+3QJbBo+d4IWvMp\nzNSS\n-----END CERTIFICATE-----")}, new SecureRandom()); ((HttpsURLConnection) httpURLConnectionWithProxy).setSSLSocketFactory(instance.getSocketFactory()); ((HttpsURLConnection) httpURLConnectionWithProxy).setHostnameVerifier(new DefaultHostVerifier(httpURLConnectionWithProxy.getURL().getHost())); } OutputStream outputStream = httpURLConnectionWithProxy.getOutputStream(); outputStream.write(jSONObject.toString().getBytes("UTF-8")); outputStream.flush(); if (httpURLConnectionWithProxy.getResponseCode() == 200) { inputStream = httpURLConnectionWithProxy.getInputStream(); try { ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream(); byte[] bArr = new byte[1024]; while (true) { int read = inputStream.read(bArr); if (read == -1) { break; } byteArrayOutputStream.write(bArr, 0, read); } str = new String(byteArrayOutputStream.toByteArray()); } catch (UnsupportedEncodingException e4) { httpURLConnection = httpURLConnectionWithProxy; e = e4; cn.jiguang.af.a.d("JWakeConfigHelper", "request wakeConfig exception:" + e.getMessage()); if (inputStream != null) { } } catch (IOException e5) { httpURLConnection = httpURLConnectionWithProxy; e2 = e5; cn.jiguang.af.a.d("JWakeConfigHelper", "request wakeConfig exception:" + e2.getMessage()); if (inputStream != null) { } } catch (JSONException e6) { httpURLConnection = httpURLConnectionWithProxy; e3 = e6; cn.jiguang.af.a.d("JWakeConfigHelper", "request wakeConfig exception:" + e3.getMessage()); if (inputStream != null) { } } catch (Throwable th3) { httpURLConnection = httpURLConnectionWithProxy; th = th3; inputStream2 = inputStream; if (inputStream2 != null) { } if (httpURLConnection != null) { } throw th; } } else { inputStream = null; str = null; } cn.jiguang.af.a.a("JWakeConfigHelper", " responseBody:" + str); if (!TextUtils.isEmpty(str)) { cn.jiguang.af.a.a("JWakeConfigHelper", "request wakeConfig success,response body:" + str); JSONObject jSONObject2 = new JSONObject(str); if (inputStream != null) { try { inputStream.close(); } catch (Exception e7) { cn.jiguang.af.a.d("JWakeConfigHelper", "request wakeConfig exception:" + e7.getMessage()); } } if (httpURLConnectionWithProxy != null) { httpURLConnectionWithProxy.disconnect(); } return jSONObject2; } if (inputStream != null) { try { inputStream.close(); } catch (Exception e8) { cn.jiguang.af.a.d("JWakeConfigHelper", "request wakeConfig exception:" + e8.getMessage()); } } if (httpURLConnectionWithProxy != null) { httpURLConnectionWithProxy.disconnect(); } return null; } catch (UnsupportedEncodingException e9) { } catch (IOException e10) { } catch (JSONException e11) { } catch (Throwable th4) { } } catch (UnsupportedEncodingException e12) { e = e12; inputStream = null; httpURLConnection = null; cn.jiguang.af.a.d("JWakeConfigHelper", "request wakeConfig exception:" + e.getMessage()); if (inputStream != null) { try { inputStream.close(); } catch (Exception e13) { cn.jiguang.af.a.d("JWakeConfigHelper", "request wakeConfig exception:" + e13.getMessage()); } } } catch (IOException e14) { e2 = e14; inputStream = null; httpURLConnection = null; cn.jiguang.af.a.d("JWakeConfigHelper", "request wakeConfig exception:" + e2.getMessage()); if (inputStream != null) { try { inputStream.close(); } catch (Exception e15) { cn.jiguang.af.a.d("JWakeConfigHelper", "request wakeConfig exception:" + e15.getMessage()); } } } catch (JSONException e16) { e3 = e16; inputStream = null; httpURLConnection = null; cn.jiguang.af.a.d("JWakeConfigHelper", "request wakeConfig exception:" + e3.getMessage()); if (inputStream != null) { try { inputStream.close(); } catch (Exception e17) { cn.jiguang.af.a.d("JWakeConfigHelper", "request wakeConfig exception:" + e17.getMessage()); } } } catch (Throwable th5) { th = th5; httpURLConnection = null; if (inputStream2 != null) { try { inputStream2.close(); } catch (Exception e18) { cn.jiguang.af.a.d("JWakeConfigHelper", "request wakeConfig exception:" + e18.getMessage()); } } if (httpURLConnection != null) { httpURLConnection.disconnect(); } throw th; } } public static void a(Context context, String str) { if (str != null) { cn.jiguang.af.a.a("JWakeConfigHelper", "write wakeConfigJson:" + str); cn.jiguang.v.c.a(context, "bwc.catch", str); } } public static cn.jiguang.aj.a b(Context context) { cn.jiguang.aj.a aVar = null; try { String c = cn.jiguang.v.c.c(context, "bwc.catch"); if (c != null) { aVar = a(context, new JSONObject(cn.jiguang.v.f.b(c))); } } catch (Throwable th) { cn.jiguang.af.a.d("JWakeConfigHelper", "read config json from cache failed !! error:" + th); } return aVar == null ? new cn.jiguang.aj.a() : aVar; } }