package c.i.a.f.i.b; import android.content.Context; import android.os.Binder; import android.os.Bundle; import android.text.TextUtils; import androidx.annotation.BinderThread; import androidx.annotation.Nullable; import c.c.a.a0.d; import c.i.a.f.e.e; import c.i.a.f.e.o.c; import c.i.a.f.e.o.f; import c.i.a.f.h.l.ea; import c.i.a.f.h.l.t8; 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 java.util.ArrayList; import java.util.Collections; import java.util.List; import java.util.Objects; import java.util.concurrent.Callable; import java.util.concurrent.ExecutionException; import java.util.concurrent.FutureTask; import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeoutException; /* compiled from: com.google.android.gms:play-services-measurement@@18.0.0 */ public final class z4 extends l3 { public final k9 a; public Boolean b; @Nullable /* renamed from: c reason: collision with root package name */ public String f1250c = null; public z4(k9 k9Var) { Objects.requireNonNull(k9Var, "null reference"); this.a = k9Var; } @Override // c.i.a.f.i.b.i3 @BinderThread public final String A(zzn zzn) { y0(zzn); k9 k9Var = this.a; try { return (String) ((FutureTask) k9Var.k.f().t(new o9(k9Var, zzn))).get(30000, TimeUnit.MILLISECONDS); } catch (InterruptedException | ExecutionException | TimeoutException e) { k9Var.k.g().f.c("Failed to get app instance id. appId", q3.s(zzn.i), e); return null; } } @Override // c.i.a.f.i.b.i3 @BinderThread public final void H(long j, String str, String str2, String str3) { h(new p5(this, str2, str3, str, j)); } @Override // c.i.a.f.i.b.i3 @BinderThread public final void I(zzn zzn) { x0(zzn.i, false); h(new h5(this, zzn)); } @Override // c.i.a.f.i.b.i3 @BinderThread public final List J(String str, String str2, String str3) { x0(str, true); try { return (List) ((FutureTask) this.a.f().t(new i5(this, str, str2, str3))).get(); } catch (InterruptedException | ExecutionException e) { this.a.g().f.b("Failed to get conditional user properties as", e); return Collections.emptyList(); } } @Override // c.i.a.f.i.b.i3 @BinderThread public final List K(String str, String str2, zzn zzn) { y0(zzn); try { return (List) ((FutureTask) this.a.f().t(new f5(this, zzn, str, str2))).get(); } catch (InterruptedException | ExecutionException e) { this.a.g().f.b("Failed to get conditional user properties", e); return Collections.emptyList(); } } @Override // c.i.a.f.i.b.i3 @BinderThread public final List S(String str, String str2, boolean z2, zzn zzn) { y0(zzn); try { List list = (List) ((FutureTask) this.a.f().t(new d5(this, zzn, str, str2))).get(); ArrayList arrayList = new ArrayList(list.size()); for (u9 u9Var : list) { if (z2 || !t9.r0(u9Var.f1246c)) { arrayList.add(new zzku(u9Var)); } } return arrayList; } catch (InterruptedException | ExecutionException e) { this.a.g().f.c("Failed to query user properties. appId", q3.s(zzn.i), e); return Collections.emptyList(); } } @Override // c.i.a.f.i.b.i3 @BinderThread public final void U(zzn zzn) { y0(zzn); h(new q5(this, zzn)); } @Override // c.i.a.f.i.b.i3 @BinderThread public final void f0(zzn zzn) { y0(zzn); h(new c5(this, zzn)); } @BinderThread public final void g(zzz zzz) { Objects.requireNonNull(zzz, "null reference"); Objects.requireNonNull(zzz.k, "null reference"); x0(zzz.i, true); h(new e5(this, new zzz(zzz))); } public final void h(Runnable runnable) { if (this.a.f().y()) { runnable.run(); } else { this.a.f().v(runnable); } } @Override // c.i.a.f.i.b.i3 @BinderThread public final byte[] i(zzaq zzaq, String str) { d.w(str); Objects.requireNonNull(zzaq, "null reference"); x0(str, true); this.a.g().m.b("Log and bundle. event", this.a.O().u(zzaq.i)); Objects.requireNonNull((c) this.a.k.o); long nanoTime = System.nanoTime() / 1000000; r4 f = this.a.f(); l5 l5Var = new l5(this, zzaq, str); f.o(); s4 s4Var = new s4<>(f, (Callable) l5Var, true, "Task exception on worker thread"); if (Thread.currentThread() == f.d) { s4Var.run(); } else { f.u(s4Var); } try { byte[] bArr = (byte[]) s4Var.get(); if (bArr == null) { this.a.g().f.b("Log and bundle returned null. appId", q3.s(str)); bArr = new byte[0]; } Objects.requireNonNull((c) this.a.k.o); this.a.g().m.d("Log and bundle processed. event, size, time_ms", this.a.O().u(zzaq.i), Integer.valueOf(bArr.length), Long.valueOf((System.nanoTime() / 1000000) - nanoTime)); return bArr; } catch (InterruptedException | ExecutionException e) { this.a.g().f.d("Failed to log and bundle. appId, event, error", q3.s(str), this.a.O().u(zzaq.i), e); return null; } } @Override // c.i.a.f.i.b.i3 @BinderThread public final void l(zzn zzn) { if (t8.b() && this.a.k.h.o(p.J0)) { d.w(zzn.i); Objects.requireNonNull(zzn.E, "null reference"); k5 k5Var = new k5(this, zzn); if (this.a.f().y()) { k5Var.run(); } else { this.a.f().w(k5Var); } } } @Override // c.i.a.f.i.b.i3 @BinderThread public final void o0(zzaq zzaq, zzn zzn) { Objects.requireNonNull(zzaq, "null reference"); y0(zzn); h(new j5(this, zzaq, zzn)); } @Override // c.i.a.f.i.b.i3 @BinderThread public final void p0(Bundle bundle, zzn zzn) { if (ea.b() && this.a.k.h.o(p.A0)) { y0(zzn); h(new y4(this, zzn, bundle)); } } @Override // c.i.a.f.i.b.i3 @BinderThread public final void t0(zzku zzku, zzn zzn) { Objects.requireNonNull(zzku, "null reference"); y0(zzn); h(new o5(this, zzku, zzn)); } @Override // c.i.a.f.i.b.i3 @BinderThread public final List u(String str, String str2, String str3, boolean z2) { x0(str, true); try { List list = (List) ((FutureTask) this.a.f().t(new g5(this, str, str2, str3))).get(); ArrayList arrayList = new ArrayList(list.size()); for (u9 u9Var : list) { if (z2 || !t9.r0(u9Var.f1246c)) { arrayList.add(new zzku(u9Var)); } } return arrayList; } catch (InterruptedException | ExecutionException e) { this.a.g().f.c("Failed to get user properties as. appId", q3.s(str), e); return Collections.emptyList(); } } @Override // c.i.a.f.i.b.i3 @BinderThread public final void u0(zzz zzz, zzn zzn) { Objects.requireNonNull(zzz, "null reference"); Objects.requireNonNull(zzz.k, "null reference"); y0(zzn); zzz zzz2 = new zzz(zzz); zzz2.i = zzn.i; h(new b5(this, zzz2, zzn)); } @BinderThread public final void x0(String str, boolean z2) { boolean z3; if (!TextUtils.isEmpty(str)) { if (z2) { try { if (this.b == null) { if (!"com.google.android.gms".equals(this.f1250c) && !f.t0(this.a.k.b, Binder.getCallingUid())) { if (!c.i.a.f.e.f.a(this.a.k.b).b(Binder.getCallingUid())) { z3 = false; this.b = Boolean.valueOf(z3); } } z3 = true; this.b = Boolean.valueOf(z3); } if (this.b.booleanValue()) { return; } } catch (SecurityException e) { this.a.g().f.b("Measurement Service called with invalid calling package. appId", q3.s(str)); throw e; } } if (this.f1250c == null) { Context context = this.a.k.b; int callingUid = Binder.getCallingUid(); boolean z4 = e.a; if (f.i1(context, callingUid, str)) { this.f1250c = str; } } if (!str.equals(this.f1250c)) { throw new SecurityException(String.format("Unknown calling package name '%s'.", str)); } return; } this.a.g().f.a("Measurement Service called without app package"); throw new SecurityException("Measurement Service called without app package"); } @BinderThread public final void y0(zzn zzn) { Objects.requireNonNull(zzn, "null reference"); x0(zzn.i, false); this.a.k.t().c0(zzn.j, zzn.f2394z, zzn.D); } }