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 com.google.android.play.core.appupdate.internal.zzy; /* loaded from: classes2.dex */ public final class UDL extends BMB { private BMB a; private iNu b; private TaskCompletionSource d; /* JADX WARN: 'super' call moved to the top of the method (can break code semantics) */ public UDL(iNu inu, TaskCompletionSource taskCompletionSource, TaskCompletionSource taskCompletionSource2, BMB bmb) { super(taskCompletionSource); this.b = inu; this.d = taskCompletionSource2; this.a = bmb; } @Override // o.BMB public final void a() { synchronized (this.b.f) { final iNu inu = this.b; final TaskCompletionSource taskCompletionSource = this.d; inu.c.add(taskCompletionSource); taskCompletionSource.getTask().addOnCompleteListener(new OnCompleteListener(inu, taskCompletionSource) { // from class: o.EzR private iNu a; private TaskCompletionSource d; @Override // com.google.android.gms.tasks.OnCompleteListener public final void onComplete(Task task) { iNu inu2 = this.a; TaskCompletionSource taskCompletionSource2 = this.d; synchronized (inu2.f) { inu2.c.remove(taskCompletionSource2); } } { this.a = inu; this.d = taskCompletionSource; } }); if (this.b.n.getAndIncrement() > 0) { yax yaxVar = this.b.e; Object[] objArr = new Object[0]; if (Log.isLoggable("PlayCore", 4)) { yax.d(yaxVar.d, "Already connected to the service.", objArr); } } iNu inu2 = this.b; BMB bmb = this.a; if (inu2.k == null && !inu2.j) { yax yaxVar2 = inu2.e; Object[] objArr2 = new Object[0]; if (Log.isLoggable("PlayCore", 4)) { yax.d(yaxVar2.d, "Initiate binding to the service.", objArr2); } inu2.d.add(bmb); ServiceConnectionC3033apq serviceConnectionC3033apq = new ServiceConnectionC3033apq(inu2); inu2.l = serviceConnectionC3033apq; inu2.j = true; if (!inu2.a.bindService(inu2.g, serviceConnectionC3033apq, 1)) { yax yaxVar3 = inu2.e; Object[] objArr3 = new Object[0]; if (Log.isLoggable("PlayCore", 4)) { yax.d(yaxVar3.d, "Failed to bind to the service.", objArr3); } inu2.j = false; for (BMB bmb2 : inu2.d) { zzy zzyVar = new zzy(); TaskCompletionSource taskCompletionSource2 = bmb2.c; if (taskCompletionSource2 != null) { taskCompletionSource2.trySetException(zzyVar); } } inu2.d.clear(); } } else if (!inu2.j) { bmb.run(); } else { yax yaxVar4 = inu2.e; Object[] objArr4 = new Object[0]; if (Log.isLoggable("PlayCore", 4)) { yax.d(yaxVar4.d, "Waiting to bind to the service.", objArr4); } inu2.d.add(bmb); } } } }