package n8; import android.content.ActivityNotFoundException; import android.os.Handler; import android.os.Looper; import android.text.TextUtils; import android.util.Log; import android.view.MotionEvent; import android.webkit.WebView; import android.webkit.WebViewRenderProcess; import com.google.android.gms.ads.RequestConfiguration; import com.google.android.gms.common.internal.ImagesContract; import com.google.android.gms.measurement.api.AppMeasurementSdk; import com.vungle.warren.VungleLogger; import com.vungle.warren.c0; import com.vungle.warren.l; import com.vungle.warren.model.m; 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 com.vungle.warren.utility.v; import g8.j; import java.io.File; import java.util.HashMap; import java.util.Map; import java.util.concurrent.atomic.AtomicBoolean; import l8.f; import m8.b; import z4.k; /* loaded from: classes2.dex */ public class b implements m8.e, p.a, p.b { /* renamed from: w, reason: collision with root package name */ private static final String f12202w = "n8.b"; /* renamed from: a, reason: collision with root package name */ private final t f12203a; /* renamed from: b, reason: collision with root package name */ private final y7.a f12204b; /* renamed from: c, reason: collision with root package name */ private final f8.b f12205c; /* renamed from: e, reason: collision with root package name */ private c.a f12207e; /* renamed from: f, reason: collision with root package name */ private l f12208f; /* renamed from: g, reason: collision with root package name */ private b.a f12209g; /* renamed from: h, reason: collision with root package name */ private com.vungle.warren.model.c f12210h; /* renamed from: i, reason: collision with root package name */ private com.vungle.warren.model.p f12211i; /* renamed from: j, reason: collision with root package name */ private final n f12212j; /* renamed from: k, reason: collision with root package name */ private p f12213k; /* renamed from: l, reason: collision with root package name */ private j f12214l; /* renamed from: m, reason: collision with root package name */ private File f12215m; /* renamed from: n, reason: collision with root package name */ private m8.f f12216n; /* renamed from: o, reason: collision with root package name */ private boolean f12217o; /* renamed from: p, reason: collision with root package name */ private long f12218p; /* renamed from: q, reason: collision with root package name */ private boolean f12219q; /* renamed from: u, reason: collision with root package name */ private l8.b f12223u; /* renamed from: v, reason: collision with root package name */ private final String[] f12224v; /* renamed from: d, reason: collision with root package name */ private Map f12206d = new HashMap(); /* renamed from: r, reason: collision with root package name */ private AtomicBoolean f12220r = new AtomicBoolean(false); /* renamed from: s, reason: collision with root package name */ private AtomicBoolean f12221s = new AtomicBoolean(false); /* renamed from: t, reason: collision with root package name */ private j.c0 f12222t = new a(); class a implements j.c0 { /* renamed from: a, reason: collision with root package name */ boolean f12225a = false; a() { } @Override // g8.j.c0 public void a(Exception exc) { if (this.f12225a) { return; } this.f12225a = true; com.vungle.warren.error.a aVar = new com.vungle.warren.error.a(26); b.this.I(aVar); VungleLogger.c(b.class.getSimpleName(), aVar.getLocalizedMessage()); b.this.D(); } @Override // g8.j.c0 public void b() { } } /* renamed from: n8.b$b, reason: collision with other inner class name */ class RunnableC0200b implements Runnable { RunnableC0200b() { } @Override // java.lang.Runnable public void run() { b.this.f12217o = true; } } class c implements c.b { /* renamed from: a, reason: collision with root package name */ final /* synthetic */ File f12228a; c(File file) { this.f12228a = file; } @Override // com.vungle.warren.utility.c.b public void a(boolean z10) { if (!z10) { b.this.I(new com.vungle.warren.error.a(27)); b.this.I(new com.vungle.warren.error.a(10)); b.this.f12216n.close(); } else { b.this.f12216n.o("file://" + this.f12228a.getPath()); b.this.L(); } } } class d implements Runnable { d() { } @Override // java.lang.Runnable public void run() { b.this.f12213k.d(true); } } class e implements Runnable { e() { } @Override // java.lang.Runnable public void run() { b.this.f12216n.setVisibility(true); } } class f implements l8.f { f() { } @Override // l8.f public void a(f.a aVar) { if (aVar == f.a.DEEP_LINK) { b.this.M("deeplinkSuccess", null); } } } class g implements Runnable { /* renamed from: a, reason: collision with root package name */ final /* synthetic */ String f12233a; g(String str) { this.f12233a = str; } @Override // java.lang.Runnable public void run() { b.this.F(new com.vungle.warren.error.a(40, this.f12233a)); } } class h implements l8.f { h() { } @Override // l8.f public void a(f.a aVar) { if (aVar == f.a.DEEP_LINK) { b.this.M("deeplinkSuccess", null); } } } public b(com.vungle.warren.model.c cVar, n nVar, j jVar, t tVar, y7.a aVar, p pVar, o8.b bVar, File file, f8.b bVar2, String[] strArr) { this.f12210h = cVar; this.f12214l = jVar; this.f12212j = nVar; this.f12203a = tVar; this.f12204b = aVar; this.f12213k = pVar; this.f12215m = file; this.f12205c = bVar2; this.f12224v = strArr; G(bVar); if (cVar.I()) { this.f12208f = new l(cVar, aVar); } } /* JADX INFO: Access modifiers changed from: private */ public void D() { this.f12216n.close(); this.f12203a.a(); } private void E() { M("cta", RequestConfiguration.MAX_AD_CONTENT_RATING_UNSPECIFIED); try { this.f12204b.c(new String[]{this.f12210h.k(true)}); this.f12216n.f(this.f12210h.q(), this.f12210h.k(false), new l8.g(this.f12209g, this.f12212j), new h()); } catch (ActivityNotFoundException unused) { VungleLogger.c(b.class.getSimpleName() + "#download", "Download - Activity Not Found"); } } /* JADX INFO: Access modifiers changed from: private */ public void F(com.vungle.warren.error.a aVar) { m8.f fVar = this.f12216n; if (fVar != null) { fVar.g(); } VungleLogger.c(b.class.getSimpleName() + "#handleWebViewException", "WebViewException: " + aVar.getLocalizedMessage()); N(aVar); } private void G(o8.b bVar) { this.f12206d.put("incentivizedTextSetByPub", this.f12214l.T("incentivizedTextSetByPub", com.vungle.warren.model.j.class).get()); this.f12206d.put("consentIsImportantToVungle", this.f12214l.T("consentIsImportantToVungle", com.vungle.warren.model.j.class).get()); this.f12206d.put("configSettings", this.f12214l.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.f12214l.T(f10, com.vungle.warren.model.p.class).get(); if (pVar != null) { this.f12211i = pVar; } } } private void H(File file) { File file2 = new File(new File(file.getParent()).getPath() + File.separator + "index.html"); this.f12207e = com.vungle.warren.utility.c.a(file2, new c(file2)); } /* JADX INFO: Access modifiers changed from: private */ public void I(com.vungle.warren.error.a aVar) { b.a aVar2 = this.f12209g; if (aVar2 != null) { aVar2.b(aVar, this.f12212j.d()); } } private void J(o8.b bVar) { this.f12213k.c(this); this.f12213k.b(this); H(new File(this.f12215m.getPath() + File.separator + "template")); com.vungle.warren.model.j jVar = (com.vungle.warren.model.j) this.f12206d.get("incentivizedTextSetByPub"); if (jVar != null) { this.f12210h.R(jVar.d("title"), jVar.d("body"), jVar.d("continue"), jVar.d("close")); } String d10 = jVar == null ? null : jVar.d("userID"); if (this.f12211i == null) { com.vungle.warren.model.p pVar = new com.vungle.warren.model.p(this.f12210h, this.f12212j, System.currentTimeMillis(), d10); this.f12211i = pVar; pVar.l(this.f12210h.E()); this.f12214l.i0(this.f12211i, this.f12222t); } if (this.f12223u == null) { this.f12223u = new l8.b(this.f12211i, this.f12214l, this.f12222t); } com.vungle.warren.model.j jVar2 = (com.vungle.warren.model.j) this.f12206d.get("consentIsImportantToVungle"); if (jVar2 != null) { boolean z10 = jVar2.a("is_country_data_protected").booleanValue() && "unknown".equals(jVar2.d("consent_status")); this.f12213k.e(z10, jVar2.d("consent_title"), jVar2.d("consent_message"), jVar2.d("button_accept"), jVar2.d("button_deny")); if (z10) { jVar2.e("consent_status", "opted_out_by_timeout"); jVar2.e("timestamp", Long.valueOf(System.currentTimeMillis() / 1000)); jVar2.e("consent_source", "vungle_modal"); this.f12214l.i0(jVar2, this.f12222t); } } int z11 = this.f12210h.z(this.f12212j.k()); if (z11 > 0) { this.f12203a.b(new RunnableC0200b(), z11); } else { this.f12217o = true; } this.f12216n.l(); b.a aVar = this.f12209g; if (aVar != null) { aVar.a("start", null, this.f12212j.d()); } } private void K(String str) { if (this.f12211i == null || TextUtils.isEmpty(str)) { return; } this.f12211i.g(str); this.f12214l.i0(this.f12211i, this.f12222t); } /* JADX INFO: Access modifiers changed from: private */ public void L() { com.vungle.warren.model.p pVar; com.vungle.warren.model.c cVar = (com.vungle.warren.model.c) this.f12214l.T(this.f12210h.t(), com.vungle.warren.model.c.class).get(); if (cVar == null || (pVar = this.f12211i) == null) { return; } pVar.j(cVar.Z); this.f12214l.i0(this.f12211i, this.f12222t); } private void N(com.vungle.warren.error.a aVar) { I(aVar); D(); } @Override // m8.b /* renamed from: C, reason: merged with bridge method [inline-methods] */ public void f(m8.f fVar, o8.b bVar) { this.f12221s.set(false); this.f12216n = fVar; fVar.setPresenter(this); b.a aVar = this.f12209g; if (aVar != null) { aVar.a("attach", this.f12210h.o(), this.f12212j.d()); } this.f12205c.b(); int b10 = this.f12210h.d().b(); if (b10 > 0) { this.f12217o = (b10 & 2) == 2; } int e10 = this.f12210h.d().e(); int i10 = 6; if (e10 == 3) { int w10 = this.f12210h.w(); if (w10 != 0) { if (w10 != 1) { i10 = -1; } } i10 = 7; } else { if (e10 != 0) { if (e10 != 1) { i10 = 4; } } i10 = 7; } Log.d(f12202w, "Requested Orientation " + i10); fVar.setOrientation(i10); J(bVar); c0.l().w(new r.b().d(h8.c.PLAY_AD).b(h8.a.SUCCESS, true).a(h8.a.EVENT_ID, this.f12210h.t()).c()); } public void M(String str, String str2) { if (!str.equals("videoLength")) { this.f12211i.f(str, str2, System.currentTimeMillis()); this.f12214l.i0(this.f12211i, this.f12222t); } else { long parseLong = Long.parseLong(str2); this.f12218p = parseLong; this.f12211i.m(parseLong); this.f12214l.i0(this.f12211i, this.f12222t); } } @Override // m8.e public void a(boolean z10) { this.f12213k.a(z10); if (z10) { this.f12223u.b(); } else { this.f12223u.c(); } } @Override // m8.b public void b() { this.f12216n.l(); this.f12213k.d(true); } /* JADX WARN: Can't fix incorrect switch cases order, some code will duplicate */ @Override // com.vungle.warren.ui.view.p.a public boolean d(String str, k kVar) { char c10; Handler handler; float f10; char c11; char c12; Handler handler2 = new Handler(Looper.getMainLooper()); str.hashCode(); switch (str.hashCode()) { case -1912374177: if (str.equals("successfulView")) { c10 = 0; break; } c10 = 65535; break; case -1422950858: if (str.equals("action")) { c10 = 1; break; } c10 = 65535; break; case -735200587: if (str.equals("actionWithValue")) { c10 = 2; break; } c10 = 65535; break; case -660787472: if (str.equals("consentAction")) { c10 = 3; break; } c10 = 65535; break; case -511324706: if (str.equals("openPrivacy")) { c10 = 4; break; } c10 = 65535; break; case -418575596: if (str.equals("openNonMraid")) { c10 = 5; break; } c10 = 65535; break; case -348095344: if (str.equals("useCustomPrivacy")) { c10 = 6; break; } c10 = 65535; break; case 3417674: if (str.equals("open")) { c10 = 7; break; } c10 = 65535; break; case 3566511: if (str.equals("tpat")) { c10 = '\b'; break; } c10 = 65535; break; case 94756344: if (str.equals("close")) { c10 = '\t'; break; } c10 = 65535; break; case 96784904: if (str.equals("error")) { c10 = '\n'; break; } c10 = 65535; break; case 1614272768: if (str.equals("useCustomClose")) { c10 = 11; break; } c10 = 65535; break; default: c10 = 65535; break; } switch (c10) { case 0: b.a aVar = this.f12209g; if (aVar != null) { aVar.a("successfulView", null, this.f12212j.d()); } com.vungle.warren.model.j jVar = (com.vungle.warren.model.j) this.f12206d.get("configSettings"); if (!this.f12212j.k() || jVar == null || !jVar.a("isReportIncentivizedEnabled").booleanValue() || this.f12220r.getAndSet(true)) { return true; } k kVar2 = new k(); kVar2.o("placement_reference_id", new z4.n(this.f12212j.d())); kVar2.o("app_id", new z4.n(this.f12210h.h())); kVar2.o("adStartTime", new z4.n(Long.valueOf(this.f12211i.b()))); kVar2.o("user", new z4.n(this.f12211i.d())); this.f12204b.a(kVar2); return true; case 1: return true; case 2: String j10 = kVar.u("event").j(); String j11 = kVar.u(AppMeasurementSdk.ConditionalUserProperty.VALUE).j(); this.f12211i.f(j10, j11, System.currentTimeMillis()); this.f12214l.i0(this.f12211i, this.f12222t); if (j10.equals("videoViewed")) { try { f10 = Float.parseFloat(j11); } catch (NumberFormatException unused) { Log.e(f12202w, "value for videoViewed is null !"); f10 = 0.0f; } b.a aVar2 = this.f12209g; if (aVar2 != null && f10 > 0.0f && !this.f12219q) { this.f12219q = true; aVar2.a("adViewed", null, this.f12212j.d()); String[] strArr = this.f12224v; if (strArr != null) { this.f12204b.c(strArr); } } long j12 = this.f12218p; if (j12 > 0) { int i10 = (int) ((f10 / j12) * 100.0f); if (i10 > 0) { b.a aVar3 = this.f12209g; if (aVar3 != null) { aVar3.a("percentViewed:" + i10, null, this.f12212j.d()); } com.vungle.warren.model.j jVar2 = (com.vungle.warren.model.j) this.f12206d.get("configSettings"); if (this.f12212j.k() && i10 > 75 && jVar2 != null && jVar2.a("isReportIncentivizedEnabled").booleanValue() && !this.f12220r.getAndSet(true)) { k kVar3 = new k(); kVar3.o("placement_reference_id", new z4.n(this.f12212j.d())); kVar3.o("app_id", new z4.n(this.f12210h.h())); kVar3.o("adStartTime", new z4.n(Long.valueOf(this.f12211i.b()))); kVar3.o("user", new z4.n(this.f12211i.d())); this.f12204b.a(kVar3); } } this.f12223u.d(); } } if (j10.equals("videoLength")) { this.f12218p = Long.parseLong(j11); M("videoLength", j11); handler = handler2; handler.post(new d()); } else { handler = handler2; } handler.post(new e()); return true; case 3: com.vungle.warren.model.j jVar3 = (com.vungle.warren.model.j) this.f12206d.get("consentIsImportantToVungle"); if (jVar3 == null) { jVar3 = new com.vungle.warren.model.j("consentIsImportantToVungle"); } jVar3.e("consent_status", kVar.u("event").j()); jVar3.e("consent_source", "vungle_modal"); jVar3.e("timestamp", Long.valueOf(System.currentTimeMillis() / 1000)); this.f12214l.i0(jVar3, this.f12222t); return true; case 4: this.f12216n.f(null, kVar.u(ImagesContract.URL).j(), new l8.g(this.f12209g, this.f12212j), null); return true; case 5: case 7: M("download", null); if ("open".equalsIgnoreCase(str)) { M("mraidOpen", null); } else if ("openNonMraid".equalsIgnoreCase(str)) { M("nonMraidOpen", null); } String q10 = this.f12210h.q(); String j13 = kVar.u(ImagesContract.URL).j(); if ((q10 == null || q10.isEmpty()) && (j13 == null || j13.isEmpty())) { Log.e(f12202w, "CTA destination URL is not configured properly"); } else { this.f12216n.f(q10, j13, new l8.g(this.f12209g, this.f12212j), new f()); } b.a aVar4 = this.f12209g; if (aVar4 == null) { return true; } aVar4.a("open", "adClick", this.f12212j.d()); return true; case 6: String j14 = kVar.u("useCustomPrivacy").j(); j14.hashCode(); switch (j14.hashCode()) { case 3178655: if (j14.equals("gone")) { c11 = 0; break; } c11 = 65535; break; case 3569038: if (j14.equals("true")) { c11 = 1; break; } c11 = 65535; break; case 97196323: if (j14.equals("false")) { c11 = 2; break; } c11 = 65535; break; default: c11 = 65535; break; } switch (c11) { case 0: case 1: case 2: return true; default: throw new IllegalArgumentException("Unknown value " + j14); } case '\b': this.f12204b.c(this.f12210h.D(kVar.u("event").j())); return true; case '\t': M("mraidClose", null); D(); return true; case '\n': String d10 = m.d(kVar, "code", null); String format = String.format("%s Creative Id: %s", d10, this.f12210h.o()); Log.e(f12202w, "Receive Creative error: " + format); K(d10); v.b(new g(format)); return true; case 11: String j15 = kVar.u("sdkCloseButton").j(); j15.hashCode(); switch (j15.hashCode()) { case -1901805651: if (j15.equals("invisible")) { c12 = 0; break; } c12 = 65535; break; case 3178655: if (j15.equals("gone")) { c12 = 1; break; } c12 = 65535; break; case 466743410: if (j15.equals("visible")) { c12 = 2; break; } c12 = 65535; break; default: c12 = 65535; break; } switch (c12) { case 0: case 1: case 2: return true; default: throw new IllegalArgumentException("Unknown value " + j15); } default: VungleLogger.c(b.class.getSimpleName() + "#processCommand", "Unknown MRAID Command"); return false; } } @Override // m8.b public void e(o8.b bVar) { if (bVar == null) { return; } boolean a10 = bVar.a("incentivized_sent", false); if (a10) { this.f12220r.set(a10); } if (this.f12211i == null) { this.f12216n.close(); VungleLogger.c(b.class.getSimpleName() + "#restoreFromSave", "The advertisement was not started and cannot be restored."); } } @Override // m8.e public void g(MotionEvent motionEvent) { l lVar = this.f12208f; if (lVar != null) { lVar.f(motionEvent); } } @Override // m8.b public void h(o8.b bVar) { if (bVar == null) { return; } this.f12214l.i0(this.f12211i, this.f12222t); bVar.b("saved_report", this.f12211i.c()); bVar.c("incentivized_sent", this.f12220r.get()); } @Override // m8.b public void i(int i10) { boolean z10 = (i10 & 1) != 0; boolean z11 = (i10 & 2) != 0; boolean z12 = (i10 & 4) != 0; this.f12216n.c(); a(false); if (z10 || !z11 || this.f12221s.getAndSet(true)) { return; } p pVar = this.f12213k; if (pVar != null) { pVar.c(null); } if (z12) { M("mraidCloseByApi", null); } this.f12214l.i0(this.f12211i, this.f12222t); b.a aVar = this.f12209g; if (aVar != null) { aVar.a("end", this.f12211i.e() ? "isCTAClicked" : null, this.f12212j.d()); } } @Override // com.vungle.warren.ui.view.p.b public void l(String str, boolean z10) { K(str); VungleLogger.c(b.class.getSimpleName() + "#onReceivedError", str); if (z10) { N(new com.vungle.warren.error.a(38)); } } @Override // m8.b public void o(b.a aVar) { this.f12209g = aVar; } @Override // m8.b public void p(int i10) { c.a aVar = this.f12207e; if (aVar != null) { aVar.a(); } i(i10); this.f12213k.f(null); this.f12216n.q(this.f12205c.c()); } @Override // com.vungle.warren.ui.view.p.b public void q(WebView webView, WebViewRenderProcess webViewRenderProcess) { com.vungle.warren.error.a aVar = new com.vungle.warren.error.a(32); F(aVar); VungleLogger.c(b.class.getSimpleName() + "#onRenderProcessUnresponsive", aVar.getLocalizedMessage()); } @Override // l8.d.a public void r(String str) { str.hashCode(); switch (str) { case "privacy": return; case "close": D(); return; case "download": E(); return; default: throw new IllegalArgumentException("Unknown action " + str); } } @Override // com.vungle.warren.ui.view.p.b public boolean s(WebView webView, boolean z10) { F(new com.vungle.warren.error.a(31)); VungleLogger.c(b.class.getSimpleName() + "onWebRenderingProcessGone", new com.vungle.warren.error.a(31).getLocalizedMessage()); return true; } @Override // m8.b public void start() { if (!this.f12216n.n()) { N(new com.vungle.warren.error.a(31)); return; } this.f12216n.p(); this.f12216n.h(); a(true); } @Override // m8.b public boolean u() { if (!this.f12217o) { return false; } this.f12216n.o("javascript:window.vungle.mraidBridgeExt.requestMRAIDClose()"); return false; } }