package n8; import android.content.DialogInterface; import android.text.TextUtils; import android.util.Log; import android.webkit.WebView; import android.webkit.WebViewRenderProcess; import com.unity3d.services.core.device.MimeTypes; import com.vungle.warren.VungleLogger; import com.vungle.warren.c0; import com.vungle.warren.model.c; import com.vungle.warren.model.n; import com.vungle.warren.model.r; import com.vungle.warren.ui.view.p; import com.vungle.warren.utility.c; import com.vungle.warren.utility.t; import g8.j; import java.io.File; import java.util.Collections; import java.util.HashMap; import java.util.LinkedList; import java.util.Locale; import java.util.Map; import java.util.concurrent.atomic.AtomicBoolean; import l8.f; import l8.g; import m8.b; import z4.k; /* loaded from: classes2.dex */ public class a implements m8.c, p.b { private l8.b B; private final String[] C; /* renamed from: a, reason: collision with root package name */ private final t f12167a; /* renamed from: b, reason: collision with root package name */ private final y7.a f12168b; /* renamed from: c, reason: collision with root package name */ private final p f12169c; /* renamed from: e, reason: collision with root package name */ private c.a f12171e; /* renamed from: f, reason: collision with root package name */ private n f12172f; /* renamed from: g, reason: collision with root package name */ private com.vungle.warren.model.c f12173g; /* renamed from: h, reason: collision with root package name */ private com.vungle.warren.model.p f12174h; /* renamed from: i, reason: collision with root package name */ private j f12175i; /* renamed from: j, reason: collision with root package name */ private File f12176j; /* renamed from: k, reason: collision with root package name */ private boolean f12177k; /* renamed from: l, reason: collision with root package name */ private boolean f12178l; /* renamed from: m, reason: collision with root package name */ private boolean f12179m; /* renamed from: n, reason: collision with root package name */ private m8.d f12180n; /* renamed from: s, reason: collision with root package name */ private b.a f12185s; /* renamed from: t, reason: collision with root package name */ private int f12186t; /* renamed from: u, reason: collision with root package name */ private boolean f12187u; /* renamed from: x, reason: collision with root package name */ private int f12190x; /* renamed from: y, reason: collision with root package name */ private int f12191y; /* renamed from: d, reason: collision with root package name */ private final Map f12170d = new HashMap(); /* renamed from: o, reason: collision with root package name */ private String f12181o = "Are you sure?"; /* renamed from: p, reason: collision with root package name */ private String f12182p = "If you exit now, you will not get your reward"; /* renamed from: q, reason: collision with root package name */ private String f12183q = "Continue"; /* renamed from: r, reason: collision with root package name */ private String f12184r = "Close"; /* renamed from: v, reason: collision with root package name */ private AtomicBoolean f12188v = new AtomicBoolean(false); /* renamed from: w, reason: collision with root package name */ private AtomicBoolean f12189w = new AtomicBoolean(false); /* renamed from: z, reason: collision with root package name */ private LinkedList f12192z = new LinkedList(); private j.c0 A = new C0199a(); private AtomicBoolean D = new AtomicBoolean(false); /* renamed from: n8.a$a, reason: collision with other inner class name */ class C0199a implements j.c0 { /* renamed from: a, reason: collision with root package name */ boolean f12193a = false; C0199a() { } @Override // g8.j.c0 public void a(Exception exc) { if (this.f12193a) { return; } this.f12193a = true; a.this.L(26); VungleLogger.c(a.class.getSimpleName() + "#onError", new com.vungle.warren.error.a(26).getLocalizedMessage()); a.this.F(); } @Override // g8.j.c0 public void b() { } } class b implements c.b { /* renamed from: a, reason: collision with root package name */ final /* synthetic */ File f12195a; b(File file) { this.f12195a = file; } @Override // com.vungle.warren.utility.c.b public void a(boolean z10) { if (z10) { a.this.f12180n.o("file://" + this.f12195a.getPath()); a.this.f12168b.c(a.this.f12173g.D("postroll_view")); a.this.f12179m = true; return; } a.this.L(27); a.this.L(10); VungleLogger.c(a.class.getSimpleName() + "#playPost", "Error Rendering Postroll"); a.this.F(); } } class c implements DialogInterface.OnClickListener { /* renamed from: a, reason: collision with root package name */ final /* synthetic */ com.vungle.warren.model.j f12197a; c(com.vungle.warren.model.j jVar) { this.f12197a = jVar; } @Override // android.content.DialogInterface.OnClickListener public void onClick(DialogInterface dialogInterface, int i10) { this.f12197a.e("consent_status", i10 == -2 ? "opted_out" : i10 == -1 ? "opted_in" : "opted_out_by_timeout"); this.f12197a.e("timestamp", Long.valueOf(System.currentTimeMillis() / 1000)); this.f12197a.e("consent_source", "vungle_modal"); a.this.f12175i.i0(this.f12197a, null); a.this.start(); } } class d implements DialogInterface.OnClickListener { d() { } @Override // android.content.DialogInterface.OnClickListener public void onClick(DialogInterface dialogInterface, int i10) { if (i10 == -2) { a.this.P("video_close", null); a.this.G(); } } } class e implements Runnable { e() { } @Override // java.lang.Runnable public void run() { a.this.f12178l = true; if (a.this.f12179m) { return; } a.this.f12180n.d(); } } class f implements l8.f { f() { } @Override // l8.f public void a(f.a aVar) { if (aVar == f.a.DEEP_LINK) { a.this.P("deeplinkSuccess", null); } } } public a(com.vungle.warren.model.c cVar, n nVar, j jVar, t tVar, y7.a aVar, p pVar, o8.b bVar, File file, String[] strArr) { this.f12173g = cVar; this.f12172f = nVar; this.f12167a = tVar; this.f12168b = aVar; this.f12169c = pVar; this.f12175i = jVar; this.f12176j = file; this.C = strArr; if (cVar.n() != null) { this.f12192z.addAll(cVar.n()); Collections.sort(this.f12192z); } K(bVar); } /* JADX INFO: Access modifiers changed from: private */ public void F() { if (this.D.get()) { Log.w("LocalAdPresenter", "Busy with closing"); return; } this.D.set(true); P("close", null); this.f12167a.a(); this.f12180n.close(); } /* JADX INFO: Access modifiers changed from: private */ public void G() { if (this.f12173g.H()) { N(); } else { F(); } } /* JADX WARN: Removed duplicated region for block: B:11:0x0079 A[Catch: ActivityNotFoundException -> 0x0087, TRY_LEAVE, TryCatch #0 {ActivityNotFoundException -> 0x0087, blocks: (B:3:0x0009, B:5:0x004f, B:8:0x0056, B:9:0x0075, B:11:0x0079, B:16:0x0070), top: B:2:0x0009 }] */ /* JADX WARN: Removed duplicated region for block: B:15:? A[RETURN, SYNTHETIC] */ /* Code decompiled incorrectly, please refer to instructions dump. To view partially-correct code enable 'Show inconsistent code' option in preferences */ private void H() { /* r7 = this; java.lang.String r0 = "LocalAdPresenter" java.lang.String r1 = "cta" java.lang.String r2 = "" r7.P(r1, r2) y7.a r1 = r7.f12168b // Catch: android.content.ActivityNotFoundException -> L87 com.vungle.warren.model.c r2 = r7.f12173g // Catch: android.content.ActivityNotFoundException -> L87 java.lang.String r3 = "postroll_click" java.lang.String[] r2 = r2.D(r3) // Catch: android.content.ActivityNotFoundException -> L87 r1.c(r2) // Catch: android.content.ActivityNotFoundException -> L87 y7.a r1 = r7.f12168b // Catch: android.content.ActivityNotFoundException -> L87 com.vungle.warren.model.c r2 = r7.f12173g // Catch: android.content.ActivityNotFoundException -> L87 java.lang.String r3 = "click_url" java.lang.String[] r2 = r2.D(r3) // Catch: android.content.ActivityNotFoundException -> L87 r1.c(r2) // Catch: android.content.ActivityNotFoundException -> L87 y7.a r1 = r7.f12168b // Catch: android.content.ActivityNotFoundException -> L87 com.vungle.warren.model.c r2 = r7.f12173g // Catch: android.content.ActivityNotFoundException -> L87 java.lang.String r3 = "video_click" java.lang.String[] r2 = r2.D(r3) // Catch: android.content.ActivityNotFoundException -> L87 r1.c(r2) // Catch: android.content.ActivityNotFoundException -> L87 y7.a r1 = r7.f12168b // Catch: android.content.ActivityNotFoundException -> L87 r2 = 1 java.lang.String[] r3 = new java.lang.String[r2] // Catch: android.content.ActivityNotFoundException -> L87 com.vungle.warren.model.c r4 = r7.f12173g // Catch: android.content.ActivityNotFoundException -> L87 java.lang.String r2 = r4.k(r2) // Catch: android.content.ActivityNotFoundException -> L87 r4 = 0 r3[r4] = r2 // Catch: android.content.ActivityNotFoundException -> L87 r1.c(r3) // Catch: android.content.ActivityNotFoundException -> L87 java.lang.String r1 = "download" r2 = 0 r7.P(r1, r2) // Catch: android.content.ActivityNotFoundException -> L87 com.vungle.warren.model.c r1 = r7.f12173g // Catch: android.content.ActivityNotFoundException -> L87 java.lang.String r1 = r1.k(r4) // Catch: android.content.ActivityNotFoundException -> L87 if (r1 == 0) goto L70 boolean r2 = r1.isEmpty() // Catch: android.content.ActivityNotFoundException -> L87 if (r2 == 0) goto L56 goto L70 L56: m8.d r2 = r7.f12180n // Catch: android.content.ActivityNotFoundException -> L87 com.vungle.warren.model.c r3 = r7.f12173g // Catch: android.content.ActivityNotFoundException -> L87 java.lang.String r3 = r3.q() // Catch: android.content.ActivityNotFoundException -> L87 l8.g r4 = new l8.g // Catch: android.content.ActivityNotFoundException -> L87 m8.b$a r5 = r7.f12185s // Catch: android.content.ActivityNotFoundException -> L87 com.vungle.warren.model.n r6 = r7.f12172f // Catch: android.content.ActivityNotFoundException -> L87 r4.(r5, r6) // Catch: android.content.ActivityNotFoundException -> L87 n8.a$f r5 = new n8.a$f // Catch: android.content.ActivityNotFoundException -> L87 r5.() // Catch: android.content.ActivityNotFoundException -> L87 r2.f(r3, r1, r4, r5) // Catch: android.content.ActivityNotFoundException -> L87 goto L75 L70: java.lang.String r1 = "CTA destination URL is not configured properly" android.util.Log.e(r0, r1) // Catch: android.content.ActivityNotFoundException -> L87 L75: m8.b$a r1 = r7.f12185s // Catch: android.content.ActivityNotFoundException -> L87 if (r1 == 0) goto La8 java.lang.String r2 = "open" java.lang.String r3 = "adClick" com.vungle.warren.model.n r4 = r7.f12172f // Catch: android.content.ActivityNotFoundException -> L87 java.lang.String r4 = r4.d() // Catch: android.content.ActivityNotFoundException -> L87 r1.a(r2, r3, r4) // Catch: android.content.ActivityNotFoundException -> L87 goto La8 L87: java.lang.String r1 = "Unable to find destination activity" android.util.Log.e(r0, r1) java.lang.StringBuilder r0 = new java.lang.StringBuilder r0.() java.lang.Class r1 = n8.a.class java.lang.String r1 = r1.getSimpleName() r0.append(r1) java.lang.String r1 = "#download" r0.append(r1) java.lang.String r0 = r0.toString() java.lang.String r1 = "Download - Activity Not Found" com.vungle.warren.VungleLogger.c(r0, r1) La8: return */ throw new UnsupportedOperationException("Method not decompiled: n8.a.H():void"); } private void I(int i10) { m8.d dVar = this.f12180n; if (dVar != null) { dVar.g(); } R(i10); } private boolean J() { String websiteUrl = this.f12180n.getWebsiteUrl(); return TextUtils.isEmpty(websiteUrl) || "about:blank".equalsIgnoreCase(websiteUrl); } private void K(o8.b bVar) { this.f12170d.put("incentivizedTextSetByPub", this.f12175i.T("incentivizedTextSetByPub", com.vungle.warren.model.j.class).get()); this.f12170d.put("consentIsImportantToVungle", this.f12175i.T("consentIsImportantToVungle", com.vungle.warren.model.j.class).get()); this.f12170d.put("configSettings", this.f12175i.T("configSettings", com.vungle.warren.model.j.class).get()); if (bVar != null) { String f10 = bVar.f("saved_report"); com.vungle.warren.model.p pVar = TextUtils.isEmpty(f10) ? null : (com.vungle.warren.model.p) this.f12175i.T(f10, com.vungle.warren.model.p.class).get(); if (pVar != null) { this.f12174h = pVar; } } } /* JADX INFO: Access modifiers changed from: private */ public void L(int i10) { b.a aVar = this.f12185s; if (aVar != null) { aVar.b(new com.vungle.warren.error.a(i10), this.f12172f.d()); } } private boolean M(com.vungle.warren.model.j jVar) { return jVar != null && jVar.a("is_country_data_protected").booleanValue() && "unknown".equals(jVar.d("consent_status")); } private void N() { File file = new File(new File(this.f12176j.getPath()).getPath() + File.separator + "index.html"); this.f12171e = com.vungle.warren.utility.c.a(file, new b(file)); } private void O(o8.b bVar) { e(bVar); com.vungle.warren.model.j jVar = (com.vungle.warren.model.j) this.f12170d.get("incentivizedTextSetByPub"); String d10 = jVar == null ? null : jVar.d("userID"); if (this.f12174h == null) { com.vungle.warren.model.p pVar = new com.vungle.warren.model.p(this.f12173g, this.f12172f, System.currentTimeMillis(), d10); this.f12174h = pVar; pVar.l(this.f12173g.E()); this.f12175i.i0(this.f12174h, this.A); } if (this.B == null) { this.B = new l8.b(this.f12174h, this.f12175i, this.A); } this.f12169c.b(this); this.f12180n.a(this.f12173g.J(), this.f12173g.p()); b.a aVar = this.f12185s; if (aVar != null) { aVar.a("start", null, this.f12172f.d()); } } private void Q(String str) { this.f12174h.g(str); this.f12175i.i0(this.f12174h, this.A); L(27); if (!this.f12179m && this.f12173g.H()) { N(); } else { L(10); this.f12180n.close(); } } private void R(int i10) { L(i10); VungleLogger.c(a.class.getSimpleName(), "WebViewException: " + new com.vungle.warren.error.a(i10).getLocalizedMessage()); F(); } private void S(String str, String str2, String str3, String str4, DialogInterface.OnClickListener onClickListener) { this.f12180n.j(); this.f12180n.k(str, str2, str3, str4, onClickListener); } private void T(com.vungle.warren.model.j jVar) { c cVar = new c(jVar); jVar.e("consent_status", "opted_out_by_timeout"); jVar.e("timestamp", Long.valueOf(System.currentTimeMillis() / 1000)); jVar.e("consent_source", "vungle_modal"); this.f12175i.i0(jVar, this.A); S(jVar.d("consent_title"), jVar.d("consent_message"), jVar.d("button_accept"), jVar.d("button_deny"), cVar); } private void U() { String str = this.f12181o; String str2 = this.f12182p; String str3 = this.f12183q; String str4 = this.f12184r; com.vungle.warren.model.j jVar = (com.vungle.warren.model.j) this.f12170d.get("incentivizedTextSetByPub"); if (jVar != null) { str = jVar.d("title"); if (TextUtils.isEmpty(str)) { str = this.f12181o; } str2 = jVar.d("body"); if (TextUtils.isEmpty(str2)) { str2 = this.f12182p; } str3 = jVar.d("continue"); if (TextUtils.isEmpty(str3)) { str3 = this.f12183q; } str4 = jVar.d("close"); if (TextUtils.isEmpty(str4)) { str4 = this.f12184r; } } S(str, str2, str3, str4, new d()); } @Override // m8.b /* renamed from: E, reason: merged with bridge method [inline-methods] */ public void f(m8.d dVar, o8.b bVar) { this.f12189w.set(false); this.f12180n = dVar; dVar.setPresenter(this); b.a aVar = this.f12185s; if (aVar != null) { aVar.a("attach", this.f12173g.o(), this.f12172f.d()); } int b10 = this.f12173g.d().b(); if (b10 > 0) { this.f12177k = (b10 & 1) == 1; this.f12178l = (b10 & 2) == 2; } int e10 = this.f12173g.d().e(); int i10 = 6; if (e10 == 3) { int w10 = this.f12173g.w(); if (w10 != 0) { if (w10 != 1) { i10 = -1; } } i10 = 7; } else { if (e10 != 0) { if (e10 != 1) { i10 = 4; } } i10 = 7; } Log.d("LocalAdPresenter", "Requested Orientation " + i10); dVar.setOrientation(i10); O(bVar); c0.l().w(new r.b().d(h8.c.PLAY_AD).b(h8.a.SUCCESS, true).a(h8.a.EVENT_ID, this.f12173g.t()).c()); } public void P(String str, String str2) { if (str.equals("videoLength")) { int parseInt = Integer.parseInt(str2); this.f12186t = parseInt; this.f12174h.m(parseInt); this.f12175i.i0(this.f12174h, this.A); return; } switch (str) { case "unmute": case "mute": case "video_close": this.f12168b.c(this.f12173g.D(str)); break; } this.f12174h.f(str, str2, System.currentTimeMillis()); this.f12175i.i0(this.f12174h, this.A); } @Override // m8.b public void b() { this.f12169c.d(true); this.f12180n.r(); } @Override // m8.c public void c(int i10, float f10) { this.f12191y = (int) ((i10 / f10) * 100.0f); this.f12190x = i10; this.B.d(); b.a aVar = this.f12185s; if (aVar != null) { aVar.a("percentViewed:" + this.f12191y, null, this.f12172f.d()); } b.a aVar2 = this.f12185s; if (aVar2 != null && i10 > 0 && !this.f12187u) { this.f12187u = true; aVar2.a("adViewed", null, this.f12172f.d()); String[] strArr = this.C; if (strArr != null) { this.f12168b.c(strArr); } } P("video_viewed", String.format(Locale.ENGLISH, "%d", Integer.valueOf(i10))); if (this.f12191y == 100) { if (this.f12192z.peekLast() != null && ((c.a) this.f12192z.peekLast()).b() == 100) { this.f12168b.c(((c.a) this.f12192z.pollLast()).c()); } G(); } this.f12174h.h(this.f12190x); this.f12175i.i0(this.f12174h, this.A); while (this.f12192z.peek() != null && this.f12191y > ((c.a) this.f12192z.peek()).b()) { this.f12168b.c(((c.a) this.f12192z.poll()).c()); } com.vungle.warren.model.j jVar = (com.vungle.warren.model.j) this.f12170d.get("configSettings"); if (!this.f12172f.k() || this.f12191y <= 75 || jVar == null || !jVar.a("isReportIncentivizedEnabled").booleanValue() || this.f12188v.getAndSet(true)) { return; } k kVar = new k(); kVar.o("placement_reference_id", new z4.n(this.f12172f.d())); kVar.o("app_id", new z4.n(this.f12173g.h())); kVar.o("adStartTime", new z4.n(Long.valueOf(this.f12174h.b()))); kVar.o("user", new z4.n(this.f12174h.d())); this.f12168b.a(kVar); } @Override // m8.b public void e(o8.b bVar) { if (bVar == null) { return; } if (bVar.a("incentivized_sent", false)) { this.f12188v.set(true); } this.f12179m = bVar.a("in_post_roll", this.f12179m); this.f12177k = bVar.a("is_muted_mode", this.f12177k); this.f12190x = bVar.e("videoPosition", this.f12190x).intValue(); } @Override // m8.b public void h(o8.b bVar) { if (bVar == null) { return; } this.f12175i.i0(this.f12174h, this.A); com.vungle.warren.model.p pVar = this.f12174h; bVar.b("saved_report", pVar == null ? null : pVar.c()); bVar.c("incentivized_sent", this.f12188v.get()); bVar.c("in_post_roll", this.f12179m); bVar.c("is_muted_mode", this.f12177k); m8.d dVar = this.f12180n; bVar.d("videoPosition", (dVar == null || !dVar.i()) ? this.f12190x : this.f12180n.e()); } @Override // m8.b public void i(int i10) { this.B.c(); boolean z10 = (i10 & 1) != 0; boolean z11 = (i10 & 2) != 0; this.f12180n.c(); if (this.f12180n.i()) { this.f12190x = this.f12180n.e(); this.f12180n.j(); } if (z10 || !z11) { if (this.f12179m || z11) { this.f12180n.o("about:blank"); return; } return; } if (this.f12189w.getAndSet(true)) { return; } P("close", null); this.f12167a.a(); b.a aVar = this.f12185s; if (aVar != null) { aVar.a("end", this.f12174h.e() ? "isCTAClicked" : null, this.f12172f.d()); } } @Override // m8.c public boolean j(String str) { Q(str); VungleLogger.c(a.class.getSimpleName() + "#onMediaError", "Media Error: " + str); return false; } @Override // m8.c public void k(boolean z10) { this.f12177k = z10; if (z10) { P("mute", "true"); } else { P("unmute", "false"); } } @Override // com.vungle.warren.ui.view.p.b public void l(String str, boolean z10) { com.vungle.warren.model.p pVar = this.f12174h; if (pVar != null) { pVar.g(str); this.f12175i.i0(this.f12174h, this.A); VungleLogger.c(a.class.getSimpleName() + "onReceivedError", str); } } @Override // m8.c public void m(int i10, float f10) { P("videoLength", String.format(Locale.ENGLISH, "%d", Integer.valueOf((int) f10))); } @Override // m8.c public void n() { this.f12180n.f(null, "https://vungle.com/privacy/", new g(this.f12185s, this.f12172f), null); } @Override // m8.b public void o(b.a aVar) { this.f12185s = aVar; } @Override // m8.b public void p(int i10) { c.a aVar = this.f12171e; if (aVar != null) { aVar.a(); } i(i10); this.f12180n.q(0L); } @Override // com.vungle.warren.ui.view.p.b public void q(WebView webView, WebViewRenderProcess webViewRenderProcess) { I(32); VungleLogger.c(a.class.getSimpleName() + "#onRenderProcessUnresponsive", new com.vungle.warren.error.a(32).getLocalizedMessage()); } @Override // l8.d.a public void r(String str) { str.hashCode(); switch (str) { case "privacy": return; case "close": F(); return; case "download": H(); F(); return; default: VungleLogger.c(a.class.getSimpleName() + "#onMraidAction", "Unknown MRAID Command"); throw new IllegalArgumentException("Unknown action " + str); } } @Override // com.vungle.warren.ui.view.p.b public boolean s(WebView webView, boolean z10) { I(31); VungleLogger.c(a.class.getSimpleName() + "#onWebRenderingProcessGone", new com.vungle.warren.error.a(31).getLocalizedMessage()); return true; } @Override // m8.b public void start() { this.B.b(); if (!this.f12180n.n()) { R(31); VungleLogger.c(a.class.getSimpleName() + "#start", new com.vungle.warren.error.a(31).getLocalizedMessage()); return; } this.f12180n.p(); this.f12180n.h(); com.vungle.warren.model.j jVar = (com.vungle.warren.model.j) this.f12170d.get("consentIsImportantToVungle"); if (M(jVar)) { T(jVar); return; } if (this.f12179m) { if (J()) { N(); return; } return; } if (this.f12180n.i() || this.f12180n.b()) { return; } this.f12180n.m(new File(this.f12176j.getPath() + File.separator + MimeTypes.BASE_TYPE_VIDEO), this.f12177k, this.f12190x); int z10 = this.f12173g.z(this.f12172f.k()); if (z10 > 0) { this.f12167a.b(new e(), z10); } else { this.f12178l = true; this.f12180n.d(); } } @Override // m8.c public void t() { H(); } @Override // m8.b public boolean u() { if (this.f12179m) { F(); return true; } if (!this.f12178l) { return false; } if (this.f12172f.k() && this.f12191y <= 75) { U(); return false; } P("video_close", null); if (this.f12173g.H()) { N(); return false; } F(); return true; } }