package com.google.android.gms.games.internal; import android.app.Activity; import android.content.Context; import android.os.Bundle; import android.os.IBinder; import android.os.IInterface; import android.os.Looper; import android.os.RemoteException; import androidx.annotation.NonNull; import androidx.annotation.Nullable; import com.google.android.gms.common.ConnectionResult; import com.google.android.gms.common.Feature; import com.google.android.gms.common.GooglePlayServicesUtilLight; import com.google.android.gms.common.api.internal.ConnectionCallbacks; import com.google.android.gms.common.api.internal.OnConnectionFailedListener; import com.google.android.gms.common.data.BitmapTeleporter; import com.google.android.gms.common.internal.BaseGmsClient; import com.google.android.gms.common.internal.BinderWrapper; import com.google.android.gms.common.internal.ClientSettings; import com.google.android.gms.common.internal.GmsClient; import com.google.android.gms.common.internal.Preconditions; import com.google.android.gms.common.internal.ServiceSpecificExtraArgs; import com.google.android.gms.drive.Contents; import com.google.android.gms.games.FriendsResolutionRequiredException; import com.google.android.gms.games.GamesClientStatusCodes; import com.google.android.gms.games.GamesStatusUtils; import com.google.android.gms.games.Player; import com.google.android.gms.games.PlayerBuffer; import com.google.android.gms.games.PlayerEntity; import com.google.android.gms.games.leaderboard.LeaderboardScoreBuffer; import com.google.android.gms.games.snapshot.Snapshot; import com.google.android.gms.games.snapshot.SnapshotContents; import com.google.android.gms.games.snapshot.SnapshotMetadataChange; import com.google.android.gms.games.snapshot.SnapshotMetadataChangeEntity; import com.google.android.gms.internal.games_v2.zzfg; import com.google.android.gms.signin.internal.SignInClientImpl; import com.google.android.gms.tasks.TaskCompletionSource; import java.util.Set; /* loaded from: classes2.dex */ public final class zzaj extends GmsClient { public static final /* synthetic */ int zze = 0; private final com.google.android.gms.internal.games_v2.zzac zzf; private final String zzg; private PlayerEntity zzh; private final zzap zzi; private boolean zzj; private final long zzk; private final com.google.android.gms.games.zzn zzl; private final zzaq zzm; public zzaj(Context context, Looper looper, ClientSettings clientSettings, com.google.android.gms.games.zzn zznVar, ConnectionCallbacks connectionCallbacks, OnConnectionFailedListener onConnectionFailedListener, zzaq zzaqVar) { super(context, looper, 1, clientSettings, connectionCallbacks, onConnectionFailedListener); this.zzf = new zzm(this); this.zzj = false; this.zzg = clientSettings.getRealClientPackageName(); this.zzm = (zzaq) Preconditions.checkNotNull(zzaqVar); zzap zzd = zzap.zzd(this, clientSettings.getGravityForPopups()); this.zzi = zzd; this.zzk = hashCode(); this.zzl = zznVar; boolean z = zznVar.zzh; if (clientSettings.getViewForPopups() != null || (context instanceof Activity)) { zzd.zzf(clientSettings.getViewForPopups()); } } /* JADX INFO: Access modifiers changed from: private */ public static void zzU(RemoteException remoteException) { zzfg.zzh("GamesGmsClientImpl", "service died", remoteException); } /* JADX WARN: Multi-variable type inference failed */ public static /* bridge */ /* synthetic */ void zzq(zzaj zzajVar, TaskCompletionSource taskCompletionSource) { try { taskCompletionSource.setException(FriendsResolutionRequiredException.zza(GamesClientStatusCodes.zzb(GamesClientStatusCodes.CONSENT_REQUIRED, ((zzao) zzajVar.getService()).zzf()))); } catch (RemoteException e) { taskCompletionSource.setException(e); } } @Override // com.google.android.gms.common.internal.BaseGmsClient, com.google.android.gms.common.api.Api.Client public final void connect(BaseGmsClient.ConnectionProgressReportCallbacks connectionProgressReportCallbacks) { this.zzh = null; super.connect(connectionProgressReportCallbacks); } @Override // com.google.android.gms.common.internal.BaseGmsClient public final /* synthetic */ IInterface createServiceInterface(IBinder iBinder) { if (iBinder == null) { return null; } IInterface queryLocalInterface = iBinder.queryLocalInterface("com.google.android.gms.games.internal.IGamesService"); return queryLocalInterface instanceof zzao ? (zzao) queryLocalInterface : new zzao(iBinder); } /* JADX WARN: Multi-variable type inference failed */ @Override // com.google.android.gms.common.internal.BaseGmsClient, com.google.android.gms.common.api.Api.Client public final void disconnect() { this.zzj = false; if (isConnected()) { try { this.zzf.zzb(); ((zzao) getService()).zzq(this.zzk); } catch (RemoteException unused) { zzfg.zzg("GamesGmsClientImpl", "Failed to notify client disconnect."); } } super.disconnect(); } @Override // com.google.android.gms.common.internal.BaseGmsClient public final Feature[] getApiFeatures() { return com.google.android.gms.games.zzd.zzh; } @Override // com.google.android.gms.common.internal.BaseGmsClient @Nullable public final Bundle getConnectionHint() { return null; } @Override // com.google.android.gms.common.internal.BaseGmsClient public final Bundle getGetServiceRequestExtraArgs() { String locale = getContext().getResources().getConfiguration().locale.toString(); Bundle zza = this.zzl.zza(); zza.putString(ServiceSpecificExtraArgs.GamesExtraArgs.GAME_PACKAGE_NAME, this.zzg); zza.putString(ServiceSpecificExtraArgs.GamesExtraArgs.DESIRED_LOCALE, locale); zza.putParcelable(ServiceSpecificExtraArgs.GamesExtraArgs.WINDOW_TOKEN, new BinderWrapper(this.zzi.zzc())); if (!zza.containsKey("com.google.android.gms.games.key.API_VERSION")) { zza.putInt("com.google.android.gms.games.key.API_VERSION", 9); } zza.putBundle(ServiceSpecificExtraArgs.GamesExtraArgs.SIGNIN_OPTIONS, SignInClientImpl.createBundleFromClientSettings(getClientSettings())); return zza; } @Override // com.google.android.gms.common.internal.BaseGmsClient, com.google.android.gms.common.api.Api.Client public final int getMinApkVersion() { return GooglePlayServicesUtilLight.GOOGLE_PLAY_SERVICES_VERSION_CODE; } @Override // com.google.android.gms.common.internal.GmsClient, com.google.android.gms.common.api.Api.Client public final Set getScopesForConnectionlessNonSignIn() { return getScopes(); } @Override // com.google.android.gms.common.internal.BaseGmsClient public final String getServiceDescriptor() { return "com.google.android.gms.games.internal.IGamesService"; } @Override // com.google.android.gms.common.internal.BaseGmsClient public final String getStartServiceAction() { return "com.google.android.gms.games.service.START"; } @Override // com.google.android.gms.common.internal.BaseGmsClient public final /* bridge */ /* synthetic */ void onConnectedLocked(@NonNull IInterface iInterface) { zzao zzaoVar = (zzao) iInterface; super.onConnectedLocked(zzaoVar); if (this.zzj) { this.zzi.zzg(); this.zzj = false; } boolean z = this.zzl.zza; try { zzaoVar.zzK(new zzn(new com.google.android.gms.internal.games_v2.zzaf(this.zzi.zze())), this.zzk); } catch (RemoteException e) { zzU(e); } } @Override // com.google.android.gms.common.internal.BaseGmsClient public final void onConnectionFailed(ConnectionResult connectionResult) { super.onConnectionFailed(connectionResult); this.zzj = false; } @Override // com.google.android.gms.common.internal.BaseGmsClient public final void onPostInitHandler(int i, IBinder iBinder, Bundle bundle, int i2) { if (i == 0) { i = 0; if (bundle != null) { bundle.setClassLoader(zzaj.class.getClassLoader()); this.zzj = bundle.getBoolean("show_welcome_popup"); this.zzh = (PlayerEntity) bundle.getParcelable("com.google.android.gms.games.current_player"); } } super.onPostInitHandler(i, iBinder, bundle, i2); } /* JADX WARN: Multi-variable type inference failed */ @Override // com.google.android.gms.common.internal.BaseGmsClient, com.google.android.gms.common.api.Api.Client public final void onUserSignOut(@NonNull BaseGmsClient.SignOutCallbacks signOutCallbacks) { try { zzo zzoVar = new zzo(signOutCallbacks); this.zzf.zzb(); try { ((zzao) getService()).zzQ(new zzp(zzoVar)); } catch (SecurityException unused) { zzoVar.setFailedResult(GamesClientStatusCodes.zza(4)); } } catch (RemoteException unused2) { signOutCallbacks.onSignOutComplete(); } } @Override // com.google.android.gms.common.internal.BaseGmsClient, com.google.android.gms.common.api.Api.Client public final boolean requiresAccount() { return true; } @Override // com.google.android.gms.common.internal.BaseGmsClient, com.google.android.gms.common.api.Api.Client public final boolean requiresSignIn() { if (this.zzl.zzo.zzb()) { return false; } String str = this.zzl.zzl; return true; } @Override // com.google.android.gms.common.internal.BaseGmsClient public final boolean usesClientTelemetry() { return true; } /* JADX WARN: Multi-variable type inference failed */ public final void zzA(TaskCompletionSource taskCompletionSource, boolean z) throws RemoteException { this.zzf.zzb(); try { ((zzao) getService()).zzy(new zzv(taskCompletionSource), z); } catch (SecurityException e) { GamesStatusUtils.zzb(taskCompletionSource, e); } } /* JADX WARN: Multi-variable type inference failed */ public final void zzB(TaskCompletionSource taskCompletionSource, boolean z, String... strArr) throws RemoteException { this.zzf.zzb(); try { ((zzao) getService()).zzz(new zzv(taskCompletionSource), z, strArr); } catch (SecurityException e) { GamesStatusUtils.zzb(taskCompletionSource, e); } } /* JADX WARN: Multi-variable type inference failed */ public final void zzC(TaskCompletionSource taskCompletionSource, String str, boolean z) throws RemoteException { try { ((zzao) getService()).zzA(new zzy(taskCompletionSource), str, z); } catch (SecurityException e) { GamesStatusUtils.zzb(taskCompletionSource, e); } } /* JADX WARN: Multi-variable type inference failed */ public final void zzD(TaskCompletionSource taskCompletionSource, boolean z) throws RemoteException { try { ((zzao) getService()).zzB(new zzab(taskCompletionSource), z); } catch (SecurityException e) { GamesStatusUtils.zzb(taskCompletionSource, e); } } /* JADX WARN: Multi-variable type inference failed */ public final void zzE(TaskCompletionSource taskCompletionSource, LeaderboardScoreBuffer leaderboardScoreBuffer, int i, int i2) throws RemoteException { try { ((zzao) getService()).zzC(new zzaa(this, taskCompletionSource), leaderboardScoreBuffer.zza().zza(), i, i2); } catch (SecurityException e) { GamesStatusUtils.zzb(taskCompletionSource, e); } } /* JADX WARN: Multi-variable type inference failed */ public final void zzF(TaskCompletionSource taskCompletionSource, String str, boolean z) throws RemoteException { try { ((zzao) getService()).zzF(new zzaf(taskCompletionSource), str, z); } catch (SecurityException e) { GamesStatusUtils.zzb(taskCompletionSource, e); } } /* JADX WARN: Multi-variable type inference failed */ public final void zzG(TaskCompletionSource taskCompletionSource, String str, int i, int i2, int i3, boolean z) throws RemoteException { try { ((zzao) getService()).zzD(new zzaa(this, taskCompletionSource), str, i, i2, i3, z); } catch (SecurityException e) { GamesStatusUtils.zzb(taskCompletionSource, e); } } /* JADX WARN: Multi-variable type inference failed */ public final void zzH(TaskCompletionSource taskCompletionSource, boolean z) throws RemoteException { try { ((zzao) getService()).zzE(new zzad(taskCompletionSource), z); } catch (SecurityException e) { GamesStatusUtils.zzb(taskCompletionSource, e); } } /* JADX WARN: Multi-variable type inference failed */ public final void zzI(TaskCompletionSource taskCompletionSource, String str, int i, boolean z, boolean z2) throws RemoteException { if (!str.equals("played_with") && !str.equals("friends_all")) { throw new IllegalArgumentException("Invalid player collection: ".concat(str)); } try { ((zzao) getService()).zzG(new zzae(this, taskCompletionSource), str, i, z, z2); } catch (SecurityException e) { GamesStatusUtils.zzb(taskCompletionSource, e); } } /* JADX WARN: Multi-variable type inference failed */ public final void zzJ(TaskCompletionSource taskCompletionSource, boolean z) throws RemoteException { try { ((zzao) getService()).zzH(new zzac(taskCompletionSource), z); } catch (SecurityException e) { GamesStatusUtils.zzb(taskCompletionSource, e); } } /* JADX WARN: Multi-variable type inference failed */ public final void zzK(TaskCompletionSource taskCompletionSource, String str, int i, int i2, int i3, boolean z) throws RemoteException { try { ((zzao) getService()).zzI(new zzaa(this, taskCompletionSource), str, i, i2, i3, z); } catch (SecurityException e) { GamesStatusUtils.zzb(taskCompletionSource, e); } } /* JADX WARN: Multi-variable type inference failed */ public final void zzL(TaskCompletionSource taskCompletionSource, String str, boolean z, int i) throws RemoteException { try { ((zzao) getService()).zzJ(new zzai(taskCompletionSource), str, z, i); } catch (SecurityException e) { GamesStatusUtils.zzb(taskCompletionSource, e); } } /* JADX WARN: Multi-variable type inference failed */ public final void zzM(TaskCompletionSource taskCompletionSource, String str, boolean z) throws RemoteException { ((zzao) getService()).zzL(new zzx(taskCompletionSource), str, z); } /* JADX WARN: Multi-variable type inference failed */ public final void zzN(TaskCompletionSource taskCompletionSource, String str, String str2, SnapshotMetadataChange snapshotMetadataChange, SnapshotContents snapshotContents) throws RemoteException { Preconditions.checkState(!snapshotContents.isClosed(), "SnapshotContents already closed"); BitmapTeleporter zza = snapshotMetadataChange.zza(); if (zza != null) { zza.setTempDir(getContext().getCacheDir()); } Contents zza2 = snapshotContents.zza(); snapshotContents.zzb(); try { ((zzao) getService()).zzM(new zzai(taskCompletionSource), str, str2, (SnapshotMetadataChangeEntity) snapshotMetadataChange, zza2); } catch (SecurityException e) { GamesStatusUtils.zzb(taskCompletionSource, e); } } /* JADX WARN: Multi-variable type inference failed */ public final void zzQ(IBinder iBinder, Bundle bundle) { if (isConnected()) { if (this.zzl.zzo.zzd() && this.zzm.zzc()) { return; } try { ((zzao) getService()).zzP(iBinder, bundle); this.zzm.zzb(); } catch (RemoteException e) { zzU(e); } } } /* JADX WARN: Multi-variable type inference failed */ public final void zzR(TaskCompletionSource taskCompletionSource, String str, long j, @Nullable String str2) throws RemoteException { try { ((zzao) getService()).zzR(new zzah(taskCompletionSource), str, j, str2); } catch (SecurityException e) { GamesStatusUtils.zzb(taskCompletionSource, e); } } public final void zzS(zzg zzgVar) { zzgVar.zze(this.zzi); } /* JADX WARN: Multi-variable type inference failed */ public final Player zzp() throws RemoteException { checkConnected(); synchronized (this) { try { if (this.zzh == null) { PlayerBuffer playerBuffer = new PlayerBuffer(((zzao) getService()).zzn()); try { if (playerBuffer.getCount() > 0) { this.zzh = new PlayerEntity(playerBuffer.get(0)); } playerBuffer.release(); } catch (Throwable th) { playerBuffer.release(); throw th; } } } catch (Throwable th2) { throw th2; } } return this.zzh; } /* JADX WARN: Multi-variable type inference failed */ public final void zzs() { if (isConnected()) { try { ((zzao) getService()).zzp(); } catch (RemoteException e) { zzU(e); } } } /* JADX WARN: Multi-variable type inference failed */ public final void zzt(TaskCompletionSource taskCompletionSource, Snapshot snapshot, SnapshotMetadataChange snapshotMetadataChange) throws RemoteException { SnapshotContents snapshotContents = snapshot.getSnapshotContents(); Preconditions.checkState(!snapshotContents.isClosed(), "Snapshot already closed"); BitmapTeleporter zza = snapshotMetadataChange.zza(); if (zza != null) { zza.setTempDir(getContext().getCacheDir()); } Contents zza2 = snapshotContents.zza(); snapshotContents.zzb(); try { ((zzao) getService()).zzr(new zzt(taskCompletionSource), snapshot.getMetadata().getSnapshotId(), (SnapshotMetadataChangeEntity) snapshotMetadataChange, zza2); } catch (SecurityException e) { GamesStatusUtils.zzb(taskCompletionSource, e); } } /* JADX WARN: Multi-variable type inference failed */ public final void zzu(TaskCompletionSource taskCompletionSource, String str) throws RemoteException { try { ((zzao) getService()).zzs(new zzu(taskCompletionSource), str); } catch (SecurityException e) { GamesStatusUtils.zzb(taskCompletionSource, e); } } /* JADX WARN: Multi-variable type inference failed */ public final void zzv(TaskCompletionSource taskCompletionSource, boolean z) throws RemoteException { try { ((zzao) getService()).zzF(new zzaf(taskCompletionSource), null, z); } catch (SecurityException e) { GamesStatusUtils.zzb(taskCompletionSource, e); } } public final void zzx(String str, int i) { this.zzf.zzc(str, i); } /* JADX WARN: Multi-variable type inference failed */ public final void zzy(TaskCompletionSource taskCompletionSource, boolean z) throws RemoteException { try { ((zzao) getService()).zzx(new zzs(taskCompletionSource), z); } catch (SecurityException e) { GamesStatusUtils.zzb(taskCompletionSource, e); } } /* JADX WARN: Multi-variable type inference failed */ public final void zzz(TaskCompletionSource taskCompletionSource, String str, int i, int i2) throws RemoteException { try { ((zzao) getService()).zzu(new zzz(this, taskCompletionSource), null, str, i, i2); } catch (SecurityException e) { GamesStatusUtils.zzb(taskCompletionSource, e); } } /* JADX WARN: Multi-variable type inference failed */ public final void zzO(@Nullable TaskCompletionSource taskCompletionSource, String str) throws RemoteException { try { ((zzao) getService()).zzN(taskCompletionSource == null ? null : new zzr(taskCompletionSource), str, this.zzi.zzc(), this.zzi.zzb()); } catch (SecurityException e) { GamesStatusUtils.zzb(taskCompletionSource, e); } } /* JADX WARN: Multi-variable type inference failed */ public final void zzT(@Nullable TaskCompletionSource taskCompletionSource, String str) throws RemoteException { try { ((zzao) getService()).zzS(taskCompletionSource == null ? null : new zzr(taskCompletionSource), str, this.zzi.zzc(), this.zzi.zzb()); } catch (SecurityException e) { GamesStatusUtils.zzb(taskCompletionSource, e); } } /* JADX WARN: Multi-variable type inference failed */ public final void zzP(@Nullable TaskCompletionSource taskCompletionSource, String str, int i) throws RemoteException { try { ((zzao) getService()).zzO(taskCompletionSource == null ? null : new zzq(taskCompletionSource), str, i, this.zzi.zzc(), this.zzi.zzb()); } catch (SecurityException e) { GamesStatusUtils.zzb(taskCompletionSource, e); } } /* JADX WARN: Multi-variable type inference failed */ public final void zzw(@Nullable TaskCompletionSource taskCompletionSource, String str, int i) throws RemoteException { try { ((zzao) getService()).zzv(taskCompletionSource == null ? null : new zzq(taskCompletionSource), str, i, this.zzi.zzc(), this.zzi.zzb()); } catch (SecurityException e) { GamesStatusUtils.zzb(taskCompletionSource, e); } } }