package com.fyber.inneractive.sdk.network; import android.content.Context; import android.content.SharedPreferences; import android.text.TextUtils; import com.fyber.inneractive.sdk.config.IAConfigManager; import com.fyber.inneractive.sdk.network.s; import com.fyber.inneractive.sdk.util.IAlog; import java.util.Calendar; import java.util.TimeZone; import org.json.JSONObject; /* loaded from: classes2.dex */ public final class u { public SharedPreferences a = null; public static final class a { public static final u a = new u(); } public static void a(Context context, String str, String str2, com.fyber.inneractive.sdk.flow.q qVar) { int i; if (context == null || str == null || qVar.d() == null) { IAlog.a("Invalid report request parameters!", new Object[0]); return; } u uVar = a.a; if (uVar.a == null) { uVar.a = context.getSharedPreferences("AutoWebActionPrefs", 0); } IAlog.e("IAautoWebActionReporter: reporting action: %s", str); IAlog.e("IAautoWebActionReporter: url: %s", str2); IAConfigManager iAConfigManager = IAConfigManager.L; if (!iAConfigManager.i.c) { IAlog.a("IAautoWebActionReporter: Report of Non user web actions disabled!", new Object[0]); return; } s.a aVar = new s.a(q.MRAID_AUTO_ACTION_DETECTED, qVar.a, qVar.d(), qVar.c.c()); JSONObject jSONObject = new JSONObject(); try { jSONObject.put("action", str); } catch (Exception unused) { IAlog.f("Got exception adding param to json object: %s, %s", "action", str); } if (!TextUtils.isEmpty(str2)) { try { jSONObject.put("url", str2); } catch (Exception unused2) { IAlog.f("Got exception adding param to json object: %s, %s", "url", str2); } } long j = uVar.a.getLong("lastReportTS", 0L); TimeZone timeZone = TimeZone.getTimeZone("UTC"); Calendar calendar = Calendar.getInstance(timeZone); Calendar calendar2 = Calendar.getInstance(timeZone); calendar2.setTimeInMillis(j); if (j <= 0 || calendar.get(6) != calendar2.get(6)) { i = 0; } else { IAlog.e("IAautoWebActionReporter: encountered same date", new Object[0]); i = uVar.a.getInt("numReportsToday", 0); } int i2 = iAConfigManager.i.d; int i3 = i + 1; IAlog.e("IAautoWebActionReporter: day counter: %d max: %d", Integer.valueOf(i3), Integer.valueOf(i2)); if (i < i2) { IAlog.e("IAautoWebActionReporter: adding ad data", new Object[0]); aVar.g = true; } else { IAlog.e("IAautoWebActionReporter: not adding ad data", new Object[0]); } Integer valueOf = Integer.valueOf(i3); try { jSONObject.put("daily_count", valueOf); } catch (Exception unused3) { IAlog.f("Got exception adding param to json object: %s, %s", "daily_count", valueOf); } aVar.f.put(jSONObject); aVar.a((String) null); SharedPreferences.Editor edit = uVar.a.edit(); edit.putLong("lastReportTS", calendar.getTimeInMillis()); edit.putInt("numReportsToday", i3); edit.apply(); } }