package com.fyber.inneractive.sdk.flow; import android.text.TextUtils; import com.fyber.inneractive.sdk.config.IAConfigManager; import com.fyber.inneractive.sdk.config.enums.UnitDisplayType; import com.fyber.inneractive.sdk.external.InneractiveAdManager; 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.flow.k; import com.fyber.inneractive.sdk.network.k; import com.fyber.inneractive.sdk.network.s; import com.fyber.inneractive.sdk.util.IAlog; import java.util.HashMap; import org.json.JSONArray; import org.json.JSONObject; /* loaded from: classes2.dex */ public final class j extends k { public i g; public j(String str) { super(str); } public static void a(boolean z, com.fyber.inneractive.sdk.response.e eVar, InneractiveAdRequest inneractiveAdRequest) { String spotId = inneractiveAdRequest.getSpotId(); IAConfigManager iAConfigManager = IAConfigManager.L; String str = (String) iAConfigManager.w.c.get("KEY_MISSMATCH_STATS_SPOTS"); if (TextUtils.isEmpty(str)) { str = ""; } if (str.contains(String.format("-%s-", spotId))) { return; } s.a aVar = new s.a(com.fyber.inneractive.sdk.network.q.MISSMATCH_SPOTID, inneractiveAdRequest, eVar, (JSONArray) null); String format = z ? String.format("There is no %s spot ID in current app config", spotId) : String.format("spot ID %s is not active in current app config", spotId); JSONObject jSONObject = new JSONObject(); try { jSONObject.put("reason", format); } catch (Exception unused) { IAlog.f("Got exception adding param to json object: %s, %s", "reason", format); } aVar.f.put(jSONObject); aVar.a((String) null); iAConfigManager.w.c.put("KEY_MISSMATCH_STATS_SPOTS", String.format("%s -%s-", str, spotId)); } public final void c(InneractiveAdRequest inneractiveAdRequest) { k.a aVar; com.fyber.inneractive.sdk.config.g0 g0Var; UnitDisplayType unitDisplayType; k.a aVar2; if (!InneractiveAdManager.wasInitialized() && (aVar2 = this.b) != null) { ((u) aVar2).a(inneractiveAdRequest, new InneractiveInfrastructureError(InneractiveErrorCode.SDK_NOT_INITIALIZED, g.NO_APP_CONFIG_AVAILABLE), c()); } String spotId = inneractiveAdRequest.getSpotId(); IAConfigManager iAConfigManager = IAConfigManager.L; HashMap hashMap = iAConfigManager.a; com.fyber.inneractive.sdk.config.d0 d0Var = (hashMap == null || !hashMap.containsKey(spotId)) ? null : (com.fyber.inneractive.sdk.config.d0) iAConfigManager.a.get(spotId); com.fyber.inneractive.sdk.response.e c = c(); if (d0Var != null && !d0Var.b) { a(false, c, inneractiveAdRequest); ((u) this.b).a(inneractiveAdRequest, new InneractiveInfrastructureError(InneractiveErrorCode.SPOT_DISABLED, g.NO_APP_CONFIG_AVAILABLE), c()); return; } if (d0Var == null || !d0Var.a.iterator().hasNext()) { if (d0Var == null) { a(true, c, inneractiveAdRequest); IAConfigManager.a(); } IAlog.f("************************************************************************************************************************", new Object[0]); IAlog.f("*** Requested spot id '%s' doesn't exist within this application config - application Id: '%s'", inneractiveAdRequest.getSpotId(), iAConfigManager.c); IAlog.f("*** Are you sure that you are using the correct application and spot ids, as defined for this application in the Inneractive console?", new Object[0]); IAlog.f("************************************************************************************************************************", new Object[0]); ((u) this.b).a(inneractiveAdRequest, new InneractiveInfrastructureError(InneractiveErrorCode.ERROR_CONFIGURATION_NO_SUCH_SPOT, g.NO_APP_CONFIG_AVAILABLE), c); return; } com.fyber.inneractive.sdk.config.e0 e0Var = (com.fyber.inneractive.sdk.config.e0) d0Var.a.get(0); if (e0Var.c == null && ((g0Var = e0Var.f) == null || !((unitDisplayType = g0Var.j) == UnitDisplayType.INTERSTITIAL || unitDisplayType == UnitDisplayType.REWARDED))) { ((u) this.b).a(inneractiveAdRequest, new InneractiveInfrastructureError(InneractiveErrorCode.UNSUPPORTED_SPOT, g.NO_APP_CONFIG_AVAILABLE), c()); return; } com.fyber.inneractive.sdk.config.global.s b = com.fyber.inneractive.sdk.config.global.s.b(); this.c = b; b.a(false, inneractiveAdRequest.getSpotId()); com.fyber.inneractive.sdk.network.p pVar = new com.fyber.inneractive.sdk.network.p(inneractiveAdRequest, inneractiveAdRequest.b, this.c, this); this.d = pVar; pVar.b = false; IAlog.a("IARemoteAdFetcher: requestAd called", new Object[0]); if (TextUtils.isEmpty(inneractiveAdRequest.getSpotId())) { IAlog.b("appID is null or empty. Please provide a valid appID and re-try.", new Object[0]); } else { if (com.fyber.inneractive.sdk.util.o.b("android.permission.INTERNET")) { if (!com.fyber.inneractive.sdk.util.o.b("android.permission.ACCESS_NETWORK_STATE")) { IAlog.b("It is recommended to add ACCESS_NETWORK_STATE permission to the Manifest for better targetting", new Object[0]); } if (!com.fyber.inneractive.sdk.util.o.b("android.permission.READ_PHONE_STATE")) { IAlog.f("It is recomended to add the READ_PHONE_STATE permission to the manifest for better targetting", new Object[0]); } iAConfigManager.r.a(pVar.f); return; } IAlog.b("INTERNET permission is missing. Please add it to the Manifest and re-try, otherwise ads will not be requested and displayed! ", new Object[0]); } InneractiveInfrastructureError inneractiveInfrastructureError = new InneractiveInfrastructureError(InneractiveErrorCode.INVALID_INPUT, g.VALIDATE_PARAMS_FAILED, new Exception("appID is null or empty or INTERNET permission is missing")); if (pVar.b || (aVar = pVar.a) == null) { return; } ((k) aVar).a(inneractiveAdRequest, inneractiveInfrastructureError, null); } @Override // com.fyber.inneractive.sdk.flow.k public final String d() { return IAlog.a(this); } public final void b(boolean z) { i iVar = this.g; if (iVar != null) { IAConfigManager.removeListener(iVar); } com.fyber.inneractive.sdk.network.k kVar = this.d; if (kVar != null) { kVar.a(); this.d = null; } a(z); this.b = null; } @Override // com.fyber.inneractive.sdk.interfaces.a.b public final void b() { IAlog.a("%s onTimeout()", IAlog.a(this)); } @Override // com.fyber.inneractive.sdk.interfaces.a.b public final void a() { IAlog.a("%s onRetry()", IAlog.a(this)); } }