package com.tb.tb_lib.b; import android.content.Context; import android.os.Handler; import android.os.Looper; import android.os.Process; import android.util.Log; import com.alibaba.fastjson.JSON; import com.baidu.mobads.sdk.internal.ae; import com.bytedance.sdk.openadsdk.api.plugin.PluginConstants; import com.tb.mob.bean.TbTag; import com.tb.mob.utils.AppUtils; import com.tb.mob.utils.ValueUtils; import com.tb.tb_lib.l.k; import java.io.DataOutputStream; import java.io.InputStream; import java.io.InputStreamReader; import java.net.URL; import java.security.SecureRandom; import java.util.HashMap; import java.util.Map; import java.util.concurrent.Executors; import java.util.concurrent.ScheduledExecutorService; import javax.net.ssl.HostnameVerifier; import javax.net.ssl.HttpsURLConnection; import javax.net.ssl.SSLContext; import javax.net.ssl.SSLSession; import javax.net.ssl.SSLSocketFactory; import javax.net.ssl.TrustManager; public class c { private static ScheduledExecutorService a = Executors.newScheduledThreadPool(18); private static Handler b = new Handler(Looper.getMainLooper()); /* access modifiers changed from: package-private */ public class a implements Runnable { final /* synthetic */ Context a; final /* synthetic */ String b; final /* synthetic */ a c; /* renamed from: com.tb.tb_lib.b.c$a$a reason: collision with other inner class name */ class RunnableC0311a implements Runnable { final /* synthetic */ Map a; RunnableC0311a(Map map) { this.a = map; } public void run() { String str = TbTag.Network; Log.d(str, "___" + Process.myPid() + "___get_result.code=1"); a.this.c.onResponse(this.a); } } class b implements Runnable { final /* synthetic */ Map a; final /* synthetic */ int b; b(Map map, int i) { this.a = map; this.b = i; } public void run() { String string = ValueUtils.getString(this.a.get("msg")); String str = TbTag.Network; Log.d(str, "___" + Process.myPid() + "___get_onFailure=" + string); a.this.c.onFailure(this.b, string); } } /* renamed from: com.tb.tb_lib.b.c$a$c reason: collision with other inner class name */ class RunnableC0312c implements Runnable { final /* synthetic */ int a; RunnableC0312c(int i) { this.a = i; } public void run() { a aVar = a.this.c; aVar.onFailure(-1, "请求失败:" + this.a); } } class d implements Runnable { final /* synthetic */ Exception a; d(Exception exc) { this.a = exc; } public void run() { String message = this.a.getMessage(); if (message.contains("10000ms")) { message = "网络连接10000ms超时异常"; } a.this.c.onFailure(-1, message); } } a(Context context, String str, a aVar) { this.a = context; this.b = str; this.c = aVar; } public void run() { String packageName = AppUtils.getPackageName(this.a); String str = k.h(this.a.getApplicationContext()) ? "https://appspe.qubiankeji.com" : "https://app.qubiankeji.com"; if (packageName != null) { packageName.contains("com.soyea.ryc.test"); } try { HttpsURLConnection httpsURLConnection = (HttpsURLConnection) new URL(str + this.b).openConnection(); httpsURLConnection.setRequestMethod("GET"); httpsURLConnection.setConnectTimeout(10000); httpsURLConnection.setReadTimeout(10000); c.b(this.a, httpsURLConnection); int responseCode = httpsURLConnection.getResponseCode(); String str2 = TbTag.Network; Log.d(str2, "___" + Process.myPid() + "___get_responseCode=" + responseCode); if (responseCode == 200) { String b2 = c.b(httpsURLConnection.getInputStream()); String str3 = TbTag.Network; Log.d(str3, "___" + Process.myPid() + "___get_result=" + b2); Map map = (Map) JSON.parseObject(b2, Map.class); int intValue = ValueUtils.getInt(map.get(PluginConstants.KEY_ERROR_CODE)).intValue(); if (1 == intValue) { c.b.post(new RunnableC0311a(map)); } else { c.b.post(new b(map, intValue)); } } else { c.b.post(new RunnableC0312c(responseCode)); } } catch (Exception e) { String str4 = TbTag.Network; Log.e(str4, "___" + Process.myPid() + "___get_Exception=" + e.getMessage()); c.b.post(new d(e)); e.printStackTrace(); } } } class b implements Runnable { final /* synthetic */ Context a; final /* synthetic */ String b; final /* synthetic */ String c; b(Context context, String str, String str2) { this.a = context; this.b = str; this.c = str2; } public void run() { String packageName = AppUtils.getPackageName(this.a); String str = k.h(this.a.getApplicationContext()) ? "https://appspe.qubiankeji.com" : "https://app.qubiankeji.com"; if (packageName != null) { packageName.contains("com.soyea.ryc.test"); } try { HttpsURLConnection httpsURLConnection = (HttpsURLConnection) new URL(str + this.b).openConnection(); httpsURLConnection.setRequestMethod(ae.b); httpsURLConnection.setConnectTimeout(10000); httpsURLConnection.setReadTimeout(10000); httpsURLConnection.setDoOutput(true); httpsURLConnection.setDoInput(true); httpsURLConnection.setUseCaches(false); httpsURLConnection.setRequestProperty("Content-Type", "application/json"); c.b(this.a, httpsURLConnection); c.b(httpsURLConnection, this.c); String b2 = c.b(httpsURLConnection.getInputStream()); String str2 = TbTag.Network; Log.d(str2, "___" + Process.myPid() + "___postReward_readResponse2Str=" + b2); } catch (Exception e) { String str3 = TbTag.Network; Log.e(str3, "___" + Process.myPid() + "___postReward_Exception=" + e.getMessage()); e.printStackTrace(); } } } /* renamed from: com.tb.tb_lib.b.c$c reason: collision with other inner class name */ class RunnableC0313c implements Runnable { final /* synthetic */ Context a; final /* synthetic */ String b; final /* synthetic */ String c; RunnableC0313c(Context context, String str, String str2) { this.a = context; this.b = str; this.c = str2; } public void run() { String packageName = AppUtils.getPackageName(this.a); String str = k.h(this.a.getApplicationContext()) ? "https://appspe.qubiankeji.com:8443" : "https://app.qubiankeji.com:8443"; if (packageName != null) { packageName.contains("com.soyea.ryc.test"); } try { HttpsURLConnection httpsURLConnection = (HttpsURLConnection) new URL(str + this.b).openConnection(); httpsURLConnection.setRequestMethod(ae.b); httpsURLConnection.setConnectTimeout(10000); httpsURLConnection.setReadTimeout(10000); httpsURLConnection.setDoOutput(true); httpsURLConnection.setDoInput(true); httpsURLConnection.setUseCaches(false); httpsURLConnection.setRequestProperty("Content-Type", "application/json"); c.b(this.a, httpsURLConnection); HashMap hashMap = new HashMap(); hashMap.put("data", this.c); c.b(httpsURLConnection, JSON.toJSONString(hashMap)); String b2 = c.b(httpsURLConnection.getInputStream()); String str2 = TbTag.Network; Log.d(str2, "___" + Process.myPid() + "___postUpload_readResponse2Str=" + b2); } catch (Exception e) { String str3 = TbTag.Network; Log.e(str3, "___" + Process.myPid() + "___postUpload_Exception=" + e.getMessage()); e.printStackTrace(); } } } /* access modifiers changed from: package-private */ public class d implements HostnameVerifier { d() { } public boolean verify(String str, SSLSession sSLSession) { return str.contains("qubiankeji.com"); } } public static void a(Context context, a aVar, String str) { if (a == null) { a = Executors.newScheduledThreadPool(18); } if (b == null) { b = new Handler(Looper.getMainLooper()); } a.execute(new a(context, str, aVar)); } public static void a(Context context, String str, String str2) { if (a == null) { a = Executors.newScheduledThreadPool(18); } if (b == null) { b = new Handler(Looper.getMainLooper()); } a.execute(new b(context, str, str2)); } /* access modifiers changed from: private */ /* JADX WARNING: Removed duplicated region for block: B:23:0x0073 A[SYNTHETIC, Splitter:B:23:0x0073] */ /* JADX WARNING: Removed duplicated region for block: B:30:0x0087 A[SYNTHETIC, Splitter:B:30:0x0087] */ public static String b(InputStream inputStream) { Throwable th; Exception e; String str; StringBuilder sb; StringBuilder sb2 = new StringBuilder(); InputStreamReader inputStreamReader = null; try { InputStreamReader inputStreamReader2 = new InputStreamReader(inputStream); try { char[] cArr = new char[32]; while (true) { int read = inputStreamReader2.read(cArr); if (read > 0) { sb2.append(cArr, 0, read); } else { try { break; } catch (Exception e2) { e = e2; str = TbTag.Network; sb = new StringBuilder(); } } } inputStreamReader2.close(); } catch (Exception e3) { e = e3; inputStreamReader = inputStreamReader2; try { String str2 = TbTag.Network; Log.e(str2, "___" + Process.myPid() + "___readResponse2Str_Exception=" + e.getMessage()); if (inputStreamReader != null) { } return sb2.toString(); } catch (Throwable th2) { th = th2; if (inputStreamReader != null) { } throw th; } } catch (Throwable th3) { th = th3; inputStreamReader = inputStreamReader2; if (inputStreamReader != null) { try { inputStreamReader.close(); } catch (Exception e4) { String str3 = TbTag.Network; Log.e(str3, "___" + Process.myPid() + "___readResponse2Str_Exception=" + e4.getMessage()); } } throw th; } } catch (Exception e5) { e = e5; String str22 = TbTag.Network; Log.e(str22, "___" + Process.myPid() + "___readResponse2Str_Exception=" + e.getMessage()); if (inputStreamReader != null) { try { inputStreamReader.close(); } catch (Exception e6) { e = e6; str = TbTag.Network; sb = new StringBuilder(); } } return sb2.toString(); } return sb2.toString(); sb.append("___"); sb.append(Process.myPid()); sb.append("___readResponse2Str_Exception="); sb.append(e.getMessage()); Log.e(str, sb.toString()); return sb2.toString(); } public static void b(Context context, String str, String str2) { if (a == null) { a = Executors.newScheduledThreadPool(18); } if (b == null) { b = new Handler(Looper.getMainLooper()); } a.execute(new RunnableC0313c(context, str, str2)); } /* access modifiers changed from: private */ public static void b(Context context, HttpsURLConnection httpsURLConnection) throws Exception { TrustManager[] trustManagerArr = {new b(context)}; SSLContext instance = SSLContext.getInstance("SSL"); instance.init(null, trustManagerArr, new SecureRandom()); SSLSocketFactory socketFactory = instance.getSocketFactory(); httpsURLConnection.setHostnameVerifier(new d()); httpsURLConnection.setSSLSocketFactory(socketFactory); } /* access modifiers changed from: private */ /* JADX WARNING: Removed duplicated region for block: B:19:0x006d A[SYNTHETIC, Splitter:B:19:0x006d] */ /* JADX WARNING: Removed duplicated region for block: B:24:0x007d A[SYNTHETIC, Splitter:B:24:0x007d] */ /* JADX WARNING: Removed duplicated region for block: B:30:? A[RETURN, SYNTHETIC] */ public static void b(HttpsURLConnection httpsURLConnection, String str) { Throwable th; Exception e; String str2; StringBuilder sb; DataOutputStream dataOutputStream = null; try { DataOutputStream dataOutputStream2 = new DataOutputStream(httpsURLConnection.getOutputStream()); try { dataOutputStream2.write(str.getBytes()); dataOutputStream2.flush(); try { dataOutputStream2.close(); return; } catch (Exception e2) { e = e2; str2 = TbTag.Network; sb = new StringBuilder(); } } catch (Exception e3) { e = e3; dataOutputStream = dataOutputStream2; try { String str3 = TbTag.Network; Log.e(str3, "___" + Process.myPid() + "___writeStr2Request_Exception=" + e.getMessage()); if (dataOutputStream == null) { try { dataOutputStream.close(); return; } catch (Exception e4) { e = e4; str2 = TbTag.Network; sb = new StringBuilder(); } } else { return; } } catch (Throwable th2) { th = th2; if (dataOutputStream != null) { try { dataOutputStream.close(); } catch (Exception e5) { String str4 = TbTag.Network; Log.e(str4, "___" + Process.myPid() + "___writeStr2Request_Exception=" + e5.getMessage()); } } throw th; } } catch (Throwable th3) { th = th3; dataOutputStream = dataOutputStream2; if (dataOutputStream != null) { } throw th; } sb.append("___"); sb.append(Process.myPid()); sb.append("___writeStr2Request_Exception="); sb.append(e.getMessage()); Log.e(str2, sb.toString()); } catch (Exception e6) { e = e6; String str32 = TbTag.Network; Log.e(str32, "___" + Process.myPid() + "___writeStr2Request_Exception=" + e.getMessage()); if (dataOutputStream == null) { } } } }