package com.google.android.gms.common.api.internal; import android.content.Context; import android.os.Bundle; import android.os.Handler; import android.os.Looper; import android.util.Log; import com.google.android.gms.common.ConnectionResult; import com.google.android.gms.common.api.Api; import com.google.android.gms.common.api.GoogleApiClient; import com.google.android.gms.common.api.Scope; import com.google.android.gms.common.internal.ClientSettings; import com.google.android.gms.common.internal.Preconditions; import com.google.android.gms.signin.SignInOptions; import java.util.Set; /* loaded from: classes.dex */ public final class zact extends com.google.android.gms.signin.internal.zac implements GoogleApiClient.ConnectionCallbacks, GoogleApiClient.OnConnectionFailedListener { private static final Api.AbstractClientBuilder zaa = com.google.android.gms.signin.zad.zac; private final Context zab; private final Handler zac; private final Api.AbstractClientBuilder zad; private final Set zae; private final ClientSettings zaf; private com.google.android.gms.signin.zae zag; private zacs zah; public zact(Context context, Handler handler, ClientSettings clientSettings) { Api.AbstractClientBuilder abstractClientBuilder = zaa; this.zab = context; this.zac = handler; this.zaf = (ClientSettings) Preconditions.checkNotNull(clientSettings, "ClientSettings must not be null"); this.zae = clientSettings.getRequiredScopes(); this.zad = abstractClientBuilder; } /* JADX INFO: Access modifiers changed from: package-private */ public static /* synthetic */ void zad(zact zactVar, com.google.android.gms.signin.internal.zak zakVar) { ConnectionResult zaa2 = zakVar.zaa(); if (zaa2.isSuccess()) { com.google.android.gms.common.internal.zav zavVar = (com.google.android.gms.common.internal.zav) Preconditions.checkNotNull(zakVar.zab()); ConnectionResult zaa3 = zavVar.zaa(); if (!zaa3.isSuccess()) { String valueOf = String.valueOf(zaa3); String.valueOf(valueOf).length(); Log.wtf("SignInCoordinator", "Sign-in succeeded with resolve account failure: ".concat(String.valueOf(valueOf)), new Exception()); zactVar.zah.zae(zaa3); zactVar.zag.disconnect(); return; } zactVar.zah.zaf(zavVar.zab(), zactVar.zae); } else { zactVar.zah.zae(zaa2); } zactVar.zag.disconnect(); } @Override // com.google.android.gms.common.api.internal.ConnectionCallbacks public final void onConnected(Bundle bundle) { this.zag.zad(this); } @Override // com.google.android.gms.common.api.internal.OnConnectionFailedListener public final void onConnectionFailed(ConnectionResult connectionResult) { this.zah.zae(connectionResult); } @Override // com.google.android.gms.common.api.internal.ConnectionCallbacks public final void onConnectionSuspended(int i) { this.zag.disconnect(); } @Override // com.google.android.gms.signin.internal.zac, com.google.android.gms.signin.internal.zae public final void zab(com.google.android.gms.signin.internal.zak zakVar) { this.zac.post(new zacr(this, zakVar)); } public final void zae(zacs zacsVar) { com.google.android.gms.signin.zae zaeVar = this.zag; if (zaeVar != null) { zaeVar.disconnect(); } this.zaf.zae(Integer.valueOf(System.identityHashCode(this))); Api.AbstractClientBuilder abstractClientBuilder = this.zad; Context context = this.zab; Looper looper = this.zac.getLooper(); ClientSettings clientSettings = this.zaf; this.zag = abstractClientBuilder.buildClient(context, looper, clientSettings, (ClientSettings) clientSettings.zaa(), (GoogleApiClient.ConnectionCallbacks) this, (GoogleApiClient.OnConnectionFailedListener) this); this.zah = zacsVar; Set set = this.zae; if (set == null || set.isEmpty()) { this.zac.post(new zacq(this)); } else { this.zag.zab(); } } public final void zaf() { com.google.android.gms.signin.zae zaeVar = this.zag; if (zaeVar != null) { zaeVar.disconnect(); } } }