package com.ironsource.mediationsdk.demandOnly; import android.text.TextUtils; import android.util.Log; import com.ironsource.el; import com.ironsource.environment.ContextProvider; import com.ironsource.f5; import com.ironsource.i9; import com.ironsource.ji; import com.ironsource.kb; import com.ironsource.mediationsdk.AbstractAdapter; import com.ironsource.mediationsdk.IronSource; import com.ironsource.mediationsdk.d; import com.ironsource.mediationsdk.demandOnly.a; import com.ironsource.mediationsdk.demandOnly.e; import com.ironsource.mediationsdk.demandOnly.m; import com.ironsource.mediationsdk.demandOnly.n; import com.ironsource.mediationsdk.demandOnly.p; import com.ironsource.mediationsdk.logger.IronLog; import com.ironsource.mediationsdk.logger.IronSourceError; import com.ironsource.mediationsdk.model.NetworkSettings; import com.ironsource.mediationsdk.sdk.InterstitialSmashListener; import com.ironsource.mediationsdk.utils.ErrorBuilder; import com.ironsource.mediationsdk.utils.IronSourceConstants; import com.ironsource.mediationsdk.utils.IronSourceUtils; import com.ironsource.mg; import com.ironsource.t4; import com.ironsource.ta; import com.ironsource.v2; import com.ironsource.v4; import com.ironsource.y4; import com.ironsource.ya; import java.util.List; import java.util.Map; import java.util.TimerTask; import org.json.JSONObject; /* loaded from: classes4.dex */ public class g extends m implements n.a, InterstitialSmashListener, t4 { private ta n; private ta o; private ISDemandOnlyInterstitialListener p; private v4 q; private com.ironsource.mediationsdk.e r; private p s; private final mg t; private final mg.a u; public class a extends TimerTask { public a() { } @Override // java.util.TimerTask, java.lang.Runnable public void run() { IronLog.INTERNAL.verbose("load timed out state=" + g.this.k()); g.this.a(new IronSourceError(1052, "load timed out")); } } public class b extends TimerTask { public b() { } @Override // java.util.TimerTask, java.lang.Runnable public void run() { IronLog.INTERNAL.verbose("load timed out state=" + g.this.k()); g.this.a(new IronSourceError(1052, "load timed out")); } } public g(String str, String str2, NetworkSettings networkSettings, ISDemandOnlyInterstitialListener iSDemandOnlyInterstitialListener, long j, AbstractAdapter abstractAdapter, com.ironsource.mediationsdk.e eVar) { super(new v2(networkSettings, networkSettings.getInterstitialSettings(), IronSource.AD_UNIT.INTERSTITIAL), abstractAdapter); this.s = new p.b(); this.t = el.N().k(); this.u = el.I().e(); this.p = iSDemandOnlyInterstitialListener; this.f = j; this.r = eVar; this.a.initInterstitial(str, str2, this.c, this); } private void a(int i, Object[][] objArr) { Map j = j(); if (objArr != null) { try { for (Object[] objArr2 : objArr) { j.put(objArr2[0].toString(), objArr2[1]); } } catch (Exception e) { i9.d().a(e); IronLog.INTERNAL.error("Exception: " + Log.getStackTraceString(e)); } } ji.i().a(new kb(i, new JSONObject(j))); } private void a(IronSourceError ironSourceError, long j) { if (ironSourceError.getErrorCode() == 1158) { a(2213, new Object[][]{new Object[]{IronSourceConstants.EVENTS_DURATION, Long.valueOf(j)}, new Object[]{"errorCode", Integer.valueOf(ironSourceError.getErrorCode())}}); } else { a(2200, new Object[][]{new Object[]{IronSourceConstants.EVENTS_DURATION, Long.valueOf(j)}, new Object[]{"errorCode", Integer.valueOf(ironSourceError.getErrorCode())}, new Object[]{"reason", ironSourceError.getErrorMessage()}}); } } private void a(List list, String str) { a(list, h(), i(), this.j, str); } private void c(o oVar) { this.n = new ta(); a(new a()); if (!n()) { a(new IronSourceError(2303, "loadInterstitialWithAdm: must be called by bidder instance")); return; } try { d.a aVar = (d.a) oVar.a(new ya()); f5 a2 = new a.C0173a(aVar.h()).a(h()); if (a2 == null) { IronSourceError buildLoadFailedError = ErrorBuilder.buildLoadFailedError("loadInterstitialWithAdm invalid enriched adm"); a(2303, (Object[][]) null); a(buildLoadFailedError); return; } String j = a2.j(); if (j == null) { IronLog.INTERNAL.error("serverData is null"); a(new IronSourceError(e.a.i, "No available ad to load")); return; } b(j); a(aVar.a()); a(aVar.f()); a(82002, (Object[][]) null); this.q.a(a2.b()); this.o = new ta(); this.a.loadInterstitialForBidding(this.c, null, j, this); } catch (Exception e) { i9.d().a(e); a(ErrorBuilder.buildLoadFailedError("loadInterstitialWithAdm: Exception= " + e.getMessage())); } } private void c(String str) { IronLog ironLog = IronLog.INTERNAL; ironLog.verbose(); if (a(m.a.LOAD_IN_PROGRESS)) { if (str == null) { ironLog.verbose("serverData is null"); a(new IronSourceError(e.a.i, "No available ad to load")); } else { a(82002, (Object[][]) null); this.a.loadInterstitialForBidding(this.c, null, str, this); } } } private com.ironsource.mediationsdk.i q() { String str = i() + h(); com.ironsource.mediationsdk.i iVar = new com.ironsource.mediationsdk.i(this.m); iVar.b(IronSourceUtils.isEncryptedResponse()); iVar.a(true); iVar.c(true); iVar.d(str); iVar.c(l()); iVar.a(this.t.a(this.m)); y4 y4Var = new y4(h(), false); y4Var.a(this.s.value()); Map interstitialBiddingData = this.a.getInterstitialBiddingData(this.c, new JSONObject()); if (interstitialBiddingData != null) { y4Var.b(interstitialBiddingData); } iVar.a(y4Var); return iVar; } private void r() { this.o = new ta(); this.a.loadInterstitial(this.c, null, this); } private void s() { if (!this.r.a()) { IronLog.INTERNAL.verbose("can't load the interstitial the auction isn't enabled"); a(new IronSourceError(1063, "Missing server configuration")); return; } a(82500, (Object[][]) null); com.ironsource.mediationsdk.i q = q(); IronLog.INTERNAL.verbose("auction waterfallString = " + q.q()); a(82510, new Object[][]{new Object[]{IronSourceConstants.EVENTS_EXT1, q.q()}}); this.r.a(ContextProvider.getInstance().getApplicationContext(), q, this); } private void t() { this.g = null; this.h = null; this.j = null; this.q = new v4(); } private void u() { this.n = new ta(); a(new b()); if (n()) { IronSourceError buildLoadFailedError = ErrorBuilder.buildLoadFailedError("loadInterstitial must be called by non bidder instances"); a(2303, (Object[][]) null); a(buildLoadFailedError); } else if (o()) { s(); } else { r(); } } @Override // com.ironsource.l4 public void a(int i, String str, int i2, String str2, long j) { IronLog.INTERNAL.verbose("error " + i + " - " + str); this.g = null; this.h = null; a(82300, new Object[][]{new Object[]{"errorCode", Integer.valueOf(i)}, new Object[]{"reason", str}, new Object[]{IronSourceConstants.EVENTS_DURATION, Long.valueOf(j)}, new Object[]{IronSourceConstants.EVENTS_EXT1, k()}}); if (a(m.a.LOAD_IN_PROGRESS)) { a(new IronSourceError(e.a.j, "No available ad to load")); } } @Override // com.ironsource.t4 public void a(d.a aVar, int i, long j, int i2, String str) { String str2; IronLog ironLog = IronLog.INTERNAL; ironLog.verbose(); this.g = aVar.a(); this.h = aVar.f(); this.s = aVar.a(l()); a.C0173a c0173a = new a.C0173a(aVar.h()); if (c0173a.isEmpty()) { str2 = ""; } else { f5 f5Var = c0173a.get(0); this.q.a(f5Var.b()); this.q.c(f5Var.g()); this.q.b(f5Var.f()); str2 = f5Var.j(); b(str2); } if (!TextUtils.isEmpty(str)) { a(88002, new Object[][]{new Object[]{"errorCode", Integer.valueOf(i2)}, new Object[]{"reason", str}}); } a(82301, new Object[][]{new Object[]{IronSourceConstants.EVENTS_DURATION, Long.valueOf(j)}}); a(82302, new Object[][]{new Object[]{IronSourceConstants.EVENTS_EXT1, c0173a.b()}}); if (a(m.a.LOAD_IN_PROGRESS)) { if (!c0173a.isEmpty()) { c(str2); return; } IronSourceError ironSourceError = new IronSourceError(1158, "There is no available ad to load"); ironLog.error("interstitial - empty waterfall"); a(ironSourceError); } } @Override // com.ironsource.mediationsdk.demandOnly.n.a public void a(o oVar) { IronLog.INTERNAL.verbose("state=" + k()); m.a aVar = m.a.NOT_LOADED; m.a aVar2 = m.a.LOADED; m.a aVar3 = m.a.LOAD_IN_PROGRESS; m.a a2 = a(new m.a[]{aVar, aVar2}, aVar3); if (a2 != aVar && a2 != aVar2) { a(new IronSourceError(1050, a2 == aVar3 ? "load already in progress" : "cannot load because show is in progress")); return; } t(); a(2002, (Object[][]) null); c(oVar); } public void a(IronSourceError ironSourceError) { IronLog.INTERNAL.verbose("instanceName = " + h() + ", error = " + ironSourceError.getErrorMessage()); p(); if (a(m.a.LOAD_IN_PROGRESS, m.a.NOT_LOADED)) { a(ironSourceError, ta.a(this.n)); a(this.q.b(), IronSourceUtils.getCurrentMethodName()); this.p.onInterstitialAdLoadFailed(l(), ironSourceError); } } @Override // com.ironsource.l4 public void a(List list, String str, f5 f5Var, JSONObject jSONObject, JSONObject jSONObject2, int i, long j, int i2, String str2) { IronLog.INTERNAL.error("Deprecated: Please use onAuctionSuccess(AuctionDataUtils.AuctionData auctionData, int auctionTrial, long elapsedTime, int troubleshootingErrorCode, String troubleshootingErrorMessage)"); } @Override // com.ironsource.mediationsdk.demandOnly.n.a public boolean a() { boolean z = false; if (!a(m.a.LOADED)) { a(2212, (Object[][]) null); return false; } try { z = this.a.isInterstitialReady(this.c); a(z ? 2211 : 2212, (Object[][]) null); } catch (Exception e) { i9.d().a(e); IronLog.INTERNAL.error("exception=" + e.getMessage()); } return z; } @Override // com.ironsource.mediationsdk.demandOnly.n.a public void b() { IronLog.INTERNAL.verbose("instanceName = " + h() + ", state=" + k()); a(2201, (Object[][]) null); m.a aVar = m.a.LOADED; m.a aVar2 = m.a.SHOW_IN_PROGRESS; if (a(aVar, aVar2)) { this.a.showInterstitial(this.c, this); } else { onInterstitialAdShowFailed(a(aVar2) ? new IronSourceError(1064, "showInterstitial error: can't show ad while an ad is already showing") : a(m.a.LOAD_IN_PROGRESS) ? new IronSourceError(1065, "showInterstitial error: can't show ad while an ad is loading") : new IronSourceError(1066, "showInterstitial error: no available ads to show")); } } @Override // com.ironsource.mediationsdk.demandOnly.n.a public void c() { IronLog.INTERNAL.verbose("state=" + k()); m.a aVar = m.a.NOT_LOADED; m.a aVar2 = m.a.LOADED; m.a aVar3 = m.a.LOAD_IN_PROGRESS; m.a a2 = a(new m.a[]{aVar, aVar2}, aVar3); if (a2 != aVar && a2 != aVar2) { this.p.onInterstitialAdLoadFailed(l(), new IronSourceError(1050, a2 == aVar3 ? "load already in progress" : "cannot load because show is in progress")); return; } t(); a(2002, (Object[][]) null); u(); } @Override // com.ironsource.mediationsdk.sdk.InterstitialSmashListener public void onInterstitialAdClicked() { IronLog.ADAPTER_CALLBACK.verbose("instance name= " + h()); a(2006, new Object[0][]); this.p.onInterstitialAdClicked(l()); } @Override // com.ironsource.mediationsdk.sdk.InterstitialSmashListener public void onInterstitialAdClosed() { b(m.a.NOT_LOADED); IronLog.ADAPTER_CALLBACK.verbose("instance name= " + h()); a(2204, new Object[][]{new Object[]{"sessionDepth", Integer.valueOf(this.t.a(this.m))}}); this.u.b(this.m); this.p.onInterstitialAdClosed(l()); } @Override // com.ironsource.mediationsdk.sdk.InterstitialSmashListener public void onInterstitialAdLoadFailed(IronSourceError ironSourceError) { IronLog.ADAPTER_CALLBACK.verbose("error=" + ironSourceError.getErrorMessage() + " instance name= " + h() + " state=" + k()); a(e.c.d, new Object[][]{new Object[]{"errorCode", Integer.valueOf(ironSourceError.getErrorCode())}, new Object[]{"reason", ironSourceError.getErrorMessage()}, new Object[]{IronSourceConstants.EVENTS_DURATION, Long.valueOf(ta.a(this.o))}}); a(ironSourceError); } @Override // com.ironsource.mediationsdk.sdk.InterstitialSmashListener public void onInterstitialAdOpened() { IronLog.ADAPTER_CALLBACK.verbose("instance name= " + h()); a(2005, new Object[0][]); a(this.q.a(), IronSourceUtils.getCurrentMethodName()); this.p.onInterstitialAdOpened(l()); } @Override // com.ironsource.mediationsdk.sdk.InterstitialSmashListener public void onInterstitialAdReady() { IronLog.ADAPTER_CALLBACK.verbose("instance name= " + h() + " state=" + k()); p(); a(e.c.c, new Object[][]{new Object[]{IronSourceConstants.EVENTS_DURATION, Long.valueOf(ta.a(this.o))}}); if (a(m.a.LOAD_IN_PROGRESS, m.a.LOADED)) { a(2003, new Object[][]{new Object[]{IronSourceConstants.EVENTS_DURATION, Long.valueOf(ta.a(this.n))}}); a(this.q.c(), IronSourceUtils.getCurrentMethodName()); this.p.onInterstitialAdReady(l()); } } @Override // com.ironsource.mediationsdk.sdk.InterstitialSmashListener public void onInterstitialAdShowFailed(IronSourceError ironSourceError) { IronLog.ADAPTER_CALLBACK.verbose("error=" + ironSourceError.toString() + " instance name= " + h() + " state=" + k()); b(m.a.NOT_LOADED); a(2203, new Object[][]{new Object[]{"errorCode", Integer.valueOf(ironSourceError.getErrorCode())}, new Object[]{"reason", ironSourceError.getErrorMessage()}}); this.p.onInterstitialAdShowFailed(l(), ironSourceError); } @Override // com.ironsource.mediationsdk.sdk.InterstitialSmashListener public void onInterstitialAdShowSucceeded() { } @Override // com.ironsource.mediationsdk.sdk.InterstitialSmashListener public void onInterstitialAdVisible() { IronLog.ADAPTER_CALLBACK.verbose("instance name= " + h()); a(2210, new Object[0][]); } @Override // com.ironsource.mediationsdk.sdk.InterstitialSmashListener public void onInterstitialInitFailed(IronSourceError ironSourceError) { } @Override // com.ironsource.mediationsdk.sdk.InterstitialSmashListener public void onInterstitialInitSuccess() { } }