package com.mbridge.msdk.mbnative.controller; import android.content.Context; import android.os.Build; import android.os.Handler; import android.os.Looper; import android.os.Message; import android.text.TextUtils; import android.util.Log; import androidx.constraintlayout.core.motion.utils.TypedValues; import com.mbridge.msdk.MBridgeConstans; import com.mbridge.msdk.c.c; import com.mbridge.msdk.c.d; import com.mbridge.msdk.foundation.db.i; import com.mbridge.msdk.foundation.entity.CampaignEx; import com.mbridge.msdk.foundation.entity.CampaignUnit; import com.mbridge.msdk.foundation.entity.m; import com.mbridge.msdk.foundation.same.e.a; import com.mbridge.msdk.foundation.tools.SameMD5; import com.mbridge.msdk.foundation.tools.aa; 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.mbnative.a.f; import com.mbridge.msdk.out.AdMobClickListener; import com.mbridge.msdk.out.Campaign; import com.mbridge.msdk.out.Frame; import com.mbridge.msdk.out.PreloadListener; import com.sigmob.sdk.base.mta.PointCategory; import java.util.ArrayList; import java.util.HashMap; import java.util.LinkedList; import java.util.List; import java.util.Map; import java.util.Queue; import java.util.UUID; import org.json.JSONArray; import org.json.JSONException; import org.json.JSONObject; /* compiled from: NativePreloadController */ public class b { private static final String d = "b"; private static Map<String, Map<Long, Object>> e = new HashMap(); private static Map<String, Boolean> f = new HashMap(); private static Map<String, m> g = new HashMap(); private static Map<String, Integer> h = new HashMap(); private static Map<String, Integer> i = new HashMap(); private static b j = null; private static int w = -1; private static int x = -2; private int A; private com.mbridge.msdk.foundation.same.e.b B = new com.mbridge.msdk.foundation.same.e.b(com.mbridge.msdk.foundation.controller.a.f().j()); private Map<String, Boolean> C = new HashMap(); Queue<Integer> a = null; Queue<Long> b = null; protected List<Integer> c; private c k; private com.mbridge.msdk.click.b l; private d m; private String n; private Handler o; private int p = 0; private String q = ""; private i r; private Map<String, Object> s; private List<Integer> t; private List<Integer> u; private boolean v; private boolean y; private int z; public b() { if (Looper.myLooper() == null) { Looper.prepare(); } this.o = new Handler() { /* class com.mbridge.msdk.mbnative.controller.b.AnonymousClass1 */ public final void handleMessage(Message message) { } }; } /* JADX WARNING: Removed duplicated region for block: B:124:0x02fc */ /* JADX WARNING: Removed duplicated region for block: B:125:0x0305 */ /* JADX WARNING: Removed duplicated region for block: B:130:0x032b A[Catch:{ all -> 0x0428 }] */ /* JADX WARNING: Removed duplicated region for block: B:165:0x0433 */ /* JADX WARNING: Removed duplicated region for block: B:174:? A[RETURN, SYNTHETIC] */ /* JADX WARNING: Removed duplicated region for block: B:176:? A[RETURN, SYNTHETIC] */ public final void a(Map<String, Object> map, int i2, AdMobClickListener adMobClickListener) { String str; String str2; String str3; List<Integer> list; String str4; String str5; com.mbridge.msdk.b.a.a aVar; List<Campaign> list2; com.mbridge.msdk.mbnative.a.b<String, List<Campaign>> a2; List<Campaign> b2; Object obj; try { this.s = map; this.y = false; if (!map.containsKey(MBridgeConstans.PROPERTIES_UNIT_ID)) { w.c(d, "preload error,make sure you have unitid"); return; } String str6 = (String) map.get(MBridgeConstans.PROPERTIES_UNIT_ID); Map<String, Map<Long, Object>> map2 = e; if (map2.containsKey(((i2 + 1) % 2) + "_" + str6)) { Map<String, Map<Long, Object>> map3 = e; if (!map3.containsKey(i2 + "_" + str6)) { w.d(d, "An id can have only one AD form"); return; } } if (TextUtils.isEmpty(str6)) { w.c(d, "preload error,make sure you have correct unitid"); return; } if (map.containsKey(MBridgeConstans.PREIMAGE)) { this.v = ((Boolean) map.get(MBridgeConstans.PREIMAGE)).booleanValue(); } com.mbridge.msdk.click.b bVar = this.l; if (bVar == null) { this.l = new com.mbridge.msdk.click.b(com.mbridge.msdk.foundation.controller.a.f().j(), str6); } else { bVar.a(str6); } if (map.containsKey(MBridgeConstans.PROPERTIES_AD_FRAME_NUM)) { this.p = ((Integer) map.get(MBridgeConstans.PROPERTIES_AD_FRAME_NUM)).intValue(); } if (map.containsKey(MBridgeConstans.PROPERTIES_API_REUQEST_CATEGORY)) { this.n = (String) map.get(MBridgeConstans.PROPERTIES_API_REUQEST_CATEGORY); } if (f.containsKey(str6) && f.get(str6).booleanValue()) { Map<String, Map<Long, Object>> map4 = e; Map<Long, Object> map5 = map4.get(i2 + "_" + str6); com.mbridge.msdk.c.a b3 = com.mbridge.msdk.c.b.a().b(com.mbridge.msdk.foundation.controller.a.f().k()); if (map5 != null && map5.size() > 0) { Long next = map5.keySet().iterator().next(); long currentTimeMillis = System.currentTimeMillis(); if (b3 == null) { b3 = com.mbridge.msdk.c.b.a().b(); } if (currentTimeMillis - next.longValue() >= b3.ae() * 1000) { map4.remove(str6); } else if (i2 == 1) { return; } } } f.put(str6, true); this.A = 1; try { if (map.containsKey("ad_num")) { int intValue = ((Integer) map.get("ad_num")).intValue(); this.A = intValue; if (intValue < 1) { this.A = 1; } if (this.A > 10) { this.A = 10; } } } catch (Exception unused) { w.d(d, "ADNUM MUST BE INTEGER"); } h.put(str6, Integer.valueOf(this.A)); com.mbridge.msdk.b.a.a aVar2 = (!map.containsKey(MBridgeConstans.PRELOAD_RESULT_LISTENER) || (obj = map.get(MBridgeConstans.PRELOAD_RESULT_LISTENER)) == null) ? null : new com.mbridge.msdk.b.a.a((PreloadListener) obj); if (!map.containsKey("app_id") || !map.containsKey(MBridgeConstans.APP_KEY) || !map.containsKey(MBridgeConstans.KEY_WORD)) { str2 = null; str = null; } else { str = (String) map.get("app_id"); str2 = (String) map.get(MBridgeConstans.APP_KEY); } if (this.k == null) { this.k = new c(); } this.k.a(com.mbridge.msdk.foundation.controller.a.f().j(), str, str2, str6); d e2 = com.mbridge.msdk.c.b.a().e(str, str6); this.m = e2; if (e2 == null) { this.m = d.d(str6); } if (map.containsKey(MBridgeConstans.PLACEMENT_ID) && map.get(MBridgeConstans.PLACEMENT_ID) != null) { String str7 = (String) map.get(MBridgeConstans.PLACEMENT_ID); if (!TextUtils.isEmpty(str7)) { str3 = str7; this.t = this.m.r(); this.c = this.m.s(); this.u = this.m.s(); list = this.t; if (list == null && list.size() > 0) { this.a = new LinkedList(); for (Integer num : this.t) { this.a.add(num); } List<Integer> list3 = this.u; if (list3 != null && list3.size() > 0) { this.b = new LinkedList(); for (Integer num2 : this.u) { this.b.add(Long.valueOf((long) (num2.intValue() * 1000))); } } if (this.t.contains(1) && i2 == 0) { try { str4 = ""; str5 = str6; try { a(1, (long) (this.c.get(this.t.indexOf(1)).intValue() * 1000), i2, str6, str3, false, aVar2, adMobClickListener); com.mbridge.msdk.mbnative.a.b<String, List<Campaign>> a3 = f.a(1); if (!(a3 == null || (b2 = a3.b(str5, 0)) == null || b2.size() <= 0)) { aVar = aVar2; try { a(true, aVar, (String) null); } catch (Exception unused2) { } a(i2, this.m, str5, str3, aVar, adMobClickListener); d dVar = this.m; i.put(str5, Integer.valueOf(dVar != null ? dVar.v() * this.A : 1)); Class.forName("com.mbridge.msdk.nativex.view.MBMediaView"); Class.forName("com.mbridge.msdk.videocommon.download.b"); c.a(com.mbridge.msdk.foundation.controller.a.f().j(), str5); u.b(); if (!TextUtils.isEmpty(str5)) { com.mbridge.msdk.foundation.db.f.a(i.a(com.mbridge.msdk.foundation.controller.a.f().j())).a(); int a4 = a(map.containsKey(MBridgeConstans.NATIVE_INFO) ? (String) map.get(MBridgeConstans.NATIVE_INFO) : null); if (a4 <= 0) { a4 = this.A; } d e3 = com.mbridge.msdk.c.b.a().e(str4, str5); this.m = e3; if (e3 == null) { this.m = d.d(str5); } List<Integer> r2 = this.m.r(); this.t = r2; if (r2 == null || r2.size() <= 0 || !this.t.contains(1) || (a2 = f.a(1)) == null) { list2 = null; } else { list2 = a2.b(str5, a4); } if (list2 != null) { ArrayList arrayList = new ArrayList(); for (int i3 = 0; i3 < list2.size(); i3++) { CampaignEx campaignEx = (CampaignEx) list2.get(i3); if (!TextUtils.isEmpty(campaignEx.getVideoUrlEncode())) { arrayList.add(campaignEx); } } if (arrayList.size() > 0) { Class<?> cls = Class.forName("com.mbridge.msdk.videocommon.download.b"); Object invoke = cls.getMethod("getInstance", new Class[0]).invoke(null, new Object[0]); cls.getMethod("createUnitCache", Context.class, String.class, List.class, Integer.TYPE, Class.forName("com.mbridge.msdk.videocommon.listener.a")).invoke(invoke, com.mbridge.msdk.foundation.controller.a.f().j(), str5, arrayList, 1, null); cls.getMethod(PointCategory.LOAD, String.class).invoke(invoke, str5); return; } return; } return; } return; } } catch (Exception unused3) { } aVar = aVar2; } catch (Exception unused4) { } a(i2, this.m, str5, str3, aVar, adMobClickListener); d dVar2 = this.m; i.put(str5, Integer.valueOf(dVar2 != null ? dVar2.v() * this.A : 1)); Class.forName("com.mbridge.msdk.nativex.view.MBMediaView"); Class.forName("com.mbridge.msdk.videocommon.download.b"); c.a(com.mbridge.msdk.foundation.controller.a.f().j(), str5); u.b(); if (!TextUtils.isEmpty(str5)) { } } aVar = aVar2; str4 = ""; str5 = str6; a(i2, this.m, str5, str3, aVar, adMobClickListener); d dVar22 = this.m; i.put(str5, Integer.valueOf(dVar22 != null ? dVar22.v() * this.A : 1)); try { Class.forName("com.mbridge.msdk.nativex.view.MBMediaView"); Class.forName("com.mbridge.msdk.videocommon.download.b"); c.a(com.mbridge.msdk.foundation.controller.a.f().j(), str5); u.b(); if (!TextUtils.isEmpty(str5)) { } } catch (Throwable unused5) { w.d(d, "init cam cache failed"); return; } } else if (aVar2 == null) { aVar2.onPreloadFaild("don't have sorceList"); return; } else { return; } } } str3 = ""; this.t = this.m.r(); this.c = this.m.s(); this.u = this.m.s(); list = this.t; if (list == null) { } if (aVar2 == null) { } } catch (Exception e4) { w.d(d, com.mbridge.msdk.mbnative.b.a.a(e4)); } } private int a(String str) { if (str == null) { return 0; } try { JSONArray jSONArray = new JSONArray(str); if (jSONArray.length() > 0) { for (int i2 = 0; i2 < jSONArray.length(); i2++) { JSONObject jSONObject = (JSONObject) jSONArray.opt(i2); if (2 == jSONObject.optInt("id", 0)) { return jSONObject.optInt("ad_num"); } } } } catch (Exception e2) { w.d(d, com.mbridge.msdk.mbnative.b.a.a(e2)); } return 0; } private void a(int i2, d dVar, String str, String str2, com.mbridge.msdk.b.a.a aVar, AdMobClickListener adMobClickListener) { Queue<Integer> queue = this.a; if (queue != null && queue.size() > 0) { try { int intValue = this.a.poll().intValue(); long j2 = (long) MBridgeConstans.REQUEST_TIME_OUT; Queue<Long> queue2 = this.b; if (queue2 != null && queue2.size() > 0) { j2 = this.b.poll().longValue(); } String str3 = d; w.b(str3, "preload start queue adsource = " + intValue); a(intValue, j2, str, str2, this.s, i2, dVar, aVar, adMobClickListener); } catch (Throwable unused) { w.d(d, "queue poll exception"); } } } private void a(int i2, long j2, String str, String str2, Map<String, Object> map, int i3, d dVar, com.mbridge.msdk.b.a.a aVar, AdMobClickListener adMobClickListener) { com.mbridge.msdk.mbnative.a.b<String, List<Campaign>> a2; if (i2 != 1 && (a2 = f.a(i2)) != null) { List<Campaign> b2 = a2.b(str, this.A); if (b2 != null && b2.size() > 0) { a(true, aVar, (String) null); return; } } if (i2 == 1) { a(i2, j2, i3, str, str2, true, aVar, adMobClickListener); } else if (i2 != 2) { a(i2, j2, i3, dVar, str, str2, aVar, false, adMobClickListener); } else { a(2, j2, i3, dVar, str, str2, aVar, false, adMobClickListener); } } /* JADX WARNING: Removed duplicated region for block: B:121:0x02a8 */ /* JADX WARNING: Removed duplicated region for block: B:124:0x02b7 */ /* JADX WARNING: Removed duplicated region for block: B:134:0x02f8 A[LOOP:1: B:132:0x02f2->B:134:0x02f8, LOOP_END] */ /* JADX WARNING: Removed duplicated region for block: B:137:0x030c */ /* JADX WARNING: Removed duplicated region for block: B:140:0x031d */ /* JADX WARNING: Removed duplicated region for block: B:157:0x035a */ /* JADX WARNING: Removed duplicated region for block: B:160:0x0372 */ /* JADX WARNING: Removed duplicated region for block: B:162:0x0375 */ /* JADX WARNING: Removed duplicated region for block: B:165:0x03c4 */ /* JADX WARNING: Removed duplicated region for block: B:168:0x03cf */ /* JADX WARNING: Removed duplicated region for block: B:185:0x049d */ /* JADX WARNING: Removed duplicated region for block: B:186:0x04a4 */ public final void a(int i2, long j2, int i3, d dVar, String str, String str2, com.mbridge.msdk.b.a.a aVar, boolean z2, AdMobClickListener adMobClickListener) { int i4; int i5; JSONArray jSONArray; List<Long> i6; int i7; int i8; String a2; a aVar2; int i9; m mVar; int i10; String str3; String str4; JSONException e2; int i11; List<Campaign> b2; List<Campaign> b3; try { com.mbridge.msdk.foundation.db.f.a(i.a(com.mbridge.msdk.foundation.controller.a.f().j())).a(); int p2 = this.m.p(); int q2 = this.m.q(); String str5 = d; w.b(str5, "START LOAD MB MVNATIVE"); com.mbridge.msdk.mbnative.e.a.a aVar3 = new com.mbridge.msdk.mbnative.e.a.a(com.mbridge.msdk.foundation.controller.a.f().j()); com.mbridge.msdk.foundation.same.net.g.d dVar2 = new com.mbridge.msdk.foundation.same.net.g.d(); String k2 = com.mbridge.msdk.foundation.controller.a.f().k(); String l2 = com.mbridge.msdk.foundation.controller.a.f().l(); Map<String, Object> map = this.s; if (map != null && map.containsKey("app_id") && this.s.containsKey(MBridgeConstans.APP_KEY) && this.s.containsKey(MBridgeConstans.KEY_WORD) && this.s.get(MBridgeConstans.KEY_WORD) != null) { if (this.s.get("app_id") instanceof String) { k2 = (String) this.s.get("app_id"); } if (this.s.get(MBridgeConstans.APP_KEY) instanceof String) { l2 = (String) this.s.get(MBridgeConstans.APP_KEY); } String str6 = this.s.get(MBridgeConstans.KEY_WORD) instanceof String ? (String) this.s.get(MBridgeConstans.KEY_WORD) : null; if (!TextUtils.isEmpty(str6)) { dVar2.a("smart", r.a(str6)); } } dVar2.a("app_id", k2); dVar2.a(MBridgeConstans.PROPERTIES_UNIT_ID, str); dVar2.a("req_type", "1"); if (!TextUtils.isEmpty(this.n)) { dVar2.a("category", this.n); } if (!TextUtils.isEmpty(str2)) { dVar2.a(MBridgeConstans.PLACEMENT_ID, str2); } dVar2.a("sign", SameMD5.getMD5(k2 + l2)); dVar2.a("only_impression", "1"); String e3 = aa.e(str); if (!TextUtils.isEmpty(e3)) { dVar2.a("j", e3); } int intValue = h.get(str).intValue(); if (p2 == w || p2 == 0 || intValue == 0) { a("The request was refused", i3, str, str2, aVar, adMobClickListener); return; } if (i3 == 0) { com.mbridge.msdk.mbnative.a.b<String, List<Campaign>> a3 = f.a(i2); if (z2) { if (a3 != null && (b3 = a3.b(str, intValue)) != null && b3.size() > 0) { a(true, aVar, (String) null); return; } else if (this.y) { a("", i3, str, str2, aVar, adMobClickListener); return; } else { return; } } else if (!(i2 == 1 || a3 == null || (b2 = a3.b(str, intValue)) == null || b2.size() <= 0)) { a(true, aVar, (String) null); return; } } if (intValue != 0) { dVar2.a("ad_num", intValue + ""); } if (this.p != 0) { dVar2.a("frame_num", this.p + ""); } if (this.s.containsKey(MBridgeConstans.NATIVE_INFO)) { String str7 = (String) this.s.get(MBridgeConstans.NATIVE_INFO); if (!TextUtils.isEmpty(str7)) { w.d(str5, "nativeinfo" + str7); try { JSONArray jSONArray2 = new JSONArray(str7); str4 = str7; if (jSONArray2.length() > 0) { i4 = 0; i10 = 0; for (int i12 = 0; i12 < jSONArray2.length(); i12++) { try { JSONObject jSONObject = (JSONObject) jSONArray2.opt(i12); try { int optInt = jSONObject.optInt("id", 0); if (2 == optInt) { i4 = jSONObject.optInt("ad_num"); if (p2 > 0) { try { jSONObject.put("ad_num", p2); } catch (JSONException e4) { e2 = e4; } } } else { if (3 == optInt) { i10 = jSONObject.optInt("ad_num"); if (p2 > 0) { jSONObject.put("ad_num", p2); } } i4 = i4; } } catch (JSONException e5) { e2 = e5; i4 = i4; w.d(d, com.mbridge.msdk.mbnative.b.a.a(e2)); str3 = str4; dVar2.a(MBridgeConstans.NATIVE_INFO, str3); p2 = intValue; i5 = i10; dVar2.a("ad_num", p2 + ""); dVar2.a("ping_mode", "1"); if (com.mbridge.msdk.c.b.a().b(com.mbridge.msdk.foundation.controller.a.f().k()) == null) { } if (!NativeController.a(this.s)) { } jSONArray = new JSONArray(); i6 = com.mbridge.msdk.foundation.controller.a.f().i(); while (r6.hasNext()) { } if (jSONArray.length() > 0) { } if (g.containsKey(str)) { } i8 = 1; i7 = 0; dVar2.a("ttc_ids", this.q); if (this.s.containsKey(MBridgeConstans.NATIVE_INFO)) { } if (i2 == i9) { } dVar2.a(TypedValues.CycleType.S_WAVE_OFFSET, i7 + ""); dVar2.a("ad_type", "42"); dVar2.a(CampaignEx.JSON_KEY_AD_SOURCE_ID, i2 + ""); a2 = com.mbridge.msdk.foundation.same.a.d.a(str, "native"); if (!TextUtils.isEmpty(a2)) { } if (Build.VERSION.SDK_INT >= 14) { } aVar2 = new a(i2); aVar2.d = str; aVar2.e = str2; aVar2.f = 42; aVar2.f(intValue); aVar2.d(i4); aVar2.e(i5); aVar2.c(q2); aVar2.a(adMobClickListener); aVar2.a(aVar); aVar2.b(true); aVar2.a(NativeController.b(this.s)); RunnableC0221b bVar = new RunnableC0221b(1, aVar2, i3, str, str2); aVar2.a(bVar); aVar2.g(i3); bVar.a(aVar); bVar.a(adMobClickListener); bVar.a(z2); bVar.a(str); if (i3 != 0) { } this.o.postDelayed(bVar, j2); } } catch (JSONException e6) { e2 = e6; w.d(d, com.mbridge.msdk.mbnative.b.a.a(e2)); str3 = str4; dVar2.a(MBridgeConstans.NATIVE_INFO, str3); p2 = intValue; i5 = i10; dVar2.a("ad_num", p2 + ""); dVar2.a("ping_mode", "1"); if (com.mbridge.msdk.c.b.a().b(com.mbridge.msdk.foundation.controller.a.f().k()) == null) { } if (!NativeController.a(this.s)) { } jSONArray = new JSONArray(); i6 = com.mbridge.msdk.foundation.controller.a.f().i(); while (r6.hasNext()) { } if (jSONArray.length() > 0) { } if (g.containsKey(str)) { } i8 = 1; i7 = 0; dVar2.a("ttc_ids", this.q); if (this.s.containsKey(MBridgeConstans.NATIVE_INFO)) { } if (i2 == i9) { } dVar2.a(TypedValues.CycleType.S_WAVE_OFFSET, i7 + ""); dVar2.a("ad_type", "42"); dVar2.a(CampaignEx.JSON_KEY_AD_SOURCE_ID, i2 + ""); a2 = com.mbridge.msdk.foundation.same.a.d.a(str, "native"); if (!TextUtils.isEmpty(a2)) { } if (Build.VERSION.SDK_INT >= 14) { } aVar2 = new a(i2); aVar2.d = str; aVar2.e = str2; aVar2.f = 42; aVar2.f(intValue); aVar2.d(i4); aVar2.e(i5); aVar2.c(q2); aVar2.a(adMobClickListener); aVar2.a(aVar); aVar2.b(true); aVar2.a(NativeController.b(this.s)); RunnableC0221b bVar2 = new RunnableC0221b(1, aVar2, i3, str, str2); aVar2.a(bVar2); aVar2.g(i3); bVar2.a(aVar); bVar2.a(adMobClickListener); bVar2.a(z2); bVar2.a(str); if (i3 != 0) { } this.o.postDelayed(bVar2, j2); } } i11 = i10; } else { i11 = 0; i4 = 0; } try { this.z = Math.max(i4, i11); i10 = i11; str3 = jSONArray2.toString(); } catch (JSONException e7) { e2 = e7; i10 = i11; w.d(d, com.mbridge.msdk.mbnative.b.a.a(e2)); str3 = str4; dVar2.a(MBridgeConstans.NATIVE_INFO, str3); p2 = intValue; i5 = i10; dVar2.a("ad_num", p2 + ""); dVar2.a("ping_mode", "1"); if (com.mbridge.msdk.c.b.a().b(com.mbridge.msdk.foundation.controller.a.f().k()) == null) { } if (!NativeController.a(this.s)) { } jSONArray = new JSONArray(); i6 = com.mbridge.msdk.foundation.controller.a.f().i(); while (r6.hasNext()) { } if (jSONArray.length() > 0) { } if (g.containsKey(str)) { } i8 = 1; i7 = 0; dVar2.a("ttc_ids", this.q); if (this.s.containsKey(MBridgeConstans.NATIVE_INFO)) { } if (i2 == i9) { } dVar2.a(TypedValues.CycleType.S_WAVE_OFFSET, i7 + ""); dVar2.a("ad_type", "42"); dVar2.a(CampaignEx.JSON_KEY_AD_SOURCE_ID, i2 + ""); a2 = com.mbridge.msdk.foundation.same.a.d.a(str, "native"); if (!TextUtils.isEmpty(a2)) { } if (Build.VERSION.SDK_INT >= 14) { } aVar2 = new a(i2); aVar2.d = str; aVar2.e = str2; aVar2.f = 42; aVar2.f(intValue); aVar2.d(i4); aVar2.e(i5); aVar2.c(q2); aVar2.a(adMobClickListener); aVar2.a(aVar); aVar2.b(true); aVar2.a(NativeController.b(this.s)); RunnableC0221b bVar22 = new RunnableC0221b(1, aVar2, i3, str, str2); aVar2.a(bVar22); aVar2.g(i3); bVar22.a(aVar); bVar22.a(adMobClickListener); bVar22.a(z2); bVar22.a(str); if (i3 != 0) { } this.o.postDelayed(bVar22, j2); } } catch (JSONException e8) { e2 = e8; str4 = str7; i4 = 0; i10 = 0; w.d(d, com.mbridge.msdk.mbnative.b.a.a(e2)); str3 = str4; dVar2.a(MBridgeConstans.NATIVE_INFO, str3); p2 = intValue; i5 = i10; dVar2.a("ad_num", p2 + ""); dVar2.a("ping_mode", "1"); if (com.mbridge.msdk.c.b.a().b(com.mbridge.msdk.foundation.controller.a.f().k()) == null) { } if (!NativeController.a(this.s)) { } jSONArray = new JSONArray(); i6 = com.mbridge.msdk.foundation.controller.a.f().i(); while (r6.hasNext()) { } if (jSONArray.length() > 0) { } if (g.containsKey(str)) { } i8 = 1; i7 = 0; dVar2.a("ttc_ids", this.q); if (this.s.containsKey(MBridgeConstans.NATIVE_INFO)) { } if (i2 == i9) { } dVar2.a(TypedValues.CycleType.S_WAVE_OFFSET, i7 + ""); dVar2.a("ad_type", "42"); dVar2.a(CampaignEx.JSON_KEY_AD_SOURCE_ID, i2 + ""); a2 = com.mbridge.msdk.foundation.same.a.d.a(str, "native"); if (!TextUtils.isEmpty(a2)) { } if (Build.VERSION.SDK_INT >= 14) { } aVar2 = new a(i2); aVar2.d = str; aVar2.e = str2; aVar2.f = 42; aVar2.f(intValue); aVar2.d(i4); aVar2.e(i5); aVar2.c(q2); aVar2.a(adMobClickListener); aVar2.a(aVar); aVar2.b(true); aVar2.a(NativeController.b(this.s)); RunnableC0221b bVar222 = new RunnableC0221b(1, aVar2, i3, str, str2); aVar2.a(bVar222); aVar2.g(i3); bVar222.a(aVar); bVar222.a(adMobClickListener); bVar222.a(z2); bVar222.a(str); if (i3 != 0) { } this.o.postDelayed(bVar222, j2); } dVar2.a(MBridgeConstans.NATIVE_INFO, str3); } else { i4 = 0; i10 = 0; } p2 = intValue; i5 = i10; } else { if (p2 == x || p2 == 0) { p2 = intValue; } i5 = 0; i4 = 0; } dVar2.a("ad_num", p2 + ""); dVar2.a("ping_mode", "1"); if (com.mbridge.msdk.c.b.a().b(com.mbridge.msdk.foundation.controller.a.f().k()) == null) { com.mbridge.msdk.c.b.a().b(); } if (!NativeController.a(this.s)) { w.b(d, "没有param 参数 要传fqci"); JSONArray a4 = aa.a(com.mbridge.msdk.foundation.controller.a.f().j(), str); if (a4.length() > 0) { dVar2.a(com.mbridge.msdk.foundation.same.net.g.d.c, aa.a(a4)); } } jSONArray = new JSONArray(); i6 = com.mbridge.msdk.foundation.controller.a.f().i(); if (i6 != null && i6.size() > 0) { for (Long l3 : i6) { jSONArray.put(l3.longValue()); } } if (jSONArray.length() > 0) { dVar2.a("install_ids", aa.a(jSONArray)); } if (g.containsKey(str) || (mVar = g.get(str)) == null) { i8 = 1; i7 = 0; } else { if (i2 == 1) { i7 = mVar.b(); } else if (i2 != 2) { i7 = mVar.b(); } else { i7 = mVar.a(); } i8 = 1; } if (i2 == i8 && !TextUtils.isEmpty(this.q)) { dVar2.a("ttc_ids", this.q); } if (this.s.containsKey(MBridgeConstans.NATIVE_INFO)) { i9 = 1; if (i2 == 1) { dVar2.a("tnum", this.z + ""); dVar2.a(TypedValues.CycleType.S_WAVE_OFFSET, i7 + ""); dVar2.a("ad_type", "42"); dVar2.a(CampaignEx.JSON_KEY_AD_SOURCE_ID, i2 + ""); a2 = com.mbridge.msdk.foundation.same.a.d.a(str, "native"); if (!TextUtils.isEmpty(a2)) { dVar2.a(com.mbridge.msdk.foundation.same.net.g.d.b, a2); } if (Build.VERSION.SDK_INT >= 14) { if (this.s.containsKey(MBridgeConstans.NATIVE_VIDEO_WIDTH) && (this.s.get(MBridgeConstans.NATIVE_VIDEO_WIDTH) instanceof Integer)) { dVar2.a("video_width", ((Integer) this.s.get(MBridgeConstans.NATIVE_VIDEO_WIDTH)).intValue() + ""); } if (this.s.containsKey(MBridgeConstans.NATIVE_VIDEO_HEIGHT) && (this.s.get(MBridgeConstans.NATIVE_VIDEO_HEIGHT) instanceof Integer)) { dVar2.a("video_height", ((Integer) this.s.get(MBridgeConstans.NATIVE_VIDEO_HEIGHT)).intValue() + ""); } dVar2.a("video_version", MBridgeConstans.NATIVE_VIDEO_VERSION); } aVar2 = new a(i2); aVar2.d = str; aVar2.e = str2; aVar2.f = 42; aVar2.f(intValue); aVar2.d(i4); aVar2.e(i5); aVar2.c(q2); aVar2.a(adMobClickListener); aVar2.a(aVar); if (i2 != 1 || z2) { aVar2.b(true); } aVar2.a(NativeController.b(this.s)); RunnableC0221b bVar2222 = new RunnableC0221b(1, aVar2, i3, str, str2); aVar2.a(bVar2222); aVar2.g(i3); bVar2222.a(aVar); bVar2222.a(adMobClickListener); bVar2222.a(z2); bVar2222.a(str); if (i3 != 0) { aVar3.a(1, dVar2, aVar2, ""); } else if (i3 == 1) { aVar3.b(1, com.mbridge.msdk.foundation.same.net.f.d.a().m, dVar2, aVar2); } this.o.postDelayed(bVar2222, j2); } } else { i9 = 1; } if (i2 == i9) { dVar2.a("tnum", this.A + ""); } dVar2.a(TypedValues.CycleType.S_WAVE_OFFSET, i7 + ""); dVar2.a("ad_type", "42"); dVar2.a(CampaignEx.JSON_KEY_AD_SOURCE_ID, i2 + ""); a2 = com.mbridge.msdk.foundation.same.a.d.a(str, "native"); if (!TextUtils.isEmpty(a2)) { } if (Build.VERSION.SDK_INT >= 14) { } aVar2 = new a(i2); aVar2.d = str; aVar2.e = str2; aVar2.f = 42; aVar2.f(intValue); aVar2.d(i4); aVar2.e(i5); aVar2.c(q2); aVar2.a(adMobClickListener); aVar2.a(aVar); aVar2.b(true); aVar2.a(NativeController.b(this.s)); RunnableC0221b bVar22222 = new RunnableC0221b(1, aVar2, i3, str, str2); aVar2.a(bVar22222); aVar2.g(i3); bVar22222.a(aVar); bVar22222.a(adMobClickListener); bVar22222.a(z2); bVar22222.a(str); if (i3 != 0) { } this.o.postDelayed(bVar22222, j2); } catch (Exception e9) { String str8 = d; w.d(str8, com.mbridge.msdk.mbnative.b.a.a(e9)); w.d(str8, e9.getMessage()); } } public static void a(int i2, String str) { m mVar; if (g.containsKey(str)) { mVar = g.get(str); } else { mVar = new m(); } int intValue = h.get(str).intValue(); int intValue2 = i.containsKey(str) ? i.get(str).intValue() : 1; int i3 = 0; if (i2 == 1) { int b2 = intValue + mVar.b(); if (b2 <= intValue2) { i3 = b2; } mVar.b(i3); } else if (i2 == 2) { int a2 = intValue + mVar.a(); if (a2 <= intValue2) { i3 = a2; } mVar.a(i3); } g.put(str, mVar); } public static void b(int i2, String str) { if (g.containsKey(str)) { m mVar = g.get(str); if (i2 == 1) { mVar.b(0); } else if (i2 == 2) { mVar.a(0); } g.put(str, mVar); } } /* compiled from: NativePreloadController */ public class a extends com.mbridge.msdk.mbnative.e.a.b implements com.mbridge.msdk.foundation.same.e.c { private int b; private int c; private int g; private int h; private int i; private AdMobClickListener j; private List<String> k = null; private boolean l = false; private Runnable m; private boolean n = true; private com.mbridge.msdk.b.a.a o; public final void a(AdMobClickListener adMobClickListener) { this.j = adMobClickListener; } public final void a(List<String> list) { this.k = list; } public final void c(int i2) { this.i = i2; } public final void d(int i2) { this.g = i2; } public final void e(int i2) { this.h = i2; } public final void f(int i2) { this.c = i2; } public a(int i2) { this.b = i2; } public final void a(com.mbridge.msdk.b.a.a aVar) { this.o = aVar; } public final void b(boolean z) { this.n = z; } @Override // com.mbridge.msdk.foundation.same.e.c public final void a(boolean z) { this.l = z; } @Override // com.mbridge.msdk.mbnative.e.a.b public final void a(List<com.mbridge.msdk.foundation.same.net.c.b> list, final CampaignUnit campaignUnit) { b.this.y = true; b.this.a(true, this.o, (String) null); b.this.a(new Thread(new Runnable() { /* class com.mbridge.msdk.mbnative.controller.b.a.AnonymousClass1 */ public final void run() { boolean z; int i = 1; if (!MBridgeConstans.PRELOAD_RESULT_IN_SUBTHREAD || Looper.myLooper() != null) { z = false; } else { Looper.prepare(); z = true; } if (a.this.m != null) { w.b(b.d, "REMOVE CANCEL TASK ON SUCCESS"); b.this.o.removeCallbacks(a.this.m); } w.d(b.d, "onSuccess"); aa.a((List<CampaignEx>) campaignUnit.getAds()); Map map = b.e; if (map.containsKey("0_" + a.this.d)) { Map map2 = b.e; map2.remove("0_" + a.this.d); } if (a.this.i > 0) { if (campaignUnit.ads.size() > a.this.i) { a aVar = a.this; aVar.c = aVar.i; } else { a.this.c = campaignUnit.ads.size(); } } else if (a.this.i == -1) { a.this.c = 0; } else if (a.this.i == -3) { a.this.c = campaignUnit.ads.size(); } else if (a.this.i == -2) { if (campaignUnit.getTemplate() == 3) { if (a.this.h != 0) { a aVar2 = a.this; aVar2.c = aVar2.h; } } else if (a.this.g != 0) { a aVar3 = a.this; aVar3.c = aVar3.g; } if (a.this.c <= 0) { a.this.c = ((Integer) b.h.get(a.this.d)).intValue(); } } if (campaignUnit.ads.size() < a.this.c) { a.this.c = campaignUnit.ads.size(); } ArrayList arrayList = new ArrayList(); ArrayList arrayList2 = new ArrayList(); boolean z2 = false; for (int i2 = 0; i2 < campaignUnit.ads.size(); i2++) { CampaignEx campaignEx = campaignUnit.ads.get(i2); campaignEx.setCampaignUnitId(a.this.d); boolean c = aa.c(com.mbridge.msdk.foundation.controller.a.f().j(), campaignEx.getPackageName()); if (c && com.mbridge.msdk.foundation.controller.a.e() != null) { com.mbridge.msdk.foundation.controller.a.e().add(new com.mbridge.msdk.foundation.entity.i(campaignEx.getId(), campaignEx.getPackageName())); z2 = true; } if (arrayList.size() < a.this.c && campaignEx.getOfferType() != 99) { if (aa.b(campaignEx)) { campaignEx.setRtinsType(c ? 1 : 2); } if (campaignEx.getWtick() == 1 || !c) { arrayList.add(campaignEx); if (!TextUtils.isEmpty(campaignEx.getVideoUrlEncode())) { arrayList2.add(campaignEx); } } else if (aa.b(campaignEx)) { arrayList.add(campaignEx); if (!TextUtils.isEmpty(campaignEx.getVideoUrlEncode())) { arrayList2.add(campaignEx); } } else { aa.a(a.this.d, campaignEx, com.mbridge.msdk.foundation.same.a.D); } } b.this.a(b.this.v, campaignEx); } b.a(b.this, arrayList2, a.this.d); if (z2) { com.mbridge.msdk.foundation.controller.a.f().h(); } if (campaignUnit.getAds().get(0) != null) { i = campaignUnit.getAds().get(0).getType(); } com.mbridge.msdk.mbnative.a.b<String, List<Campaign>> a2 = f.a(i); if (a2 != null) { a2.a(a.this.d, arrayList); } b.a(a.this.b, a.this.d); if (Looper.myLooper() != null && z) { Looper.loop(); } } })); } @Override // com.mbridge.msdk.mbnative.e.a.b public final void a(final int i2, final String str) { b.this.a(new Thread(new Runnable() { /* class com.mbridge.msdk.mbnative.controller.b.a.AnonymousClass2 */ public final void run() { boolean z; if (!MBridgeConstans.PRELOAD_RESULT_IN_SUBTHREAD || Looper.myLooper() != null) { z = false; } else { Looper.prepare(); z = true; } if (!a.this.l) { if (a.this.m != null) { w.b(b.d, "REMOVE CANCEL TASK ON onFailed"); b.this.o.removeCallbacks(a.this.m); } if (a.this.g() == 1 || a.this.n) { b.this.a(str, a.this.g(), a.this.d, a.this.e, a.this.o, a.this.j); } } else if (a.this.n) { b.this.a(str, a.this.g(), a.this.d, a.this.e, a.this.o, a.this.j); } if (i2 == -1) { b.b(a.this.b, a.this.d); } if (Looper.myLooper() != null && z) { Looper.loop(); } } })); } public final void a(Runnable runnable) { this.m = runnable; } @Override // com.mbridge.msdk.mbnative.e.a.b public final void b(final List<Frame> list) { b.this.a(new Thread(new Runnable() { /* class com.mbridge.msdk.mbnative.controller.b.a.AnonymousClass3 */ public final void run() { boolean z; if (!MBridgeConstans.PRELOAD_RESULT_IN_SUBTHREAD || Looper.myLooper() != null) { z = false; } else { Looper.prepare(); z = true; } if (!a.this.l && a.this.m != null) { w.b(b.d, "REMOVE CANCEL TASK ON onAdLoaded"); b.this.o.removeCallbacks(a.this.m); } List list = list; if (list != null && list.size() > 0) { for (Frame frame : list) { for (CampaignEx campaignEx : frame.getCampaigns()) { b.this.a(b.this.v, campaignEx); } } HashMap hashMap = new HashMap(); hashMap.put(Long.valueOf(System.currentTimeMillis()), list); Map map = b.e; if (map.containsKey("1_" + a.this.d)) { Map map2 = b.e; map2.remove("1_" + a.this.d); } Map map3 = b.e; map3.put("1_" + a.this.d, hashMap); } if (Looper.myLooper() != null && z) { Looper.loop(); } } })); } } public final void a(String str, int i2, String str2, String str3, com.mbridge.msdk.b.a.a aVar, AdMobClickListener adMobClickListener) { Log.e(d, str); try { Queue<Integer> queue = this.a; if ((queue == null || queue.size() > 0) && this.a != null) { a(i2, this.m, str2, str3, aVar, adMobClickListener); } else { a(false, aVar, str); } } catch (Exception e2) { if (MBridgeConstans.DEBUG) { e2.printStackTrace(); } } } /* renamed from: com.mbridge.msdk.mbnative.controller.b$b reason: collision with other inner class name */ /* compiled from: NativePreloadController */ public class RunnableC0221b implements Runnable { private int b; private com.mbridge.msdk.foundation.same.e.c c; private int d; private String e; private String f; private com.mbridge.msdk.b.a.a g; private boolean h = false; private AdMobClickListener i; public final void a(AdMobClickListener adMobClickListener) { this.i = adMobClickListener; } public final void a(boolean z) { this.h = z; } public final void a(com.mbridge.msdk.b.a.a aVar) { this.g = aVar; } public final void a(String str) { this.e = str; } public RunnableC0221b(int i2, com.mbridge.msdk.foundation.same.e.c cVar, int i3, String str, String str2) { this.b = i2; this.c = cVar; this.d = i3; this.e = str; this.f = str2; } public final void run() { String str = b.d; w.b(str, "cancel task adsource is = " + this.b); this.c.a(true); int i2 = this.b; if (i2 == 1) { b.this.y = true; if (this.h || this.d == 1) { b.this.a("REQUEST_TIMEOUT", this.d, this.e, this.f, this.g, this.i); } } else if (i2 == 2) { b.this.a("REQUEST_TIMEOUT", this.d, this.e, this.f, this.g, this.i); } } } public static Map<String, Map<Long, Object>> a() { return e; } public static Map<String, Boolean> b() { return f; } public static Map<String, m> c() { return g; } public static Map<String, Integer> d() { return h; } public static Map<String, Integer> e() { return i; } private void a(final int i2, final long j2, final int i3, final String str, final String str2, final boolean z2, final com.mbridge.msdk.b.a.a aVar, final AdMobClickListener adMobClickListener) { final UUID D = s.D(); if (D == null) { Map<String, Boolean> map = this.C; map.put(str + "_" + z2 + "_ttc", false); Map<String, Boolean> map2 = this.C; map2.put(str + "_" + z2 + "_post", false); } else { Map<String, Boolean> map3 = this.C; map3.put(D + str + "_" + z2 + "_ttc", false); Map<String, Boolean> map4 = this.C; map4.put(D + str + "_" + z2 + "_post", false); } final AnonymousClass2 r11 = new com.mbridge.msdk.foundation.same.e.a() { /* class com.mbridge.msdk.mbnative.controller.b.AnonymousClass2 */ @Override // com.mbridge.msdk.foundation.same.e.a public final void cancelTask() { } @Override // com.mbridge.msdk.foundation.same.e.a public final void pauseTask(boolean z) { } @Override // com.mbridge.msdk.foundation.same.e.a public final void runTask() { if (b.this.r == null) { b.this.r = i.a(com.mbridge.msdk.foundation.controller.a.f().j()); } com.mbridge.msdk.foundation.db.c a2 = com.mbridge.msdk.foundation.db.c.a(b.this.r); a2.a(); b.this.q = a2.a(str); if (b.this.C != null && !b.this.C.isEmpty()) { if (D == null) { Map map = b.this.C; if (map.containsKey(str + "_" + z2 + "_ttc")) { Map map2 = b.this.C; map2.put(str + "_" + z2 + "_ttc", true); return; } } if (D != null) { Map map3 = b.this.C; if (map3.containsKey(D + str + "_" + z2 + "_ttc")) { Map map4 = b.this.C; map4.put(D + str + "_" + z2 + "_ttc", true); } } } } }; this.o.postDelayed(new com.mbridge.msdk.foundation.same.e.a() { /* class com.mbridge.msdk.mbnative.controller.b.AnonymousClass3 */ @Override // com.mbridge.msdk.foundation.same.e.a public final void cancelTask() { } @Override // com.mbridge.msdk.foundation.same.e.a public final void pauseTask(boolean z) { } @Override // com.mbridge.msdk.foundation.same.e.a public final void runTask() { boolean z = false; if (b.this.C != null && !b.this.C.isEmpty()) { Map map = b.this.C; if (map.containsKey(str + "_" + z2 + "_ttc")) { Map map2 = b.this.C; z = ((Boolean) map2.get(str + "_" + z2 + "_ttc")).booleanValue(); Map map3 = b.this.C; map3.remove(str + "_" + z2 + "_ttc"); } Map map4 = b.this.C; if (map4.containsKey(D + str + "_" + z2 + "_ttc")) { Map map5 = b.this.C; z = ((Boolean) map5.get(D + str + "_" + z2 + "_ttc")).booleanValue(); Map map6 = b.this.C; map6.remove(D + str + "_" + z2 + "_ttc"); } } if (!z) { b.this.o.post(new Runnable() { /* class com.mbridge.msdk.mbnative.controller.b.AnonymousClass3.AnonymousClass1 */ public final void run() { if (b.this.C != null && !b.this.C.isEmpty()) { Map map = b.this.C; if (map.containsKey(str + "_" + z2 + "_post")) { Map map2 = b.this.C; map2.put(str + "_" + z2 + "_post", true); } Map map3 = b.this.C; if (map3.containsKey(D + str + "_" + z2 + "_post")) { Map map4 = b.this.C; map4.put(D + str + "_" + z2 + "_post", true); } } if (b.this.B != null) { b.this.B.a(r11); } b.this.a(i2, j2, i3, b.this.m, str, str2, aVar, z2, adMobClickListener); } }); } } }, 90000); AnonymousClass4 r12 = new a.b() { /* class com.mbridge.msdk.mbnative.controller.b.AnonymousClass4 */ @Override // com.mbridge.msdk.foundation.same.e.a.b public final void a(a.EnumC0206a aVar) { if (aVar == a.EnumC0206a.FINISH) { b.this.o.post(new Runnable() { /* class com.mbridge.msdk.mbnative.controller.b.AnonymousClass4.AnonymousClass1 */ public final void run() { boolean z = false; if (b.this.C != null && !b.this.C.isEmpty()) { Map map = b.this.C; if (map.containsKey(str + "_" + z2 + "_post")) { Map map2 = b.this.C; z = ((Boolean) map2.get(str + "_" + z2 + "_post")).booleanValue(); Map map3 = b.this.C; map3.remove(str + "_" + z2 + "_post"); } Map map4 = b.this.C; if (map4.containsKey(D + str + "_" + z2 + "_post")) { Map map5 = b.this.C; z = ((Boolean) map5.get(D + str + "_" + z2 + "_post")).booleanValue(); Map map6 = b.this.C; map6.remove(D + str + "_" + z2 + "_post"); } } if (!z) { b.this.a(i2, j2, i3, b.this.m, str, str2, aVar, z2, adMobClickListener); } } }); } } }; if (this.B == null) { this.B = new com.mbridge.msdk.foundation.same.e.b(com.mbridge.msdk.foundation.controller.a.f().j()); } com.mbridge.msdk.foundation.same.e.b bVar = this.B; if (bVar != null) { bVar.a(r11, r12); } } public final void a(boolean z2, com.mbridge.msdk.b.a.a aVar, String str) { if (z2) { if (aVar != null && !aVar.a()) { aVar.a(true); aVar.onPreloadSucceed(); } } else if (aVar != null && !aVar.a()) { aVar.a(true); aVar.onPreloadFaild(str); } } public final void a(boolean z2, Campaign campaign) { if (campaign != null) { if (z2 && campaign.getIconDrawable() == null) { campaign.loadIconUrlAsyncWithBlock(null); } if (z2 && campaign.getBigDrawable() == null) { campaign.loadImageUrlAsyncWithBlock(null); } } } public final void a(Thread thread) { if (!MBridgeConstans.PRELOAD_RESULT_IN_SUBTHREAD) { thread.run(); } else { thread.start(); } } static /* synthetic */ void a(b bVar, List list, String str) { if (list != null) { try { if (list.size() > 0) { try { Class.forName("com.mbridge.msdk.nativex.view.MBMediaView"); Class.forName("com.mbridge.msdk.videocommon.download.b"); Class<?> cls = Class.forName("com.mbridge.msdk.videocommon.download.b"); Object invoke = cls.getMethod("getInstance", new Class[0]).invoke(null, new Object[0]); if (invoke != null) { cls.getMethod("createUnitCache", Context.class, String.class, List.class, Integer.TYPE, Class.forName("com.mbridge.msdk.videocommon.listener.a")).invoke(invoke, com.mbridge.msdk.foundation.controller.a.f().j(), str, list, 1, null); cls.getMethod(PointCategory.LOAD, String.class).invoke(invoke, str); return; } return; } catch (Exception unused) { w.d(d, "please import the videocommon aar"); return; } } } catch (Exception e2) { w.d(d, com.mbridge.msdk.mbnative.b.a.a(e2)); return; } } w.b(d, "onload 不用下载视频素材 size为0"); } }