package com.google.android.gms.common.api; import android.accounts.Account; import android.app.Activity; import android.content.Context; import android.os.Build; import android.os.Handler; import android.os.Looper; import androidx.annotation.MainThread; import androidx.annotation.NonNull; import androidx.annotation.Nullable; import androidx.annotation.WorkerThread; import com.google.android.gms.auth.api.signin.GoogleSignInAccount; import com.google.android.gms.common.annotation.KeepForSdk; import com.google.android.gms.common.api.Api; import com.google.android.gms.common.api.Api.ApiOptions; import com.google.android.gms.common.api.GoogleApiClient; import com.google.android.gms.common.api.internal.ApiExceptionMapper; import com.google.android.gms.common.api.internal.ApiKey; import com.google.android.gms.common.api.internal.BaseImplementation; import com.google.android.gms.common.api.internal.GoogleApiManager; import com.google.android.gms.common.api.internal.ListenerHolder; import com.google.android.gms.common.api.internal.ListenerHolders; import com.google.android.gms.common.api.internal.NonGmsServiceBrokerClient; import com.google.android.gms.common.api.internal.RegisterListenerMethod; import com.google.android.gms.common.api.internal.RegistrationMethods; import com.google.android.gms.common.api.internal.StatusExceptionMapper; import com.google.android.gms.common.api.internal.TaskApiCall; import com.google.android.gms.common.api.internal.UnregisterListenerMethod; import com.google.android.gms.common.api.internal.zaae; import com.google.android.gms.common.api.internal.zabq; import com.google.android.gms.common.api.internal.zabv; import com.google.android.gms.common.api.internal.zact; import com.google.android.gms.common.internal.BaseGmsClient; import com.google.android.gms.common.internal.ClientSettings; import com.google.android.gms.common.internal.Objects; import com.google.android.gms.common.internal.Preconditions; import com.google.android.gms.tasks.Task; import com.google.android.gms.tasks.TaskCompletionSource; import com.google.errorprone.annotations.ResultIgnorabilityUnspecified; import java.util.Collections; import java.util.Set; /* loaded from: classes2.dex */ public abstract class GoogleApi implements HasApiKey { @NonNull protected final GoogleApiManager zaa; private final Context zab; @Nullable private final String zac; private final Api zad; private final Api.ApiOptions zae; private final ApiKey zaf; private final Looper zag; private final int zah; private final GoogleApiClient zai; private final StatusExceptionMapper zaj; @KeepForSdk public static class Settings { @NonNull @KeepForSdk public static final Settings DEFAULT_SETTINGS = new Builder().build(); @NonNull public final StatusExceptionMapper zaa; @NonNull public final Looper zab; @KeepForSdk public static class Builder { private StatusExceptionMapper zaa; private Looper zab; @KeepForSdk public Builder() { } /* JADX WARN: Multi-variable type inference failed */ @NonNull @KeepForSdk public Settings build() { if (this.zaa == null) { this.zaa = new ApiExceptionMapper(); } if (this.zab == null) { this.zab = Looper.getMainLooper(); } return new Settings(this.zaa, this.zab); } @NonNull @KeepForSdk public Builder setLooper(@NonNull Looper looper) { Preconditions.checkNotNull(looper, "Looper must not be null."); this.zab = looper; return this; } @NonNull @KeepForSdk public Builder setMapper(@NonNull StatusExceptionMapper statusExceptionMapper) { Preconditions.checkNotNull(statusExceptionMapper, "StatusExceptionMapper must not be null."); this.zaa = statusExceptionMapper; return this; } } @KeepForSdk private Settings(StatusExceptionMapper statusExceptionMapper, Account account, Looper looper) { this.zaa = statusExceptionMapper; this.zab = looper; } } @KeepForSdk @MainThread public GoogleApi(@NonNull Activity activity, @NonNull Api api, @NonNull O o, @NonNull Settings settings) { this(activity, activity, api, o, settings); } private final BaseImplementation.ApiMethodImpl zad(int i, @NonNull BaseImplementation.ApiMethodImpl apiMethodImpl) { apiMethodImpl.zak(); this.zaa.zau(this, i, apiMethodImpl); return apiMethodImpl; } private final Task zae(int i, @NonNull TaskApiCall taskApiCall) { TaskCompletionSource taskCompletionSource = new TaskCompletionSource(); this.zaa.zav(this, i, taskApiCall, taskCompletionSource, this.zaj); return taskCompletionSource.getTask(); } @NonNull @KeepForSdk public GoogleApiClient asGoogleApiClient() { return this.zai; } @NonNull @KeepForSdk public ClientSettings.Builder createClientSettingsBuilder() { Account account; Set emptySet; GoogleSignInAccount googleSignInAccount; ClientSettings.Builder builder = new ClientSettings.Builder(); Api.ApiOptions apiOptions = this.zae; if (!(apiOptions instanceof Api.ApiOptions.HasGoogleSignInAccountOptions) || (googleSignInAccount = ((Api.ApiOptions.HasGoogleSignInAccountOptions) apiOptions).getGoogleSignInAccount()) == null) { Api.ApiOptions apiOptions2 = this.zae; account = apiOptions2 instanceof Api.ApiOptions.HasAccountOptions ? ((Api.ApiOptions.HasAccountOptions) apiOptions2).getAccount() : null; } else { account = googleSignInAccount.getAccount(); } builder.zab(account); Api.ApiOptions apiOptions3 = this.zae; if (apiOptions3 instanceof Api.ApiOptions.HasGoogleSignInAccountOptions) { GoogleSignInAccount googleSignInAccount2 = ((Api.ApiOptions.HasGoogleSignInAccountOptions) apiOptions3).getGoogleSignInAccount(); emptySet = googleSignInAccount2 == null ? Collections.emptySet() : googleSignInAccount2.getRequestedScopes(); } else { emptySet = Collections.emptySet(); } builder.zaa(emptySet); builder.zac(this.zab.getClass().getName()); builder.setRealClientPackageName(this.zab.getPackageName()); return builder; } @NonNull @KeepForSdk public Task disconnectService() { return this.zaa.zan(this); } @NonNull @KeepForSdk public > T doBestEffortWrite(@NonNull T t) { zad(2, t); return t; } @NonNull @KeepForSdk public > T doRead(@NonNull T t) { zad(0, t); return t; } @NonNull @ResultIgnorabilityUnspecified @Deprecated @KeepForSdk public , U extends UnregisterListenerMethod> Task doRegisterEventListener(@NonNull T t, @NonNull U u) { Preconditions.checkNotNull(t); Preconditions.checkNotNull(u); Preconditions.checkNotNull(t.getListenerKey(), "Listener has already been released."); Preconditions.checkNotNull(u.getListenerKey(), "Listener has already been released."); Preconditions.checkArgument(Objects.equal(t.getListenerKey(), u.getListenerKey()), "Listener registration and unregistration methods must be constructed with the same ListenerHolder."); return this.zaa.zao(this, t, u, new Runnable() { // from class: com.google.android.gms.common.api.zad @Override // java.lang.Runnable public final void run() { } }); } @NonNull @ResultIgnorabilityUnspecified @KeepForSdk public Task doUnregisterEventListener(@NonNull ListenerHolder.ListenerKey listenerKey) { return doUnregisterEventListener(listenerKey, 0); } @NonNull @KeepForSdk public > T doWrite(@NonNull T t) { zad(1, t); return t; } @Nullable public String getApiFallbackAttributionTag(@NonNull Context context) { return null; } @Override // com.google.android.gms.common.api.HasApiKey @NonNull public final ApiKey getApiKey() { return this.zaf; } @NonNull @KeepForSdk public O getApiOptions() { return (O) this.zae; } @NonNull @KeepForSdk public Context getApplicationContext() { return this.zab; } @Nullable @KeepForSdk public String getContextAttributionTag() { return this.zac; } @Nullable @KeepForSdk @Deprecated public String getContextFeatureId() { return this.zac; } @NonNull @KeepForSdk public Looper getLooper() { return this.zag; } @NonNull @KeepForSdk public ListenerHolder registerListener(@NonNull L l, @NonNull String str) { return ListenerHolders.createListenerHolder(l, this.zag, str); } public final int zaa() { return this.zah; } /* JADX WARN: Multi-variable type inference failed */ @WorkerThread public final Api.Client zab(Looper looper, zabq zabqVar) { ClientSettings build = createClientSettingsBuilder().build(); Api.Client buildClient = ((Api.AbstractClientBuilder) Preconditions.checkNotNull(this.zad.zaa())).buildClient(this.zab, looper, build, (ClientSettings) this.zae, (GoogleApiClient.ConnectionCallbacks) zabqVar, (GoogleApiClient.OnConnectionFailedListener) zabqVar); String contextAttributionTag = getContextAttributionTag(); if (contextAttributionTag != null && (buildClient instanceof BaseGmsClient)) { ((BaseGmsClient) buildClient).setAttributionTag(contextAttributionTag); } if (contextAttributionTag != null && (buildClient instanceof NonGmsServiceBrokerClient)) { ((NonGmsServiceBrokerClient) buildClient).zac(contextAttributionTag); } return buildClient; } public final zact zac(Context context, Handler handler) { return new zact(context, handler, createClientSettingsBuilder().build()); } /* JADX WARN: Illegal instructions before constructor call */ @com.google.android.gms.common.annotation.KeepForSdk @java.lang.Deprecated /* Code decompiled incorrectly, please refer to instructions dump. To view partially-correct add '--show-bad-code' argument */ public GoogleApi(@androidx.annotation.NonNull android.app.Activity r2, @androidx.annotation.NonNull com.google.android.gms.common.api.Api r3, @androidx.annotation.NonNull O r4, @androidx.annotation.NonNull com.google.android.gms.common.api.internal.StatusExceptionMapper r5) { /* r1 = this; com.google.android.gms.common.api.GoogleApi$Settings$Builder r0 = new com.google.android.gms.common.api.GoogleApi$Settings$Builder r0.() r0.setMapper(r5) android.os.Looper r5 = r2.getMainLooper() r0.setLooper(r5) com.google.android.gms.common.api.GoogleApi$Settings r5 = r0.build() r1.(r2, r3, r4, r5) return */ throw new UnsupportedOperationException("Method not decompiled: com.google.android.gms.common.api.GoogleApi.(android.app.Activity, com.google.android.gms.common.api.Api, com.google.android.gms.common.api.Api$ApiOptions, com.google.android.gms.common.api.internal.StatusExceptionMapper):void"); } @NonNull @ResultIgnorabilityUnspecified @KeepForSdk public Task doBestEffortWrite(@NonNull TaskApiCall taskApiCall) { return zae(2, taskApiCall); } @NonNull @ResultIgnorabilityUnspecified @KeepForSdk public Task doRead(@NonNull TaskApiCall taskApiCall) { return zae(0, taskApiCall); } @NonNull @ResultIgnorabilityUnspecified @KeepForSdk public Task doUnregisterEventListener(@NonNull ListenerHolder.ListenerKey listenerKey, int i) { Preconditions.checkNotNull(listenerKey, "Listener key cannot be null."); return this.zaa.zap(this, listenerKey, i); } @NonNull @ResultIgnorabilityUnspecified @KeepForSdk public Task doWrite(@NonNull TaskApiCall taskApiCall) { return zae(1, taskApiCall); } private GoogleApi(@NonNull Context context, @Nullable Activity activity, Api api, Api.ApiOptions apiOptions, Settings settings) { String apiFallbackAttributionTag; Preconditions.checkNotNull(context, "Null context is not permitted."); Preconditions.checkNotNull(api, "Api must not be null."); Preconditions.checkNotNull(settings, "Settings must not be null; use Settings.DEFAULT_SETTINGS instead."); Context context2 = (Context) Preconditions.checkNotNull(context.getApplicationContext(), "The provided context did not have an application context."); this.zab = context2; if (Build.VERSION.SDK_INT < 30) { apiFallbackAttributionTag = getApiFallbackAttributionTag(context); } else { apiFallbackAttributionTag = context.getAttributionTag(); } this.zac = apiFallbackAttributionTag; this.zad = api; this.zae = apiOptions; this.zag = settings.zab; ApiKey sharedApiKey = ApiKey.getSharedApiKey(api, apiOptions, apiFallbackAttributionTag); this.zaf = sharedApiKey; this.zai = new zabv(this); GoogleApiManager zak = GoogleApiManager.zak(context2); this.zaa = zak; this.zah = zak.zaa(); this.zaj = settings.zaa; if (activity != null && !(activity instanceof GoogleApiActivity) && Looper.myLooper() == Looper.getMainLooper()) { zaae.zad(activity, zak, sharedApiKey); } zak.zaz(this); } @NonNull @ResultIgnorabilityUnspecified @KeepForSdk public Task doRegisterEventListener(@NonNull RegistrationMethods registrationMethods) { Preconditions.checkNotNull(registrationMethods); Preconditions.checkNotNull(registrationMethods.register.getListenerKey(), "Listener has already been released."); Preconditions.checkNotNull(registrationMethods.zaa.getListenerKey(), "Listener has already been released."); return this.zaa.zao(this, registrationMethods.register, registrationMethods.zaa, registrationMethods.zab); } /* JADX WARN: Illegal instructions before constructor call */ @com.google.android.gms.common.annotation.KeepForSdk @java.lang.Deprecated /* Code decompiled incorrectly, please refer to instructions dump. To view partially-correct add '--show-bad-code' argument */ public GoogleApi(@androidx.annotation.NonNull android.content.Context r2, @androidx.annotation.NonNull com.google.android.gms.common.api.Api r3, @androidx.annotation.NonNull O r4, @androidx.annotation.NonNull android.os.Looper r5, @androidx.annotation.NonNull com.google.android.gms.common.api.internal.StatusExceptionMapper r6) { /* r1 = this; com.google.android.gms.common.api.GoogleApi$Settings$Builder r0 = new com.google.android.gms.common.api.GoogleApi$Settings$Builder r0.() r0.setLooper(r5) r0.setMapper(r6) com.google.android.gms.common.api.GoogleApi$Settings r5 = r0.build() r1.(r2, r3, r4, r5) return */ throw new UnsupportedOperationException("Method not decompiled: com.google.android.gms.common.api.GoogleApi.(android.content.Context, com.google.android.gms.common.api.Api, com.google.android.gms.common.api.Api$ApiOptions, android.os.Looper, com.google.android.gms.common.api.internal.StatusExceptionMapper):void"); } @KeepForSdk public GoogleApi(@NonNull Context context, @NonNull Api api, @NonNull O o, @NonNull Settings settings) { this(context, (Activity) null, api, o, settings); } /* JADX WARN: Illegal instructions before constructor call */ @com.google.android.gms.common.annotation.KeepForSdk @java.lang.Deprecated /* Code decompiled incorrectly, please refer to instructions dump. To view partially-correct add '--show-bad-code' argument */ public GoogleApi(@androidx.annotation.NonNull android.content.Context r2, @androidx.annotation.NonNull com.google.android.gms.common.api.Api r3, @androidx.annotation.NonNull O r4, @androidx.annotation.NonNull com.google.android.gms.common.api.internal.StatusExceptionMapper r5) { /* r1 = this; com.google.android.gms.common.api.GoogleApi$Settings$Builder r0 = new com.google.android.gms.common.api.GoogleApi$Settings$Builder r0.() r0.setMapper(r5) com.google.android.gms.common.api.GoogleApi$Settings r5 = r0.build() r1.(r2, r3, r4, r5) return */ throw new UnsupportedOperationException("Method not decompiled: com.google.android.gms.common.api.GoogleApi.(android.content.Context, com.google.android.gms.common.api.Api, com.google.android.gms.common.api.Api$ApiOptions, com.google.android.gms.common.api.internal.StatusExceptionMapper):void"); } }