package com.google.android.gms.common.api; import android.accounts.Account; import android.app.Activity; import android.content.Context; import android.os.Handler; import android.os.Looper; import com.google.android.gms.auth.api.signin.GoogleSignInAccount; 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.common.util.PlatformVersion; import com.google.android.gms.tasks.Task; import com.google.android.gms.tasks.TaskCompletionSource; import java.lang.reflect.InvocationTargetException; import java.util.Collections; import java.util.Set; import org.checkerframework.checker.initialization.qual.NotOnlyInitialized; /* loaded from: classes.dex */ public abstract class GoogleApi implements HasApiKey { protected final GoogleApiManager zaa; private final Context zab; private final String zac; private final Api zad; private final O zae; private final ApiKey zaf; private final Looper zag; private final int zah; @NotOnlyInitialized private final GoogleApiClient zai; private final StatusExceptionMapper zaj; public GoogleApi(Activity activity, Api api, O o2, Settings settings) { this(activity, activity, api, o2, settings); } private final > T zad(int i, T t) { t.zak(); this.zaa.zaw(this, i, t); return t; } private final Task zae(int i, TaskApiCall taskApiCall) { TaskCompletionSource taskCompletionSource = new TaskCompletionSource(); this.zaa.zax(this, i, taskApiCall, taskCompletionSource, this.zaj); return taskCompletionSource.getTask(); } protected ClientSettings.Builder createClientSettingsBuilder() { Account account; Set emptySet; GoogleSignInAccount googleSignInAccount; ClientSettings.Builder builder = new ClientSettings.Builder(); O o2 = this.zae; if (!(o2 instanceof Api.ApiOptions.HasGoogleSignInAccountOptions) || (googleSignInAccount = ((Api.ApiOptions.HasGoogleSignInAccountOptions) o2).getGoogleSignInAccount()) == null) { O o3 = this.zae; account = o3 instanceof Api.ApiOptions.HasAccountOptions ? ((Api.ApiOptions.HasAccountOptions) o3).getAccount() : null; } else { account = googleSignInAccount.getAccount(); } builder.zab(account); O o4 = this.zae; if (o4 instanceof Api.ApiOptions.HasGoogleSignInAccountOptions) { GoogleSignInAccount googleSignInAccount2 = ((Api.ApiOptions.HasGoogleSignInAccountOptions) o4).getGoogleSignInAccount(); if (googleSignInAccount2 == null) { emptySet = Collections.emptySet(); } else { emptySet = googleSignInAccount2.getRequestedScopes(); } } else { emptySet = Collections.emptySet(); } builder.zaa(emptySet); builder.zac(this.zab.getClass().getName()); builder.setRealClientPackageName(this.zab.getPackageName()); return builder; } protected Task disconnectService() { return this.zaa.zap(this); } public > T doBestEffortWrite(T t) { zad(2, t); return t; } public > T doRead(T t) { zad(0, t); return t; } @Deprecated public , U extends UnregisterListenerMethod> Task doRegisterEventListener(T t, 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.zaq(this, t, u, new Runnable() { // from class: com.google.android.gms.common.api.zad @Override // java.lang.Runnable public final void run() { } }); } public Task doUnregisterEventListener(ListenerHolder.ListenerKey listenerKey) { return doUnregisterEventListener(listenerKey, 0); } public > T doWrite(T t) { zad(1, t); return t; } public ListenerHolder registerListener(L l, String str) { return ListenerHolders.createListenerHolder(l, this.zag, str); } /* JADX WARN: Multi-variable type inference failed */ public final Api.Client zab(Looper looper, zabq zabqVar) { Api.Client buildClient = ((Api.AbstractClientBuilder) Preconditions.checkNotNull(this.zad.zaa())).buildClient(this.zab, looper, createClientSettingsBuilder().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 */ @java.lang.Deprecated /* Code decompiled incorrectly, please refer to instructions dump. To view partially-correct add '--show-bad-code' argument */ public GoogleApi(android.app.Activity r2, com.google.android.gms.common.api.Api r3, O r4, 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"); } public Task doBestEffortWrite(TaskApiCall taskApiCall) { return zae(2, taskApiCall); } public Task doRead(TaskApiCall taskApiCall) { return zae(0, taskApiCall); } public Task doUnregisterEventListener(ListenerHolder.ListenerKey listenerKey, int i) { Preconditions.checkNotNull(listenerKey, "Listener key cannot be null."); return this.zaa.zar(this, listenerKey, i); } public Task doWrite(TaskApiCall taskApiCall) { return zae(1, taskApiCall); } private GoogleApi(Context context, Activity activity, Api api, O o2, Settings settings) { String str; ApiKey zaa; GoogleApiManager zam; 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."); this.zab = context.getApplicationContext(); if (PlatformVersion.isAtLeastR()) { try { str = (String) Context.class.getMethod("getAttributionTag", new Class[0]).invoke(context, new Object[0]); } catch (IllegalAccessException | NoSuchMethodException | InvocationTargetException unused) { } this.zac = str; this.zad = api; this.zae = o2; this.zag = settings.zab; zaa = ApiKey.zaa(api, o2, str); this.zaf = zaa; this.zai = new zabv(this); zam = GoogleApiManager.zam(this.zab); this.zaa = zam; this.zah = zam.zaa(); this.zaj = settings.zaa; if (activity != null && !(activity instanceof GoogleApiActivity) && Looper.myLooper() == Looper.getMainLooper()) { zaae.zad(activity, zam, zaa); } zam.zaB(this); } str = null; this.zac = str; this.zad = api; this.zae = o2; this.zag = settings.zab; zaa = ApiKey.zaa(api, o2, str); this.zaf = zaa; this.zai = new zabv(this); zam = GoogleApiManager.zam(this.zab); this.zaa = zam; this.zah = zam.zaa(); this.zaj = settings.zaa; if (activity != null) { zaae.zad(activity, zam, zaa); } zam.zaB(this); } public Task doRegisterEventListener(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.zaq(this, registrationMethods.register, registrationMethods.zaa, registrationMethods.zab); } /* JADX WARN: Illegal instructions before constructor call */ @java.lang.Deprecated /* Code decompiled incorrectly, please refer to instructions dump. To view partially-correct add '--show-bad-code' argument */ public GoogleApi(android.content.Context r2, com.google.android.gms.common.api.Api r3, O r4, android.os.Looper r5, 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"); } public GoogleApi(Context context, Api api, O o2, Settings settings) { this(context, (Activity) null, api, o2, settings); } /* JADX WARN: Illegal instructions before constructor call */ @java.lang.Deprecated /* Code decompiled incorrectly, please refer to instructions dump. To view partially-correct add '--show-bad-code' argument */ public GoogleApi(android.content.Context r2, com.google.android.gms.common.api.Api r3, O r4, 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"); } public final int zaa() { return this.zah; } public Looper getLooper() { return this.zag; } @Deprecated protected String getContextFeatureId() { return this.zac; } /* JADX INFO: Access modifiers changed from: protected */ public String getContextAttributionTag() { return this.zac; } public Context getApplicationContext() { return this.zab; } public O getApiOptions() { return this.zae; } /* loaded from: classes.dex */ public static class Settings { public static final Settings DEFAULT_SETTINGS = new Builder().build(); public final StatusExceptionMapper zaa; public final Looper zab; /* loaded from: classes.dex */ public static class Builder { private StatusExceptionMapper zaa; private Looper zab; /* JADX WARN: Multi-variable type inference failed */ 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); } public Builder setLooper(Looper looper) { Preconditions.checkNotNull(looper, "Looper must not be null."); this.zab = looper; return this; } public Builder setMapper(StatusExceptionMapper statusExceptionMapper) { Preconditions.checkNotNull(statusExceptionMapper, "StatusExceptionMapper must not be null."); this.zaa = statusExceptionMapper; return this; } } private Settings(StatusExceptionMapper statusExceptionMapper, Account account, Looper looper) { this.zaa = statusExceptionMapper; this.zab = looper; } } @Override // com.google.android.gms.common.api.HasApiKey public final ApiKey getApiKey() { return this.zaf; } public GoogleApiClient asGoogleApiClient() { return this.zai; } }