package com.mbridge.msdk.videocommon.download; import android.content.Context; import android.text.TextUtils; import com.mbridge.msdk.MBridgeConstans; import com.mbridge.msdk.c.k; import com.mbridge.msdk.foundation.download.download.H5DownLoadManager; import com.mbridge.msdk.foundation.download.download.HTMLResourceManager; import com.mbridge.msdk.foundation.entity.CampaignEx; import com.mbridge.msdk.foundation.tools.af; import com.mbridge.msdk.foundation.tools.ah; import com.mbridge.msdk.foundation.tools.ak; import com.mbridge.msdk.foundation.tools.ap; import com.mbridge.msdk.newreward.function.common.MBridgeError; import com.mbridge.msdk.videocommon.download.h; import java.util.ArrayList; import java.util.Iterator; import java.util.List; import java.util.Map; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.CopyOnWriteArrayList; /* loaded from: classes4.dex */ public final class j { private com.mbridge.msdk.videocommon.listener.a e; private ConcurrentHashMap g; private Context j; private String l; private com.mbridge.msdk.videocommon.d.c m; private int o; private i p; private boolean q; private List c = new ArrayList(); private boolean d = true; private String f = ""; private c h = new c() { // from class: com.mbridge.msdk.videocommon.download.j.1 @Override // com.mbridge.msdk.videocommon.download.c public final void a(long j, int i) { if (i == 5 || i == 4) { j.this.d = true; j.this.a(); } if (i == 2) { j.this.d = true; } } }; private CopyOnWriteArrayList> i = new CopyOnWriteArrayList<>(); private long k = 3600; private int n = 1; k a = null; k b = null; public j(Context context, List list, String str, int i) { this.o = 1; try { boolean a = h.a.a.a(i); this.q = a; if (a) { this.l = str; this.o = i; this.p = new i(list, str, i); return; } } catch (Exception unused) { this.p = null; this.q = false; } this.j = com.mbridge.msdk.foundation.controller.c.m().c(); List list2 = this.c; if (list2 != null && list != null) { list2.addAll(list); } this.l = str; this.o = i; b(this.c); } public j(Context context, CampaignEx campaignEx, String str, int i) { this.o = 1; try { boolean a = h.a.a.a(i); this.q = a; if (a) { this.l = str; this.o = i; this.p = new i(campaignEx, str, i); return; } } catch (Exception unused) { this.p = null; this.q = false; } this.j = com.mbridge.msdk.foundation.controller.c.m().c(); List list = this.c; if (list != null && campaignEx != null) { list.add(campaignEx); } this.l = str; this.o = i; b(this.c); } public final void a(com.mbridge.msdk.videocommon.listener.a aVar) { i iVar; if (!this.q || (iVar = this.p) == null) { this.e = aVar; } else { iVar.a(aVar); } } public final void a(String str, com.mbridge.msdk.videocommon.listener.a aVar) { i iVar; if (this.q && (iVar = this.p) != null) { iVar.a(str, aVar); return; } if (this.g == null) { this.g = new ConcurrentHashMap<>(); } if (aVar == null || TextUtils.isEmpty(str)) { return; } this.g.put(str, aVar); } public final void a(List list) { i iVar; if (this.q && (iVar = this.p) != null) { iVar.a(list); return; } List list2 = this.c; if (list2 != null && list != null) { list2.addAll(list); } b(this.c); } public final void a(CampaignEx campaignEx) { i iVar; if (this.q && (iVar = this.p) != null) { iVar.a(campaignEx); return; } List list = this.c; if (list != null && campaignEx != null) { list.add(campaignEx); } b(this.c); } /* JADX WARN: Can't wrap try/catch for region: R(5:56|57|58|59|(1:61)(0)) */ /* JADX WARN: Code restructure failed: missing block: B:56:0x01d4, code lost: r4 = move-exception; */ /* JADX WARN: Code restructure failed: missing block: B:60:0x0202, code lost: if (com.mbridge.msdk.MBridgeConstans.DEBUG != false) goto L93; */ /* JADX WARN: Code restructure failed: missing block: B:61:0x0204, code lost: com.mbridge.msdk.foundation.tools.af.b("UnitCacheCtroller", r4.getMessage()); */ /* JADX WARN: Code restructure failed: missing block: B:62:0x020e, code lost: r12 = move-exception; */ /* JADX WARN: Code restructure failed: missing block: B:65:0x0213, code lost: throw r12; */ /* JADX WARN: Finally extract failed */ /* Code decompiled incorrectly, please refer to instructions dump. To view partially-correct add '--show-bad-code' argument */ private void b(java.util.List r12) { /* Method dump skipped, instructions count: 560 To view this dump add '--comments-level debug' option */ throw new UnsupportedOperationException("Method not decompiled: com.mbridge.msdk.videocommon.download.j.b(java.util.List):void"); } private void d() { CopyOnWriteArrayList> copyOnWriteArrayList; if ((this.q && this.p != null) || ah.a().a("u_n_c_e_d", true) || (copyOnWriteArrayList = this.i) == null) { return; } try { synchronized (copyOnWriteArrayList) { try { long currentTimeMillis = System.currentTimeMillis(); int i = 0; while (i < this.i.size()) { Map map = this.i.get(i); Iterator> it = map.entrySet().iterator(); while (it.hasNext()) { a value = it.next().getValue(); if (value != null) { if (currentTimeMillis - value.g() > this.k * 1000 && value.k() == 1) { value.b(MBridgeError.ERROR_MESSAGE_DOWNLOAD_DOWNLOAD_TIMEOUT); value.a(this.n); value.s(); this.i.remove(map); i--; } if (value.k() != 1 && value.k() != 5 && value.k() != 0) { value.s(); this.i.remove(map); i--; } } } i++; } } finally { } } } catch (Throwable th) { th.printStackTrace(); } } private void e() { CopyOnWriteArrayList> copyOnWriteArrayList = this.i; if (copyOnWriteArrayList != null) { try { synchronized (copyOnWriteArrayList) { int i = 0; while (i < this.i.size()) { try { Map map = this.i.get(i); Iterator> it = map.entrySet().iterator(); while (it.hasNext()) { a value = it.next().getValue(); if (value != null && value.l() != null && value.f()) { value.r(); this.i.remove(map); i--; } } i++; } finally { } } } } catch (Throwable unused) { af.b("UnitCacheCtroller", "cleanDisplayTask ERROR"); } } } /* JADX WARN: Code restructure failed: missing block: B:117:0x01f1, code lost: if (r29 != 94) goto L125; */ /* JADX WARN: Code restructure failed: missing block: B:63:0x00e8, code lost: if (r15.isBidCampaign() == false) goto L57; */ /* Code decompiled incorrectly, please refer to instructions dump. To view partially-correct add '--show-bad-code' argument */ public final java.util.List a(java.lang.String r28, int r29, boolean r30, java.util.List r31, boolean r32, com.mbridge.msdk.foundation.same.report.d.e r33) { /* Method dump skipped, instructions count: 662 To view this dump add '--comments-level debug' option */ throw new UnsupportedOperationException("Method not decompiled: com.mbridge.msdk.videocommon.download.j.a(java.lang.String, int, boolean, java.util.List, boolean, com.mbridge.msdk.foundation.same.report.d.e):java.util.List"); } public final boolean a(List list, String str) { if (list == null || list.size() == 0) { return false; } for (int i = 0; i < list.size(); i++) { CampaignEx campaignEx = list.get(i); if (campaignEx == null || !a(new a(com.mbridge.msdk.foundation.controller.c.m().c(), campaignEx, str, this.n), b(campaignEx), false) || !a(campaignEx.getendcard_url(), campaignEx)) { return false; } } return true; } private int b(CampaignEx campaignEx) { if (campaignEx == null) { return -1; } if (campaignEx.getReady_rate() != -1) { return campaignEx.getReady_rate(); } return e(campaignEx); } /* JADX WARN: Code restructure failed: missing block: B:103:0x01e7, code lost: if (r5 != 94) goto L123; */ /* JADX WARN: Removed duplicated region for block: B:107:0x01fb A[Catch: all -> 0x0033, Exception -> 0x0036, TryCatch #1 {Exception -> 0x0036, blocks: (B:12:0x0019, B:16:0x0025, B:20:0x0077, B:21:0x007c, B:23:0x0084, B:24:0x0094, B:26:0x009a, B:28:0x00a8, B:30:0x00b3, B:31:0x00bd, B:33:0x00c3, B:42:0x00e4, B:51:0x00ec, B:55:0x00f3, B:57:0x0103, B:58:0x010b, B:62:0x0158, B:64:0x016a, B:71:0x017b, B:74:0x0181, B:78:0x0197, B:86:0x01a1, B:94:0x01ad, B:96:0x01ba, B:98:0x01c4, B:100:0x01d1, B:105:0x01f5, B:107:0x01fb, B:109:0x0201, B:114:0x020e, B:121:0x0224, B:124:0x022f, B:126:0x023a, B:128:0x023e, B:130:0x0248, B:135:0x0250, B:138:0x025a, B:140:0x0264, B:146:0x0118, B:148:0x011e, B:150:0x0128, B:153:0x0134, B:155:0x013a, B:168:0x0140, B:157:0x0144, B:159:0x014c, B:179:0x0039, B:181:0x0045, B:184:0x005d, B:185:0x027d, B:190:0x004f), top: B:11:0x0019, outer: #0 }] */ /* JADX WARN: Removed duplicated region for block: B:114:0x020e A[Catch: all -> 0x0033, Exception -> 0x0036, TRY_ENTER, TryCatch #1 {Exception -> 0x0036, blocks: (B:12:0x0019, B:16:0x0025, B:20:0x0077, B:21:0x007c, B:23:0x0084, B:24:0x0094, B:26:0x009a, B:28:0x00a8, B:30:0x00b3, B:31:0x00bd, B:33:0x00c3, B:42:0x00e4, B:51:0x00ec, B:55:0x00f3, B:57:0x0103, B:58:0x010b, B:62:0x0158, B:64:0x016a, B:71:0x017b, B:74:0x0181, B:78:0x0197, B:86:0x01a1, B:94:0x01ad, B:96:0x01ba, B:98:0x01c4, B:100:0x01d1, B:105:0x01f5, B:107:0x01fb, B:109:0x0201, B:114:0x020e, B:121:0x0224, B:124:0x022f, B:126:0x023a, B:128:0x023e, B:130:0x0248, B:135:0x0250, B:138:0x025a, B:140:0x0264, B:146:0x0118, B:148:0x011e, B:150:0x0128, B:153:0x0134, B:155:0x013a, B:168:0x0140, B:157:0x0144, B:159:0x014c, B:179:0x0039, B:181:0x0045, B:184:0x005d, B:185:0x027d, B:190:0x004f), top: B:11:0x0019, outer: #0 }] */ /* JADX WARN: Removed duplicated region for block: B:23:0x0084 A[Catch: all -> 0x0033, Exception -> 0x0036, TryCatch #1 {Exception -> 0x0036, blocks: (B:12:0x0019, B:16:0x0025, B:20:0x0077, B:21:0x007c, B:23:0x0084, B:24:0x0094, B:26:0x009a, B:28:0x00a8, B:30:0x00b3, B:31:0x00bd, B:33:0x00c3, B:42:0x00e4, B:51:0x00ec, B:55:0x00f3, B:57:0x0103, B:58:0x010b, B:62:0x0158, B:64:0x016a, B:71:0x017b, B:74:0x0181, B:78:0x0197, B:86:0x01a1, B:94:0x01ad, B:96:0x01ba, B:98:0x01c4, B:100:0x01d1, B:105:0x01f5, B:107:0x01fb, B:109:0x0201, B:114:0x020e, B:121:0x0224, B:124:0x022f, B:126:0x023a, B:128:0x023e, B:130:0x0248, B:135:0x0250, B:138:0x025a, B:140:0x0264, B:146:0x0118, B:148:0x011e, B:150:0x0128, B:153:0x0134, B:155:0x013a, B:168:0x0140, B:157:0x0144, B:159:0x014c, B:179:0x0039, B:181:0x0045, B:184:0x005d, B:185:0x027d, B:190:0x004f), top: B:11:0x0019, outer: #0 }] */ /* Code decompiled incorrectly, please refer to instructions dump. To view partially-correct add '--show-bad-code' argument */ public final com.mbridge.msdk.videocommon.download.a a(int r25, boolean r26) { /* Method dump skipped, instructions count: 657 To view this dump add '--comments-level debug' option */ throw new UnsupportedOperationException("Method not decompiled: com.mbridge.msdk.videocommon.download.j.a(int, boolean):com.mbridge.msdk.videocommon.download.a"); } public static boolean a(a aVar, int i) { long m = aVar.m(); long j = aVar.j(); if (TextUtils.isEmpty(aVar.e())) { af.a("UnitCacheCtroller", "checkVideoDownload video done return true"); return true; } if (i == 0) { if (aVar.l() != null && !TextUtils.isEmpty(aVar.l().getVideoUrlEncode())) { return true; } } else if (j > 0 && m * 100 >= j * i) { if (i != 100 || aVar.k() == 5) { return true; } aVar.s(); return false; } return false; } private static boolean a(a aVar, int i, boolean z) { long m = aVar.m(); long j = aVar.j(); if (TextUtils.isEmpty(aVar.e())) { af.a("UnitCacheCtroller", "checkVideoDownload video done return true"); return true; } CampaignEx l = aVar.l(); if (l != null) { if (l.getRsIgnoreCheckRule() != null && l.getRsIgnoreCheckRule().size() > 0 && l.getRsIgnoreCheckRule().contains(0)) { af.c("UnitCacheCtroller", "Is not check video download status"); return true; } if (l.getIsTimeoutCheckVideoStatus() == 1 && l.getVideoCheckType() == 1) { return true; } if (z && l.getVideoCheckType() == 1) { if (i == 0) { return true; } if ((j != 0 || m != 0) && m >= (i / 100) * j) { l.setIsTimeoutCheckVideoStatus(1); return true; } } } return a(aVar, i); } private boolean a(String str, CampaignEx campaignEx) { try { if (campaignEx.getRsIgnoreCheckRule() == null || campaignEx.getRsIgnoreCheckRule().size() <= 0 || !campaignEx.getRsIgnoreCheckRule().contains(2)) { return (campaignEx.isDynamicView() && !ak.l(str)) || ap.a(str) || b(str, campaignEx); } af.c("UnitCacheCtroller", "Is not check endCard download status : " + str); return true; } catch (Throwable th) { af.b("UnitCacheCtroller", th.getMessage(), th); return false; } } private boolean b(String str, CampaignEx campaignEx) { if (campaignEx.isMraid() || TextUtils.isEmpty(str)) { return true; } if (campaignEx.getLoadTimeoutState() == 1 && !c(campaignEx)) { return true; } if (campaignEx.getRsIgnoreCheckRule() == null || campaignEx.getRsIgnoreCheckRule().size() <= 0 || !campaignEx.getRsIgnoreCheckRule().contains(2)) { return ap.b(H5DownLoadManager.getInstance().getH5ResAddress(str)) || ap.b(HTMLResourceManager.getInstance().getHtmlContentFromUrl(str)); } af.c("UnitCacheCtroller", "Is not check endCard download status : " + str); return true; } private boolean a(int i, CampaignEx campaignEx, String str) { if (campaignEx.isDynamicView()) { return true; } if (campaignEx.getRsIgnoreCheckRule() != null && campaignEx.getRsIgnoreCheckRule().size() > 0 && campaignEx.getRsIgnoreCheckRule().contains(1)) { af.c("UnitCacheCtroller", "Is not check template download status"); return true; } if (!TextUtils.isEmpty(str) && campaignEx.getLoadTimeoutState() == 0) { af.a("UnitCacheCtroller", "check template 下载情况:" + H5DownLoadManager.getInstance().getH5ResAddress(str)); if (H5DownLoadManager.getInstance().getH5ResAddress(str) == null) { return false; } } return true; } public final a b(int i, boolean z) { i iVar; if (this.q && (iVar = this.p) != null) { return iVar.c(); } try { return a(i, z); } catch (Throwable th) { af.b("UnitCacheCtroller", th.getMessage(), th); return null; } } public final a a(String str) { i iVar; if (this.q && (iVar = this.p) != null) { return iVar.a(str); } CopyOnWriteArrayList> copyOnWriteArrayList = this.i; if (copyOnWriteArrayList == null) { return null; } synchronized (copyOnWriteArrayList) { try { try { Iterator> it = this.i.iterator(); while (it.hasNext()) { Map next = it.next(); if (next != null && next.containsKey(str)) { return next.get(str); } } } catch (Throwable unused) { af.b("UnitCacheCtroller", "failed to get campaignTast by cid"); } return null; } finally { } } } private boolean a(CopyOnWriteArrayList> copyOnWriteArrayList) { try { Iterator> it = copyOnWriteArrayList.iterator(); while (it.hasNext()) { Map next = it.next(); if (next != null) { Iterator> it2 = next.entrySet().iterator(); while (it2.hasNext()) { if (it2.next().getValue().k() == 1) { return true; } } } } return false; } catch (Throwable th) { if (!MBridgeConstans.DEBUG) { return false; } th.printStackTrace(); return false; } } /* JADX WARN: Removed duplicated region for block: B:104:0x01c2 A[SYNTHETIC] */ /* JADX WARN: Removed duplicated region for block: B:112:0x01ce A[SYNTHETIC] */ /* JADX WARN: Removed duplicated region for block: B:150:0x0042 A[SYNTHETIC] */ /* JADX WARN: Removed duplicated region for block: B:153:0x0042 A[ADDED_TO_REGION, SYNTHETIC] */ /* JADX WARN: Removed duplicated region for block: B:154:0x0133 */ /* JADX WARN: Removed duplicated region for block: B:57:0x00df A[Catch: all -> 0x0022, TryCatch #1 {all -> 0x0022, blocks: (B:12:0x0016, B:14:0x001f, B:15:0x0025, B:16:0x002b, B:18:0x0031, B:21:0x003a, B:22:0x0042, B:24:0x0048, B:27:0x0058, B:30:0x005f, B:32:0x0065, B:33:0x0067, B:36:0x0073, B:37:0x0083, B:39:0x0094, B:41:0x0098, B:42:0x00a0, B:43:0x00a4, B:49:0x00b9, B:51:0x00bd, B:52:0x00d1, B:54:0x00d5, B:55:0x00db, B:57:0x00df, B:59:0x00e3, B:60:0x00f7, B:62:0x00fb, B:63:0x0129, B:65:0x012e, B:66:0x0134, B:70:0x016b, B:71:0x016f, B:73:0x0174, B:78:0x017c, B:82:0x0182, B:84:0x0186, B:85:0x018f, B:87:0x0193, B:91:0x019d, B:92:0x01a1, B:96:0x01ad, B:100:0x01b3, B:102:0x01b7, B:107:0x01c5, B:113:0x01ce, B:115:0x01d9, B:118:0x01dd, B:121:0x01e1, B:124:0x01e7, B:137:0x01f2, B:142:0x01fa, B:127:0x01ff, B:132:0x020c, B:135:0x0209, B:156:0x0100, B:158:0x0104, B:161:0x0119, B:163:0x011f, B:165:0x0123, B:179:0x0211), top: B:11:0x0016, inners: #0, #2 }] */ /* JADX WARN: Removed duplicated region for block: B:65:0x012e A[Catch: all -> 0x0022, TryCatch #1 {all -> 0x0022, blocks: (B:12:0x0016, B:14:0x001f, B:15:0x0025, B:16:0x002b, B:18:0x0031, B:21:0x003a, B:22:0x0042, B:24:0x0048, B:27:0x0058, B:30:0x005f, B:32:0x0065, B:33:0x0067, B:36:0x0073, B:37:0x0083, B:39:0x0094, B:41:0x0098, B:42:0x00a0, B:43:0x00a4, B:49:0x00b9, B:51:0x00bd, B:52:0x00d1, B:54:0x00d5, B:55:0x00db, B:57:0x00df, B:59:0x00e3, B:60:0x00f7, B:62:0x00fb, B:63:0x0129, B:65:0x012e, B:66:0x0134, B:70:0x016b, B:71:0x016f, B:73:0x0174, B:78:0x017c, B:82:0x0182, B:84:0x0186, B:85:0x018f, B:87:0x0193, B:91:0x019d, B:92:0x01a1, B:96:0x01ad, B:100:0x01b3, B:102:0x01b7, B:107:0x01c5, B:113:0x01ce, B:115:0x01d9, B:118:0x01dd, B:121:0x01e1, B:124:0x01e7, B:137:0x01f2, B:142:0x01fa, B:127:0x01ff, B:132:0x020c, B:135:0x0209, B:156:0x0100, B:158:0x0104, B:161:0x0119, B:163:0x011f, B:165:0x0123, B:179:0x0211), top: B:11:0x0016, inners: #0, #2 }] */ /* JADX WARN: Removed duplicated region for block: B:68:0x0167 */ /* Code decompiled incorrectly, please refer to instructions dump. To view partially-correct add '--show-bad-code' argument */ public final void a() { /* Method dump skipped, instructions count: 534 To view this dump add '--comments-level debug' option */ throw new UnsupportedOperationException("Method not decompiled: com.mbridge.msdk.videocommon.download.j.a():void"); } public final void b() { CopyOnWriteArrayList> copyOnWriteArrayList; if ((!this.q || this.p == null) && (copyOnWriteArrayList = this.i) != null) { try { synchronized (copyOnWriteArrayList) { try { Iterator> it = this.i.iterator(); while (it.hasNext()) { Map next = it.next(); if (next != null) { Iterator> it2 = next.entrySet().iterator(); while (it2.hasNext()) { a value = it2.next().getValue(); if (value != null && value.k() == 1) { value.b("playing and stop download"); value.s(); this.i.remove(next); return; } } } } } finally { } } } catch (Throwable th) { if (MBridgeConstans.DEBUG) { af.b("UnitCacheCtroller", th.getMessage()); } } } } public final CopyOnWriteArrayList> c() { i iVar; return (!this.q || (iVar = this.p) == null) ? this.i : iVar.d(); } private boolean c(CampaignEx campaignEx) { if (campaignEx == null) { return false; } try { return campaignEx.getPlayable_ads_without_video() == 2; } catch (Throwable th) { if (!MBridgeConstans.DEBUG) { return false; } th.printStackTrace(); return false; } } private int d(CampaignEx campaignEx) { try { k kVar = this.a; if (kVar != null) { return kVar.p(); } return 100; } catch (Exception e) { if (!MBridgeConstans.DEBUG) { return 100; } af.b("UnitCacheCtroller", e.getMessage()); return 100; } } public final void b(String str) { CopyOnWriteArrayList> copyOnWriteArrayList; i iVar; if (this.q && (iVar = this.p) != null) { iVar.b(str); return; } try { synchronized (this.i) { try { if (!TextUtils.isEmpty(str) && (copyOnWriteArrayList = this.i) != null && copyOnWriteArrayList.size() > 0) { Iterator> it = this.i.iterator(); while (it.hasNext()) { Map next = it.next(); if (next != null) { for (Map.Entry entry : next.entrySet()) { if (entry != null && TextUtils.equals(entry.getKey(), str)) { this.i.remove(next); } } } } } } catch (Throwable th) { throw th; } } } catch (Exception e) { if (MBridgeConstans.DEBUG) { af.b("UnitCacheCtroller", e.getMessage()); } } } private int e(CampaignEx campaignEx) { try { if (campaignEx.getAdType() == 298) { if (this.b == null) { this.b = com.mbridge.msdk.c.h.a().c(com.mbridge.msdk.foundation.controller.c.m().k(), this.l); } return this.b.p(); } if (campaignEx.getAdType() == 42) { return d(null); } if (this.m == null) { this.m = com.mbridge.msdk.videocommon.d.b.a().a(com.mbridge.msdk.foundation.controller.c.m().k(), this.l, false); } return this.m.r(); } catch (Throwable th) { af.b("UnitCacheCtroller", th.getMessage(), th); return 100; } } private void f(CampaignEx campaignEx) { if (campaignEx != null) { try { com.mbridge.msdk.foundation.same.report.d.e eVar = new com.mbridge.msdk.foundation.same.report.d.e(); eVar.a("cache", 1); eVar.a(CampaignEx.JSON_KEY_READY_RATE, Integer.valueOf(b(campaignEx))); if (b(campaignEx) == 100) { eVar.a("resumed_breakpoint", "2"); } else { eVar.a("resumed_breakpoint", "1"); } eVar.a("resource_type", 4); eVar.a("scenes", "1"); eVar.a("url", campaignEx.getVideoUrlEncode()); com.mbridge.msdk.foundation.same.report.d.d.a().a("m_download_start", campaignEx, eVar); } catch (Exception e) { if (MBridgeConstans.DEBUG) { e.printStackTrace(); } } } } }