package com.mobile.auth.z; import android.content.Context; import android.net.Network; import android.os.Build; import android.text.TextUtils; import com.huawei.updatesdk.service.otaupdate.UpdateDialogStatusCode; import com.iflytek.cloud.SpeechEvent; import com.mobile.auth.BuildConfig; import com.mobile.auth.ab.b; import com.mobile.auth.ab.c; import com.mobile.auth.ab.f; import com.mobile.auth.ab.g; import com.mobile.auth.y.b; import java.net.URLDecoder; import java.util.HashMap; import java.util.concurrent.ExecutorService; import java.util.concurrent.ScheduledExecutorService; import java.util.concurrent.TimeUnit; import org.json.JSONObject; public class a { /* renamed from: a reason: collision with root package name */ private ScheduledExecutorService f20967a = b03.f(1, "com.mobile.auth.z.a"); /* renamed from: b reason: collision with root package name */ private ExecutorService f20968b = b03.h("com.mobile.auth.z.a"); private b c; private String d; public static /* synthetic */ b a(a aVar) { try { return aVar.c; } catch (Throwable th) { com.mobile.auth.gatewayauth.a.a(th); return null; } } public static /* synthetic */ b a(a aVar, b bVar) { try { aVar.c = bVar; return bVar; } catch (Throwable th) { com.mobile.auth.gatewayauth.a.a(th); return null; } } private String a(Context context, int i, String str) { try { String packageName = context.getPackageName(); String b2 = g.b(context, context.getPackageName()); if (packageName == null) { packageName = ""; } if (b2 == null) { b2 = ""; } String a2 = f.a(); String str2 = i != 2 ? "1" : ""; String str3 = "" + System.currentTimeMillis(); String a3 = b.a(g.c(context).getBytes()); String d2 = g.d(str); String a4 = g.a(str2 + a2 + "30100" + "jsonp" + a3 + d2 + packageName + b2 + str3 + BuildConfig.CUCC_SDK_VERSION + f.b()); JSONObject jSONObject = new JSONObject(); jSONObject.put("client_id", a2); jSONObject.put("client_type", "30100"); jSONObject.put("format", b.a("jsonp")); jSONObject.put("version", b.a(BuildConfig.CUCC_SDK_VERSION)); if (i != 2) { jSONObject.put("business_type", b.a(str2)); } jSONObject.put("packname", b.a(packageName)); jSONObject.put("packsign", b.a(b2)); jSONObject.put("timeStamp", b.a(str3)); jSONObject.put("key", b.a(d2)); jSONObject.put("fp", b.a(a3)); jSONObject.put("sign", b.a(a4)); return jSONObject.toString(); } catch (Exception e) { try { e.printStackTrace(); return ""; } catch (Throwable th) { com.mobile.auth.gatewayauth.a.a(th); return null; } } } private void a() { try { ScheduledExecutorService scheduledExecutorService = this.f20967a; if (scheduledExecutorService != null) { scheduledExecutorService.shutdownNow(); this.f20967a = null; } } catch (Exception e) { try { e.printStackTrace(); } catch (Throwable th) { com.mobile.auth.gatewayauth.a.a(th); } } } private void a(Context context, int i) { try { this.d = com.mobile.auth.y.a.a(); a(context, i, new com.mobile.auth.aa.a() { /* class com.mobile.auth.z.a.AnonymousClass2 */ @Override // com.mobile.auth.aa.a public void a(int i, String str) { try { synchronized (a.this) { if (a.a(a.this) != null) { if (i == 1) { try { JSONObject jSONObject = new JSONObject(str); int optInt = jSONObject.optInt("code"); String optString = jSONObject.optString("msg"); String optString2 = jSONObject.optString("data"); if (optInt == 0) { a.a(a.this).a(optString, URLDecoder.decode(com.mobile.auth.y.a.a(optString2, a.c(a.this)), "UTF-8")); } else { a.a(a.this).a(optInt, optString, optString2); } } catch (Exception e) { b a2 = a.a(a.this); a2.a(UpdateDialogStatusCode.SHOW, "异常" + e.getMessage(), str); } } else { a.a(a.this).a(i, str); } a.a(a.this, (b) null); a.b(a.this); } } } catch (Throwable th) { com.mobile.auth.gatewayauth.a.a(th); } } }); } catch (Throwable th) { com.mobile.auth.gatewayauth.a.a(th); } } private void a(final Context context, final int i, final com.mobile.auth.aa.a aVar) { try { int a2 = g.a(context.getApplicationContext()); f.b(a2); if (a2 == 1) { com.mobile.auth.ab.b.a().a(context, "https://opencloud.wostore.cn/openapi/netauth/precheck/wp?", new b.a() { /* class com.mobile.auth.z.a.AnonymousClass3 */ @Override // com.mobile.auth.ab.b.a public void a(boolean z, Network network) { if (z) { try { a.a(a.this, context, i, "https://opencloud.wostore.cn/openapi/netauth/precheck/wp?", network, aVar); } catch (Throwable th) { com.mobile.auth.gatewayauth.a.a(th); } } else { aVar.a(10003, "无法切换至数据网络"); } } }); } else if (a2 == 0) { a(context, i, "https://opencloud.wostore.cn/openapi/netauth/precheck/wp?", null, aVar); } else { aVar.a(SpeechEvent.EVENT_IST_AUDIO_FILE, "数据网络未开启"); } } catch (Exception e) { try { e.printStackTrace(); aVar.a(10005, "网络判断异常" + e.getMessage()); } catch (Throwable th) { com.mobile.auth.gatewayauth.a.a(th); } } } private void a(Context context, int i, String str, final Network network, final com.mobile.auth.aa.a aVar) { try { synchronized (this) { try { final String str2 = str + c.a(a(context, i, this.d), "&"); this.f20968b.submit(new Runnable() { /* class com.mobile.auth.z.a.AnonymousClass4 */ public void run() { try { String a2 = new com.mobile.auth.aa.b().a(str2, a.d(a.this), network); if (TextUtils.isEmpty(a2)) { aVar.a(10022, "网络请求响应为空"); } else { aVar.a(1, a2); } } catch (Exception e) { try { e.printStackTrace(); } catch (Throwable th) { com.mobile.auth.gatewayauth.a.a(th); } } } }); } catch (Exception e) { aVar.a(SpeechEvent.EVENT_IST_SYNC_ID, "10009" + e.getMessage()); } } } catch (Throwable th) { com.mobile.auth.gatewayauth.a.a(th); } } public static /* synthetic */ void a(a aVar, Context context, int i, String str, Network network, com.mobile.auth.aa.a aVar2) { try { aVar.a(context, i, str, network, aVar2); } catch (Throwable th) { com.mobile.auth.gatewayauth.a.a(th); } } private HashMap<String, String> b() { try { HashMap<String, String> hashMap = new HashMap<>(); hashMap.put("model", Build.MODEL); hashMap.put("system", Build.VERSION.RELEASE); hashMap.put("woodcock", f.i()); return hashMap; } catch (Throwable th) { com.mobile.auth.gatewayauth.a.a(th); return null; } } public static /* synthetic */ void b(a aVar) { try { aVar.a(); } catch (Throwable th) { com.mobile.auth.gatewayauth.a.a(th); } } public static /* synthetic */ String c(a aVar) { try { return aVar.d; } catch (Throwable th) { com.mobile.auth.gatewayauth.a.a(th); return null; } } public static /* synthetic */ HashMap d(a aVar) { try { return aVar.b(); } catch (Throwable th) { com.mobile.auth.gatewayauth.a.a(th); return null; } } public void a(Context context, int i, int i2, com.mobile.auth.x.a aVar) { try { b bVar = new b(); this.c = bVar; bVar.a(aVar); try { this.f20967a.schedule(new Runnable() { /* class com.mobile.auth.z.a.AnonymousClass1 */ public void run() { try { synchronized (a.this) { if (a.a(a.this) != null) { a.a(a.this).a(10000, "请求超时"); a.a(a.this, (b) null); a.b(a.this); } } } catch (Throwable th) { com.mobile.auth.gatewayauth.a.a(th); } } }, (long) i, TimeUnit.MILLISECONDS); a(context, i2); } catch (Exception e) { e.printStackTrace(); } } catch (Throwable th) { com.mobile.auth.gatewayauth.a.a(th); } } }