package c.i.a.f.i.b; import android.app.job.JobInfo; import android.app.job.JobScheduler; import android.content.ComponentName; import android.content.ContentValues; import android.content.Context; import android.content.IntentFilter; import android.content.pm.ApplicationInfo; import android.content.pm.PackageInfo; import android.content.pm.PackageManager; import android.database.Cursor; import android.database.sqlite.SQLiteDatabase; import android.database.sqlite.SQLiteException; import android.net.Uri; import android.os.Build; import android.os.Bundle; import android.os.PersistableBundle; import android.os.SystemClock; import android.provider.Settings; import android.text.TextUtils; import android.util.Log; import android.util.Pair; import androidx.annotation.NonNull; import androidx.annotation.WorkerThread; import androidx.collection.ArrayMap; import androidx.exifinterface.media.ExifInterface; import androidx.recyclerview.widget.RecyclerView; import c.c.a.a0.d; import c.i.a.f.e.o.c; import c.i.a.f.e.p.b; import c.i.a.f.h.l.a1; import c.i.a.f.h.l.a4; import c.i.a.f.h.l.c1; import c.i.a.f.h.l.d1; import c.i.a.f.h.l.da; import c.i.a.f.h.l.e1; import c.i.a.f.h.l.ea; import c.i.a.f.h.l.hb; import c.i.a.f.h.l.i1; import c.i.a.f.h.l.m9; import c.i.a.f.h.l.o8; import c.i.a.f.h.l.p9; import c.i.a.f.h.l.t8; import c.i.a.f.h.l.u0; import c.i.a.f.h.l.u4; import c.i.a.f.h.l.x7; import com.adjust.sdk.AdjustConfig; import com.discord.models.domain.ModelAuditLogEntry; import com.google.android.gms.measurement.internal.zzap; import com.google.android.gms.measurement.internal.zzaq; import com.google.android.gms.measurement.internal.zzku; import com.google.android.gms.measurement.internal.zzn; import com.google.android.gms.measurement.internal.zzz; import com.google.android.material.shadow.ShadowDrawableWrapper; import java.io.File; import java.io.FileNotFoundException; import java.io.IOException; import java.io.RandomAccessFile; import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; import java.math.BigInteger; import java.net.MalformedURLException; import java.net.URL; import java.nio.ByteBuffer; import java.nio.channels.FileChannel; import java.nio.channels.FileLock; import java.nio.channels.OverlappingFileLockException; import java.security.SecureRandom; import java.util.ArrayList; import java.util.Collections; import java.util.HashMap; import java.util.Iterator; import java.util.List; import java.util.Locale; import java.util.Map; import java.util.Objects; /* compiled from: com.google.android.gms:play-services-measurement@@18.0.0 */ public class k9 implements t5 { public static volatile k9 a; public final v9 A = new n9(this); public p4 b; /* renamed from: c reason: collision with root package name */ public x3 f1209c; public g d; public b4 e; public h9 f; public ba g; public final q9 h; public g7 i; public q8 j; public final u4 k; public boolean l = false; public boolean m; public long n; public List o; public int p; public int q; public boolean r; /* renamed from: s reason: collision with root package name */ public boolean f1210s; public boolean t; public FileLock u; public FileChannel v; public List w; /* renamed from: x reason: collision with root package name */ public List f1211x; /* renamed from: y reason: collision with root package name */ public long f1212y; /* renamed from: z reason: collision with root package name */ public final Map f1213z; /* compiled from: com.google.android.gms:play-services-measurement@@18.0.0 */ public class a { public e1 a; public List b; /* renamed from: c reason: collision with root package name */ public List f1214c; public long d; public a(k9 k9Var, j9 j9Var) { } public final void a(e1 e1Var) { this.a = e1Var; } public final boolean b(long j, a1 a1Var) { if (this.f1214c == null) { this.f1214c = new ArrayList(); } if (this.b == null) { this.b = new ArrayList(); } if (this.f1214c.size() > 0 && ((this.f1214c.get(0).H() / 1000) / 60) / 60 != ((a1Var.H() / 1000) / 60) / 60) { return false; } long g = this.d + ((long) a1Var.g()); if (g >= ((long) Math.max(0, p.i.a(null).intValue()))) { return false; } this.d = g; this.f1214c.add(a1Var); this.b.add(Long.valueOf(j)); return this.f1214c.size() < Math.max(1, p.j.a(null).intValue()); } } public k9(r9 r9Var) { u4 b = u4.b(r9Var.a, null, null); this.k = b; this.f1212y = -1; q9 q9Var = new q9(this); q9Var.o(); this.h = q9Var; x3 x3Var = new x3(this); x3Var.o(); this.f1209c = x3Var; p4 p4Var = new p4(this); p4Var.o(); this.b = p4Var; this.f1213z = new HashMap(); b.f().v(new j9(this, r9Var)); } public static void C(i9 i9Var) { if (i9Var == null) { throw new IllegalStateException("Upload Component not created"); } else if (!i9Var.f1204c) { String valueOf = String.valueOf(i9Var.getClass()); throw new IllegalStateException(c.d.b.a.a.i(valueOf.length() + 27, "Component not initialized: ", valueOf)); } } public static k9 b(Context context) { Objects.requireNonNull(context, "null reference"); Objects.requireNonNull(context.getApplicationContext(), "null reference"); if (a == null) { synchronized (k9.class) { if (a == null) { a = new k9(new r9(context)); } } } return a; } public static void d(a1.a aVar, int i, String str) { List v = aVar.v(); for (int i2 = 0; i2 < v.size(); i2++) { if ("_err".equals(v.get(i2).B())) { return; } } c1.a Q = c1.Q(); Q.s("_err"); Q.r(Long.valueOf((long) i).longValue()); c1 c1Var = (c1) ((u4) Q.p()); c1.a Q2 = c1.Q(); Q2.s("_ev"); Q2.t(str); c1 c1Var2 = (c1) ((u4) Q2.p()); if (aVar.k) { aVar.n(); aVar.k = false; } a1.A((a1) aVar.j, c1Var); if (aVar.k) { aVar.n(); aVar.k = false; } a1.A((a1) aVar.j, c1Var2); } public static void e(a1.a aVar, @NonNull String str) { List v = aVar.v(); for (int i = 0; i < v.size(); i++) { if (str.equals(v.get(i).B())) { aVar.x(i); return; } } } public final void A(a1.a aVar, a1.a aVar2) { d.l("_e".equals(aVar.y())); N(); c1 w = q9.w((a1) ((u4) aVar.p()), "_et"); if (w.I() && w.J() > 0) { long J = w.J(); N(); c1 w2 = q9.w((a1) ((u4) aVar2.p()), "_et"); if (w2 != null && w2.J() > 0) { J += w2.J(); } N(); q9.E(aVar2, "_et", Long.valueOf(J)); N(); q9.E(aVar, "_fr", 1L); } } @WorkerThread public final void B(zzaq zzaq, zzn zzn) { if (ea.b() && this.k.h.o(p.A0)) { u3 b = u3.b(zzaq); this.k.t().H(b.d, K().h0(zzn.i)); this.k.t().Q(b, this.k.h.m(zzn.i)); zzaq = b.a(); } if (this.k.h.o(p.f1225e0) && "_cmp".equals(zzaq.i) && "referrer API v2".equals(zzaq.j.i.getString("_cis"))) { String string = zzaq.j.i.getString("gclid"); if (!TextUtils.isEmpty(string)) { o(new zzku("_lgclid", zzaq.l, string, "auto"), zzn); } } l(zzaq, zzn); } @WorkerThread public final void D(zzku zzku, zzn zzn) { U(); P(); if (L(zzn)) { if (!zzn.p) { G(zzn); } else if (!"_npa".equals(zzku.j) || zzn.A == null) { this.k.g().m.b("Removing user property", this.k.u().y(zzku.j)); K().b0(); try { G(zzn); K().V(zzn.i, zzku.j); K().s(); this.k.g().m.b("User property removed", this.k.u().y(zzku.j)); } finally { K().e0(); } } else { this.k.g().m.a("Falling back to manifest metadata value for ad personalization"); Objects.requireNonNull((c) this.k.o); o(new zzku("_npa", System.currentTimeMillis(), Long.valueOf(zzn.A.booleanValue() ? 1 : 0), "auto"), zzn); } } } /* JADX DEBUG: Multi-variable search result rejected for r0v16, resolved type: android.content.pm.PackageInfo */ /* JADX DEBUG: Multi-variable search result rejected for r14v16, resolved type: android.content.pm.ApplicationInfo */ /* JADX DEBUG: Multi-variable search result rejected for r14v17, resolved type: android.content.pm.ApplicationInfo */ /* JADX DEBUG: Multi-variable search result rejected for r0v34, resolved type: android.content.pm.PackageInfo */ /* JADX WARN: Multi-variable type inference failed */ /* JADX WARNING: Removed duplicated region for block: B:123:0x03b5 */ /* JADX WARNING: Removed duplicated region for block: B:149:0x0488 */ /* JADX WARNING: Removed duplicated region for block: B:45:0x0125 A[Catch:{ all -> 0x04b4 }] */ /* JADX WARNING: Removed duplicated region for block: B:56:0x01d8 */ /* JADX WARNING: Removed duplicated region for block: B:76:0x023d */ /* JADX WARNING: Removed duplicated region for block: B:77:0x024a */ /* JADX WARNING: Removed duplicated region for block: B:82:0x025e */ @WorkerThread public final void E(zzn zzn) { a4 a4Var; a4 T; String str; long j; long j2; String str2; PackageInfo packageInfo; String str3; long j3; ApplicationInfo applicationInfo; boolean z2; U(); P(); Objects.requireNonNull(zzn, "null reference"); d.w(zzn.i); if (L(zzn)) { a4 T2 = K().T(zzn.i); if (T2 != null && TextUtils.isEmpty(T2.v()) && !TextUtils.isEmpty(zzn.j)) { T2.F(0); K().I(T2); p4 H = H(); String str4 = zzn.i; H.b(); H.g.remove(str4); } if (!zzn.p) { G(zzn); return; } long j4 = zzn.u; if (j4 == 0) { Objects.requireNonNull((c) this.k.o); j4 = System.currentTimeMillis(); } j y2 = this.k.y(); y2.b(); y2.g = null; y2.h = 0; int i = zzn.v; if (!(i == 0 || i == 1)) { this.k.g().i.c("Incorrect app type, assuming installed app. appId, appType", q3.s(zzn.i), Integer.valueOf(i)); i = 0; } K().b0(); try { u9 Y = K().Y(zzn.i, "_npa"); if (Y != null) { if (!"auto".equals(Y.b)) { a4Var = null; T = K().T(zzn.i); if (T != null) { this.k.t(); if (t9.d0(zzn.j, T.v(), zzn.f2399z, T.y())) { this.k.g().i.b("New GMP App Id passed in. Removing cached database data. appId", q3.s(T.o())); g K = K(); String o = T.o(); K.n(); K.b(); d.w(o); try { SQLiteDatabase t = K.t(); String[] strArr = {o}; int delete = t.delete("events", "app_id=?", strArr) + 0 + t.delete("user_attributes", "app_id=?", strArr) + t.delete("conditional_properties", "app_id=?", strArr) + t.delete("apps", "app_id=?", strArr) + t.delete("raw_events", "app_id=?", strArr) + t.delete("raw_events_metadata", "app_id=?", strArr) + t.delete("event_filters", "app_id=?", strArr) + t.delete("property_filters", "app_id=?", strArr) + t.delete("audience_filter_values", "app_id=?", strArr) + t.delete("consent_settings", "app_id=?", strArr); if (delete > 0) { K.g().n.c("Deleted application data. app, records", o, Integer.valueOf(delete)); } } catch (SQLiteException e) { K.g().f.c("Error deleting application data. appId, error", q3.s(o), e); } T = a4Var; } } if (T != null) { if (((T.N() == -2147483648L || T.N() == zzn.r) ? false : true) || (T.N() == -2147483648L && T.M() != null && !T.M().equals(zzn.k))) { Bundle bundle = new Bundle(); bundle.putString("_pv", T.M()); l(new zzaq("_au", new zzap(bundle), "auto", j4), zzn); G(zzn); if ((i == 0 ? K().z(zzn.i, "_f") : i == 1 ? K().z(zzn.i, "_v") : a4Var) == null) { long j5 = ((j4 / 3600000) + 1) * 3600000; if (i == 0) { o(new zzku("_fot", j4, Long.valueOf(j5), "auto"), zzn); U(); this.k.f1243x.a(zzn.i); U(); P(); Bundle bundle2 = new Bundle(); bundle2.putLong("_c", 1); bundle2.putLong("_r", 1); bundle2.putLong("_uwa", 0); bundle2.putLong("_pfo", 0); bundle2.putLong("_sys", 0); bundle2.putLong("_sysu", 0); if (this.k.h.u(zzn.i, p.T)) { str2 = "_et"; j2 = 1; bundle2.putLong(str2, 1); } else { str2 = "_et"; j2 = 1; } if (zzn.f2398y) { bundle2.putLong("_dac", j2); } g K2 = K(); String str5 = zzn.i; d.w(str5); K2.b(); K2.n(); long g02 = K2.g0(str5, "first_open_count"); if (this.k.b.getPackageManager() == null) { this.k.g().f.b("PackageManager is null, first open report might be inaccurate. appId", q3.s(zzn.i)); str3 = str2; j3 = g02; } else { try { packageInfo = b.a(this.k.b).b(zzn.i, 0); } catch (PackageManager.NameNotFoundException e2) { this.k.g().f.c("Package info is null, first open report might be inaccurate. appId", q3.s(zzn.i), e2); packageInfo = a4Var; } if (packageInfo != 0) { long j6 = packageInfo.firstInstallTime; if (j6 != 0) { str3 = str2; if (j6 != packageInfo.lastUpdateTime) { if (!this.k.h.o(p.n0)) { bundle2.putLong("_uwa", 1); } else if (g02 == 0) { bundle2.putLong("_uwa", 1); } z2 = false; } else { z2 = true; } j3 = g02; o(new zzku("_fi", j4, Long.valueOf(z2 ? 1 : 0), "auto"), zzn); applicationInfo = b.a(this.k.b).a(zzn.i, 0); if (applicationInfo != null) { if ((applicationInfo.flags & 1) != 0) { bundle2.putLong("_sys", 1); } if ((applicationInfo.flags & 128) != 0) { bundle2.putLong("_sysu", 1); } } } } str3 = str2; j3 = g02; try { applicationInfo = b.a(this.k.b).a(zzn.i, 0); } catch (PackageManager.NameNotFoundException e3) { this.k.g().f.c("Application info is null, first open report might be inaccurate. appId", q3.s(zzn.i), e3); applicationInfo = a4Var; } if (applicationInfo != null) { } } if (j3 >= 0) { bundle2.putLong("_pfo", j3); } B(new zzaq("_f", new zzap(bundle2), "auto", j4), zzn); str = str3; } else { str = "_et"; if (i == 1) { o(new zzku("_fvt", j4, Long.valueOf(j5), "auto"), zzn); U(); P(); Bundle bundle3 = new Bundle(); bundle3.putLong("_c", 1); bundle3.putLong("_r", 1); if (this.k.h.u(zzn.i, p.T)) { j = 1; bundle3.putLong(str, 1); } else { j = 1; } if (zzn.f2398y) { bundle3.putLong("_dac", j); } B(new zzaq("_v", new zzap(bundle3), "auto", j4), zzn); } } if (!this.k.h.u(zzn.i, p.U)) { Bundle bundle4 = new Bundle(); bundle4.putLong(str, 1); if (this.k.h.u(zzn.i, p.T)) { bundle4.putLong("_fr", 1); } B(new zzaq("_e", new zzap(bundle4), "auto", j4), zzn); } } else if (zzn.q) { B(new zzaq("_cd", new zzap(new Bundle()), "auto", j4), zzn); } K().s(); } } G(zzn); if ((i == 0 ? K().z(zzn.i, "_f") : i == 1 ? K().z(zzn.i, "_v") : a4Var) == null) { } K().s(); } } Boolean bool = zzn.A; if (bool != null) { a4Var = null; zzku zzku = new zzku("_npa", j4, Long.valueOf(bool.booleanValue() ? 1 : 0), "auto"); if (Y == null || !Y.e.equals(zzku.l)) { o(zzku, zzn); } } else { a4Var = null; if (Y != null) { D(new zzku("_npa", j4, null, "auto"), zzn); } } T = K().T(zzn.i); if (T != null) { } if (T != null) { } G(zzn); if ((i == 0 ? K().z(zzn.i, "_f") : i == 1 ? K().z(zzn.i, "_v") : a4Var) == null) { } K().s(); } finally { K().e0(); } } } @WorkerThread public final void F(zzz zzz, zzn zzn) { Objects.requireNonNull(zzz, "null reference"); d.w(zzz.i); Objects.requireNonNull(zzz.k, "null reference"); d.w(zzz.k.j); U(); P(); if (L(zzn)) { if (!zzn.p) { G(zzn); return; } K().b0(); try { G(zzn); zzz Z = K().Z(zzz.i, zzz.k.j); if (Z != null) { this.k.g().m.c("Removing conditional user property", zzz.i, this.k.u().y(zzz.k.j)); K().a0(zzz.i, zzz.k.j); if (Z.m) { K().V(zzz.i, zzz.k.j); } zzaq zzaq = zzz.f2400s; if (zzaq != null) { Bundle bundle = null; zzap zzap = zzaq.j; if (zzap != null) { bundle = zzap.x0(); } t9 t = this.k.t(); String str = zzz.i; zzaq zzaq2 = zzz.f2400s; I(t.B(str, zzaq2.i, bundle, Z.j, zzaq2.l, true, x7.b() && this.k.h.o(p.M0)), zzn); } } else { this.k.g().i.c("Conditional user property doesn't exist", q3.s(zzz.i), this.k.u().y(zzz.k.j)); } K().s(); } finally { K().e0(); } } } /* JADX WARNING: Removed duplicated region for block: B:127:0x02bf */ /* JADX WARNING: Removed duplicated region for block: B:130:0x02d1 */ /* JADX WARNING: Removed duplicated region for block: B:155:0x0351 */ /* JADX WARNING: Removed duplicated region for block: B:163:0x0375 */ /* JADX WARNING: Removed duplicated region for block: B:166:0x0383 */ /* JADX WARNING: Removed duplicated region for block: B:169:0x0391 */ /* JADX WARNING: Removed duplicated region for block: B:179:0x03ce */ /* JADX WARNING: Removed duplicated region for block: B:182:0x03dc */ /* JADX WARNING: Removed duplicated region for block: B:185:0x03ea */ /* JADX WARNING: Removed duplicated region for block: B:193:0x0407 */ @WorkerThread public final a4 G(zzn zzn) { boolean z2; long j; U(); P(); Objects.requireNonNull(zzn, "null reference"); d.w(zzn.i); a4 T = K().T(zzn.i); d dVar = d.a; d h = (!t8.b() || !this.k.h.o(p.J0)) ? dVar : a(zzn.i).h(d.b(zzn.E)); String t = (!t8.b() || !this.k.h.o(p.J0) || h.j()) ? this.j.t(zzn.i) : ""; if (!((p9) m9.i.a()).a() || !this.k.h.o(p.o0)) { if (t8.b() && this.k.h.o(p.J0)) { dVar = a(zzn.i).h(d.b(zzn.E)); } boolean z3 = true; if (T == null) { T = new a4(this.k, zzn.i); if (!t8.b() || !this.k.h.o(p.J0)) { T.c(W()); T.x(t); } else { if (dVar.k()) { T.c(c(dVar)); } if (dVar.j()) { T.x(t); } } } else if ((!t8.b() || !this.k.h.o(p.J0) || dVar.j()) && !t.equals(T.E())) { T.x(t); if (!t8.b() || !this.k.h.o(p.J0)) { T.c(W()); } else if (dVar.k()) { T.c(c(dVar)); } } else if (!t8.b() || !this.k.h.o(p.J0) || !TextUtils.isEmpty(T.s()) || !dVar.k()) { z2 = false; if (!TextUtils.equals(zzn.j, T.v())) { T.m(zzn.j); z2 = true; } if (!TextUtils.equals(zzn.f2399z, T.y())) { T.q(zzn.f2399z); z2 = true; } if (da.b() && this.k.h.u(T.o(), p.f1230j0) && !TextUtils.equals(zzn.D, T.B())) { T.u(zzn.D); z2 = true; } if (!TextUtils.isEmpty(zzn.f2396s) && !zzn.f2396s.equals(T.H())) { T.A(zzn.f2396s); z2 = true; } long j2 = zzn.m; if (!(j2 == 0 || j2 == T.P())) { T.t(zzn.m); z2 = true; } if (!TextUtils.isEmpty(zzn.k) && !zzn.k.equals(T.M())) { T.D(zzn.k); z2 = true; } if (zzn.r != T.N()) { T.p(zzn.r); z2 = true; } String str = zzn.l; if (str != null && !str.equals(T.O())) { T.G(zzn.l); z2 = true; } if (zzn.n != T.Q()) { T.w(zzn.n); z2 = true; } if (zzn.p != T.T()) { T.e(zzn.p); z2 = true; } if (!TextUtils.isEmpty(zzn.o)) { String str2 = zzn.o; T.a.f().b(); if (!str2.equals(T.D)) { T.J(zzn.o); z2 = true; } } if (!this.k.h.o(p.y0) && zzn.t != T.g()) { T.R(zzn.t); z2 = true; } if (zzn.w != T.h()) { T.n(zzn.w); z2 = true; } if (zzn.f2397x != T.i()) { T.r(zzn.f2397x); z2 = true; } if (zzn.A != T.j()) { T.b(zzn.A); z2 = true; } j = zzn.B; if (j != 0 || j == T.S()) { z3 = z2; } else { T.z(zzn.B); } if (z3) { K().I(T); } return T; } else { T.c(c(dVar)); } z2 = true; if (!TextUtils.equals(zzn.j, T.v())) { } if (!TextUtils.equals(zzn.f2399z, T.y())) { } T.u(zzn.D); z2 = true; T.A(zzn.f2396s); z2 = true; long j2 = zzn.m; T.t(zzn.m); z2 = true; T.D(zzn.k); z2 = true; if (zzn.r != T.N()) { } String str = zzn.l; T.G(zzn.l); z2 = true; if (zzn.n != T.Q()) { } if (zzn.p != T.T()) { } if (!TextUtils.isEmpty(zzn.o)) { } T.R(zzn.t); z2 = true; if (zzn.w != T.h()) { } if (zzn.f2397x != T.i()) { } if (zzn.A != T.j()) { } j = zzn.B; if (j != 0) { } z3 = z2; if (z3) { } return T; } if (T == null) { T = new a4(this.k, zzn.i); if (!t8.b() || !this.k.h.o(p.J0)) { T.c(W()); T.x(t); } else { if (h.k()) { T.c(c(h)); } if (h.j()) { T.x(t); } } } else if ((!t8.b() || !this.k.h.o(p.J0) || h.j()) && !t.equals(T.E())) { T.x(t); if (!t8.b() || !this.k.h.o(p.J0)) { T.c(W()); } else { T.c(c(h)); } } else if (t8.b() && this.k.h.o(p.J0) && TextUtils.isEmpty(T.s()) && h.k()) { T.c(c(h)); } T.m(zzn.j); T.q(zzn.f2399z); if (da.b() && this.k.h.u(T.o(), p.f1230j0)) { T.u(zzn.D); } if (!TextUtils.isEmpty(zzn.f2396s)) { T.A(zzn.f2396s); } long j3 = zzn.m; if (j3 != 0) { T.t(j3); } if (!TextUtils.isEmpty(zzn.k)) { T.D(zzn.k); } T.p(zzn.r); String str3 = zzn.l; if (str3 != null) { T.G(str3); } T.w(zzn.n); T.e(zzn.p); if (!TextUtils.isEmpty(zzn.o)) { T.J(zzn.o); } if (!this.k.h.o(p.y0)) { T.R(zzn.t); } T.n(zzn.w); T.r(zzn.f2397x); T.b(zzn.A); T.z(zzn.B); T.a.f().b(); if (T.E) { K().I(T); } return T; } public final p4 H() { C(this.b); return this.b; } /* JADX WARNING: Code restructure failed: missing block: B:276:0x0944, code lost: r5 = true; */ /* JADX WARNING: Removed duplicated region for block: B:86:0x02ba */ /* JADX WARNING: Removed duplicated region for block: B:90:0x02f3 */ @WorkerThread public final void I(zzaq zzaq, zzn zzn) { long j; int i; boolean X; boolean equals; f x2; long intValue; l lVar; zzap zzap; u9 Y; boolean z2; long j2; u9 u9Var; Long l; a4 T; zzaq zzaq2 = zzaq; d.A(zzn); d.w(zzn.i); long nanoTime = System.nanoTime(); U(); P(); String str = zzn.i; N(); if (q9.O(zzaq, zzn)) { if (!zzn.p) { G(zzn); return; } boolean z3 = true; if (H().x(str, zzaq2.i)) { this.k.g().A().c("Dropping blacklisted event. appId", q3.s(str), this.k.u().u(zzaq2.i)); if (!H().C(str) && !H().D(str)) { z3 = false; } if (z3 || "_err".equals(zzaq2.i)) { l = null; } else { l = null; this.k.t().S(this.A, str, 11, "_ev", zzaq2.i, 0); } if (z3 && (T = K().T(str)) != null && Math.abs(((c) this.k.h()).a() - Math.max(T.W(), T.V())) > p.f1234z.a(l).longValue()) { this.k.g().C().a("Fetching config for blacklisted app"); n(T); return; } return; } if (o8.b() && this.k.a().o(p.w0)) { u3 b = u3.b(zzaq); this.k.t().Q(b, this.k.a().m(str)); zzaq2 = b.a(); } if (this.k.g().x(2)) { this.k.g().D().b("Logging event", this.k.u().t(zzaq2)); } K().b0(); try { G(zzn); boolean z4 = "ecommerce_purchase".equals(zzaq2.i) || "purchase".equals(zzaq2.i) || "refund".equals(zzaq2.i); if ("_iap".equals(zzaq2.i) || z4) { String A0 = zzaq2.j.A0("currency"); if (z4) { double doubleValue = zzaq2.j.z0("value").doubleValue() * 1000000.0d; if (doubleValue == ShadowDrawableWrapper.COS_45) { doubleValue = ((double) zzaq2.j.y0("value").longValue()) * 1000000.0d; } if (doubleValue > 9.223372036854776E18d || doubleValue < -9.223372036854776E18d) { this.k.g().A().c("Data lost. Currency value is too big. appId", q3.s(str), Double.valueOf(doubleValue)); j = nanoTime; i = 0; z2 = false; if (!z2) { K().s(); return; } } else { j2 = Math.round(doubleValue); if ("refund".equals(zzaq2.i)) { j2 = -j2; } } } else { j2 = zzaq2.j.y0("value").longValue(); } if (!TextUtils.isEmpty(A0)) { String upperCase = A0.toUpperCase(Locale.US); if (upperCase.matches("[A-Z]{3}")) { String concat = upperCase.length() != 0 ? "_ltv_".concat(upperCase) : new String("_ltv_"); u9 Y2 = K().Y(str, concat); if (Y2 != null) { Object obj = Y2.e; if (obj instanceof Long) { j = nanoTime; i = 0; u9Var = new u9(str, zzaq2.k, concat, ((c) this.k.h()).a(), Long.valueOf(((Long) obj).longValue() + j2)); if (!K().M(u9Var)) { this.k.g().z().d("Too many unique user properties are set. Ignoring user property. appId", q3.s(str), this.k.u().y(u9Var.f1247c), u9Var.e); this.k.t().S(this.A, str, 9, null, null, 0); } z2 = true; if (!z2) { } } } j = nanoTime; i = 0; g K = K(); int q = this.k.a().q(str, p.E) - 1; d.w(str); K.b(); K.n(); try { K.t().execSQL("delete from user_attributes where app_id=? and name in (select name from user_attributes where app_id=? and name like '_ltv_%' order by set_timestamp desc limit ?,10);", new String[]{str, str, String.valueOf(q)}); } catch (SQLiteException e) { K.g().z().c("Error pruning currencies. appId", q3.s(str), e); } u9Var = new u9(str, zzaq2.k, concat, ((c) this.k.h()).a(), Long.valueOf(j2)); if (!K().M(u9Var)) { } z2 = true; if (!z2) { } } } j = nanoTime; i = 0; z2 = true; if (!z2) { } } else { j = nanoTime; i = 0; } X = t9.X(zzaq2.i); equals = "_err".equals(zzaq2.i); this.k.t(); x2 = K().x(V(), str, t9.v(zzaq2.j) + 1, true, X, false, equals, false); intValue = x2.b - ((long) p.k.a(null).intValue()); } finally { K().e0(); } if (intValue > 0) { if (intValue % 1000 == 1) { this.k.g().z().c("Data loss. Too many events logged. appId, count", q3.s(str), Long.valueOf(x2.b)); } K().s(); K().e0(); return; } if (X) { long intValue2 = x2.a - ((long) p.m.a(null).intValue()); if (intValue2 > 0) { if (intValue2 % 1000 == 1) { this.k.g().z().c("Data loss. Too many public events logged. appId, count", q3.s(str), Long.valueOf(x2.a)); } this.k.t().S(this.A, str, 16, "_ev", zzaq2.i, 0); K().s(); K().e0(); return; } } if (equals) { long max = x2.d - ((long) Math.max(i, Math.min(1000000, this.k.a().q(zzn.i, p.l)))); if (max > 0) { if (max == 1) { this.k.g().z().c("Too many error events logged. appId, count", q3.s(str), Long.valueOf(x2.d)); } K().s(); K().e0(); return; } } Bundle x0 = zzaq2.j.x0(); this.k.t().I(x0, "_o", zzaq2.k); if (this.k.t().s0(str)) { this.k.t().I(x0, "_dbg", 1L); this.k.t().I(x0, "_r", 1L); } if ("_s".equals(zzaq2.i) && (Y = K().Y(zzn.i, "_sno")) != null && (Y.e instanceof Long)) { this.k.t().I(x0, "_sno", Y.e); } long X2 = K().X(str); if (X2 > 0) { this.k.g().A().c("Data lost. Too many events stored on disk, deleted. appId", q3.s(str), Long.valueOf(X2)); } m mVar = new m(this.k, zzaq2.k, str, zzaq2.i, zzaq2.l, 0, x0); l z5 = K().z(str, mVar.b); if (z5 != null) { mVar = mVar.a(this.k, z5.f); lVar = z5.a(mVar.d); } else if (K().f0(str) < ((long) this.k.a().p(str)) || !X) { lVar = new l(str, mVar.b, mVar.d); } else { this.k.g().z().d("Too many event names used, ignoring event. appId, name, supported count", q3.s(str), this.k.u().u(mVar.b), Integer.valueOf(this.k.a().p(str))); this.k.t().S(this.A, str, 8, null, null, 0); K().e0(); return; } K().H(lVar); U(); P(); d.A(mVar); d.A(zzn); d.w(mVar.a); d.l(mVar.a.equals(zzn.i)); e1.a u0 = e1.u0(); u0.q(); u0.x("android"); if (!TextUtils.isEmpty(zzn.i)) { u0.X(zzn.i); } if (!TextUtils.isEmpty(zzn.l)) { u0.T(zzn.l); } if (!TextUtils.isEmpty(zzn.k)) { u0.a0(zzn.k); } long j3 = zzn.r; if (j3 != -2147483648L) { u0.c0((int) j3); } u0.W(zzn.m); if (!TextUtils.isEmpty(zzn.j)) { u0.m0(zzn.j); } if (t8.b() && this.k.a().o(p.J0)) { u0.w0(a(zzn.i).h(d.b(zzn.E)).d()); } if (da.b() && this.k.a().v(zzn.i, p.f1230j0)) { if (TextUtils.isEmpty(u0.s0()) && !TextUtils.isEmpty(zzn.D)) { u0.u0(zzn.D); } if (TextUtils.isEmpty(u0.s0()) && TextUtils.isEmpty(u0.x0()) && !TextUtils.isEmpty(zzn.f2399z)) { u0.r0(zzn.f2399z); } } else if (TextUtils.isEmpty(u0.s0()) && !TextUtils.isEmpty(zzn.f2399z)) { u0.r0(zzn.f2399z); } long j4 = zzn.n; if (j4 != 0) { u0.d0(j4); } u0.l0(zzn.B); List U = N().U(); if (U != null) { u0.M(U); } d h = a(zzn.i).h(d.b(zzn.E)); if (!t8.b() || !this.k.a().o(p.J0) || h.j()) { Pair s2 = this.j.s(zzn.i, h); if (!TextUtils.isEmpty((CharSequence) s2.first)) { if (zzn.w) { u0.e0((String) s2.first); Object obj2 = s2.second; if (obj2 != null) { u0.y(((Boolean) obj2).booleanValue()); } } } else if (!this.k.y().s(this.k.j()) && zzn.f2397x && (!hb.b() || !this.k.a().v(zzn.i, p.G0))) { String string = Settings.Secure.getString(this.k.j().getContentResolver(), "android_id"); if (string == null) { this.k.g().A().b("null secure ID. appId", q3.s(u0.k0())); string = "null"; } else if (string.isEmpty()) { this.k.g().A().b("empty secure ID. appId", q3.s(u0.k0())); } u0.o0(string); } } this.k.y().o(); u0.J(Build.MODEL); this.k.y().o(); u0.E(Build.VERSION.RELEASE); u0.V((int) this.k.y().t()); u0.N(this.k.y().u()); if (!this.k.a().o(p.y0)) { u0.i0(zzn.t); } if (this.k.d()) { if (!t8.b() || !this.k.a().o(p.J0)) { u0.k0(); } else { u0.k0(); } if (!TextUtils.isEmpty(null)) { u0.q0(); throw null; } } a4 T2 = K().T(zzn.i); if (T2 == null) { T2 = new a4(this.k, zzn.i); if (!t8.b() || !this.k.a().o(p.J0)) { T2.c(W()); } else { T2.c(c(h)); } T2.A(zzn.f2396s); T2.m(zzn.j); if (!t8.b() || !this.k.a().o(p.J0) || h.j()) { T2.x(this.j.t(zzn.i)); } T2.C(0); T2.a(0); T2.l(0); T2.D(zzn.k); T2.p(zzn.r); T2.G(zzn.l); T2.t(zzn.m); T2.w(zzn.n); T2.e(zzn.p); if (!this.k.a().o(p.y0)) { T2.R(zzn.t); } T2.z(zzn.B); K().I(T2); } if ((!t8.b() || !this.k.a().o(p.J0) || h.k()) && !TextUtils.isEmpty(T2.s())) { u0.h0(T2.s()); } if (!TextUtils.isEmpty(T2.H())) { u0.n0(T2.H()); } List C = K().C(zzn.i); for (int i2 = 0; i2 < C.size(); i2++) { i1.a L = i1.L(); L.r(C.get(i2).f1247c); L.q(C.get(i2).d); N().G(L, C.get(i2).e); u0.u(L); } try { long v = K().v((e1) ((u4) u0.p())); g K2 = K(); zzap = mVar.f; boolean z6 = false; if (K2.L(mVar, v, z6)) { this.n = 0; } } catch (IOException e2) { this.k.g().z().c("Data loss. Failed to insert raw event metadata. appId", q3.s(u0.k0()), e2); } if (zzap != null) { Iterator it = zzap.iterator(); while (true) { n nVar = (n) it; if (nVar.hasNext()) { if ("_r".equals((String) nVar.next())) { break; } } else { boolean y2 = H().y(mVar.a, mVar.b); f y3 = K().y(V(), mVar.a, false, false); if (y2 && y3.e < ((long) this.k.a().s(mVar.a))) { break; } } } } K().s(); K().e0(); w(); this.k.g().D().b("Background event processing time, ms", Long.valueOf(((System.nanoTime() - j) + 500000) / 1000000)); } } public final x3 J() { C(this.f1209c); return this.f1209c; } public final g K() { C(this.d); return this.d; } public final boolean L(zzn zzn) { return (!da.b() || !this.k.h.u(zzn.i, p.f1230j0)) ? !TextUtils.isEmpty(zzn.j) || !TextUtils.isEmpty(zzn.f2399z) : !TextUtils.isEmpty(zzn.j) || !TextUtils.isEmpty(zzn.D) || !TextUtils.isEmpty(zzn.f2399z); } public final ba M() { C(this.g); return this.g; } public final q9 N() { C(this.h); return this.h; } public final o3 O() { return this.k.u(); } public final void P() { if (!this.l) { throw new IllegalStateException("UploadController is not initialized"); } } @WorkerThread public final void Q() { a4 T; String str; U(); P(); this.t = true; boolean z2 = false; try { Boolean bool = this.k.x().e; if (bool == null) { this.k.g().i.a("Upload data called on the client side before use of service was decided"); } else if (bool.booleanValue()) { this.k.g().f.a("Upload called in the client side when service should be used"); this.t = false; x(); } else if (this.n > 0) { w(); this.t = false; x(); } else { U(); if (this.w != null) { this.k.g().n.a("Uploading requested multiple times"); this.t = false; x(); } else if (!J().u()) { this.k.g().n.a("Network not connected, ignoring upload request"); w(); this.t = false; x(); } else { Objects.requireNonNull((c) this.k.o); long currentTimeMillis = System.currentTimeMillis(); int q = this.k.h.q(null, p.Q); long longValue = currentTimeMillis - p.d.a(null).longValue(); for (int i = 0; i < q && t(longValue); i++) { } long a2 = this.k.o().f.a(); if (a2 != 0) { this.k.g().m.b("Uploading events. Elapsed time since last upload attempt (ms)", Long.valueOf(Math.abs(currentTimeMillis - a2))); } String u = K().u(); if (!TextUtils.isEmpty(u)) { if (this.f1212y == -1) { this.f1212y = K().j0(); } List> D = K().D(u, this.k.h.q(u, p.g), Math.max(0, this.k.h.q(u, p.h))); if (!D.isEmpty()) { if (!t8.b() || !this.k.h.o(p.J0) || a(u).j()) { Iterator> it = D.iterator(); while (true) { if (!it.hasNext()) { str = null; break; } e1 e1Var = (e1) it.next().first; if (!TextUtils.isEmpty(e1Var.J())) { str = e1Var.J(); break; } } if (str != null) { int i2 = 0; while (true) { if (i2 >= D.size()) { break; } e1 e1Var2 = (e1) D.get(i2).first; if (!(TextUtils.isEmpty(e1Var2.J()) || e1Var2.J().equals(str))) { D = D.subList(0, i2); break; } i2++; } } } d1.a x2 = d1.x(); int size = D.size(); ArrayList arrayList = new ArrayList(D.size()); boolean z3 = "1".equals(this.k.h.f1185c.i(u, "gaia_collection_enabled")) && (!t8.b() || !this.k.h.o(p.J0) || a(u).j()); boolean z4 = !t8.b() || !this.k.h.o(p.J0) || a(u).j(); boolean z5 = !t8.b() || !this.k.h.o(p.J0) || a(u).k(); int i3 = 0; while (i3 < size) { e1.a t = ((e1) D.get(i3).first).t(); arrayList.add((Long) D.get(i3).second); if (t.k) { t.n(); t.k = false; } e1.W0((e1) t.j, 33025); if (t.k) { t.n(); t.k = false; } e1.y((e1) t.j, currentTimeMillis); if (t.k) { t.n(); t.k = false; } e1.m0((e1) t.j, false); if (!z3) { if (t.k) { t.n(); t.k = false; } e1.i1((e1) t.j); } if (t8.b() && this.k.h.o(p.J0)) { if (!z4) { if (t.k) { t.n(); t.k = false; } e1.F0((e1) t.j); if (t.k) { t.n(); t.k = false; } e1.L0((e1) t.j); } if (!z5) { if (t.k) { t.n(); t.k = false; } e1.Q0((e1) t.j); } } if (this.k.h.u(u, p.X)) { long t2 = N().t(((e1) ((u4) t.p())).d()); if (t.k) { t.n(); t.k = false; } e1.p1((e1) t.j, t2); } x2.q(t); i3++; arrayList = arrayList; } String z6 = this.k.g().x(2) ? N().z((d1) ((u4) x2.p())) : null; N(); byte[] d = ((d1) ((u4) x2.p())).d(); String a3 = p.q.a(null); try { URL url = new URL(a3); d.l(!arrayList.isEmpty()); if (this.w != null) { this.k.g().f.a("Set uploading progress before finishing the previous upload"); } else { this.w = new ArrayList(arrayList); } this.k.o().g.b(currentTimeMillis); String str2 = "?"; if (size > 0) { str2 = ((d1) x2.j).u().G1(); } this.k.g().n.d("Uploading data. app, uncompressed size, data", str2, Integer.valueOf(d.length), z6); this.f1210s = true; x3 J = J(); m9 m9Var = new m9(this, u); J.b(); J.n(); J.f().x(new c4(J, u, url, d, null, m9Var)); } catch (MalformedURLException unused) { this.k.g().f.c("Failed to parse upload URL. Not uploading. appId", q3.s(u), a3); } } } else { this.f1212y = -1; String B = K().B(currentTimeMillis - p.d.a(null).longValue()); if (!TextUtils.isEmpty(B) && (T = K().T(B)) != null) { n(T); } } this.t = false; x(); } } } finally { this.t = z2; x(); } } /* JADX WARNING: Removed duplicated region for block: B:24:0x00a3 */ /* JADX WARNING: Removed duplicated region for block: B:42:0x010b */ /* JADX WARNING: Removed duplicated region for block: B:43:0x0122 */ /* JADX WARNING: Removed duplicated region for block: B:58:0x018b */ /* JADX WARNING: Removed duplicated region for block: B:59:0x01a1 */ /* JADX WARNING: Removed duplicated region for block: B:62:? A[RETURN, SYNTHETIC] */ @WorkerThread public final void R() { boolean z2; int i; int i2; FileLock fileLock; U(); P(); if (!this.m) { boolean z3 = true; this.m = true; U(); if (!this.k.h.o(p.f1229i0) || (fileLock = this.u) == null || !fileLock.isValid()) { try { FileChannel channel = new RandomAccessFile(new File(this.k.b.getFilesDir(), "google_app_measurement.db"), "rw").getChannel(); this.v = channel; FileLock tryLock = channel.tryLock(); this.u = tryLock; if (tryLock != null) { this.k.g().n.a("Storage concurrent access okay"); } else { this.k.g().f.a("Storage concurrent data access panic"); z2 = false; if (!z2) { FileChannel fileChannel = this.v; U(); if (fileChannel == null || !fileChannel.isOpen()) { this.k.g().f.a("Bad channel to read from"); } else { ByteBuffer allocate = ByteBuffer.allocate(4); try { fileChannel.position(0L); int read = fileChannel.read(allocate); if (read == 4) { allocate.flip(); i = allocate.getInt(); n3 z4 = this.k.z(); z4.t(); i2 = z4.e; U(); if (i <= i2) { this.k.g().f.c("Panic: can't downgrade version. Previous, current version", Integer.valueOf(i), Integer.valueOf(i2)); return; } else if (i < i2) { FileChannel fileChannel2 = this.v; U(); if (fileChannel2 == null || !fileChannel2.isOpen()) { this.k.g().f.a("Bad channel to read from"); } else { ByteBuffer allocate2 = ByteBuffer.allocate(4); allocate2.putInt(i2); allocate2.flip(); try { fileChannel2.truncate(0L); this.k.h.o(p.s0); fileChannel2.write(allocate2); fileChannel2.force(true); if (fileChannel2.size() != 4) { this.k.g().f.b("Error writing to channel. Bytes written", Long.valueOf(fileChannel2.size())); } } catch (IOException e) { this.k.g().f.b("Failed to write to channel", e); } if (!z3) { this.k.g().n.c("Storage version upgraded. Previous, current version", Integer.valueOf(i), Integer.valueOf(i2)); return; } else { this.k.g().f.c("Storage version upgrade failed. Previous, current version", Integer.valueOf(i), Integer.valueOf(i2)); return; } } z3 = false; if (!z3) { } } else { return; } } else if (read != -1) { this.k.g().i.b("Unexpected data length. Bytes read", Integer.valueOf(read)); } } catch (IOException e2) { this.k.g().f.b("Failed to read from channel", e2); } } i = 0; n3 z4 = this.k.z(); z4.t(); i2 = z4.e; U(); if (i <= i2) { } } else { return; } } } catch (FileNotFoundException e3) { this.k.g().f.b("Failed to acquire storage lock", e3); } catch (IOException e4) { this.k.g().f.b("Failed to access storage lock file", e4); } catch (OverlappingFileLockException e5) { this.k.g().i.b("Storage lock already acquired", e5); } } else { this.k.g().n.a("Storage concurrent access okay"); } z2 = true; if (!z2) { } } } public final b4 S() { b4 b4Var = this.e; if (b4Var != null) { return b4Var; } throw new IllegalStateException("Network broadcast receiver not created"); } public final h9 T() { C(this.f); return this.f; } @WorkerThread public final void U() { this.k.f().b(); } public final long V() { Objects.requireNonNull((c) this.k.o); long currentTimeMillis = System.currentTimeMillis(); d4 o = this.k.o(); o.o(); o.b(); long a2 = o.j.a(); if (a2 == 0) { a2 = 1 + ((long) o.e().v0().nextInt(86400000)); o.j.b(a2); } return ((((currentTimeMillis + a2) / 1000) / 60) / 60) / 24; } @WorkerThread @Deprecated public final String W() { byte[] bArr = new byte[16]; this.k.t().v0().nextBytes(bArr); return String.format(Locale.US, "%032x", new BigInteger(1, bArr)); } @WorkerThread public final d a(String str) { String str2; d dVar = d.a; if (!t8.b() || !this.k.h.o(p.J0)) { return dVar; } U(); P(); d dVar2 = this.f1213z.get(str); if (dVar2 != null) { return dVar2; } g K = K(); Objects.requireNonNull(K); Objects.requireNonNull(str, "null reference"); K.b(); K.n(); Cursor cursor = null; try { Cursor rawQuery = K.t().rawQuery("select consent_state from consent_settings where app_id=? limit 1;", new String[]{str}); if (rawQuery.moveToFirst()) { str2 = rawQuery.getString(0); rawQuery.close(); } else { rawQuery.close(); str2 = "G1"; } d b = d.b(str2); s(str, b); return b; } catch (SQLiteException e) { K.g().f.c("Database error", "select consent_state from consent_settings where app_id=? limit 1;", e); throw e; } catch (Throwable th) { if (0 != 0) { cursor.close(); } throw th; } } @WorkerThread public final String c(d dVar) { if (!t8.b() || !this.k.h.o(p.J0) || dVar.k()) { return W(); } return null; } @Override // c.i.a.f.i.b.t5 public final r4 f() { return this.k.f(); } @Override // c.i.a.f.i.b.t5 public final q3 g() { return this.k.g(); } @Override // c.i.a.f.i.b.t5 public final c.i.a.f.e.o.b h() { return this.k.o; } public final void i(e1.a aVar, long j, boolean z2) { u9 u9Var; boolean z3; String str = z2 ? "_se" : "_lte"; u9 Y = K().Y(aVar.k0(), str); if (Y == null || Y.e == null) { String k0 = aVar.k0(); Objects.requireNonNull((c) this.k.o); u9Var = new u9(k0, "auto", str, System.currentTimeMillis(), Long.valueOf(j)); } else { String k02 = aVar.k0(); Objects.requireNonNull((c) this.k.o); u9Var = new u9(k02, "auto", str, System.currentTimeMillis(), Long.valueOf(((Long) Y.e).longValue() + j)); } i1.a L = i1.L(); L.r(str); Objects.requireNonNull((c) this.k.o); L.q(System.currentTimeMillis()); L.s(((Long) u9Var.e).longValue()); i1 i1Var = (i1) ((u4) L.p()); int s2 = q9.s(aVar, str); if (s2 >= 0) { if (aVar.k) { aVar.n(); aVar.k = false; } e1.x((e1) aVar.j, s2, i1Var); z3 = true; } else { z3 = false; } if (!z3) { if (aVar.k) { aVar.n(); aVar.k = false; } e1.A((e1) aVar.j, i1Var); } if (j > 0) { K().M(u9Var); this.k.g().n.c("Updated engagement user property. scope, value", z2 ? "session-scoped" : "lifetime", u9Var.e); } } @Override // c.i.a.f.i.b.t5 public final Context j() { return this.k.b; } @Override // c.i.a.f.i.b.t5 public final ga k() { return this.k.g; } @WorkerThread public final void l(zzaq zzaq, zzn zzn) { List list; List list2; List list3; zzaq zzaq2 = zzaq; Objects.requireNonNull(zzn, "null reference"); d.w(zzn.i); U(); P(); String str = zzn.i; long j = zzaq2.l; N(); if (q9.O(zzaq, zzn)) { if (!zzn.p) { G(zzn); return; } List list4 = zzn.C; if (list4 != null) { if (list4.contains(zzaq2.i)) { Bundle x0 = zzaq2.j.x0(); x0.putLong("ga_safelisted", 1); zzaq2 = new zzaq(zzaq2.i, new zzap(x0), zzaq2.k, zzaq2.l); } else { this.k.g().m.d("Dropping non-safelisted event. appId, event name, origin", str, zzaq2.i, zzaq2.k); return; } } K().b0(); try { g K = K(); d.w(str); K.b(); K.n(); int i = (j > 0 ? 1 : (j == 0 ? 0 : -1)); if (i < 0) { K.g().i.c("Invalid time querying timed out conditional properties", q3.s(str), Long.valueOf(j)); list = Collections.emptyList(); } else { list = K.F("active=0 and app_id=? and abs(? - creation_timestamp) > trigger_timeout", new String[]{str, String.valueOf(j)}); } for (zzz zzz : list) { if (zzz != null) { this.k.g().n.d("User property timed out", zzz.i, this.k.u().y(zzz.k.j), zzz.k.w0()); zzaq zzaq3 = zzz.o; if (zzaq3 != null) { I(new zzaq(zzaq3, j), zzn); } K().a0(str, zzz.k.j); } } g K2 = K(); d.w(str); K2.b(); K2.n(); if (i < 0) { K2.g().i.c("Invalid time querying expired conditional properties", q3.s(str), Long.valueOf(j)); list2 = Collections.emptyList(); } else { list2 = K2.F("active<>0 and app_id=? and abs(? - triggered_timestamp) > time_to_live", new String[]{str, String.valueOf(j)}); } ArrayList arrayList = new ArrayList(list2.size()); for (zzz zzz2 : list2) { if (zzz2 != null) { this.k.g().n.d("User property expired", zzz2.i, this.k.u().y(zzz2.k.j), zzz2.k.w0()); K().V(str, zzz2.k.j); zzaq zzaq4 = zzz2.f2400s; if (zzaq4 != null) { arrayList.add(zzaq4); } K().a0(str, zzz2.k.j); } } int size = arrayList.size(); int i2 = 0; while (i2 < size) { Object obj = arrayList.get(i2); i2++; I(new zzaq((zzaq) obj, j), zzn); } g K3 = K(); String str2 = zzaq2.i; d.w(str); d.w(str2); K3.b(); K3.n(); if (i < 0) { K3.g().i.d("Invalid time querying triggered conditional properties", q3.s(str), K3.d().u(str2), Long.valueOf(j)); list3 = Collections.emptyList(); } else { list3 = K3.F("active=0 and app_id=? and trigger_event_name=? and abs(? - creation_timestamp) <= trigger_timeout", new String[]{str, str2, String.valueOf(j)}); } ArrayList arrayList2 = new ArrayList(list3.size()); for (zzz zzz3 : list3) { if (zzz3 != null) { zzku zzku = zzz3.k; u9 u9Var = new u9(zzz3.i, zzz3.j, zzku.j, j, zzku.w0()); if (K().M(u9Var)) { this.k.g().n.d("User property triggered", zzz3.i, this.k.u().y(u9Var.f1247c), u9Var.e); } else { this.k.g().f.d("Too many active user properties, ignoring", q3.s(zzz3.i), this.k.u().y(u9Var.f1247c), u9Var.e); } zzaq zzaq5 = zzz3.q; if (zzaq5 != null) { arrayList2.add(zzaq5); } zzz3.k = new zzku(u9Var); zzz3.m = true; K().N(zzz3); } } I(zzaq2, zzn); int size2 = arrayList2.size(); int i3 = 0; while (i3 < size2) { Object obj2 = arrayList2.get(i3); i3++; I(new zzaq((zzaq) obj2, j), zzn); } K().s(); } finally { K().e0(); } } } @WorkerThread public final void m(zzaq zzaq, String str) { boolean z2; String str2; a4 T = K().T(str); if (T == null || TextUtils.isEmpty(T.M())) { this.k.g().m.b("No app data available; dropping event", str); return; } Boolean z3 = z(T); if (z3 == null) { if (!"_ui".equals(zzaq.i)) { this.k.g().i.b("Could not find package. appId", q3.s(str)); } } else if (!z3.booleanValue()) { this.k.g().f.b("App version does not match; dropping event. appId", q3.s(str)); return; } String v = T.v(); String M = T.M(); long N = T.N(); String O = T.O(); long P = T.P(); long Q = T.Q(); boolean T2 = T.T(); String H = T.H(); long g = T.g(); boolean h = T.h(); boolean i = T.i(); String y2 = T.y(); Boolean j = T.j(); long S = T.S(); List k = T.k(); if (da.b()) { z2 = T2; if (this.k.h.u(T.o(), p.f1230j0)) { str2 = T.B(); B(zzaq, new zzn(str, v, M, N, O, P, Q, (String) null, z2, false, H, g, 0L, 0, h, i, false, y2, j, S, k, str2, (t8.b() || !this.k.h.o(p.J0)) ? "" : a(str).d())); } } else { z2 = T2; } str2 = null; B(zzaq, new zzn(str, v, M, N, O, P, Q, (String) null, z2, false, H, g, 0L, 0, h, i, false, y2, j, S, k, str2, (t8.b() || !this.k.h.o(p.J0)) ? "" : a(str).d())); } /* JADX WARNING: Code restructure failed: missing block: B:25:0x009b, code lost: if (android.text.TextUtils.isEmpty(r2) != false) goto L_0x009d; */ @WorkerThread public final void n(a4 a4Var) { U(); if (!da.b() || !this.k.h.u(a4Var.o(), p.f1230j0)) { if (TextUtils.isEmpty(a4Var.v()) && TextUtils.isEmpty(a4Var.y())) { r(a4Var.o(), 204, null, null, null); return; } } else if (TextUtils.isEmpty(a4Var.v()) && TextUtils.isEmpty(a4Var.B()) && TextUtils.isEmpty(a4Var.y())) { r(a4Var.o(), 204, null, null, null); return; } c cVar = this.k.h; Objects.requireNonNull(cVar); Uri.Builder builder = new Uri.Builder(); String v = a4Var.v(); if (TextUtils.isEmpty(v)) { if (da.b() && cVar.a.h.u(a4Var.o(), p.f1230j0)) { v = a4Var.B(); } v = a4Var.y(); } ArrayMap arrayMap = null; Uri.Builder encodedAuthority = builder.scheme(p.e.a(null)).encodedAuthority(p.f.a(null)); String valueOf = String.valueOf(v); encodedAuthority.path(valueOf.length() != 0 ? "config/app/".concat(valueOf) : new String("config/app/")).appendQueryParameter("app_instance_id", a4Var.s()).appendQueryParameter("platform", "android").appendQueryParameter("gmp_version", "33025"); String uri = builder.build().toString(); try { URL url = new URL(uri); this.k.g().n.b("Fetching remote configuration", a4Var.o()); u0 s2 = H().s(a4Var.o()); p4 H = H(); String o = a4Var.o(); H.b(); String str = H.i.get(o); if (s2 != null && !TextUtils.isEmpty(str)) { arrayMap = new ArrayMap(); arrayMap.put("If-Modified-Since", str); } this.r = true; x3 J = J(); String o2 = a4Var.o(); l9 l9Var = new l9(this); J.b(); J.n(); J.f().x(new c4(J, o2, url, null, arrayMap, l9Var)); } catch (MalformedURLException unused) { this.k.g().f.c("Failed to parse config URL. Not fetching. appId", q3.s(a4Var.o()), uri); } } @WorkerThread public final void o(zzku zzku, zzn zzn) { U(); P(); if (L(zzn)) { if (!zzn.p) { G(zzn); return; } int h02 = this.k.t().h0(zzku.j); if (h02 != 0) { this.k.t(); String E = t9.E(zzku.j, 24, true); String str = zzku.j; this.k.t().S(this.A, zzn.i, h02, "_ev", E, str != null ? str.length() : 0); return; } int i02 = this.k.t().i0(zzku.j, zzku.w0()); if (i02 != 0) { this.k.t(); String E2 = t9.E(zzku.j, 24, true); Object w0 = zzku.w0(); this.k.t().S(this.A, zzn.i, i02, "_ev", E2, (w0 == null || (!(w0 instanceof String) && !(w0 instanceof CharSequence))) ? 0 : String.valueOf(w0).length()); return; } Object n0 = this.k.t().n0(zzku.j, zzku.w0()); if (n0 != null) { if ("_sid".equals(zzku.j)) { long j = zzku.k; String str2 = zzku.n; long j2 = 0; u9 Y = K().Y(zzn.i, "_sno"); if (Y != null) { Object obj = Y.e; if (obj instanceof Long) { j2 = ((Long) obj).longValue(); o(new zzku("_sno", j, Long.valueOf(j2 + 1), str2), zzn); } } if (Y != null) { this.k.g().i.b("Retrieved last session number from database does not contain a valid (long) value", Y.e); } l z2 = K().z(zzn.i, "_s"); if (z2 != null) { j2 = z2.f1215c; this.k.g().n.b("Backfill the session number. Last used session number", Long.valueOf(j2)); } o(new zzku("_sno", j, Long.valueOf(j2 + 1), str2), zzn); } u9 u9Var = new u9(zzn.i, zzku.n, zzku.j, zzku.k, n0); this.k.g().n.c("Setting user property", this.k.u().y(u9Var.f1247c), n0); K().b0(); try { G(zzn); boolean M = K().M(u9Var); K().s(); if (!M) { this.k.g().f.c("Too many unique user properties are set. Ignoring user property", this.k.u().y(u9Var.f1247c), u9Var.e); this.k.t().S(this.A, zzn.i, 9, null, null, 0); } } finally { K().e0(); } } } } @WorkerThread public final void p(zzn zzn) { if (this.w != null) { ArrayList arrayList = new ArrayList(); this.f1211x = arrayList; arrayList.addAll(this.w); } g K = K(); String str = zzn.i; d.w(str); K.b(); K.n(); try { SQLiteDatabase t = K.t(); String[] strArr = {str}; int delete = t.delete("apps", "app_id=?", strArr) + 0 + t.delete("events", "app_id=?", strArr) + t.delete("user_attributes", "app_id=?", strArr) + t.delete("conditional_properties", "app_id=?", strArr) + t.delete("raw_events", "app_id=?", strArr) + t.delete("raw_events_metadata", "app_id=?", strArr) + t.delete("queue", "app_id=?", strArr) + t.delete("audience_filter_values", "app_id=?", strArr) + t.delete("main_event_params", "app_id=?", strArr) + t.delete("default_event_params", "app_id=?", strArr); if (delete > 0) { K.g().n.c("Reset analytics data. app, records", str, Integer.valueOf(delete)); } } catch (SQLiteException e) { K.g().f.c("Error resetting analytics data. appId, error", q3.s(str), e); } if (zzn.p) { E(zzn); } } @WorkerThread public final void q(zzz zzz, zzn zzn) { zzaq zzaq; boolean z2; Objects.requireNonNull(zzz, "null reference"); d.w(zzz.i); Objects.requireNonNull(zzz.j, "null reference"); Objects.requireNonNull(zzz.k, "null reference"); d.w(zzz.k.j); U(); P(); if (L(zzn)) { if (!zzn.p) { G(zzn); return; } zzz zzz2 = new zzz(zzz); boolean z3 = false; zzz2.m = false; K().b0(); try { zzz Z = K().Z(zzz2.i, zzz2.k.j); if (Z != null && !Z.j.equals(zzz2.j)) { this.k.g().i.d("Updating a conditional user property with different origin. name, origin, origin (from DB)", this.k.u().y(zzz2.k.j), zzz2.j, Z.j); } if (Z != null && (z2 = Z.m)) { zzz2.j = Z.j; zzz2.l = Z.l; zzz2.p = Z.p; zzz2.n = Z.n; zzz2.q = Z.q; zzz2.m = z2; zzku zzku = zzz2.k; zzz2.k = new zzku(zzku.j, Z.k.k, zzku.w0(), Z.k.n); } else if (TextUtils.isEmpty(zzz2.n)) { zzku zzku2 = zzz2.k; zzz2.k = new zzku(zzku2.j, zzz2.l, zzku2.w0(), zzz2.k.n); zzz2.m = true; z3 = true; } if (zzz2.m) { zzku zzku3 = zzz2.k; u9 u9Var = new u9(zzz2.i, zzz2.j, zzku3.j, zzku3.k, zzku3.w0()); if (K().M(u9Var)) { this.k.g().m.d("User property updated immediately", zzz2.i, this.k.u().y(u9Var.f1247c), u9Var.e); } else { this.k.g().f.d("(2)Too many active user properties, ignoring", q3.s(zzz2.i), this.k.u().y(u9Var.f1247c), u9Var.e); } if (z3 && (zzaq = zzz2.q) != null) { I(new zzaq(zzaq, zzz2.l), zzn); } } if (K().N(zzz2)) { this.k.g().m.d("Conditional property added", zzz2.i, this.k.u().y(zzz2.k.j), zzz2.k.w0()); } else { this.k.g().f.d("Too many conditional properties, ignoring", q3.s(zzz2.i), this.k.u().y(zzz2.k.j), zzz2.k.w0()); } K().s(); } finally { K().e0(); } } } /* JADX INFO: finally extract failed */ /* JADX WARNING: Removed duplicated region for block: B:46:0x0126 A[Catch:{ all -> 0x0175 }] */ /* JADX WARNING: Removed duplicated region for block: B:47:0x0134 A[Catch:{ all -> 0x0175 }] */ @WorkerThread public final void r(String str, int i, Throwable th, byte[] bArr, Map> map) { U(); P(); d.w(str); if (bArr == null) { try { bArr = new byte[0]; } catch (Throwable th2) { this.r = false; x(); throw th2; } } this.k.g().n.b("onConfigFetched. Response size", Integer.valueOf(bArr.length)); K().b0(); try { a4 T = K().T(str); boolean z2 = true; boolean z3 = (i == 200 || i == 204 || i == 304) && th == null; if (T == null) { this.k.g().i.b("App does not exist in onConfigFetched. appId", q3.s(str)); } else { if (!z3) { if (i != 404) { Objects.requireNonNull((c) this.k.o); T.I(System.currentTimeMillis()); K().I(T); this.k.g().n.c("Fetching config failed. code, error", Integer.valueOf(i), th); p4 H = H(); H.b(); H.i.put(str, null); h4 h4Var = this.k.o().g; Objects.requireNonNull((c) this.k.o); h4Var.b(System.currentTimeMillis()); if (i != 503) { if (i != 429) { z2 = false; } } if (z2) { h4 h4Var2 = this.k.o().h; Objects.requireNonNull((c) this.k.o); h4Var2.b(System.currentTimeMillis()); } w(); } } List list = map != null ? map.get("Last-Modified") : null; String str2 = (list == null || list.size() <= 0) ? null : list.get(0); if (i != 404) { if (i != 304) { H().w(str, bArr, str2); Objects.requireNonNull((c) this.k.o); T.F(System.currentTimeMillis()); K().I(T); if (i != 404) { this.k.g().k.b("Config not found. Using empty config. appId", str); } else { this.k.g().n.c("Successfully fetched config. Got network response. code, size", Integer.valueOf(i), Integer.valueOf(bArr.length)); } if (J().u() || !v()) { w(); } else { Q(); } } } if (H().s(str) == null) { H().w(str, null, null); } Objects.requireNonNull((c) this.k.o); T.F(System.currentTimeMillis()); K().I(T); if (i != 404) { } if (J().u()) { } w(); } K().s(); K().e0(); this.r = false; x(); } catch (Throwable th3) { K().e0(); throw th3; } } @WorkerThread public final void s(String str, d dVar) { if (t8.b() && this.k.h.o(p.J0)) { U(); P(); this.f1213z.put(str, dVar); g K = K(); if (t8.b() && K.a.h.o(p.J0)) { Objects.requireNonNull(str, "null reference"); K.b(); K.n(); ContentValues contentValues = new ContentValues(); contentValues.put("app_id", str); contentValues.put("consent_state", dVar.d()); try { if (K.t().insertWithOnConflict("consent_settings", null, contentValues, 5) == -1) { K.g().f.b("Failed to insert/update consent setting (got -1). appId", q3.s(str)); } } catch (SQLiteException e) { K.g().f.c("Error storing consent setting. appId, error", q3.s(str), e); } } } } /* JADX WARNING: Code restructure failed: missing block: B:107:0x025f, code lost: r0 = e; */ /* JADX WARNING: Code restructure failed: missing block: B:108:0x0261, code lost: r0 = e; */ /* JADX WARNING: Code restructure failed: missing block: B:109:0x0262, code lost: r9 = r4; */ /* JADX WARNING: Code restructure failed: missing block: B:113:0x0283, code lost: r0 = e; */ /* JADX WARNING: Code restructure failed: missing block: B:114:0x0284, code lost: r28 = "_si"; r29 = "_sc"; */ /* JADX WARNING: Code restructure failed: missing block: B:123:0x02aa, code lost: r0 = move-exception; */ /* JADX WARNING: Code restructure failed: missing block: B:124:0x02ab, code lost: r2 = r0; */ /* JADX WARNING: Code restructure failed: missing block: B:125:0x02af, code lost: r0 = move-exception; */ /* JADX WARNING: Code restructure failed: missing block: B:126:0x02b0, code lost: r28 = "_si"; r29 = "_sc"; r9 = r4; r27 = "_npa"; r2 = r0; */ /* JADX WARNING: Code restructure failed: missing block: B:127:0x02b9, code lost: r0 = e; */ /* JADX WARNING: Code restructure failed: missing block: B:128:0x02ba, code lost: r28 = "_si"; r29 = "_sc"; r9 = r4; r27 = "_npa"; */ /* JADX WARNING: Code restructure failed: missing block: B:129:0x02c2, code lost: r0 = move-exception; */ /* JADX WARNING: Code restructure failed: missing block: B:130:0x02c3, code lost: r2 = r0; r9 = null; */ /* JADX WARNING: Code restructure failed: missing block: B:131:0x02c8, code lost: r0 = e; */ /* JADX WARNING: Code restructure failed: missing block: B:132:0x02c9, code lost: r28 = "_si"; r29 = "_sc"; r9 = r4; r27 = "_npa"; r26 = ""; */ /* JADX WARNING: Code restructure failed: missing block: B:133:0x02d2, code lost: r2 = r0; r7 = null; */ /* JADX WARNING: Code restructure failed: missing block: B:134:0x02d4, code lost: r14 = null; */ /* JADX WARNING: Code restructure failed: missing block: B:32:0x00a8, code lost: r0 = move-exception; */ /* JADX WARNING: Code restructure failed: missing block: B:33:0x00a9, code lost: r9 = r0; */ /* JADX WARNING: Code restructure failed: missing block: B:34:0x00ab, code lost: r0 = e; */ /* JADX WARNING: Code restructure failed: missing block: B:35:0x00ac, code lost: r26 = ""; */ /* JADX WARNING: Code restructure failed: missing block: B:36:0x00ae, code lost: r9 = r0; */ /* JADX WARNING: Code restructure failed: missing block: B:40:0x00c5, code lost: r0 = e; */ /* JADX WARNING: Code restructure failed: missing block: B:46:0x00d1, code lost: r7 = null; */ /* JADX WARNING: Code restructure failed: missing block: B:47:0x00d2, code lost: r28 = "_si"; r29 = "_sc"; r27 = "_npa"; r2 = r9; r14 = null; */ /* JADX WARNING: Code restructure failed: missing block: B:77:0x0190, code lost: r0 = e; */ /* JADX WARNING: Code restructure failed: missing block: B:78:0x0191, code lost: r28 = "_si"; */ /* JADX WARNING: Code restructure failed: missing block: B:79:0x0193, code lost: r29 = "_sc"; */ /* JADX WARNING: Code restructure failed: missing block: B:90:0x0201, code lost: r0 = e; */ /* JADX WARNING: Exception block dominator not found, dom blocks: [B:23:0x0084, B:50:0x00fe] */ /* JADX WARNING: Failed to process nested try/catch */ /* JADX WARNING: Removed duplicated region for block: B:123:0x02aa A[ExcHandler: all (r0v9 'th' java.lang.Throwable A[CUSTOM_DECLARE]), PHI: r7 PHI: (r7v42 android.database.Cursor) = (r7v49 android.database.Cursor), (r7v49 android.database.Cursor), (r7v54 android.database.Cursor), (r7v54 android.database.Cursor) binds: [B:97:0x0224, B:98:?, B:50:0x00fe, B:51:?] A[DONT_GENERATE, DONT_INLINE], Splitter:B:23:0x0084] */ /* JADX WARNING: Removed duplicated region for block: B:129:0x02c2 A[ExcHandler: all (r0v8 'th' java.lang.Throwable A[CUSTOM_DECLARE]), Splitter:B:4:0x002c] */ /* JADX WARNING: Removed duplicated region for block: B:138:0x02e8 */ /* JADX WARNING: Removed duplicated region for block: B:141:0x02ef */ /* JADX WARNING: Removed duplicated region for block: B:146:0x02fb */ /* JADX WARNING: Removed duplicated region for block: B:200:0x04d1 */ /* JADX WARNING: Removed duplicated region for block: B:207:0x04dd */ /* JADX WARNING: Removed duplicated region for block: B:213:0x04fa */ /* JADX WARNING: Removed duplicated region for block: B:226:0x058f */ /* JADX WARNING: Removed duplicated region for block: B:229:0x05e8 */ /* JADX WARNING: Removed duplicated region for block: B:230:0x05ec */ /* JADX WARNING: Removed duplicated region for block: B:239:0x064c */ /* JADX WARNING: Removed duplicated region for block: B:247:0x0673 A[ADDED_TO_REGION] */ /* JADX WARNING: Removed duplicated region for block: B:250:0x067c */ /* JADX WARNING: Removed duplicated region for block: B:251:0x0699 */ /* JADX WARNING: Removed duplicated region for block: B:289:0x078d */ /* JADX WARNING: Removed duplicated region for block: B:342:0x0934 */ /* JADX WARNING: Removed duplicated region for block: B:349:0x0955 */ /* JADX WARNING: Removed duplicated region for block: B:350:0x096f */ /* JADX WARNING: Removed duplicated region for block: B:472:0x0ce2 */ /* JADX WARNING: Removed duplicated region for block: B:473:0x0cf5 */ /* JADX WARNING: Removed duplicated region for block: B:475:0x0cf8 */ /* JADX WARNING: Removed duplicated region for block: B:476:0x0d1f */ /* JADX WARNING: Removed duplicated region for block: B:590:0x1083 */ /* JADX WARNING: Removed duplicated region for block: B:596:0x109a */ /* JADX WARNING: Removed duplicated region for block: B:610:0x055b A[EDGE_INSN: B:610:0x055b->B:221:0x055b ?: BREAK , SYNTHETIC] */ @WorkerThread public final boolean t(long j) { Cursor cursor; Throwable th; Cursor cursor2; String str; String str2; String str3; String str4; String str5; List list; boolean z2; boolean z3; a aVar; k9 k9Var; SecureRandom secureRandom; a aVar2; HashMap hashMap; k9 k9Var2; int i; boolean z4; int z5; Long l; HashMap hashMap2; int i2; long j2; a4 T; boolean z6; a1.a aVar3; String str6; boolean z7; int i3; String str7; int i4; e1.a aVar4; String str8; String str9; int i5; a1.a aVar5; int i6; boolean z8; e1.a aVar6; int i7; boolean z9; c1.a aVar7; a1.a aVar8; String str10; int i8; int i9; boolean z10; char c2; String str11; SQLiteException sQLiteException; SQLiteException e; String str12; Cursor cursor3; Throwable th2; String[] strArr; String str13; SQLiteException e2; k9 k9Var3 = this; String str14 = "_sn"; String str15 = "_ai"; K().b0(); try { a aVar9 = new a(k9Var3, null); g K = K(); long j3 = k9Var3.f1212y; d.A(aVar9); K.b(); K.n(); try { SQLiteDatabase t = K.t(); if (TextUtils.isEmpty(null)) { int i10 = (j3 > -1 ? 1 : (j3 == -1 ? 0 : -1)); String[] strArr2 = i10 != 0 ? new String[]{String.valueOf(j3), String.valueOf(j)} : new String[]{String.valueOf(j)}; String str16 = i10 != 0 ? "rowid <= ? and " : ""; str4 = ""; StringBuilder sb = new StringBuilder(str16.length() + 148); sb.append("select app_id, metadata_fingerprint from raw_events where "); sb.append(str16); sb.append("app_id in (select app_id from apps where config_fetched_time >= ?) order by rowid limit 1;"); cursor2 = t.rawQuery(sb.toString(), strArr2); try { if (!cursor2.moveToFirst()) { cursor2.close(); str2 = "_si"; str = "_sc"; str5 = str14; str3 = "_npa"; list = aVar9.f1214c; if (!(list != null || list.isEmpty())) { e1.a t2 = aVar9.a.t(); t2.F(); boolean v = k9Var3.k.a().v(aVar9.a.G1(), p.U); int i11 = -1; boolean z11 = false; int i12 = 0; int i13 = 0; a1.a aVar10 = null; a1.a aVar11 = null; int i14 = -1; long j4 = 0; while (true) { z2 = z11; if (i13 >= aVar9.f1214c.size()) { break; } a1.a t3 = aVar9.f1214c.get(i13).t(); if (H().x(aVar9.a.G1(), t3.y())) { z7 = v; k9Var3.k.g().A().c("Dropping blacklisted raw event. appId", q3.s(aVar9.a.G1()), k9Var3.k.u().u(t3.y())); if (!(H().C(aVar9.a.G1()) || H().D(aVar9.a.G1())) && !"_err".equals(t3.y())) { k9Var3.k.t().S(k9Var3.A, aVar9.a.G1(), 11, "_ev", t3.y(), 0); } i3 = i11; str6 = str15; aVar3 = aVar11; z11 = z2; i12 = i12; str7 = str5; str8 = str2; str9 = str; i4 = i13; aVar4 = t2; } else { z7 = v; if (x7.b() && k9Var3.k.a().v(aVar9.a.G1(), p.M0) && t3.y().equals(v5.a(str15))) { t3.t(str15); k9Var3.k.g().D().a("Renaming ad_impression to _ai"); if (k9Var3.k.g().x(5)) { for (int i15 = 0; i15 < t3.w(); i15++) { if ("ad_platform".equals(t3.u(i15).B()) && !TextUtils.isEmpty(t3.u(i15).G()) && AdjustConfig.AD_REVENUE_ADMOB.equalsIgnoreCase(t3.u(i15).G())) { k9Var3.k.g().B().a("AdMob ad impression logged from app. Potentially duplicative."); } } } } boolean y2 = H().y(aVar9.a.G1(), t3.y()); if (!y2) { N(); String y3 = t3.y(); d.w(y3); str6 = str15; int hashCode = y3.hashCode(); i5 = i14; if (hashCode != 94660) { if (hashCode != 95025) { if (hashCode == 95027 && y3.equals("_ui")) { c2 = 1; if (!(c2 != 0 || c2 == 1 || c2 == 2)) { aVar6 = t2; aVar5 = aVar10; aVar3 = aVar11; } aVar5 = aVar10; i6 = 0; boolean z12 = false; z8 = false; while (true) { aVar6 = t2; if (i6 >= t3.w()) { break; } if ("_c".equals(t3.u(i6).B())) { c1.a t4 = t3.u(i6).t(); t4.r(1); t3.q(i6, (c1) ((u4) t4.p())); aVar8 = aVar11; z12 = true; } else if ("_r".equals(t3.u(i6).B())) { c1.a t5 = t3.u(i6).t(); aVar8 = aVar11; t5.r(1); t3.q(i6, (c1) ((u4) t5.p())); z8 = true; } else { aVar8 = aVar11; } i6++; t2 = aVar6; aVar11 = aVar8; } aVar3 = aVar11; if (!z12 && y2) { k9Var3.k.g().D().b("Marking event as conversion", k9Var3.k.u().u(t3.y())); c1.a Q = c1.Q(); Q.s("_c"); Q.r(1); t3.s(Q); } if (!z8) { k9Var3.k.g().D().b("Marking event as real-time", k9Var3.k.u().u(t3.y())); c1.a Q2 = c1.Q(); Q2.s("_r"); Q2.r(1); t3.s(Q2); } if (K().y(V(), aVar9.a.G1(), false, true).e > ((long) k9Var3.k.a().s(aVar9.a.G1()))) { e(t3, "_r"); } else { z2 = true; } if (t9.X(t3.y()) && y2 && K().y(V(), aVar9.a.G1(), true, false).f1197c > ((long) k9Var3.k.a().q(aVar9.a.G1(), p.n))) { k9Var3.k.g().A().b("Too many conversions. Not logging as conversion. appId", q3.s(aVar9.a.G1())); z9 = false; int i16 = -1; aVar7 = null; for (i7 = 0; i7 < t3.w(); i7++) { c1 u = t3.u(i7); if ("_c".equals(u.B())) { aVar7 = u.t(); i16 = i7; } else if ("_err".equals(u.B())) { z9 = true; } } if (!z9 && aVar7 != null) { t3.x(i16); } else if (aVar7 != null) { c1.a aVar12 = (c1.a) ((u4.b) aVar7.clone()); aVar12.s("_err"); aVar12.r(10); t3.q(i16, (c1) ((u4) aVar12.p())); } else { k9Var3.k.g().z().b("Did not find conversion parameter. appId", q3.s(aVar9.a.G1())); } } } } else if (y3.equals("_ug")) { c2 = 2; if (!(c2 != 0 || c2 == 1 || c2 == 2)) { } aVar5 = aVar10; i6 = 0; boolean z12 = false; z8 = false; while (true) { aVar6 = t2; if (i6 >= t3.w()) { } i6++; t2 = aVar6; aVar11 = aVar8; } aVar3 = aVar11; k9Var3.k.g().D().b("Marking event as conversion", k9Var3.k.u().u(t3.y())); c1.a Q = c1.Q(); Q.s("_c"); Q.r(1); t3.s(Q); if (!z8) { } if (K().y(V(), aVar9.a.G1(), false, true).e > ((long) k9Var3.k.a().s(aVar9.a.G1()))) { } k9Var3.k.g().A().b("Too many conversions. Not logging as conversion. appId", q3.s(aVar9.a.G1())); z9 = false; int i16 = -1; aVar7 = null; while (i7 < t3.w()) { } if (!z9) { } if (aVar7 != null) { } } } else if (y3.equals("_in")) { c2 = 0; if (!(c2 != 0 || c2 == 1 || c2 == 2)) { } aVar5 = aVar10; i6 = 0; boolean z12 = false; z8 = false; while (true) { aVar6 = t2; if (i6 >= t3.w()) { } i6++; t2 = aVar6; aVar11 = aVar8; } aVar3 = aVar11; k9Var3.k.g().D().b("Marking event as conversion", k9Var3.k.u().u(t3.y())); c1.a Q = c1.Q(); Q.s("_c"); Q.r(1); t3.s(Q); if (!z8) { } if (K().y(V(), aVar9.a.G1(), false, true).e > ((long) k9Var3.k.a().s(aVar9.a.G1()))) { } k9Var3.k.g().A().b("Too many conversions. Not logging as conversion. appId", q3.s(aVar9.a.G1())); z9 = false; int i16 = -1; aVar7 = null; while (i7 < t3.w()) { } if (!z9) { } if (aVar7 != null) { } } c2 = 65535; if (!(c2 != 0 || c2 == 1 || c2 == 2)) { } aVar5 = aVar10; i6 = 0; boolean z12 = false; z8 = false; while (true) { aVar6 = t2; if (i6 >= t3.w()) { } i6++; t2 = aVar6; aVar11 = aVar8; } aVar3 = aVar11; k9Var3.k.g().D().b("Marking event as conversion", k9Var3.k.u().u(t3.y())); c1.a Q = c1.Q(); Q.s("_c"); Q.r(1); t3.s(Q); if (!z8) { } if (K().y(V(), aVar9.a.G1(), false, true).e > ((long) k9Var3.k.a().s(aVar9.a.G1()))) { } k9Var3.k.g().A().b("Too many conversions. Not logging as conversion. appId", q3.s(aVar9.a.G1())); z9 = false; int i16 = -1; aVar7 = null; while (i7 < t3.w()) { } if (!z9) { } if (aVar7 != null) { } } else { str6 = str15; i5 = i14; aVar5 = aVar10; i6 = 0; boolean z12 = false; z8 = false; while (true) { aVar6 = t2; if (i6 >= t3.w()) { } i6++; t2 = aVar6; aVar11 = aVar8; } aVar3 = aVar11; k9Var3.k.g().D().b("Marking event as conversion", k9Var3.k.u().u(t3.y())); c1.a Q = c1.Q(); Q.s("_c"); Q.r(1); t3.s(Q); if (!z8) { } if (K().y(V(), aVar9.a.G1(), false, true).e > ((long) k9Var3.k.a().s(aVar9.a.G1()))) { } k9Var3.k.g().A().b("Too many conversions. Not logging as conversion. appId", q3.s(aVar9.a.G1())); z9 = false; int i16 = -1; aVar7 = null; while (i7 < t3.w()) { } if (!z9) { } if (aVar7 != null) { } } z11 = z2; if (y2) { ArrayList arrayList = new ArrayList(t3.v()); int i17 = -1; int i18 = -1; for (int i19 = 0; i19 < arrayList.size(); i19++) { if ("value".equals(((c1) arrayList.get(i19)).B())) { i17 = i19; } else if ("currency".equals(((c1) arrayList.get(i19)).B())) { i18 = i19; } } if (i17 != -1) { if (((c1) arrayList.get(i17)).I() || ((c1) arrayList.get(i17)).M()) { if (i18 == -1) { z10 = true; } else { String G = ((c1) arrayList.get(i18)).G(); if (G.length() == 3) { int i20 = 0; while (true) { if (i20 >= G.length()) { z10 = false; break; } int codePointAt = G.codePointAt(i20); if (!Character.isLetter(codePointAt)) { break; } i20 += Character.charCount(codePointAt); } } z10 = true; } if (z10) { k9Var3.k.g().B().a("Value parameter discarded. You must also supply a 3-letter ISO_4217 currency code in the currency parameter."); t3.x(i17); e(t3, "_c"); d(t3, 19, "currency"); } if (k9Var3.k.a().v(aVar9.a.G1(), p.T)) { if ("_e".equals(t3.y())) { N(); if (q9.w((a1) ((u4) t3.p()), "_fr") == null) { if (aVar3 != null && Math.abs(aVar3.z() - t3.z()) <= 1000) { a1.a aVar13 = (a1.a) ((u4.b) aVar3.clone()); if (k9Var3.u(t3, aVar13)) { aVar4 = aVar6; aVar4.r(i11, aVar13); str10 = "_et"; i9 = i5; i3 = i11; i14 = i9; str7 = str5; str8 = str2; str9 = str; aVar5 = null; aVar3 = null; if (!z7 && "_e".equals(t3.y())) { if (t3.w() == 0) { k9Var3.k.g().A().b("Engagement event does not contain any parameters. appId", q3.s(aVar9.a.G1())); } else { N(); Long l2 = (Long) q9.R((a1) ((u4) t3.p()), str10); if (l2 == null) { k9Var3.k.g().A().b("Engagement event does not include duration. appId", q3.s(aVar9.a.G1())); } else { j4 += l2.longValue(); } } } i4 = i13; aVar9.f1214c.set(i4, (a1) ((u4) t3.p())); i12++; aVar4.t(t3); aVar10 = aVar5; } } aVar4 = aVar6; aVar5 = t3; i14 = i12; } else { aVar4 = aVar6; i14 = i5; } i3 = i11; str7 = str5; str10 = "_et"; } else { aVar4 = aVar6; if ("_vs".equals(t3.y())) { N(); str10 = "_et"; if (q9.w((a1) ((u4) t3.p()), str10) == null) { if (aVar5 != null && Math.abs(aVar5.z() - t3.z()) <= 1000) { a1.a aVar14 = (a1.a) ((u4.b) aVar5.clone()); if (k9Var3.u(aVar14, t3)) { i9 = i5; aVar4.r(i9, aVar14); i3 = i11; i14 = i9; str7 = str5; str8 = str2; str9 = str; aVar5 = null; aVar3 = null; if (t3.w() == 0) { } i4 = i13; aVar9.f1214c.set(i4, (a1) ((u4) t3.p())); i12++; aVar4.t(t3); aVar10 = aVar5; } } aVar3 = t3; i14 = i5; i3 = i12; str7 = str5; } else { i8 = i5; } } else { str10 = "_et"; i8 = i5; if (k9Var3.k.a().v(aVar9.a.G1(), p.m0) && "_ab".equals(t3.y())) { N(); if (q9.w((a1) ((u4) t3.p()), str10) == null && aVar5 != null && Math.abs(aVar5.z() - t3.z()) <= 4000) { a1.a aVar15 = (a1.a) ((u4.b) aVar5.clone()); k9Var3.A(aVar15, t3); d.l("_e".equals(aVar15.y())); N(); str7 = str5; c1 w = q9.w((a1) ((u4) aVar15.p()), str7); N(); str9 = str; c1 w2 = q9.w((a1) ((u4) aVar15.p()), str9); N(); i3 = i11; str8 = str2; c1 w3 = q9.w((a1) ((u4) aVar15.p()), str8); String G2 = w != null ? w.G() : str4; if (!TextUtils.isEmpty(G2)) { N(); q9.E(t3, str7, G2); } String G3 = w2 != null ? w2.G() : str4; if (!TextUtils.isEmpty(G3)) { N(); q9.E(t3, str9, G3); } if (w3 != null) { N(); q9.E(t3, str8, Long.valueOf(w3.J())); } aVar4.r(i8, aVar15); i14 = i8; aVar5 = null; if (t3.w() == 0) { } i4 = i13; aVar9.f1214c.set(i4, (a1) ((u4) t3.p())); i12++; aVar4.t(t3); aVar10 = aVar5; } } } i3 = i11; str7 = str5; str8 = str2; str9 = str; } str8 = str2; str9 = str; if (t3.w() == 0) { } i4 = i13; aVar9.f1214c.set(i4, (a1) ((u4) t3.p())); i12++; aVar4.t(t3); aVar10 = aVar5; } else { i3 = i11; str7 = str5; str10 = "_et"; str8 = str2; str9 = str; i8 = i5; aVar4 = aVar6; } i14 = i8; if (t3.w() == 0) { } i4 = i13; aVar9.f1214c.set(i4, (a1) ((u4) t3.p())); i12++; aVar4.t(t3); aVar10 = aVar5; } else { k9Var3.k.g().B().a("Value must be specified with a numeric type."); t3.x(i17); e(t3, "_c"); d(t3, 18, "value"); } } if (k9Var3.k.a().v(aVar9.a.G1(), p.T)) { } i14 = i8; if (t3.w() == 0) { } i4 = i13; aVar9.f1214c.set(i4, (a1) ((u4) t3.p())); i12++; aVar4.t(t3); aVar10 = aVar5; } if (k9Var3.k.a().v(aVar9.a.G1(), p.T)) { } i14 = i8; if (t3.w() == 0) { } i4 = i13; aVar9.f1214c.set(i4, (a1) ((u4) t3.p())); i12++; aVar4.t(t3); aVar10 = aVar5; } i13 = i4 + 1; str = str9; str2 = str8; t2 = aVar4; str5 = str7; i11 = i3; v = z7; str15 = str6; aVar11 = aVar3; } if (v) { int i21 = i12; int i22 = 0; while (i22 < i21) { a1 B = t2.B(i22); if ("_e".equals(B.F())) { N(); if (q9.w(B, "_fr") != null) { t2.G(i22); i21--; i22--; i22++; } } N(); c1 w4 = q9.w(B, "_et"); if (w4 != null) { Long valueOf = w4.I() ? Long.valueOf(w4.J()) : null; if (valueOf != null && valueOf.longValue() > 0) { j4 += valueOf.longValue(); } } i22++; } } k9Var3.i(t2, j4, false); Iterator it = t2.z().iterator(); while (true) { if (it.hasNext()) { if ("_s".equals(it.next().F())) { z3 = true; break; } } else { z3 = false; break; } } if (z3) { K().V(t2.k0(), "_se"); } if (q9.s(t2, "_sid") >= 0) { k9Var3.i(t2, j4, true); } else { int s2 = q9.s(t2, "_se"); if (s2 >= 0) { t2.R(s2); k9Var3.k.g().z().b("Session engagement user property is in the bundle without session ID. appId", q3.s(aVar9.a.G1())); } } q9 N = N(); N.g().D().a("Checking account type status for ad personalization signals"); if (N.r().A(t2.k0()) && (T = N.q().T(t2.k0())) != null && T.h() && N.c().w()) { N.g().C().a("Turning off ad personalization due to account type"); i1.a L = i1.L(); L.r(str3); L.q(N.c().v()); L.s(1); i1 i1Var = (i1) ((u4) L.p()); int i23 = 0; while (true) { if (i23 >= t2.Q()) { z6 = false; break; } else if (str3.equals(t2.O(i23).D())) { t2.s(i23, i1Var); z6 = true; break; } else { i23++; } } if (!z6) { t2.v(i1Var); } } t2.D(RecyclerView.FOREVER_NS); t2.H(Long.MIN_VALUE); for (int i24 = 0; i24 < t2.A(); i24++) { a1 B2 = t2.B(i24); if (B2.H() < t2.U()) { t2.D(B2.H()); } if (B2.H() > t2.Y()) { t2.H(B2.H()); } } if (hb.b() && k9Var3.k.a().v(t2.k0(), p.G0)) { t2.v0(); } t2.t0(); t2.I(M().t(t2.k0(), t2.z(), t2.P(), Long.valueOf(t2.U()), Long.valueOf(t2.Y()))); if (k9Var3.k.a().A(aVar9.a.G1())) { HashMap hashMap3 = new HashMap(); ArrayList arrayList2 = new ArrayList(); SecureRandom v0 = k9Var3.k.t().v0(); int i25 = 0; while (i25 < t2.A()) { a1.a t6 = t2.B(i25).t(); if (t6.y().equals("_ep")) { N(); String str17 = (String) q9.R((a1) ((u4) t6.p()), "_en"); l lVar = (l) hashMap3.get(str17); if (lVar == null) { lVar = K().z(aVar9.a.G1(), str17); hashMap3.put(str17, lVar); } if (lVar.i == null) { if (lVar.j.longValue() > 1) { N(); q9.E(t6, "_sr", lVar.j); } Boolean bool = lVar.k; if (bool != null && bool.booleanValue()) { N(); q9.E(t6, "_efs", 1L); } arrayList2.add((a1) ((u4) t6.p())); } t2.r(i25, t6); } else { long B3 = H().B(aVar9.a.G1()); k9Var3.k.t(); long u2 = t9.u(t6.z(), B3); a1 a1Var = (a1) ((u4) t6.p()); Long l3 = 1L; if (!TextUtils.isEmpty("_dbg") && l3 != null) { Iterator it2 = a1Var.v().iterator(); while (true) { if (!it2.hasNext()) { break; } c1 next = it2.next(); if (!"_dbg".equals(next.B())) { it2 = it2; } else if (l3.equals(Long.valueOf(next.J())) || (((l3 instanceof String) && l3.equals(next.G())) || ((l3 instanceof Double) && l3.equals(Double.valueOf(next.N()))))) { z4 = true; } } z5 = z4 ? H().z(aVar9.a.G1(), t6.y()) : 1; if (z5 > 0) { k9Var3.k.g().A().c("Sample rate must be positive. event, rate", t6.y(), Integer.valueOf(z5)); arrayList2.add((a1) ((u4) t6.p())); t2.r(i25, t6); } else { l lVar2 = (l) hashMap3.get(t6.y()); if (lVar2 == null) { try { lVar2 = K().z(aVar9.a.G1(), t6.y()); if (lVar2 == null) { k9Var3.k.g().A().c("Event being bundled has no eventAggregate. appId, eventName", aVar9.a.G1(), t6.y()); lVar2 = new l(aVar9.a.G1(), t6.y(), 1, 1, 1, t6.z(), 0, null, null, null, null); } } catch (Throwable th3) { th = th3; K().e0(); throw th; } } N(); Long l4 = (Long) q9.R((a1) ((u4) t6.p()), "_eid"); Boolean valueOf2 = Boolean.valueOf(l4 != null); if (z5 == 1) { arrayList2.add((a1) ((u4) t6.p())); if (valueOf2.booleanValue() && !(lVar2.i == null && lVar2.j == null && lVar2.k == null)) { hashMap3.put(t6.y(), lVar2.c(null, null, null)); } t2.r(i25, t6); } else { if (v0.nextInt(z5) == 0) { N(); aVar2 = aVar9; long j5 = (long) z5; q9.E(t6, "_sr", Long.valueOf(j5)); arrayList2.add((a1) ((u4) t6.p())); if (valueOf2.booleanValue()) { lVar2 = lVar2.c(null, Long.valueOf(j5), null); } hashMap3.put(t6.y(), lVar2.b(t6.z(), u2)); k9Var2 = this; hashMap = hashMap3; secureRandom = v0; i = i25; } else { aVar2 = aVar9; Long l5 = lVar2.h; if (l5 != null) { long longValue = l5.longValue(); k9Var2 = this; l = l4; hashMap2 = hashMap3; j2 = longValue; secureRandom = v0; i2 = i25; } else { k9Var2 = this; secureRandom = v0; k9Var2.k.t(); i2 = i25; l = l4; hashMap2 = hashMap3; j2 = t9.u(t6.A(), B3); } if (j2 != u2) { N(); q9.E(t6, "_efs", 1L); N(); long j6 = (long) z5; q9.E(t6, "_sr", Long.valueOf(j6)); arrayList2.add((a1) ((u4) t6.p())); if (valueOf2.booleanValue()) { lVar2 = lVar2.c(null, Long.valueOf(j6), Boolean.TRUE); } hashMap = hashMap2; hashMap.put(t6.y(), lVar2.b(t6.z(), u2)); } else { hashMap = hashMap2; if (valueOf2.booleanValue()) { hashMap.put(t6.y(), lVar2.c(l, null, null)); } } i = i2; } t2.r(i, t6); i25 = i + 1; k9Var3 = k9Var2; hashMap3 = hashMap; aVar9 = aVar2; v0 = secureRandom; } } } z4 = false; if (z4) { } if (z5 > 0) { } } hashMap = hashMap3; secureRandom = v0; i = i25; aVar2 = aVar9; k9Var2 = this; i25 = i + 1; k9Var3 = k9Var2; hashMap3 = hashMap; aVar9 = aVar2; v0 = secureRandom; } aVar = aVar9; k9Var = k9Var3; if (arrayList2.size() < t2.A()) { t2.F(); t2.w(arrayList2); } for (Map.Entry entry : hashMap3.entrySet()) { K().H((l) entry.getValue()); } } else { aVar = aVar9; k9Var = k9Var3; } String G1 = aVar.a.G1(); a4 T2 = K().T(G1); if (T2 == null) { k9Var.k.g().z().b("Bundling raw events w/o app info. appId", q3.s(aVar.a.G1())); } else if (t2.A() > 0) { long L2 = T2.L(); if (L2 != 0) { t2.S(L2); } else { t2.f0(); } long K2 = T2.K(); if (K2 != 0) { L2 = K2; } if (L2 != 0) { t2.K(L2); } else { t2.b0(); } T2.X(); t2.Z((int) T2.U()); T2.a(t2.U()); T2.l(t2.Y()); String f = T2.f(); if (f != null) { t2.j0(f); } else { t2.p0(); } K().I(T2); } if (t2.A() > 0) { u0 s3 = H().s(aVar.a.G1()); if (s3 != null) { if (s3.x()) { t2.g0(s3.y()); K().K((e1) ((u4) t2.p()), z2); } } if (TextUtils.isEmpty(aVar.a.S())) { t2.g0(-1); } else { k9Var.k.g().A().b("Did not find measurement config or missing version info. appId", q3.s(aVar.a.G1())); } K().K((e1) ((u4) t2.p()), z2); } g K3 = K(); List list2 = aVar.b; d.A(list2); K3.b(); K3.n(); StringBuilder sb2 = new StringBuilder("rowid in ("); for (int i26 = 0; i26 < list2.size(); i26++) { if (i26 != 0) { sb2.append(","); } sb2.append(list2.get(i26).longValue()); } sb2.append(")"); int delete = K3.t().delete("raw_events", sb2.toString(), null); if (delete != list2.size()) { K3.g().z().c("Deleted fewer rows from raw events table than expected", Integer.valueOf(delete), Integer.valueOf(list2.size())); } g K4 = K(); try { K4.t().execSQL("delete from raw_events_metadata where app_id=? and metadata_fingerprint not in (select distinct metadata_fingerprint from raw_events where app_id=?)", new String[]{G1, G1}); } catch (SQLiteException e3) { K4.g().z().c("Failed to remove unused event metadata. appId", q3.s(G1), e3); } K().s(); K().e0(); return true; } K().s(); K().e0(); return false; } str11 = cursor2.getString(0); str12 = cursor2.getString(1); cursor2.close(); } catch (SQLiteException e4) { e = e4; str2 = "_si"; str = "_sc"; str5 = str14; str3 = "_npa"; } catch (Throwable th4) { } } else { str4 = ""; int i27 = (j3 > -1 ? 1 : (j3 == -1 ? 0 : -1)); String[] strArr3 = i27 != 0 ? new String[]{null, String.valueOf(j3)} : new String[]{null}; String str18 = i27 != 0 ? " and rowid <= ?" : str4; StringBuilder sb3 = new StringBuilder(str18.length() + 84); sb3.append("select metadata_fingerprint from raw_events where app_id = ?"); sb3.append(str18); sb3.append(" order by rowid limit 1;"); cursor2 = t.rawQuery(sb3.toString(), strArr3); if (!cursor2.moveToFirst()) { cursor2.close(); str2 = "_si"; str = "_sc"; str5 = str14; str3 = "_npa"; list = aVar9.f1214c; if (!(list != null || list.isEmpty())) { } } else { str12 = cursor2.getString(0); cursor2.close(); str11 = null; } } try { cursor3 = cursor2; try { cursor2 = t.query("raw_events_metadata", new String[]{"metadata"}, "app_id = ? and metadata_fingerprint = ?", new String[]{str11, str12}, null, null, "rowid", ExifInterface.GPS_MEASUREMENT_2D); if (!cursor2.moveToFirst()) { K.g().z().b("Raw event metadata record is missing. appId", q3.s(str11)); cursor2.close(); str2 = "_si"; str = "_sc"; str5 = str14; str3 = "_npa"; list = aVar9.f1214c; if (!(list != null || list.isEmpty())) { } } else { str3 = "_npa"; try { e1 e1Var = (e1) ((u4) ((e1.a) q9.x(e1.u0(), cursor2.getBlob(0))).p()); if (cursor2.moveToNext()) { str2 = "_si"; str = "_sc"; K.g().A().b("Get multiple raw event metadata records, expected one. appId", q3.s(str11)); } else { str2 = "_si"; str = "_sc"; } cursor2.close(); aVar9.a(e1Var); if (j3 != -1) { str13 = "app_id = ? and metadata_fingerprint = ? and rowid <= ?"; strArr = new String[]{str11, str12, String.valueOf(j3)}; } else { str13 = "app_id = ? and metadata_fingerprint = ?"; strArr = new String[]{str11, str12}; } cursor2 = t.query("raw_events", new String[]{"rowid", ModelAuditLogEntry.CHANGE_KEY_NAME, "timestamp", "data"}, str13, strArr, null, null, "rowid", null); if (!cursor2.moveToFirst()) { K.g().A().b("Raw event data disappeared while in transaction. appId", q3.s(str11)); cursor2.close(); str5 = str14; } else { while (true) { long j7 = cursor2.getLong(0); try { a1.a aVar16 = (a1.a) q9.x(a1.M(), cursor2.getBlob(3)); aVar16.t(cursor2.getString(1)); str5 = str14; aVar16.r(cursor2.getLong(2)); if (!aVar9.b(j7, (a1) ((u4) aVar16.p()))) { cursor2.close(); break; } } catch (IOException e5) { str5 = str14; K.g().z().c("Data loss. Failed to merge raw event. appId", q3.s(str11), e5); } if (!cursor2.moveToNext()) { cursor2.close(); break; } str14 = str5; } } } catch (IOException e6) { str2 = "_si"; str = "_sc"; str5 = str14; K.g().z().c("Data loss. Failed to merge raw event metadata. appId", q3.s(str11), e6); cursor2.close(); } list = aVar9.f1214c; if (!(list != null || list.isEmpty())) { } } } catch (SQLiteException e7) { e = e7; str2 = "_si"; str = "_sc"; str5 = str14; str3 = "_npa"; cursor2 = cursor3; sQLiteException = e; try { K.g().z().c("Data loss. Error selecting raw event. appId", q3.s(str11), sQLiteException); if (cursor2 != null) { cursor2.close(); } list = aVar9.f1214c; if (!(list != null || list.isEmpty())) { } } catch (Throwable th5) { th = th5; cursor = cursor2; if (cursor != null) { } throw th; } } catch (Throwable th6) { th2 = th6; cursor = cursor3; th = th2; if (cursor != null) { cursor.close(); } throw th; } } catch (SQLiteException e8) { e = e8; str2 = "_si"; str = "_sc"; str5 = str14; str3 = "_npa"; sQLiteException = e; K.g().z().c("Data loss. Error selecting raw event. appId", q3.s(str11), sQLiteException); if (cursor2 != null) { } list = aVar9.f1214c; if (!(list != null || list.isEmpty())) { } } catch (Throwable th7) { th2 = th7; cursor3 = cursor2; cursor = cursor3; th = th2; if (cursor != null) { } throw th; } sQLiteException = e2; str5 = str14; K.g().z().c("Data loss. Error selecting raw event. appId", q3.s(str11), sQLiteException); if (cursor2 != null) { } list = aVar9.f1214c; if (!(list != null || list.isEmpty())) { } } catch (SQLiteException e9) { SQLiteException sQLiteException2 = e9; str4 = ""; } catch (Throwable th8) { } } catch (Throwable th9) { th = th9; K().e0(); throw th; } } public final boolean u(a1.a aVar, a1.a aVar2) { d.l("_e".equals(aVar.y())); N(); c1 w = q9.w((a1) ((u4) aVar.p()), "_sc"); String str = null; String G = w == null ? null : w.G(); N(); c1 w2 = q9.w((a1) ((u4) aVar2.p()), "_pc"); if (w2 != null) { str = w2.G(); } if (str == null || !str.equals(G)) { return false; } A(aVar, aVar2); return true; } public final boolean v() { U(); P(); return ((K().S("select count(1) > 0 from raw_events", null) > 0 ? 1 : (K().S("select count(1) > 0 from raw_events", null) == 0 ? 0 : -1)) != 0) || !TextUtils.isEmpty(K().u()); } /* JADX WARNING: Removed duplicated region for block: B:101:0x0399 */ /* JADX WARNING: Removed duplicated region for block: B:24:0x00a8 */ /* JADX WARNING: Removed duplicated region for block: B:30:0x00e4 */ /* JADX WARNING: Removed duplicated region for block: B:33:0x012c */ /* JADX WARNING: Removed duplicated region for block: B:54:0x01a4 */ /* JADX WARNING: Removed duplicated region for block: B:56:0x01c2 */ @WorkerThread public final void w() { boolean z2; long j; long max; long j2; int i; Method method; U(); P(); if (this.n > 0) { Objects.requireNonNull((c) this.k.o); long abs = 3600000 - Math.abs(SystemClock.elapsedRealtime() - this.n); if (abs > 0) { this.k.g().n.b("Upload has been suspended. Will update scheduling later in approximately ms", Long.valueOf(abs)); S().a(); T().s(); return; } this.n = 0; } if (!this.k.m() || !v()) { this.k.g().n.a("Nothing to upload or uploading impossible"); S().a(); T().s(); return; } Objects.requireNonNull((c) this.k.o); long currentTimeMillis = System.currentTimeMillis(); long max2 = Math.max(0L, p.A.a(null).longValue()); if (!(K().S("select count(1) > 0 from raw_events where realtime = 1", null) != 0)) { if (!(K().S("select count(1) > 0 from queue where has_realtime = 1", null) != 0)) { z2 = false; if (!z2) { String i2 = this.k.h.i("debug.firebase.analytics.app", ""); j = (TextUtils.isEmpty(i2) || ".none.".equals(i2)) ? Math.max(0L, p.u.a(null).longValue()) : Math.max(0L, p.v.a(null).longValue()); } else { j = Math.max(0L, p.t.a(null).longValue()); } long a2 = this.k.o().f.a(); long a3 = this.k.o().g.a(); max = Math.max(K().w("select max(bundle_end_timestamp) from queue", null, 0), K().w("select max(timestamp) from raw_events", null, 0)); if (max != 0) { long abs2 = currentTimeMillis - Math.abs(max - currentTimeMillis); long abs3 = currentTimeMillis - Math.abs(a2 - currentTimeMillis); long abs4 = currentTimeMillis - Math.abs(a3 - currentTimeMillis); long max3 = Math.max(abs3, abs4); j2 = max2 + abs2; if (z2 && max3 > 0) { j2 = Math.min(abs2, max3) + j; } if (!N().N(max3, j)) { j2 = max3 + j; } if (abs4 != 0 && abs4 >= abs2) { int i3 = 0; while (true) { if (i3 >= Math.min(20, Math.max(0, p.C.a(null).intValue()))) { break; } j2 += Math.max(0L, p.B.a(null).longValue()) * (1 << i3); if (j2 > abs4) { break; } i3++; } } if (j2 == 0) { this.k.g().n.a("Next upload time is 0"); S().a(); T().s(); return; } else if (!J().u()) { this.k.g().n.a("No network"); b4 S = S(); S.a.P(); S.a.f().b(); if (!S.b) { S.a.k.b.registerReceiver(S, new IntentFilter("android.net.conn.CONNECTIVITY_CHANGE")); S.f1184c = S.a.J().u(); S.a.g().n.b("Registering connectivity change receiver. Network connected", Boolean.valueOf(S.f1184c)); S.b = true; } T().s(); return; } else { long a4 = this.k.o().h.a(); long max4 = Math.max(0L, p.r.a(null).longValue()); if (!N().N(a4, max4)) { j2 = Math.max(j2, a4 + max4); } S().a(); Objects.requireNonNull((c) this.k.o); long currentTimeMillis2 = j2 - System.currentTimeMillis(); if (currentTimeMillis2 <= 0) { currentTimeMillis2 = Math.max(0L, p.w.a(null).longValue()); h4 h4Var = this.k.o().f; Objects.requireNonNull((c) this.k.o); h4Var.b(System.currentTimeMillis()); } this.k.g().n.b("Upload scheduled in approximately ms", Long.valueOf(currentTimeMillis2)); h9 T = T(); T.n(); Context context = T.a.b; if (!n4.a(context)) { T.g().m.a("Receiver not registered/enabled"); } if (!t9.U(context)) { T.g().m.a("Service not registered/enabled"); } T.s(); T.g().n.b("Scheduling upload, millis", Long.valueOf(currentTimeMillis2)); Objects.requireNonNull((c) T.a.o); long elapsedRealtime = SystemClock.elapsedRealtime() + currentTimeMillis2; if (currentTimeMillis2 < Math.max(0L, p.f1232x.a(null).longValue())) { if (!(T.e.d != 0)) { T.e.b(currentTimeMillis2); } } if (Build.VERSION.SDK_INT >= 24) { Context context2 = T.a.b; ComponentName componentName = new ComponentName(context2, "com.google.android.gms.measurement.AppMeasurementJobService"); int t = T.t(); PersistableBundle persistableBundle = new PersistableBundle(); persistableBundle.putString("action", "com.google.android.gms.measurement.UPLOAD"); JobInfo build = new JobInfo.Builder(t, componentName).setMinimumLatency(currentTimeMillis2).setOverrideDeadline(currentTimeMillis2 << 1).setExtras(persistableBundle).build(); Method method2 = a4.a; JobScheduler jobScheduler = (JobScheduler) context2.getSystemService("jobscheduler"); if (a4.a == null || context2.checkSelfPermission("android.permission.UPDATE_DEVICE_STATS") != 0) { jobScheduler.schedule(build); return; } Method method3 = a4.b; if (method3 != null) { try { i = ((Integer) method3.invoke(null, new Object[0])).intValue(); } catch (IllegalAccessException | InvocationTargetException e) { if (Log.isLoggable("JobSchedulerCompat", 6)) { Log.e("JobSchedulerCompat", "myUserId invocation illegal", e); } } method = a4.a; if (method != null) { try { ((Integer) method.invoke(jobScheduler, build, "com.google.android.gms", Integer.valueOf(i), "UploadAlarm")).intValue(); return; } catch (IllegalAccessException | InvocationTargetException e2) { Log.e("UploadAlarm", "error calling scheduleAsPackage", e2); } } jobScheduler.schedule(build); return; } i = 0; method = a4.a; if (method != null) { } jobScheduler.schedule(build); return; } T.d.setInexactRepeating(2, elapsedRealtime, Math.max(p.f1231s.a(null).longValue(), currentTimeMillis2), T.u()); return; } } j2 = 0; if (j2 == 0) { } } } z2 = true; if (!z2) { } long a2 = this.k.o().f.a(); long a3 = this.k.o().g.a(); max = Math.max(K().w("select max(bundle_end_timestamp) from queue", null, 0), K().w("select max(timestamp) from raw_events", null, 0)); if (max != 0) { } j2 = 0; if (j2 == 0) { } } @WorkerThread public final void x() { U(); if (this.r || this.f1210s || this.t) { this.k.g().n.d("Not stopping services. fetch, network, upload", Boolean.valueOf(this.r), Boolean.valueOf(this.f1210s), Boolean.valueOf(this.t)); return; } this.k.g().n.a("Stopping uploading service(s)"); List list = this.o; if (list != null) { for (Runnable runnable : list) { runnable.run(); } this.o.clear(); } } @WorkerThread public final zzn y(String str) { a4 T = K().T(str); if (T == null || TextUtils.isEmpty(T.M())) { this.k.g().m.b("No app data available; dropping", str); return null; } Boolean z2 = z(T); if (z2 == null || z2.booleanValue()) { return new zzn(str, T.v(), T.M(), T.N(), T.O(), T.P(), T.Q(), (String) null, T.T(), false, T.H(), T.g(), 0L, 0, T.h(), T.i(), false, T.y(), T.j(), T.S(), T.k(), (!da.b() || !this.k.h.u(str, p.f1230j0)) ? null : T.B(), (!t8.b() || !this.k.h.o(p.J0)) ? "" : a(str).d()); } this.k.g().f.b("App version does not match; dropping. appId", q3.s(str)); return null; } @WorkerThread public final Boolean z(a4 a4Var) { try { if (a4Var.N() != -2147483648L) { if (a4Var.N() == ((long) b.a(this.k.b).b(a4Var.o(), 0).versionCode)) { return Boolean.TRUE; } } else { String str = b.a(this.k.b).b(a4Var.o(), 0).versionName; if (a4Var.M() != null && a4Var.M().equals(str)) { return Boolean.TRUE; } } return Boolean.FALSE; } catch (PackageManager.NameNotFoundException unused) { return null; } } }