package com.fyber.inneractive.sdk.flow; import android.app.Application; import android.content.SharedPreferences; import com.fyber.inneractive.sdk.config.IAConfigManager; import com.fyber.inneractive.sdk.external.InneractiveAdRequest; import com.fyber.inneractive.sdk.external.InneractiveInfrastructureError; import com.fyber.inneractive.sdk.network.s; import com.fyber.inneractive.sdk.util.IAlog; import java.util.Collection; import java.util.Map; import java.util.concurrent.CopyOnWriteArrayList; import org.json.JSONArray; import org.json.JSONException; import org.json.JSONObject; /* loaded from: classes2.dex */ public final class c implements Runnable { public final /* synthetic */ InneractiveInfrastructureError a; public final /* synthetic */ d b; public c(d dVar, InneractiveInfrastructureError inneractiveInfrastructureError) { this.b = dVar; this.a = inneractiveInfrastructureError; } @Override // java.lang.Runnable public final void run() { String str; String str2; T t = this.b.b; if (t == 0 || (str = t.h) == null) { return; } Map map = t.p; if (map == null && t.q == null) { return; } com.fyber.inneractive.sdk.config.k kVar = IAConfigManager.L.t.b; String a = kVar.a("max_failed_creatives_interval_hours", d.e); String a2 = kVar.a("max_failed_creatives_per_interval", d.f); int a3 = com.fyber.inneractive.sdk.util.t.a(a, 24); int a4 = com.fyber.inneractive.sdk.util.t.a(a2, 1); Application application = com.fyber.inneractive.sdk.util.o.a; if (application != null) { SharedPreferences sharedPreferences = application.getSharedPreferences("IAConfigPrefs", 0); JSONArray jSONArray = new JSONArray(); try { jSONArray = new JSONArray(sharedPreferences.getString("lt", "[]")); } catch (JSONException unused) { } CopyOnWriteArrayList copyOnWriteArrayList = new CopyOnWriteArrayList(); if (kVar.a(false, this.b.a) && !com.fyber.inneractive.sdk.metrics.a.a(a3, a4, jSONArray, copyOnWriteArrayList)) { copyOnWriteArrayList.add(Long.valueOf(System.currentTimeMillis())); if (map != null) { try { str2 = new JSONObject(map).toString(); } catch (Throwable unused2) { str2 = ""; } } else { str2 = this.b.b.q; } d dVar = this.b; InneractiveAdRequest inneractiveAdRequest = dVar.c; T t2 = dVar.b; InneractiveInfrastructureError inneractiveInfrastructureError = this.a; s.a aVar = new s.a(com.fyber.inneractive.sdk.network.q.IA_AD_FAILURE_DATA, inneractiveAdRequest, t2, dVar.d); JSONObject jSONObject = new JSONObject(); try { jSONObject.put("raw_response", str); } catch (Exception unused3) { IAlog.f("Got exception adding param to json object: %s, %s", "raw_response", str); } try { jSONObject.put("headers", str2); } catch (Exception unused4) { IAlog.f("Got exception adding param to json object: %s, %s", "headers", str2); } String description = inneractiveInfrastructureError.description(); try { jSONObject.put("error_code", description); } catch (Exception unused5) { IAlog.f("Got exception adding param to json object: %s, %s", "error_code", description); } aVar.f.put(jSONObject); aVar.a((String) null); } sharedPreferences.edit().putString("lt", new JSONArray((Collection) copyOnWriteArrayList).toString()).apply(); } } }