package o; import android.util.Log; import com.google.android.gms.tasks.OnCompleteListener; import com.google.android.gms.tasks.Task; import com.google.android.gms.tasks.TaskCompletionSource; import java.util.Iterator; /* loaded from: classes2.dex */ public final class YYs extends AbstractRunnableC16156liu { private TaskCompletionSource c; private C16741qpn d; private AbstractRunnableC16156liu e; /* JADX WARN: 'super' call moved to the top of the method (can break code semantics) */ public YYs(C16741qpn c16741qpn, TaskCompletionSource taskCompletionSource, TaskCompletionSource taskCompletionSource2, AbstractRunnableC16156liu abstractRunnableC16156liu) { super(taskCompletionSource); this.d = c16741qpn; this.c = taskCompletionSource2; this.e = abstractRunnableC16156liu; } @Override // o.AbstractRunnableC16156liu public final void e() { synchronized (this.d.g) { final C16741qpn c16741qpn = this.d; final TaskCompletionSource taskCompletionSource = this.c; c16741qpn.e.add(taskCompletionSource); taskCompletionSource.getTask().addOnCompleteListener(new OnCompleteListener(c16741qpn, taskCompletionSource) { // from class: o.OzI private TaskCompletionSource c; private C16741qpn e; @Override // com.google.android.gms.tasks.OnCompleteListener public final void onComplete(Task task) { C16741qpn c16741qpn2 = this.e; TaskCompletionSource taskCompletionSource2 = this.c; synchronized (c16741qpn2.g) { c16741qpn2.e.remove(taskCompletionSource2); } } { this.e = c16741qpn; this.c = taskCompletionSource; } }); if (this.d.f9251o.getAndIncrement() > 0) { C16916sOz c16916sOz = this.d.c; Object[] objArr = new Object[0]; if (Log.isLoggable("PlayCore", 4)) { C16916sOz.c(c16916sOz.d, "Already connected to the service.", objArr); } } C16741qpn c16741qpn2 = this.d; AbstractRunnableC16156liu abstractRunnableC16156liu = this.e; if (c16741qpn2.l == null && !c16741qpn2.i) { C16916sOz c16916sOz2 = c16741qpn2.c; Object[] objArr2 = new Object[0]; if (Log.isLoggable("PlayCore", 4)) { C16916sOz.c(c16916sOz2.d, "Initiate binding to the service.", objArr2); } c16741qpn2.d.add(abstractRunnableC16156liu); ServiceConnectionC17033tQF serviceConnectionC17033tQF = new ServiceConnectionC17033tQF(c16741qpn2); c16741qpn2.n = serviceConnectionC17033tQF; c16741qpn2.i = true; if (!c16741qpn2.b.bindService(c16741qpn2.h, serviceConnectionC17033tQF, 1)) { C16916sOz c16916sOz3 = c16741qpn2.c; Object[] objArr3 = new Object[0]; if (Log.isLoggable("PlayCore", 4)) { C16916sOz.c(c16916sOz3.d, "Failed to bind to the service.", objArr3); } c16741qpn2.i = false; Iterator it = c16741qpn2.d.iterator(); while (it.hasNext()) { ((AbstractRunnableC16156liu) it.next()).e(new com.google.android.play.integrity.internal.ad()); } c16741qpn2.d.clear(); } } else if (!c16741qpn2.i) { abstractRunnableC16156liu.run(); } else { C16916sOz c16916sOz4 = c16741qpn2.c; Object[] objArr4 = new Object[0]; if (Log.isLoggable("PlayCore", 4)) { C16916sOz.c(c16916sOz4.d, "Waiting to bind to the service.", objArr4); } c16741qpn2.d.add(abstractRunnableC16156liu); } } } }