package com.mbridge.msdk.foundation.controller; import android.content.Context; import android.content.SharedPreferences; import android.os.Build; import android.os.Handler; import android.os.Looper; import android.os.Message; import android.text.TextUtils; import com.iab.omid.library.mmadbridge.Omid; import com.kwai.video.player.PlayerProps; import com.mbridge.msdk.MBridgeConstans; import com.mbridge.msdk.MBridgeSDK; import com.mbridge.msdk.foundation.controller.a; import com.mbridge.msdk.foundation.controller.authoritycontroller.a; import com.mbridge.msdk.foundation.db.i; import com.mbridge.msdk.foundation.db.m; import com.mbridge.msdk.foundation.db.o; import com.mbridge.msdk.foundation.db.q; import com.mbridge.msdk.foundation.entity.j; import com.mbridge.msdk.foundation.entity.n; import com.mbridge.msdk.foundation.same.b.c; import com.mbridge.msdk.foundation.same.b.e; import com.mbridge.msdk.foundation.same.report.d; import com.mbridge.msdk.foundation.tools.FastKV; import com.mbridge.msdk.foundation.tools.ac; import com.mbridge.msdk.foundation.tools.ae; import com.mbridge.msdk.foundation.tools.r; import com.mbridge.msdk.foundation.tools.s; import com.mbridge.msdk.foundation.tools.u; import com.mbridge.msdk.foundation.tools.w; import com.mbridge.msdk.foundation.tools.y; import com.mbridge.msdk.out.AdMobClickListener; import com.mbridge.msdk.out.Frame; import com.mbridge.msdk.out.MBridgeSDKFactory; import java.io.File; import java.util.List; import java.util.Map; import java.util.concurrent.atomic.AtomicBoolean; /* compiled from: SDKController */ public class b { private static b j; public final int a = 1; public final int b = 2; public final int c = 3; public final int d = 4; public final int e = 5; public final int f = 6; public final int g = 7; public final int h = 8; Handler i = new Handler() { /* class com.mbridge.msdk.foundation.controller.b.AnonymousClass4 */ public final void handleMessage(Message message) { List list; List<n> list2; try { switch (message.what) { case 2: if ((message.obj instanceof List) && (list = (List) message.obj) != null && list.size() > 0) { d dVar = new d(b.this.k, 0); for (int i = 0; i < list.size(); i++) { n nVar = (n) list.get(i); boolean z = false; if (i == list.size() - 1) { z = true; } dVar.a(nVar, z); } return; } return; case 3: File file = (File) message.obj; if (file != null) { String a2 = u.a(file); if (!TextUtils.isEmpty(a2)) { String[] split = a2.split("===="); if (split.length > 0) { new d(b.this.k).a(split[0], file); return; } return; } return; } return; case 4: String str = (String) message.obj; if (TextUtils.isEmpty(str)) { return; } if (com.mbridge.msdk.foundation.same.report.b.a().c()) { com.mbridge.msdk.foundation.same.report.b.a().a(str); return; } else { new d(b.this.k, 0).a("click_duration", str, (String) null, (Frame) null); return; } case 5: String str2 = (String) message.obj; if (TextUtils.isEmpty(str2)) { return; } if (com.mbridge.msdk.foundation.same.report.b.a().c()) { com.mbridge.msdk.foundation.same.report.b.a().a(str2); return; } else { new d(b.this.k, 0).a("load_duration", str2, (String) null, (Frame) null); return; } case 6: if (message.obj != null && (message.obj instanceof String)) { String str3 = (String) message.obj; if (TextUtils.isEmpty(str3)) { return; } if (com.mbridge.msdk.foundation.same.report.b.a().c()) { com.mbridge.msdk.foundation.same.report.b.a().a(str3); return; } else { new d(b.this.k, 0).a("device_data", str3, (String) null, (Frame) null); return; } } else { return; } case 7: if (message.obj != null && (message.obj instanceof List) && (list2 = (List) message.obj) != null && list2.size() > 0 && a.a().a("authority_applist")) { ac.a(b.this.k, "mbridge_setting_campaign_time", new Long(System.currentTimeMillis())); for (n nVar2 : list2) { new d(b.this.k, 0).a(nVar2); } return; } return; case 8: if (message.obj != null && (message.obj instanceof String)) { String str4 = (String) message.obj; if (!ae.b(str4)) { return; } if (com.mbridge.msdk.foundation.same.report.b.a().c()) { com.mbridge.msdk.foundation.same.report.b.a().a(str4); return; } else { new d(b.this.k, 0).a(str4); return; } } else { return; } case 9: if (((com.mbridge.msdk.c.a) message.obj).I() == 1) { com.mbridge.msdk.foundation.same.report.b.a.a(b.this.k).a(); return; } return; default: return; } } catch (Exception unused) { w.d("SDKController", "REPORT HANDLE ERROR!"); } } }; private Context k; private String l; private String m; private String n; private String o; private String p; private boolean q = false; private com.mbridge.msdk.b.a r; private String s; private AtomicBoolean t = null; private FastKV u; private Map<String, Object> v; private int w; private AdMobClickListener x; private b() { } public static b a() { if (j == null) { synchronized (b.class) { if (j == null) { j = new b(); } } } return j; } public final void a(Map map, final Context context) { String str; List<com.mbridge.msdk.foundation.entity.b> n2; Class<?> cls; Object newInstance; Object newInstance2; String str2 = ""; if (context != null) { if (map.containsKey(MBridgeConstans.ID_MBRIDGE_APPID)) { this.n = (String) map.get(MBridgeConstans.ID_MBRIDGE_APPID); } this.k = context.getApplicationContext(); a.f().b(this.k); try { String str3 = (String) map.get(MBridgeConstans.ID_MBRIDGE_APPID); if (!TextUtils.isEmpty(str3)) { com.mbridge.msdk.foundation.a.a.a.a().a(MBridgeConstans.SDK_APP_ID, str3); } } catch (Exception e2) { e2.printStackTrace(); } catch (Throwable th) { th.printStackTrace(); } if (Build.VERSION.SDK_INT < 26) { com.mbridge.msdk.d.b.a(context).a(PlayerProps.FFP_PROP_FLOAT_MAX_AVDIFF_REALTIME, this.n); } if (this.q) { com.mbridge.msdk.rover.b a2 = com.mbridge.msdk.rover.b.a(); a2.a(context); a2.b(); new d(context).a(); return; } s.C(context); if (map != null) { if (map.containsKey(MBridgeConstans.ID_MBRIDGE_APPID)) { this.n = (String) map.get(MBridgeConstans.ID_MBRIDGE_APPID); } if (map.containsKey(MBridgeConstans.ID_MBRIDGE_APPKEY)) { this.o = (String) map.get(MBridgeConstans.ID_MBRIDGE_APPKEY); } if (map.containsKey(MBridgeConstans.ID_MBRIDGE_WX_APPID)) { this.p = (String) map.get(MBridgeConstans.ID_MBRIDGE_WX_APPID); } if (map.containsKey(MBridgeConstans.PACKAGE_NAME_MANIFEST)) { this.s = (String) map.get(MBridgeConstans.PACKAGE_NAME_MANIFEST); } if (map.containsKey(MBridgeConstans.ID_MBRIDGE_STARTUPCRASH)) { this.m = (String) map.get(MBridgeConstans.ID_MBRIDGE_STARTUPCRASH); } try { com.mbridge.msdk.c.a b2 = com.mbridge.msdk.c.b.a().b(a.f().k()); if (!(b2 == null || (n2 = b2.n()) == null || n2.size() <= 0)) { for (com.mbridge.msdk.foundation.entity.b bVar : n2) { if (bVar.a() == 287) { Class<?> cls2 = Class.forName("com.mbridge.msdk.interstitialvideo.out.MBInterstitialVideoHandler"); if (!(this.k == null || cls2 == null || (newInstance2 = cls2.getConstructor(String.class, String.class).newInstance(str2, bVar.b())) == null)) { cls2.getMethod("loadFormSelfFilling", new Class[0]).invoke(newInstance2, new Object[0]); } } else if (!(bVar.a() != 94 || (cls = Class.forName("com.mbridge.msdk.out.MBRewardVideoHandler")) == null || (newInstance = cls.getConstructor(String.class, String.class).newInstance(str2, bVar.b())) == null)) { cls.getMethod("loadFormSelfFilling", new Class[0]).invoke(newInstance, new Object[0]); } } } } catch (Throwable th2) { if (MBridgeConstans.DEBUG) { th2.printStackTrace(); } } a.f().c(this.n); a.f().d(this.o); a.f().e(this.p); a.f().b(this.l); a.f().a(this.s); a.f().a(new a.b() { /* class com.mbridge.msdk.foundation.controller.b.AnonymousClass6 */ @Override // com.mbridge.msdk.foundation.controller.a.b public final void a() { b.d(b.this); } }, this.i); Context applicationContext = this.k.getApplicationContext(); try { Omid.activate(applicationContext); if (!Omid.isActive()) { new d(applicationContext, 0).a("", "", "", "", "activate om failed"); } } catch (IllegalArgumentException e3) { w.b("SDKController", e3.getMessage(), e3); } w.b("SDKController", "facebook = " + this.l + "appId = " + this.n + "appKey = " + this.o); Context applicationContext2 = this.k.getApplicationContext(); try { if (d() && this.u == null) { try { this.u = new FastKV.Builder(e.b(c.MBRIDGE_700_CONFIG), r.b("H+tU+FeXHM==")).build(); } catch (Exception unused) { this.u = null; } } FastKV fastKV = this.u; if (fastKV != null) { String string = fastKV.getString(r.b("H+tU+bfPhM=="), str2); String string2 = this.u.getString(r.b("H+tU+Fz8"), str2); if (TextUtils.isEmpty(com.mbridge.msdk.foundation.same.a.s) && TextUtils.isEmpty(com.mbridge.msdk.foundation.same.a.t)) { com.mbridge.msdk.foundation.same.a.s = com.mbridge.msdk.foundation.a.a.a.a().b("b"); com.mbridge.msdk.foundation.same.a.t = com.mbridge.msdk.foundation.a.a.a.a().b("c"); } if (!TextUtils.isEmpty(string) || !TextUtils.isEmpty(string2)) { com.mbridge.msdk.foundation.same.a.s = string; com.mbridge.msdk.foundation.same.a.t = string2; com.mbridge.msdk.foundation.a.a.a.a().a("b", com.mbridge.msdk.foundation.same.a.s); com.mbridge.msdk.foundation.a.a.a.a().a("c", com.mbridge.msdk.foundation.same.a.t); } else if (!TextUtils.isEmpty(com.mbridge.msdk.foundation.same.a.s) || !TextUtils.isEmpty(com.mbridge.msdk.foundation.same.a.t)) { this.u.putString(r.b("H+tU+bfPhM=="), com.mbridge.msdk.foundation.same.a.s); this.u.putString(r.b("H+tU+Fz8"), com.mbridge.msdk.foundation.same.a.t); } } else { SharedPreferences sharedPreferences = applicationContext2.getSharedPreferences(r.b("H+tU+FeXHM=="), 0); if (sharedPreferences != null) { String string3 = sharedPreferences.getString(r.b("H+tU+bfPhM=="), str2); str = sharedPreferences.getString(r.b("H+tU+Fz8"), str2); str2 = string3; } else { str = str2; } if (TextUtils.isEmpty(com.mbridge.msdk.foundation.same.a.s) && TextUtils.isEmpty(com.mbridge.msdk.foundation.same.a.t)) { com.mbridge.msdk.foundation.same.a.s = com.mbridge.msdk.foundation.a.a.a.a().b("b"); com.mbridge.msdk.foundation.same.a.t = com.mbridge.msdk.foundation.a.a.a.a().b("c"); } if (!TextUtils.isEmpty(str2) || !TextUtils.isEmpty(str)) { com.mbridge.msdk.foundation.same.a.s = str2; com.mbridge.msdk.foundation.same.a.t = str; com.mbridge.msdk.foundation.a.a.a.a().a("b", com.mbridge.msdk.foundation.same.a.s); com.mbridge.msdk.foundation.a.a.a.a().a("c", com.mbridge.msdk.foundation.same.a.t); } else if ((!TextUtils.isEmpty(com.mbridge.msdk.foundation.same.a.s) || !TextUtils.isEmpty(com.mbridge.msdk.foundation.same.a.t)) && sharedPreferences != null) { SharedPreferences.Editor edit = sharedPreferences.edit(); edit.putString(r.b("H+tU+bfPhM=="), com.mbridge.msdk.foundation.same.a.s); edit.putString(r.b("H+tU+Fz8"), com.mbridge.msdk.foundation.same.a.t); edit.apply(); } } } catch (Throwable th3) { w.b("SDKController", th3.getMessage(), th3); } try { if (MBridgeConstans.INIT_UA_IN) { com.mbridge.msdk.foundation.same.f.b.a().execute(new Runnable() { /* class com.mbridge.msdk.foundation.controller.b.AnonymousClass2 */ public final void run() { Looper.prepare(); b.this.e(); b bVar = b.this; b.a(bVar, bVar.n); Looper.loop(); } }); } else if (Looper.myLooper() == Looper.getMainLooper()) { com.mbridge.msdk.foundation.same.f.b.a().execute(new Runnable() { /* class com.mbridge.msdk.foundation.controller.b.AnonymousClass3 */ public final void run() { Looper.prepare(); b.this.e(); Looper.loop(); } }); } else { e(); } } catch (Exception unused2) { w.d("SDKController", "get app setting failed"); } c(); y.a(this.k); this.q = true; com.mbridge.msdk.rover.b a3 = com.mbridge.msdk.rover.b.a(); a3.a(context); a3.b(); } long a4 = (long) com.mbridge.msdk.c.b.a().g(this.n).a(); if (a4 != 1300) { new Handler().postDelayed(new Runnable() { /* class com.mbridge.msdk.foundation.controller.b.AnonymousClass1 */ public final void run() { s.B(context); } }, a4); } } } /* access modifiers changed from: private */ /* access modifiers changed from: public */ private void e() { try { Class<?> cls = Class.forName("com.mbridge.msdk.e.b"); cls.getDeclaredMethod("start", new Class[0]).invoke(cls.getMethod("getInstance", new Class[0]).invoke(null, new Object[0]), new Object[0]); } catch (Throwable th) { w.b("SDKController", th.getMessage(), th); } } public final void b() { Handler handler = this.i; if (handler != null) { handler.removeCallbacksAndMessages(null); } } public final void c() { new Thread(new Runnable() { /* class com.mbridge.msdk.foundation.controller.b.AnonymousClass5 */ /* JADX WARNING: Removed duplicated region for block: B:14:0x005c A[Catch:{ Exception -> 0x025c }] */ /* JADX WARNING: Removed duplicated region for block: B:17:0x007e A[Catch:{ Exception -> 0x025c }] */ public final void run() { List<n> list; com.mbridge.msdk.foundation.db.d a2; m a3; File file; try { com.mbridge.msdk.foundation.same.report.c.a.a(); Context context = b.this.k; String str = null; if (context != null) { if (o.a(i.a(context)).a() > 0) { list = o.a(i.a(context)).a(5); if (list != null && list.size() > 0) { Message obtainMessage = b.this.i.obtainMessage(); obtainMessage.what = 2; obtainMessage.obj = list; b.this.i.sendMessage(obtainMessage); } i a4 = i.a(b.this.k); a2 = com.mbridge.msdk.foundation.db.d.a(a4); if (a2.a() >= 20) { String a5 = com.mbridge.msdk.foundation.entity.e.a(a2.a(20)); Message obtain = Message.obtain(); obtain.obj = a5; obtain.what = 4; b.this.i.sendMessage(obtain); } a3 = m.a(a4); if (a3.a() > 20) { List<j> a6 = a3.a(20); if (a6 != null && a6.size() > 0) { StringBuffer stringBuffer = new StringBuffer(); for (j jVar : a6) { if (com.mbridge.msdk.foundation.controller.authoritycontroller.a.a().a(MBridgeConstans.AUTHORITY_GENERAL_DATA)) { stringBuffer.append("ad_source_id=" + jVar.b()); stringBuffer.append("&time=" + jVar.c()); stringBuffer.append("&num=" + jVar.d()); stringBuffer.append("&unit_id=" + jVar.e()); stringBuffer.append("&key=2000006"); stringBuffer.append("&fb=" + jVar.f()); stringBuffer.append("&network_str=" + jVar.i()); stringBuffer.append("&network_type=" + jVar.h()); } else { stringBuffer.append("ad_source_id=" + jVar.b()); stringBuffer.append("&time=" + jVar.c()); stringBuffer.append("&num=" + jVar.d()); stringBuffer.append("&unit_id=" + jVar.e()); stringBuffer.append("&key=2000006"); stringBuffer.append("&fb=" + jVar.f()); } if (jVar.a() == 1) { stringBuffer.append("&hb=1"); } stringBuffer.append("&timeout=" + jVar.g() + "\n"); } str = stringBuffer.toString(); } Message obtain2 = Message.obtain(); obtain2.obj = str; obtain2.what = 5; b.this.i.sendMessage(obtain2); } String b = e.b(c.MBRIDGE_CRASH_INFO); file = new File(b); if (file.exists() && file.isDirectory() && file.list().length > 0) { for (String str2 : file.list()) { File file2 = new File(b + "/" + str2); Message obtain3 = Message.obtain(); obtain3.obj = file2; obtain3.what = 3; b.this.i.sendMessage(obtain3); } return; } return; } } list = null; Message obtainMessage2 = b.this.i.obtainMessage(); obtainMessage2.what = 2; obtainMessage2.obj = list; b.this.i.sendMessage(obtainMessage2); i a42 = i.a(b.this.k); a2 = com.mbridge.msdk.foundation.db.d.a(a42); if (a2.a() >= 20) { } a3 = m.a(a42); if (a3.a() > 20) { } String b2 = e.b(c.MBRIDGE_CRASH_INFO); file = new File(b2); if (file.exists()) { } } catch (Exception unused) { w.d("SDKController", "report netstate error !"); } } }).start(); } public final void a(Map<String, Object> map, int i2) { if (MBridgeSDKFactory.getMBridgeSDK().getStatus() != MBridgeSDK.PLUGIN_LOAD_STATUS.COMPLETED) { w.d("SDKController", "preloaad failed,sdk do not inited"); return; } this.v = map; this.w = i2; a.f().k(); if (map != null) { if (this.r == null) { this.r = new com.mbridge.msdk.b.a(); } try { Map<String, Object> map2 = this.v; if (map2 != null && map2.size() > 0 && this.v.containsKey(MBridgeConstans.PROPERTIES_LAYOUT_TYPE)) { int intValue = ((Integer) this.v.get(MBridgeConstans.PROPERTIES_LAYOUT_TYPE)).intValue(); if (intValue == 0) { Map<String, Object> map3 = this.v; int i3 = this.w; AdMobClickListener adMobClickListener = this.x; try { Class<?> cls = Class.forName("com.mbridge.msdk.mbnative.e.a"); Object newInstance = cls.newInstance(); cls.getMethod("preload", Map.class, Integer.TYPE, AdMobClickListener.class).invoke(newInstance, map3, Integer.valueOf(i3), adMobClickListener); } catch (Exception e2) { e2.printStackTrace(); } } else if (3 == intValue) { Map<String, Object> map4 = this.v; try { Class<?> cls2 = Class.forName("com.mbridge.msdk.appwall.service.HandlerProvider"); Object newInstance2 = cls2.newInstance(); cls2.getMethod("preload", Map.class).invoke(newInstance2, map4); } catch (Exception e3) { e3.printStackTrace(); } } else if (1 != intValue && 2 != intValue) { w.d("SDKController", "unknow layout type in preload"); } } } catch (Exception e4) { e4.printStackTrace(); } } } public final boolean d() { Context context = this.k; if (context != null && this.t == null) { boolean z = false; int i2 = context.getSharedPreferences("mb_optimization_setting", 0).getInt("use_thread_pool", 0); AtomicBoolean atomicBoolean = new AtomicBoolean(true); this.t = atomicBoolean; if (i2 == 0) { z = true; } atomicBoolean.set(z); } AtomicBoolean atomicBoolean2 = this.t; if (atomicBoolean2 != null) { return atomicBoolean2.get(); } return true; } static /* synthetic */ void a(b bVar, String str) { if (com.mbridge.msdk.c.b.a() != null) { com.mbridge.msdk.c.b a2 = com.mbridge.msdk.c.b.a(); if (a2 != null) { com.mbridge.msdk.c.a b2 = a2.b(str); if (b2 != null) { MBridgeConstans.OMID_JS_SERVICE_URL = b2.aK(); MBridgeConstans.OMID_JS_H5_URL = b2.aJ(); if (!TextUtils.isEmpty(b2.aj())) { com.mbridge.msdk.foundation.same.net.f.d.a().c = b2.aj(); com.mbridge.msdk.foundation.same.net.f.d.a().e(); } if (!TextUtils.isEmpty(b2.ak())) { com.mbridge.msdk.foundation.same.net.f.d.a().d = b2.ak(); com.mbridge.msdk.foundation.same.net.f.d.a().f(); } } else { MBridgeConstans.OMID_JS_SERVICE_URL = "https://cdn-adn-https.rayjump.com/cdn-adn/v2/portal/19/08/20/11/06/5d5b63cb457e2.js"; MBridgeConstans.OMID_JS_H5_URL = "https://mtg-native.rayjump.com/omsdk/omsdkjs_common_js.txt"; } } if (!com.mbridge.msdk.c.b.a().a(str) || !com.mbridge.msdk.c.b.a().a(str, 1, (String) null)) { new d(bVar.k).a(); } else { new com.mbridge.msdk.c.c().a(bVar.k, str, bVar.o); } } } static /* synthetic */ void d(b bVar) { try { long currentTimeMillis = System.currentTimeMillis(); com.mbridge.msdk.c.a b2 = com.mbridge.msdk.c.b.a().b(bVar.n); if (b2 == null) { b2 = com.mbridge.msdk.c.b.a().b(); } long longValue = ((Long) ac.b(bVar.k, "mbridge_setting_campaign_time", new Long(0))).longValue(); if (longValue > 0 && longValue + ((long) (b2.L() * 1000)) > currentTimeMillis) { return; } if (b2.K() <= 0) { q.a(i.a(a.f().j())).b(); return; } List<n> c2 = q.a(i.a(bVar.k)).c(); if (c2 != null && c2.size() > 0) { Message obtain = Message.obtain(); obtain.obj = c2; obtain.what = 7; bVar.i.sendMessage(obtain); } } catch (Exception e2) { e2.printStackTrace(); } } }