package com.google.android.gms.common.api.internal; import android.os.Bundle; import android.os.DeadObjectException; import com.google.android.gms.common.ConnectionResult; import com.google.android.gms.common.api.Api; import com.google.android.gms.common.api.Result; import com.google.android.gms.common.api.Status; import com.google.android.gms.common.api.internal.BaseImplementation; import com.google.android.gms.common.internal.Preconditions; import java.util.Iterator; import java.util.Set; /* loaded from: classes.dex */ public final class zaaj implements zabf { private final zabi zaa; private boolean zab = false; @Override // com.google.android.gms.common.api.internal.zabf public final > T zaa(T t) { zab(t); return t; } @Override // com.google.android.gms.common.api.internal.zabf public final > T zab(T t) { try { this.zaa.zag.zai.zaa(t); zabe zabeVar = this.zaa.zag; Api.Client client = zabeVar.zac.get(t.getClientKey()); Preconditions.checkNotNull(client, "Appropriate Api was not requested."); if (client.isConnected() || !this.zaa.zab.containsKey(t.getClientKey())) { t.run(client); } else { t.setFailedResult(new Status(17)); } } catch (DeadObjectException unused) { this.zaa.zal(new zaah(this, this)); } return t; } @Override // com.google.android.gms.common.api.internal.zabf public final void zad() { } @Override // com.google.android.gms.common.api.internal.zabf public final void zae() { if (this.zab) { this.zab = false; this.zaa.zal(new zaai(this, this)); } } /* JADX INFO: Access modifiers changed from: package-private */ public final void zaf() { if (this.zab) { this.zab = false; this.zaa.zag.zai.zab(); zaj(); } } @Override // com.google.android.gms.common.api.internal.zabf public final void zag(Bundle bundle) { } @Override // com.google.android.gms.common.api.internal.zabf public final void zah(ConnectionResult connectionResult, Api api, boolean z) { } @Override // com.google.android.gms.common.api.internal.zabf public final void zai(int i) { this.zaa.zak(null); this.zaa.zah.zac(i, this.zab); } @Override // com.google.android.gms.common.api.internal.zabf public final boolean zaj() { if (this.zab) { return false; } Set set = this.zaa.zag.zah; if (set == null || set.isEmpty()) { this.zaa.zak(null); return true; } this.zab = true; Iterator it = set.iterator(); while (it.hasNext()) { it.next().zah(); } return false; } public zaaj(zabi zabiVar) { this.zaa = zabiVar; } }