package com.fyber.inneractive.sdk.flow; import android.text.TextUtils; import android.webkit.WebView; import com.fyber.inneractive.sdk.config.IAConfigManager; import com.fyber.inneractive.sdk.external.InneractiveAdRequest; import com.fyber.inneractive.sdk.external.InneractiveErrorCode; import com.fyber.inneractive.sdk.external.InneractiveInfrastructureError; import com.fyber.inneractive.sdk.external.InneractiveVideoError; import com.fyber.inneractive.sdk.network.s; import com.fyber.inneractive.sdk.player.a; import com.fyber.inneractive.sdk.player.h; import com.fyber.inneractive.sdk.util.IAlog; import com.iab.omid.library.fyber.adsession.AdEvents; import com.iab.omid.library.fyber.adsession.AdSession; import com.iab.omid.library.fyber.adsession.AdSessionConfiguration; import com.iab.omid.library.fyber.adsession.AdSessionContext; import com.iab.omid.library.fyber.adsession.CreativeType; import com.iab.omid.library.fyber.adsession.ImpressionType; import com.iab.omid.library.fyber.adsession.Owner; import com.iab.omid.library.fyber.adsession.media.MediaEvents; import com.iab.omid.library.fyber.publisher.AdSessionStatePublisher; import java.util.ArrayList; import java.util.HashMap; import java.util.Iterator; /* loaded from: classes2.dex */ public final class o extends h implements h.b { public com.fyber.inneractive.sdk.player.h m; public String n; public final a o = new a(); public class a implements com.fyber.inneractive.sdk.network.w { public a() { } @Override // com.fyber.inneractive.sdk.network.w public final void a(String str, Exception exc, boolean z) { com.fyber.inneractive.sdk.player.ui.remote.g gVar; a.InterfaceC0079a interfaceC0079a; String str2 = str; IAlog.a("IAVideoContentLoader : Remote ui template callback onNetworkResult from cache: %s", Boolean.valueOf(z)); o oVar = o.this; oVar.getClass(); if (TextUtils.isEmpty(str2) && z) { String concat = "Fetched cached template is ".concat(str2 == null ? "null" : "empty"); HashMap hashMap = new HashMap(); hashMap.put("description", concat); if (exc != null) { hashMap.put("exception", exc.getMessage()); } com.fyber.inneractive.sdk.player.ui.remote.e.a(com.fyber.inneractive.sdk.web.remoteui.a.TEMPLATE_CONTENT_ERROR, oVar.n, oVar.a, oVar.b, hashMap); return; } com.fyber.inneractive.sdk.player.h hVar = oVar.m; if (hVar == null || (interfaceC0079a = hVar.f) == null || (gVar = ((com.fyber.inneractive.sdk.player.e) interfaceC0079a).B) == null) { gVar = null; } if (gVar == null) { HashMap hashMap2 = new HashMap(); hashMap2.put("description", "Flow Manager is null"); com.fyber.inneractive.sdk.player.ui.remote.e.a(com.fyber.inneractive.sdk.web.remoteui.a.TEMPLATE_CONTENT_ERROR, oVar.n, oVar.a, oVar.b, hashMap2); return; } if (!TextUtils.isEmpty(str2)) { com.fyber.inneractive.sdk.player.ui.remote.b bVar = gVar.a; bVar.getClass(); IAlog.a("%s : schedule UI load timeout task with delay: %d", "RemoteUIWebviewController", 10000); com.fyber.inneractive.sdk.util.p.b.postDelayed(bVar.j, 10000); bVar.b.loadData(str2, "text/html", "UTF-8"); return; } StringBuilder sb = new StringBuilder("Unknown error while receiving template: templateContent is: "); sb.append(TextUtils.isEmpty(str2) ? "null or empty" : "not null and not empty"); sb.append(" isFromCache: "); sb.append(z); String sb2 = sb.toString(); HashMap hashMap3 = new HashMap(); hashMap3.put("description", sb2); if (exc != null) { hashMap3.put("exception", exc.getMessage()); } com.fyber.inneractive.sdk.player.ui.remote.e.a(com.fyber.inneractive.sdk.web.remoteui.a.TEMPLATE_CONTENT_ERROR, oVar.n, oVar.a, oVar.b, hashMap3); } } @Override // com.fyber.inneractive.sdk.flow.h public final String d() { return "send_failed_vast_creatives"; } @Override // com.fyber.inneractive.sdk.flow.h public final void g() { com.fyber.inneractive.sdk.model.vast.b bVar; AdSessionConfiguration adSessionConfiguration; com.fyber.inneractive.sdk.network.q qVar; com.fyber.inneractive.sdk.model.vast.b bVar2; IAlog.a(IAlog.a(this) + "start called", new Object[0]); com.fyber.inneractive.sdk.config.f0 e = e(); Response response = this.b; AdSessionContext adSessionContext = null; com.fyber.inneractive.sdk.model.vast.b bVar3 = response == 0 ? null : ((com.fyber.inneractive.sdk.response.g) response).L; if (bVar3 != null && bVar3.d.size() < bVar3.j) { bVar3.d.clear(); bVar3.g.clear(); bVar3.d.addAll(bVar3.l); bVar3.g.addAll(bVar3.m); } g0 g0Var = new g0(e, this.g, (com.fyber.inneractive.sdk.response.g) this.b, this.a); this.c = g0Var; com.fyber.inneractive.sdk.response.g gVar = (com.fyber.inneractive.sdk.response.g) this.b; InneractiveAdRequest inneractiveAdRequest = this.a; com.fyber.inneractive.sdk.player.h hVar = new com.fyber.inneractive.sdk.player.h(gVar, inneractiveAdRequest, g0Var, this); this.m = hVar; g0 g0Var2 = (g0) this.c; g0Var2.i = hVar; g0Var2.f = this.h; this.n = bVar3 != null ? bVar3.o : null; hVar.e = null; if (gVar != null && (bVar2 = gVar.L) != null) { hVar.e = bVar2.d.poll(); } if (hVar.e == null) { InneractiveVideoError.Error playerError = new InneractiveVideoError(InneractiveVideoError.Error.ERROR_FAILED_PLAYING_ALL_MEDIA_FILES).getPlayerError(); int i = h.a.a[playerError.ordinal()]; if (i == 1) { qVar = com.fyber.inneractive.sdk.network.q.VAST_ERROR_NO_MEDIA_FILES; } else if (i == 2) { qVar = com.fyber.inneractive.sdk.network.q.VAST_ERROR_FAILED_PLAYING_MEDIA_FILE; } else if (i == 3) { qVar = com.fyber.inneractive.sdk.network.q.VAST_ERROR_FAILED_PLAYING_ALL_MEDIA_FILES; } else if (i == 4) { qVar = com.fyber.inneractive.sdk.network.q.VAST_ERROR_PRE_BUFFER_TIMEOUT; } else if (i != 5) { IAlog.a("IAReportError, Does not know player error " + playerError.getErrorString(), new Object[0]); qVar = com.fyber.inneractive.sdk.network.q.VAST_UNKNOWN_PLAYER_ERROR; } else { qVar = com.fyber.inneractive.sdk.network.q.VAST_ERROR_BUFFER_TIMEOUT; } new s.a(qVar, inneractiveAdRequest, gVar, hVar.h.c()).a((String) null); InneractiveInfrastructureError inneractiveInfrastructureError = new InneractiveInfrastructureError(InneractiveErrorCode.SDK_INTERNAL_ERROR, g.VAST_NO_MEDIA_FILES); b(inneractiveInfrastructureError); a(inneractiveInfrastructureError); } else { try { hVar.f = hVar.a.a(); } catch (Throwable th) { h.b bVar4 = hVar.d; InneractiveInfrastructureError inneractiveInfrastructureError2 = new InneractiveInfrastructureError(InneractiveErrorCode.SDK_INTERNAL_ERROR, g.COULD_NOT_CREATE_FLOW_MANAGER, th); o oVar = (o) bVar4; oVar.b(inneractiveInfrastructureError2); oVar.a(inneractiveInfrastructureError2); } a.InterfaceC0079a interfaceC0079a = hVar.f; if (interfaceC0079a != null) { com.fyber.inneractive.sdk.player.e eVar = (com.fyber.inneractive.sdk.player.e) interfaceC0079a; if (eVar.g != null) { com.fyber.inneractive.sdk.measurement.d dVar = new com.fyber.inneractive.sdk.measurement.d(); com.fyber.inneractive.sdk.measurement.a aVar = eVar.g; ArrayList arrayList = eVar.v.e; g0 g0Var3 = eVar.e; try { try { CreativeType creativeType = CreativeType.VIDEO; ImpressionType impressionType = ImpressionType.UNSPECIFIED; Owner owner = Owner.NATIVE; adSessionConfiguration = AdSessionConfiguration.createAdSessionConfiguration(creativeType, impressionType, owner, owner, false); } catch (Throwable th2) { dVar.a(th2); } } catch (Throwable th3) { dVar.a(th3); adSessionConfiguration = null; } ArrayList a2 = dVar.a(arrayList); if (((com.fyber.inneractive.sdk.measurement.b) aVar).e != null && ((com.fyber.inneractive.sdk.measurement.b) aVar).b != null) { try { adSessionContext = AdSessionContext.createNativeAdSessionContext(((com.fyber.inneractive.sdk.measurement.b) aVar).e, ((com.fyber.inneractive.sdk.measurement.b) aVar).b, a2, "", ""); } catch (Throwable th4) { dVar.a(th4); } } AdSession createAdSession = AdSession.createAdSession(adSessionConfiguration, adSessionContext); dVar.a = createAdSession; AdSessionStatePublisher adSessionStatePublisher = createAdSession.getAdSessionStatePublisher(); if (adSessionStatePublisher != null) { adSessionStatePublisher.getWebView(); WebView webView = adSessionStatePublisher.getWebView(); if (webView != null) { webView.setWebViewClient(dVar.g); } } dVar.b = AdEvents.createAdEvents(dVar.a); dVar.c = MediaEvents.createMediaEvents(dVar.a); dVar.a.start(); dVar.f = g0Var3; eVar.h = dVar; eVar.i = new com.fyber.inneractive.sdk.player.f(dVar); } if (eVar.h == null && (bVar = eVar.v) != null) { Iterator it = bVar.e.iterator(); while (it.hasNext()) { com.fyber.inneractive.sdk.measurement.f fVar = (com.fyber.inneractive.sdk.measurement.f) it.next(); com.fyber.inneractive.sdk.measurement.g gVar2 = com.fyber.inneractive.sdk.measurement.g.ERROR_DURING_RESOURCE_LOAD; com.fyber.inneractive.sdk.model.vast.v vVar = com.fyber.inneractive.sdk.model.vast.v.EVENT_VERIFICATION_NOT_EXECUTED; com.fyber.inneractive.sdk.player.e.a(new com.fyber.inneractive.sdk.measurement.e(fVar.a(vVar), gVar2), vVar); } } } hVar.c(); } if (TextUtils.isEmpty(this.n)) { return; } IAConfigManager.L.r.a(new com.fyber.inneractive.sdk.network.g0(this.o, com.fyber.inneractive.sdk.util.o.a, new com.fyber.inneractive.sdk.cache.j(this.n))); } @Override // com.fyber.inneractive.sdk.flow.h, com.fyber.inneractive.sdk.interfaces.a public final void cancel() { IAlog.a("%s: IAAdContentLoaderImpl : cancel load ad content retry task", IAlog.a(this)); com.fyber.inneractive.sdk.util.p.b.removeCallbacks(this.l); this.k.a(); com.fyber.inneractive.sdk.player.h hVar = this.m; if (hVar != null) { hVar.a(); } } @Override // com.fyber.inneractive.sdk.flow.h, com.fyber.inneractive.sdk.interfaces.a.b public final void b() { InneractiveVideoError inneractiveVideoError; com.fyber.inneractive.sdk.model.vast.b bVar; if (this.m != null) { Response response = this.b; if (response == 0 || (bVar = ((com.fyber.inneractive.sdk.response.g) response).L) == null) { inneractiveVideoError = null; } else if (bVar.d.size() == 0) { inneractiveVideoError = new InneractiveVideoError(InneractiveVideoError.Error.ERROR_FAILED_PLAYING_ALL_MEDIA_FILES, null); } else { inneractiveVideoError = new InneractiveVideoError(InneractiveVideoError.Error.ERROR_FAILED_PLAYING_MEDIA_FILE, null); } this.m.a(inneractiveVideoError, null, true); } cancel(); super.b(); } }