package com.mbridge.msdk.click.a; import android.content.BroadcastReceiver; import android.content.Context; import android.content.Intent; import android.content.IntentFilter; import android.os.Handler; import android.os.Looper; import android.os.Message; import android.text.TextUtils; import androidx.annotation.NonNull; import com.ironsource.v8; import com.mbridge.msdk.c.g; import com.mbridge.msdk.c.h; import com.mbridge.msdk.foundation.entity.CampaignEx; import com.mbridge.msdk.foundation.same.report.f; import com.mbridge.msdk.foundation.tools.aq; import java.util.Iterator; import java.util.concurrent.ConcurrentHashMap; /* loaded from: classes4.dex */ public final class a { public static String a = "mtg_retry_report=1"; public static int b = 10000; public static int c = 3; public static int d = 50; public static int e = 600000; public static int f = 0; public static int g = 1; public static int h = 2; public static int i = 3; public static int j = 4; public static int k = 5; private static String l = "RetryReportControl"; private static int o; private static int p; private ConcurrentHashMap m; private c n; private BroadcastReceiver q; private final Handler r; /* renamed from: com.mbridge.msdk.click.a.a$a, reason: collision with other inner class name */ public static class C0190a { private static a a = new a(); } private boolean a(int i2) { return i2 == j || i2 == i; } private boolean b(int i2) { return i2 == g || i2 == h; } private a() { this.m = new ConcurrentHashMap<>(); this.n = new c(d); this.r = new b(Looper.getMainLooper()); g a2 = h.a().a(com.mbridge.msdk.foundation.controller.c.m().k()); c = a2.ag(); b = a2.ai() * 1000; e = a2.aj() * 1000; o = a2.af(); p = a2.ah(); try { if (this.q == null) { this.q = new BroadcastReceiver() { // from class: com.mbridge.msdk.click.a.a.1 @Override // android.content.BroadcastReceiver public final void onReceive(Context context, Intent intent) { if ("android.net.conn.CONNECTIVITY_CHANGE".equals(intent.getAction())) { a.this.r.sendEmptyMessage(2); } } }; Context c2 = com.mbridge.msdk.foundation.controller.c.m().c(); if (c2 != null) { c2.registerReceiver(this.q, new IntentFilter("android.net.conn.CONNECTIVITY_CHANGE")); } } } catch (Exception e2) { e2.printStackTrace(); } } public static a a() { return C0190a.a; } public static class b extends Handler { public b(Looper looper) { super(looper); } @Override // android.os.Handler public final void handleMessage(@NonNull Message message) { int i = message.what; if (i != 1) { if (i != 2) { return; } a.a(a.a()); } else { Object obj = message.obj; if (obj instanceof String) { a.a().a((String) obj, com.mbridge.msdk.click.a.b.a); } } } } private void a(com.mbridge.msdk.click.a.b bVar) { String str; String str2; try { CampaignEx f2 = bVar.f(); if (f2 != null) { String requestId = f2.getRequestId(); str2 = f2.getRequestIdNotice(); str = requestId; } else { str = ""; str2 = str; } a(com.mbridge.msdk.foundation.controller.c.m().c(), bVar.i().toString(), bVar.g(), str, str2, bVar.d()); } catch (Exception e2) { e2.printStackTrace(); } } private static void a(Context context, String str, String str2, String str3, String str4, int i2) { f.a().a(context, str, str2, str3, str4, i2); } private void a(String str) { Message obtainMessage = this.r.obtainMessage(); obtainMessage.what = 1; obtainMessage.obj = str; this.r.sendMessageDelayed(obtainMessage, b); } /* JADX INFO: Access modifiers changed from: private */ public void a(String str, int i2) { String str2; c cVar = this.n; if (cVar != null) { com.mbridge.msdk.click.a.b a2 = cVar.a(str); this.n.b(str); if (a2 == null) { com.mbridge.msdk.click.a.b bVar = this.m.get(str); if (bVar == null || System.currentTimeMillis() > bVar.j() + e || bVar.h() >= c || i2 == com.mbridge.msdk.click.a.b.b) { return; } a(str); return; } if (System.currentTimeMillis() <= a2.j() + e) { a2.a(i2); this.m.put(str, a2); if (aq.c(str) == 0) { str2 = str + "?" + a; } else { str2 = str + v8.i.c + a; } com.mbridge.msdk.click.a.a(com.mbridge.msdk.foundation.controller.c.m().c(), a2.f(), a2.e(), str2, a2.a(), a2.b(), a2.d()); return; } if (i2 != com.mbridge.msdk.click.a.b.b) { a(a2); } } } public final void a(String str, String str2, CampaignEx campaignEx, String str3, boolean z, boolean z2, int i2) { if ((a(i2) || b(i2) || i2 == k) && !TextUtils.isEmpty(str)) { String replace = str.replace("?" + a, "").replace(v8.i.c + a, ""); if (this.m == null) { this.m = new ConcurrentHashMap<>(); } com.mbridge.msdk.click.a.b remove = this.m.remove(replace); if (remove == null) { remove = new com.mbridge.msdk.click.a.b(str, str2); remove.b(i2); remove.a(z); remove.b(z2); remove.a(campaignEx); remove.a(str3); } else if (remove.c() != com.mbridge.msdk.click.a.b.b) { remove.b(str2); } if ((!a(i2) || o == 0) && ((!b(i2) || p == 0) && i2 != k)) { a(remove); return; } if (System.currentTimeMillis() >= remove.j() + e) { if (remove.c() == com.mbridge.msdk.click.a.b.a) { a(remove); return; } return; } if (this.n == null) { this.n = new c(d); } this.n.a(replace, remove); if (remove.c() == com.mbridge.msdk.click.a.b.a) { if (remove.h() <= c) { a(replace); } else { a(remove); } } } } public static /* synthetic */ void a(a aVar) { c cVar = aVar.n; if (cVar != null) { Iterator it = cVar.a().iterator(); while (it.hasNext()) { aVar.a(it.next(), com.mbridge.msdk.click.a.b.b); } } } }