package com.mobile.auth.gatewayauth; import android.app.Activity; import android.app.Application; import android.content.Context; import android.content.Intent; import android.os.Bundle; import android.text.TextUtils; import com.mobile.auth.gatewayauth.AuthUIConfig; import com.mobile.auth.gatewayauth.activity.AuthWebVeiwActivity; import com.mobile.auth.gatewayauth.manager.SystemManager; import com.mobile.auth.gatewayauth.manager.compat.ResultCodeProcessor; import com.mobile.auth.gatewayauth.manager.d; import com.mobile.auth.gatewayauth.model.TokenRet; import com.mobile.auth.gatewayauth.model.UStruct; import com.mobile.auth.gatewayauth.utils.ReflectionUtils; import com.mobile.auth.gatewayauth.utils.g; import com.mobile.auth.gatewayauth.utils.j; import com.mobile.auth.m.a; import com.nirvana.tools.core.AppUtils; import com.nirvana.tools.core.ExecutorManager; import com.nirvana.tools.core.SupportJarUtils; import java.lang.ref.WeakReference; import java.util.ArrayList; import java.util.LinkedHashMap; import java.util.concurrent.ConcurrentHashMap; import org.json.JSONException; import org.json.JSONObject; public class b { public static final AuthUIConfig a = new AuthUIConfig.Builder().create(); private static final ConcurrentHashMap<Integer, b> b = new ConcurrentHashMap<>(5); private final Context c; private AuthUIControlClickListener d; private volatile WeakReference<Activity> e; private AuthUIConfig f; private LinkedHashMap<String, AuthRegisterViewConfig> g; private ArrayList<AuthRegisterXmlConfig> h; private ArrayList<Object> i; private final int j; private final a k; private WeakReference<Activity> l; private TokenResultListener m; private ActivityResultListener n; private final PhoneNumberAuthHelper o; private final SystemManager p; private ResultCodeProcessor q; private final d r; private long s; private long t; private volatile boolean u = false; private final Application.ActivityLifecycleCallbacks v = new Application.ActivityLifecycleCallbacks() { /* class com.mobile.auth.gatewayauth.b.AnonymousClass1 */ public void onActivityCreated(Activity activity, Bundle bundle) { try { b.this.a(activity); } catch (Throwable th) { ExceptionProcessor.processException(th); } } public void onActivityDestroyed(Activity activity) { Activity activity2; try { if ((activity instanceof LoginAuthActivity) && ((LoginAuthActivity) activity).getUIManagerID() == b.a(b.this) && b.b(b.this) != null && (activity2 = (Activity) b.b(b.this).get()) != null && activity2 == activity) { Application application = ReflectionUtils.getApplication(); if (application != null) { application.unregisterActivityLifecycleCallbacks(b.c(b.this)); } b.a(b.this, (WeakReference) null); } } catch (Throwable th) { ExceptionProcessor.processException(th); } } public void onActivityPaused(Activity activity) { try { if ((activity instanceof LoginAuthActivity) && ((LoginAuthActivity) activity).getUIManagerID() == b.a(b.this)) { b.a(b.this, false); } } catch (Throwable th) { ExceptionProcessor.processException(th); } } public void onActivityResumed(Activity activity) { try { if ((activity instanceof LoginAuthActivity) && ((LoginAuthActivity) activity).getUIManagerID() == b.a(b.this)) { b.a(b.this, true); } } catch (Throwable th) { ExceptionProcessor.processException(th); } } public void onActivitySaveInstanceState(Activity activity, Bundle bundle) { } public void onActivityStarted(Activity activity) { } public void onActivityStopped(Activity activity) { } }; public b(Context context, d dVar, SystemManager systemManager, PhoneNumberAuthHelper phoneNumberAuthHelper) { this.c = context.getApplicationContext(); this.r = dVar; this.k = dVar.a(); this.p = systemManager; this.o = phoneNumberAuthHelper; this.j = hashCode(); } static /* synthetic */ int a(b bVar) { try { return bVar.j; } catch (Throwable th) { ExceptionProcessor.processException(th); return -1; } } static /* synthetic */ AuthUIConfig a(b bVar, AuthUIConfig authUIConfig) { try { bVar.f = authUIConfig; return authUIConfig; } catch (Throwable th) { ExceptionProcessor.processException(th); return null; } } public static b a(int i2) { try { return b.get(Integer.valueOf(i2)); } catch (Throwable th) { ExceptionProcessor.processException(th); return null; } } static /* synthetic */ WeakReference a(b bVar, WeakReference weakReference) { try { bVar.l = weakReference; return weakReference; } catch (Throwable th) { ExceptionProcessor.processException(th); return null; } } public static void a(AuthUIConfig authUIConfig, int i2, Activity activity) { try { if (authUIConfig.isStatusBarHidden()) { j.a(activity); } else { j.c(activity, authUIConfig.getStatusBarUIFlag()); } j.a(activity, i2); j.a(activity, authUIConfig.isLightColor()); j.b(activity, authUIConfig.getBottomNavBarColor()); } catch (Throwable th) { ExceptionProcessor.processException(th); } } private void a(final String str, final String str2, final String str3) { try { ExecutorManager.getInstance().scheduleFuture(new Runnable() { /* class com.mobile.auth.gatewayauth.b.AnonymousClass6 */ public void run() { try { b.d(b.this).a(b.h(b.this).b(str, str2, UStruct.newUStruct().startTime(b.j(b.this)).endTime(System.currentTimeMillis()).requestId(b.h(b.this).e()).sessionId(b.h(b.this).c()).authSdkCode("700004").carrierUrl(str3).build(), ""), 2); } catch (Throwable th) { ExceptionProcessor.processException(th); } } }); } catch (Throwable th) { ExceptionProcessor.processException(th); } } private void a(final String str, final String str2, final boolean z) { try { ExecutorManager.getInstance().scheduleFuture(new Runnable() { /* class com.mobile.auth.gatewayauth.b.AnonymousClass5 */ public void run() { try { b.d(b.this).a(b.h(b.this).b(str, str2, UStruct.newUStruct().startTime(b.j(b.this)).endTime(System.currentTimeMillis()).requestId(b.h(b.this).e()).sessionId(b.h(b.this).c()).authSdkCode("700002").isAuthPageLegal(String.valueOf(z)).build(), ""), 2); } catch (Throwable th) { ExceptionProcessor.processException(th); } } }); } catch (Throwable th) { ExceptionProcessor.processException(th); } } private void a(final boolean z, final String str, final String str2, final boolean z2) { try { ExecutorManager.getInstance().postMain(new ExecutorManager.SafeRunnable() { /* class com.mobile.auth.gatewayauth.b.AnonymousClass3 */ /* access modifiers changed from: protected */ @Override // com.nirvana.tools.core.ExecutorManager.SafeRunnable public void onException(Throwable th) { try { b.d(b.this).e("QuitActivity error!", ExecutorManager.getErrorInfoFromException(th)); } catch (Throwable th2) { ExceptionProcessor.processException(th2); } } /* access modifiers changed from: protected */ @Override // com.nirvana.tools.core.ExecutorManager.SafeRunnable public void onFinal() { try { super.onFinal(); if (z2 && b.f(b.this) != null && z) { TokenRet convertErrorInfo = b.this.a().convertErrorInfo(str, str2, b.g(b.this).c()); convertErrorInfo.setVendorName(b.g(b.this).d()); convertErrorInfo.setRequestId(b.h(b.this).e()); b.f(b.this).onTokenFailed(convertErrorInfo.toJsonString()); } } catch (Throwable th) { ExceptionProcessor.processException(th); } } /* access modifiers changed from: protected */ @Override // com.nirvana.tools.core.ExecutorManager.SafeRunnable public void safeRun() { Activity activity; try { if (!(b.b(b.this) == null || (activity = (Activity) b.b(b.this).get()) == null)) { activity.finish(); b bVar = b.this; b.a(bVar, bVar.g()); if (!(b.e(b.this).getAuthPageActOut() == null || b.e(b.this).getActivityIn() == null)) { activity.overridePendingTransition(AppUtils.getAnimResID(activity, b.e(b.this).getAuthPageActOut()), AppUtils.getAnimResID(activity, b.e(b.this).getActivityIn())); } } b.this.l(); } catch (Throwable th) { ExceptionProcessor.processException(th); } } }); } catch (Throwable th) { ExceptionProcessor.processException(th); } } static /* synthetic */ boolean a(b bVar, boolean z) { try { bVar.u = z; return z; } catch (Throwable th) { ExceptionProcessor.processException(th); return false; } } static /* synthetic */ WeakReference b(b bVar) { try { return bVar.l; } catch (Throwable th) { ExceptionProcessor.processException(th); return null; } } private void b(final String str, final String str2, final String str3) { try { ExecutorManager.getInstance().scheduleFuture(new Runnable() { /* class com.mobile.auth.gatewayauth.b.AnonymousClass7 */ public void run() { try { b.d(b.this).a(b.h(b.this).b(str, str2, UStruct.newUStruct().startTime(b.j(b.this)).endTime(System.currentTimeMillis()).requestId(b.h(b.this).e()).sessionId(b.h(b.this).c()).authSdkCode(b.i(b.this).convertCode(str3)).build(), ""), 2); } catch (Throwable th) { ExceptionProcessor.processException(th); } } }); } catch (Throwable th) { ExceptionProcessor.processException(th); } } static /* synthetic */ Application.ActivityLifecycleCallbacks c(b bVar) { try { return bVar.v; } catch (Throwable th) { ExceptionProcessor.processException(th); return null; } } static /* synthetic */ a d(b bVar) { try { return bVar.k; } catch (Throwable th) { ExceptionProcessor.processException(th); return null; } } static /* synthetic */ AuthUIConfig e(b bVar) { try { return bVar.f; } catch (Throwable th) { ExceptionProcessor.processException(th); return null; } } static /* synthetic */ TokenResultListener f(b bVar) { try { return bVar.m; } catch (Throwable th) { ExceptionProcessor.processException(th); return null; } } static /* synthetic */ SystemManager g(b bVar) { try { return bVar.p; } catch (Throwable th) { ExceptionProcessor.processException(th); return null; } } static /* synthetic */ d h(b bVar) { try { return bVar.r; } catch (Throwable th) { ExceptionProcessor.processException(th); return null; } } static /* synthetic */ ResultCodeProcessor i(b bVar) { try { return bVar.q; } catch (Throwable th) { ExceptionProcessor.processException(th); return null; } } static /* synthetic */ long j(b bVar) { try { return bVar.s; } catch (Throwable th) { ExceptionProcessor.processException(th); return -1; } } public ResultCodeProcessor a() { try { if (this.q == null) { this.q = new com.mobile.auth.gatewayauth.manager.compat.b(); } return this.q; } catch (Throwable th) { ExceptionProcessor.processException(th); return null; } } public void a(long j2) { try { this.s = j2; } catch (Throwable th) { ExceptionProcessor.processException(th); } } /* JADX WARNING: Removed duplicated region for block: B:24:0x0099 A[Catch:{ Exception -> 0x009d }] */ /* JADX WARNING: Removed duplicated region for block: B:32:? A[RETURN, SYNTHETIC] */ public void a(long j2, String str, String str2, ResultCodeProcessor resultCodeProcessor, c cVar) { Context context; try { this.t = j2; b(); Intent intent = new Intent(this.c, LoginAuthActivity.class); intent.putExtra("number", str); intent.putExtra("vendor", str2); intent.putExtra("ui_manager_id", this.j); intent.putExtra("startTime", System.currentTimeMillis()); try { a(resultCodeProcessor); b.put(Integer.valueOf(this.j), this); Activity activity = this.e != null ? this.e.get() : null; if (g().getAuthPageActIn() == null || g().getActivityOut() == null) { if (activity != null) { activity.startActivityForResult(intent, 1); if (cVar != null) { cVar.a(str2, str); return; } return; } intent.addFlags(268435456); context = this.c; } else if (activity != null) { String authPageActIn = g().getAuthPageActIn(); String activityOut = g().getActivityOut(); if (TextUtils.isEmpty(authPageActIn) || TextUtils.isEmpty(activityOut)) { SupportJarUtils.startActivityForResult(activity, intent, 1, null, null); } else { SupportJarUtils.startActivityForResult(activity, intent, 1, authPageActIn, activityOut); } if (cVar != null) { } } else { intent.addFlags(268435456); context = this.c; } context.startActivity(intent); if (cVar != null) { } } catch (Exception e2) { String errorInfoFromException = ExecutorManager.getErrorInfoFromException(e2); g.c(errorInfoFromException); cVar.a(errorInfoFromException); l(); } } catch (Throwable th) { ExceptionProcessor.processException(th); } } public void a(Activity activity) { Intent intent; try { if ((activity instanceof LoginAuthActivity) && (intent = activity.getIntent()) != null && intent.getIntExtra("ui_manager_id", -1) == this.j) { this.l = new WeakReference<>(activity); } } catch (Throwable th) { ExceptionProcessor.processException(th); } } public void a(ActivityResultListener activityResultListener) { try { this.n = activityResultListener; } catch (Throwable th) { ExceptionProcessor.processException(th); } } public void a(AuthRegisterXmlConfig authRegisterXmlConfig) { try { if (this.h == null) { this.h = new ArrayList<>(); } this.h.add(authRegisterXmlConfig); a((Object) authRegisterXmlConfig); } catch (Exception e2) { g.a(e2); } catch (Throwable th) { ExceptionProcessor.processException(th); } } public void a(AuthUIConfig authUIConfig) { try { this.f = authUIConfig; } catch (Throwable th) { ExceptionProcessor.processException(th); } } public void a(AuthUIControlClickListener authUIControlClickListener) { try { this.d = authUIControlClickListener; } catch (Throwable th) { ExceptionProcessor.processException(th); } } public void a(TokenResultListener tokenResultListener) { try { this.m = tokenResultListener; } catch (Throwable th) { ExceptionProcessor.processException(th); } } public void a(ResultCodeProcessor resultCodeProcessor) { try { this.q = resultCodeProcessor; } catch (Throwable th) { ExceptionProcessor.processException(th); } } public void a(Object obj) { try { if (this.i == null) { this.i = new ArrayList<>(); } this.i.add(obj); } catch (Throwable th) { ExceptionProcessor.processException(th); } } public void a(String str) { try { AuthUIControlClickListener authUIControlClickListener = this.d; if (authUIControlClickListener != null) { authUIControlClickListener.onClick("700000", this.c, null); } b(str, this.p.i(str), "-72931"); } catch (Throwable th) { ExceptionProcessor.processException(th); } } public void a(final String str, final long j2, final boolean z, final boolean z2) { try { ExecutorManager.getInstance().scheduleFuture(new Runnable() { /* class com.mobile.auth.gatewayauth.b.AnonymousClass4 */ public void run() { ResultCodeProcessor i; String str; try { a d2 = b.d(b.this); d h = b.h(b.this); String str2 = str; String l = b.g(b.this).l(str); boolean z = false; UStruct.Builder isVertical = UStruct.newUStruct().isSuccess(z2).isFullScreen(String.valueOf(!b.this.g().isDialog())).isVertical(String.valueOf(z)); if (b.this.g().isCheckboxHidden() || b.this.g().isPrivacyState()) { z = true; } UStruct.Builder endTime = isVertical.isChecked(String.valueOf(z)).isCheckboxHidden(String.valueOf(b.this.g().isCheckboxHidden())).requestId(b.h(b.this).e()).sessionId(b.h(b.this).c()).startTime(j2).endTime(b.j(b.this)); if (z2) { i = b.i(b.this); str = "6000"; } else { i = b.i(b.this); str = "-10001"; } d2.a(h.b(str2, l, endTime.authSdkCode(i.convertCode(str)).build(), ""), 1); } catch (Throwable th) { ExceptionProcessor.processException(th); } } }); } catch (Throwable th) { ExceptionProcessor.processException(th); } } public void a(String str, AuthRegisterViewConfig authRegisterViewConfig) { try { if (this.g == null) { this.g = new LinkedHashMap<>(); } this.g.put(str, authRegisterViewConfig); if (authRegisterViewConfig.getRootViewId() == 0) { a(authRegisterViewConfig); } } catch (Exception e2) { g.a(e2); } catch (Throwable th) { ExceptionProcessor.processException(th); } } public void a(String str, String str2) { Activity activity; try { WeakReference<Activity> weakReference = this.l; if (weakReference == null || (activity = weakReference.get()) == null) { this.k.e("LoginAuthActivity实例被释放"); return; } AuthUIConfig g2 = g(); this.f = g2; if (TextUtils.isEmpty(g2.getProtocolAction())) { Intent intent = new Intent(activity, AuthWebVeiwActivity.class); intent.putExtra("url", str2); intent.putExtra("name", str); intent.putExtra("orientation", g().getScreenOrientation()); intent.putExtra("ui_manager_id", this.j); activity.startActivity(intent); return; } Intent intent2 = new Intent(); intent2.setAction(this.f.getProtocolAction()); if (!TextUtils.isEmpty(this.f.getPackageName())) { intent2.setPackage(this.f.getPackageName()); } intent2.putExtra("url", str2); intent2.putExtra("name", str); intent2.putExtra("orientation", g().getScreenOrientation()); activity.startActivity(intent2); } catch (Throwable th) { ExceptionProcessor.processException(th); } } public void a(String str, String str2, String str3, boolean z) { try { if (this.d != null) { JSONObject jSONObject = new JSONObject(); try { jSONObject.put("name", str2); jSONObject.put("url", str3); } catch (JSONException e2) { e2.printStackTrace(); } this.d.onClick("700004", this.c, jSONObject.toString()); } if (z) { a(str, this.p.k(str), str3); } } catch (Throwable th) { ExceptionProcessor.processException(th); } } public void a(String str, boolean z, boolean z2) { try { if (this.d != null) { JSONObject jSONObject = new JSONObject(); try { jSONObject.put("isChecked", z); } catch (JSONException e2) { e2.printStackTrace(); } this.d.onClick("700002", this.c, jSONObject.toString()); } a(str, this.p.h(str), z2); } catch (Throwable th) { ExceptionProcessor.processException(th); } } public void a(boolean z) { try { if (this.d != null) { JSONObject jSONObject = new JSONObject(); try { jSONObject.put("isChecked", z); } catch (JSONException e2) { e2.printStackTrace(); } this.d.onClick("700003", this.c, jSONObject.toString()); } } catch (Throwable th) { ExceptionProcessor.processException(th); } } public void a(boolean z, String str, String str2) { try { a(z, str, str2, true); } catch (Throwable th) { ExceptionProcessor.processException(th); } } public void b() { try { Application application = ReflectionUtils.getApplication(); if (application != null) { application.registerActivityLifecycleCallbacks(this.v); } } catch (Throwable th) { ExceptionProcessor.processException(th); } } public void b(Activity activity) { try { this.e = new WeakReference<>(activity); } catch (Throwable th) { ExceptionProcessor.processException(th); } } public void b(ResultCodeProcessor resultCodeProcessor) { try { this.o.a(this.t, new TokenResultListener() { /* class com.mobile.auth.gatewayauth.b.AnonymousClass8 */ @Override // com.mobile.auth.gatewayauth.TokenResultListener public void onTokenFailed(String str) { try { if (b.f(b.this) != null) { b.f(b.this).onTokenFailed(str); } } catch (Throwable th) { ExceptionProcessor.processException(th); } } @Override // com.mobile.auth.gatewayauth.TokenResultListener public void onTokenSuccess(String str) { try { if (b.f(b.this) != null) { b.f(b.this).onTokenSuccess(str); } } catch (Throwable th) { ExceptionProcessor.processException(th); } } }, resultCodeProcessor); } catch (Throwable th) { ExceptionProcessor.processException(th); } } public void b(String str) { try { AuthUIControlClickListener authUIControlClickListener = this.d; if (authUIControlClickListener != null) { authUIControlClickListener.onClick("700001", this.c, null); } b(str, this.p.j(str), "-72932"); } catch (Throwable th) { ExceptionProcessor.processException(th); } } public void c() { try { ExecutorManager.getInstance().postMain(new ExecutorManager.SafeRunnable() { /* class com.mobile.auth.gatewayauth.b.AnonymousClass2 */ /* access modifiers changed from: protected */ @Override // com.nirvana.tools.core.ExecutorManager.SafeRunnable public void onException(Throwable th) { try { b.d(b.this).e("Hide Loading error!", ExecutorManager.getErrorInfoFromException(th)); } catch (Throwable th2) { ExceptionProcessor.processException(th2); } } /* access modifiers changed from: protected */ @Override // com.nirvana.tools.core.ExecutorManager.SafeRunnable public void safeRun() { Activity activity; try { if (b.b(b.this) != null && (activity = (Activity) b.b(b.this).get()) != null) { ((LoginAuthActivity) activity).hideLoadingDialog(); } } catch (Throwable th) { ExceptionProcessor.processException(th); } } }); } catch (Throwable th) { ExceptionProcessor.processException(th); } } public void d() { try { a(false, (String) null, (String) null, false); } catch (Throwable th) { ExceptionProcessor.processException(th); } } public ActivityResultListener e() { try { return this.n; } catch (Throwable th) { ExceptionProcessor.processException(th); return null; } } public void f() { try { if (this.m != null) { TokenRet tokenRet = new TokenRet(); tokenRet.setVendorName(this.p.d()); tokenRet.setCode("600023"); tokenRet.setMsg("加载自定义控件异常"); this.m.onTokenFailed(tokenRet.toJsonString()); } } catch (Throwable th) { ExceptionProcessor.processException(th); } } public AuthUIConfig g() { try { AuthUIConfig authUIConfig = this.f; return authUIConfig == null ? a : authUIConfig; } catch (Throwable th) { ExceptionProcessor.processException(th); return null; } } public LinkedHashMap<String, AuthRegisterViewConfig> h() { try { if (this.g == null) { this.g = new LinkedHashMap<>(); } return this.g; } catch (Throwable th) { ExceptionProcessor.processException(th); return null; } } public ArrayList<AuthRegisterXmlConfig> i() { try { if (this.h == null) { this.h = new ArrayList<>(); } return this.h; } catch (Throwable th) { ExceptionProcessor.processException(th); return null; } } public void j() { try { LinkedHashMap<String, AuthRegisterViewConfig> linkedHashMap = this.g; if (linkedHashMap != null) { ArrayList<Object> arrayList = this.i; if (arrayList != null) { arrayList.removeAll(linkedHashMap.values()); } this.g.clear(); this.g = null; } } catch (Exception e2) { g.a(e2); } catch (Throwable th) { ExceptionProcessor.processException(th); } } public void k() { try { ArrayList<AuthRegisterXmlConfig> arrayList = this.h; if (arrayList != null) { ArrayList<Object> arrayList2 = this.i; if (arrayList2 != null) { arrayList2.removeAll(arrayList); } this.h.clear(); this.h = null; } } catch (Exception e2) { g.a(e2); } catch (Throwable th) { ExceptionProcessor.processException(th); } } public void l() { try { b.remove(Integer.valueOf(this.j)); } catch (Throwable th) { ExceptionProcessor.processException(th); } } public a m() { try { return this.k; } catch (Throwable th) { ExceptionProcessor.processException(th); return null; } } public SystemManager n() { try { return this.p; } catch (Throwable th) { ExceptionProcessor.processException(th); return null; } } public boolean o() { try { return this.u; } catch (Throwable th) { ExceptionProcessor.processException(th); return false; } } }