package com.mobile.auth.gatewayauth.manager; import android.content.Context; import android.os.Debug; import android.os.Looper; import android.text.TextUtils; import com.mobile.auth.gatewayauth.ExceptionProcessor; import com.mobile.auth.gatewayauth.manager.base.Cache; import com.mobile.auth.gatewayauth.manager.base.CacheKey; import com.mobile.auth.gatewayauth.manager.compat.ResultCodeProcessor; import com.mobile.auth.gatewayauth.model.TokenRet; import com.mobile.auth.gatewayauth.utils.Checker; import com.mobile.auth.gatewayauth.utils.b; import com.mobile.auth.gatewayauth.utils.g; import com.mobile.auth.gatewayauth.utils.security.CheckProxy; import com.mobile.auth.gatewayauth.utils.security.CheckRoot; import com.mobile.auth.gatewayauth.utils.security.EmulatorDetector; import com.mobile.auth.gatewayauth.utils.security.PackageUtils; import com.mobile.auth.m.a; import com.nirvana.tools.core.CryptUtil; import com.nirvana.tools.core.ExecutorManager; import java.io.IOException; import java.io.InputStream; import java.util.concurrent.ExecutionException; import java.util.concurrent.Future; public class SystemManager { private final Context a; private String b; private String c; private final a d; private volatile boolean e = true; private Future<?> f; static { System.loadLibrary("pns-LogOnlineStandardRelease-2.12.4-SNAPSHOT_alijtca_plus"); } public SystemManager(final Context context, a aVar) { this.a = context.getApplicationContext(); this.f = ExecutorManager.getInstance().scheduleFuture(new Runnable() { /* class com.mobile.auth.gatewayauth.manager.SystemManager.AnonymousClass1 */ public void run() { try { SystemManager.a(SystemManager.this, PackageUtils.getPackageName(context)); SystemManager.b(SystemManager.this, PackageUtils.getSign(context)); } catch (Throwable th) { ExceptionProcessor.processException(th); } } }); this.d = aVar; } private TokenRet a(ResultCodeProcessor resultCodeProcessor, String str) { try { if (!b.e(this.a)) { return resultCodeProcessor.convertErrorInfo("-10005", "SIM卡无法检测", str); } if (!b.d(this.a)) { return resultCodeProcessor.convertErrorInfo("-10006", "移动网络未开启", str); } return null; } catch (Throwable th) { ExceptionProcessor.processException(th); return null; } } static /* synthetic */ String a(SystemManager systemManager, String str) { try { systemManager.b = str; return str; } catch (Throwable th) { ExceptionProcessor.processException(th); return null; } } static /* synthetic */ String b(SystemManager systemManager, String str) { try { systemManager.c = str; return str; } catch (Throwable th) { ExceptionProcessor.processException(th); return null; } } private native String requestCellularIp(); public TokenRet a(ResultCodeProcessor resultCodeProcessor, boolean z, String str) { try { TokenRet checkEnvSafe = checkEnvSafe(resultCodeProcessor, str); return (checkEnvSafe != null || !z) ? checkEnvSafe : a(resultCodeProcessor, str); } catch (Throwable th) { ExceptionProcessor.processException(th); return null; } } public synchronized String a() { try { Future<?> future = this.f; if (future != null) { try { future.get(); this.f = null; } catch (InterruptedException e2) { e2.printStackTrace(); } catch (ExecutionException e3) { e3.printStackTrace(); } } } catch (Throwable th) { ExceptionProcessor.processException(th); return null; } return this.b; } /* JADX WARNING: Code restructure failed: missing block: B:23:0x004f, code lost: r4 = move-exception; */ /* JADX WARNING: Code restructure failed: missing block: B:25:?, code lost: r3.e = true; */ /* JADX WARNING: Code restructure failed: missing block: B:26:0x0053, code lost: if (0 != 0) goto L_0x0055; */ /* JADX WARNING: Code restructure failed: missing block: B:28:?, code lost: r0.close(); */ /* JADX WARNING: Code restructure failed: missing block: B:29:0x0058, code lost: return; */ /* JADX WARNING: Code restructure failed: missing block: B:30:0x0059, code lost: r4 = move-exception; */ /* JADX WARNING: Code restructure failed: missing block: B:31:0x005a, code lost: r4.printStackTrace(); */ /* JADX WARNING: Code restructure failed: missing block: B:32:0x005e, code lost: if (0 != 0) goto L_0x0060; */ /* JADX WARNING: Code restructure failed: missing block: B:34:?, code lost: r0.close(); */ /* JADX WARNING: Code restructure failed: missing block: B:35:0x0064, code lost: r0 = move-exception; */ /* JADX WARNING: Code restructure failed: missing block: B:36:0x0065, code lost: r0.printStackTrace(); */ /* JADX WARNING: Code restructure failed: missing block: B:37:0x0068, code lost: throw r4; */ /* JADX WARNING: Code restructure failed: missing block: B:47:?, code lost: return; */ /* JADX WARNING: Code restructure failed: missing block: B:48:?, code lost: return; */ /* JADX WARNING: Failed to process nested try/catch */ /* JADX WARNING: Missing exception handler attribute for start block: B:24:0x0051 */ public void a(String str) { try { if ((FeatureManager.getInstance().get("whiteFileCheck") == null || !"false".equals(FeatureManager.getInstance().get("whiteFileCheck").toString())) && !TextUtils.isEmpty(str)) { InputStream inputStream = null; String md5Hex = CryptUtil.md5Hex(str); if (!TextUtils.isEmpty(md5Hex)) { InputStream open = this.a.getAssets().open(md5Hex); this.e = false; if (open != null) { try { open.close(); } catch (IOException e2) { e2.printStackTrace(); } } } else { this.e = true; } } } catch (Throwable th) { ExceptionProcessor.processException(th); } } /* access modifiers changed from: protected */ public synchronized <T> boolean a(String str, Cache<T> cache, long j) { try { long currentTimeMillis = System.currentTimeMillis(); if (cache != null && cache.getKey() != null && cache.getKey().equals(str) && cache.getExpiredTime() - j > currentTimeMillis) { return true; } if (cache != null) { this.d.a("ExpiredTime:", String.valueOf(cache.getExpiredTime()), "|threshold:", String.valueOf(j), "|currTime:", String.valueOf(currentTimeMillis)); } return false; } catch (Throwable th) { ExceptionProcessor.processException(th); return false; } } public synchronized String b() { try { Future<?> future = this.f; if (future != null) { try { future.get(); this.f = null; } catch (InterruptedException e2) { e2.printStackTrace(); } catch (ExecutionException e3) { e3.printStackTrace(); } } } catch (Throwable th) { ExceptionProcessor.processException(th); return null; } return this.c; } public String b(String str) { if (str == null) { return "unknown"; } char c2 = 65535; try { int hashCode = str.hashCode(); if (hashCode != -1350608857) { if (hashCode != 95009260) { if (hashCode == 880617272) { if (str.equals("cm_zyhl")) { c2 = 0; } } } else if (str.equals("cu_xw")) { c2 = 1; } } else if (str.equals("ct_sjl")) { c2 = 2; } return c2 != 0 ? c2 != 1 ? c2 != 2 ? "unknown" : "CTCC" : "CUCC" : "CMCC"; } catch (Throwable th) { ExceptionProcessor.processException(th); return null; } } public String c() { try { return b.b(this.a); } catch (Throwable th) { ExceptionProcessor.processException(th); return null; } } public String c(String str) { try { return "sdk." + b(str).toLowerCase() + ".get.prelogincode"; } catch (Throwable th) { ExceptionProcessor.processException(th); return null; } } public TokenRet checkEnvSafe(ResultCodeProcessor resultCodeProcessor, String str) { try { if (this.e) { String c2 = Checker.c(); if (!TextUtils.isEmpty(c2) && !"0".equals(c2)) { return resultCodeProcessor.convertErrorInfo("-10003", "手机终端不安全:the app is attached, please use safe phone!", str); } } String isDeviceRooted = CheckRoot.isDeviceRooted(); if (!TextUtils.isEmpty(isDeviceRooted)) { return resultCodeProcessor.convertErrorInfo("-10003", "手机终端不安全:the phone is root, ".concat(String.valueOf(isDeviceRooted)), str); } if (Thread.currentThread() == Looper.getMainLooper().getThread() && EmulatorDetector.isEmulator(this.a)) { return resultCodeProcessor.convertErrorInfo("-10003", "手机终端不安全:Emulator is detected, please use real phone!", str); } if (CheckProxy.isDevicedProxy(this.a)) { return resultCodeProcessor.convertErrorInfo("-10003", "手机终端不安全:the phone is proxy, please do not proxy!", str); } if (!Debug.isDebuggerConnected() || g.a()) { return null; } return resultCodeProcessor.convertErrorInfo("-10003", "手机终端不安全:the app is debuggerConnected, please do not debug!", str); } catch (Exception e2) { try { return resultCodeProcessor.convertErrorInfo("-10003", "无法判运营商: " + e2.getMessage(), str); } catch (Throwable th) { ExceptionProcessor.processException(th); return null; } } } public String d() { try { return b.c(this.a); } catch (Throwable th) { ExceptionProcessor.processException(th); return null; } } public String d(String str) { try { return "sdk." + b(str).toLowerCase() + ".pregetoken"; } catch (Throwable th) { ExceptionProcessor.processException(th); return null; } } /* access modifiers changed from: protected */ public native synchronized String decryptContent(String str); public Context e() { try { return this.a; } catch (Throwable th) { ExceptionProcessor.processException(th); return null; } } public String e(String str) { try { return "sdk." + b(str).toLowerCase() + ".get.logincode"; } catch (Throwable th) { ExceptionProcessor.processException(th); return null; } } /* access modifiers changed from: protected */ public native synchronized String encryptContent(String str); public String f(String str) { try { return "sdk." + b(str).toLowerCase() + ".get.logintoken"; } catch (Throwable th) { ExceptionProcessor.processException(th); return null; } } public String g(String str) { try { return "sdk." + b(str).toLowerCase() + ".getoken"; } catch (Throwable th) { ExceptionProcessor.processException(th); return null; } } public native CacheKey getSimCacheKey(boolean z, String str); public native CacheKey getVendorCacheKey(String str); public String h(String str) { try { return b(str).toLowerCase() + ".authpage.login"; } catch (Throwable th) { ExceptionProcessor.processException(th); return null; } } public String i(String str) { try { return b(str).toLowerCase() + ".authpage.return"; } catch (Throwable th) { ExceptionProcessor.processException(th); return null; } } public String j(String str) { try { return b(str).toLowerCase() + ".authpage.switch"; } catch (Throwable th) { ExceptionProcessor.processException(th); return null; } } public String k(String str) { try { return b(str).toLowerCase() + ".authpage.protocol"; } catch (Throwable th) { ExceptionProcessor.processException(th); return null; } } public String l(String str) { try { return b(str).toLowerCase() + ".authpage.start"; } catch (Throwable th) { ExceptionProcessor.processException(th); return null; } } }