package a8; import android.content.Context; import android.text.TextUtils; import android.util.Log; import com.google.android.gms.ads.RequestConfiguration; import com.vungle.warren.Vungle; import com.vungle.warren.VungleApiClient; import com.vungle.warren.VungleLogger; import java.io.File; import java.util.Map; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.Executor; import java.util.concurrent.atomic.AtomicBoolean; import java.util.concurrent.atomic.AtomicInteger; /* loaded from: classes2.dex */ public class d { /* renamed from: o, reason: collision with root package name */ private static final String f189o = "d"; /* renamed from: p, reason: collision with root package name */ public static String f190p = "com.vungle"; /* renamed from: a, reason: collision with root package name */ private final e f191a; /* renamed from: b, reason: collision with root package name */ private final f f192b; /* renamed from: c, reason: collision with root package name */ private final Executor f193c; /* renamed from: d, reason: collision with root package name */ private final g8.f f194d; /* renamed from: e, reason: collision with root package name */ private a8.b f195e; /* renamed from: f, reason: collision with root package name */ private final AtomicBoolean f196f; /* renamed from: g, reason: collision with root package name */ private final AtomicBoolean f197g; /* renamed from: h, reason: collision with root package name */ private String f198h; /* renamed from: i, reason: collision with root package name */ private AtomicInteger f199i; /* renamed from: j, reason: collision with root package name */ private boolean f200j; /* renamed from: k, reason: collision with root package name */ private final String f201k; /* renamed from: l, reason: collision with root package name */ private final Map f202l; /* renamed from: m, reason: collision with root package name */ private z4.e f203m; /* renamed from: n, reason: collision with root package name */ private c f204n; class a implements Runnable { /* renamed from: a, reason: collision with root package name */ final /* synthetic */ String f205a; /* renamed from: b, reason: collision with root package name */ final /* synthetic */ VungleLogger.LoggerLevel f206b; /* renamed from: c, reason: collision with root package name */ final /* synthetic */ String f207c; /* renamed from: d, reason: collision with root package name */ final /* synthetic */ String f208d; /* renamed from: e, reason: collision with root package name */ final /* synthetic */ String f209e; /* renamed from: f, reason: collision with root package name */ final /* synthetic */ String f210f; a(String str, VungleLogger.LoggerLevel loggerLevel, String str2, String str3, String str4, String str5) { this.f205a = str; this.f206b = loggerLevel; this.f207c = str2; this.f208d = str3; this.f209e = str4; this.f210f = str5; } @Override // java.lang.Runnable public void run() { if (d.this.h()) { d.this.f191a.u(this.f205a, this.f206b.toString(), this.f207c, RequestConfiguration.MAX_AD_CONTENT_RATING_UNSPECIFIED, this.f208d, d.this.f201k, d.this.e(), this.f209e, this.f210f); } } } class b implements c { b() { } @Override // a8.d.c public void a(VungleLogger.LoggerLevel loggerLevel, String str, String str2, String str3, String str4) { d.this.i(loggerLevel, str, str2, str3, str4); } @Override // a8.d.c public void b() { d.this.k(); } @Override // a8.d.c public boolean c() { return d.this.g(); } } interface c { void a(VungleLogger.LoggerLevel loggerLevel, String str, String str2, String str3, String str4); void b(); boolean c(); } public d(Context context, g8.a aVar, VungleApiClient vungleApiClient, Executor executor, g8.f fVar) { this(context, new e(aVar.g()), new f(vungleApiClient, fVar), executor, fVar); } /* JADX INFO: Access modifiers changed from: private */ public String e() { if (this.f202l.isEmpty()) { return null; } return this.f203m.s(this.f202l); } private void j() { if (!g()) { Log.d(f189o, "Crash report disabled, no need to send crash log files."); return; } File[] p10 = this.f191a.p(this.f199i.get()); if (p10 == null || p10.length == 0) { Log.d(f189o, "No need to send empty crash log files."); } else { this.f192b.e(p10); } } /* JADX INFO: Access modifiers changed from: private */ public void k() { if (!h()) { Log.d(f189o, "Logging disabled, no need to send log files."); return; } File[] r10 = this.f191a.r(); if (r10 == null || r10.length == 0) { Log.d(f189o, "No need to send empty files."); } else { this.f192b.e(r10); } } synchronized void f() { if (!this.f200j) { if (!g()) { Log.d(f189o, "crash report is disabled."); return; } if (this.f195e == null) { this.f195e = new a8.b(this.f204n); } this.f195e.a(this.f198h); this.f200j = true; } } public boolean g() { return this.f197g.get(); } public boolean h() { return this.f196f.get(); } public void i(VungleLogger.LoggerLevel loggerLevel, String str, String str2, String str3, String str4) { String p10 = VungleApiClient.p(); if (loggerLevel != VungleLogger.LoggerLevel.CRASH || !g()) { this.f193c.execute(new a(str2, loggerLevel, str, p10, str3, str4)); } else { synchronized (this) { this.f191a.s(str2, loggerLevel.toString(), str, RequestConfiguration.MAX_AD_CONTENT_RATING_UNSPECIFIED, p10, this.f201k, e(), str3, str4); } } } public void l() { j(); k(); } public void m(boolean z10) { if (this.f196f.compareAndSet(!z10, z10)) { this.f194d.l("logging_enabled", z10); this.f194d.c(); } } public void n(int i10) { e eVar = this.f191a; if (i10 <= 0) { i10 = 100; } eVar.v(i10); } public synchronized void o(boolean z10, String str, int i10) { boolean z11 = true; boolean z12 = this.f197g.get() != z10; boolean z13 = (TextUtils.isEmpty(str) || str.equals(this.f198h)) ? false : true; int max = Math.max(i10, 0); if (this.f199i.get() == max) { z11 = false; } if (z12 || z13 || z11) { if (z12) { this.f197g.set(z10); this.f194d.l("crash_report_enabled", z10); } if (z13) { if ("*".equals(str)) { this.f198h = RequestConfiguration.MAX_AD_CONTENT_RATING_UNSPECIFIED; } else { this.f198h = str; } this.f194d.j("crash_collect_filter", this.f198h); } if (z11) { this.f199i.set(max); this.f194d.i("crash_batch_max", max); } this.f194d.c(); a8.b bVar = this.f195e; if (bVar != null) { bVar.a(this.f198h); } if (z10) { f(); } } } d(Context context, e eVar, f fVar, Executor executor, g8.f fVar2) { AtomicBoolean atomicBoolean = new AtomicBoolean(false); this.f196f = atomicBoolean; AtomicBoolean atomicBoolean2 = new AtomicBoolean(false); this.f197g = atomicBoolean2; this.f198h = f190p; this.f199i = new AtomicInteger(5); this.f200j = false; this.f202l = new ConcurrentHashMap(); this.f203m = new z4.e(); this.f204n = new b(); this.f201k = context.getPackageName(); this.f192b = fVar; this.f191a = eVar; this.f193c = executor; this.f194d = fVar2; eVar.w(this.f204n); Package r62 = Vungle.class.getPackage(); if (r62 != null) { f190p = r62.getName(); } atomicBoolean.set(fVar2.d("logging_enabled", false)); atomicBoolean2.set(fVar2.d("crash_report_enabled", false)); this.f198h = fVar2.f("crash_collect_filter", f190p); this.f199i.set(fVar2.e("crash_batch_max", 5)); f(); } }