package a8; import android.text.TextUtils; import android.util.Log; import com.google.android.gms.ads.RequestConfiguration; import com.vungle.warren.VungleApiClient; import com.vungle.warren.utility.j; import java.io.BufferedReader; import java.io.Closeable; import java.io.File; import java.io.FileReader; import java.io.IOException; import java.util.UUID; import z4.g; import z4.k; import z4.m; /* loaded from: classes2.dex */ class f { /* renamed from: e, reason: collision with root package name */ private static final String f221e = "f"; /* renamed from: a, reason: collision with root package name */ private final VungleApiClient f222a; /* renamed from: b, reason: collision with root package name */ private final g8.f f223b; /* renamed from: c, reason: collision with root package name */ private final String f224c = b(); /* renamed from: d, reason: collision with root package name */ private int f225d = a(); f(VungleApiClient vungleApiClient, g8.f fVar) { this.f222a = vungleApiClient; this.f223b = fVar; } private int a() { return this.f223b.e("batch_id", 0); } private String b() { String f10 = this.f223b.f("device_id", RequestConfiguration.MAX_AD_CONTENT_RATING_UNSPECIFIED); if (!TextUtils.isEmpty(f10)) { return f10; } String uuid = UUID.randomUUID().toString(); this.f223b.j("device_id", uuid); this.f223b.c(); return uuid; } /* JADX WARN: Not initialized variable reg: 2, insn: 0x0035: MOVE (r1 I:??[OBJECT, ARRAY]) = (r2 I:??[OBJECT, ARRAY]) (LINE:54), block:B:19:0x0035 */ private g c(File file) { BufferedReader bufferedReader; Closeable closeable; g gVar = new g(); Closeable closeable2 = null; try { try { bufferedReader = new BufferedReader(new FileReader(file)); while (true) { try { String readLine = bufferedReader.readLine(); if (readLine == null) { j.a(bufferedReader); return gVar; } gVar.p(m.c(readLine).g()); } catch (Exception unused) { Log.e(f221e, "Invalidate log document file."); j.a(bufferedReader); return null; } } } catch (Exception unused2) { bufferedReader = null; } catch (Throwable th) { th = th; j.a(closeable2); throw th; } } catch (Throwable th2) { th = th2; closeable2 = closeable; j.a(closeable2); throw th; } } private void d() { this.f223b.i("batch_id", this.f225d); this.f223b.c(); } void e(File[] fileArr) { g c10; for (File file : fileArr) { k kVar = new k(); kVar.q("batch_id", Integer.valueOf(this.f225d)); kVar.r("device_guid", this.f224c); try { c10 = c(file); } catch (IOException unused) { Log.e(f221e, "Failed to generate request payload."); } if (c10 == null) { j.b(file); } else { kVar.o("payload", c10); if (this.f222a.F(kVar).c().e()) { j.b(file); } if (this.f225d >= Integer.MAX_VALUE) { this.f225d = -1; } this.f225d++; } } d(); } }