package com.fyber.inneractive.sdk.util; import android.text.TextUtils; import com.fyber.inneractive.sdk.external.InneractiveAdSpot; import com.fyber.inneractive.sdk.network.s; import java.util.Locale; import java.util.concurrent.TimeUnit; import org.json.JSONObject; /* loaded from: classes2.dex */ public final class a { public InneractiveAdSpot a; public boolean c; public boolean b = false; public long d = 0; public long e = 0; public long f = 0; public final void a(boolean z) { this.c = z; if (!this.b) { Object[] objArr = new Object[2]; objArr[0] = "AdExperienceLatency: "; objArr[1] = z ? "skip" : "close"; IAlog.a("%s%s timer started", objArr); this.d = System.currentTimeMillis(); this.b = true; return; } Object[] objArr2 = new Object[2]; objArr2[0] = "AdExperienceLatency: "; objArr2[1] = z ? "skip" : "close"; IAlog.a("%s%s timer could not start. Timer is in action!", objArr2); } public final void a(String str) { com.fyber.inneractive.sdk.config.global.s sVar; if (this.b) { long currentTimeMillis = (System.currentTimeMillis() - this.d) - this.f; TimeUnit timeUnit = TimeUnit.MILLISECONDS; long seconds = timeUnit.toSeconds(currentTimeMillis); String format = String.format(Locale.US, "%d.%d", Long.valueOf(seconds), Long.valueOf(timeUnit.toMillis(currentTimeMillis - TimeUnit.SECONDS.toMillis(seconds)))); InneractiveAdSpot inneractiveAdSpot = this.a; com.fyber.inneractive.sdk.flow.q adContent = inneractiveAdSpot != null ? inneractiveAdSpot.getAdContent() : null; s.a aVar = new s.a(this.c ? com.fyber.inneractive.sdk.network.r.USER_SKIP_ACTION_LATENCY : com.fyber.inneractive.sdk.network.r.USER_CLOSE_ACTION_LATENCY, adContent != null ? adContent.a : null, adContent != null ? adContent.d() : null, (adContent == null || (sVar = adContent.c) == null) ? null : sVar.c()); JSONObject jSONObject = new JSONObject(); String str2 = this.c ? "skip_action_latency" : "close_action_latency"; try { jSONObject.put(str2, format); } catch (Exception unused) { IAlog.f("Got exception adding param to json object: %s, %s", str2, format); } if (!TextUtils.isEmpty(str)) { try { jSONObject.put("origin", str); } catch (Exception unused2) { IAlog.f("Got exception adding param to json object: %s, %s", "origin", str); } } aVar.f.put(jSONObject); aVar.a((String) null); this.d = 0L; this.e = 0L; this.f = 0L; this.b = false; } } }