package com.google.android.gms.common.internal; import android.content.ComponentName; import android.content.Context; import android.content.ServiceConnection; import android.os.Handler; import android.os.IBinder; import android.os.Message; import com.google.android.gms.common.internal.GmsClientSupervisor; import com.google.android.gms.common.stats.ConnectionTracker; import java.util.HashMap; import java.util.HashSet; import java.util.Iterator; import java.util.Set; /* loaded from: classes.dex */ final class zzf implements ServiceConnection { private final Set a = new HashSet(); private int b = 2; private boolean c; private IBinder d; private final GmsClientSupervisor.zza e; private ComponentName f; private final /* synthetic */ zze g; public zzf(zze zzeVar, GmsClientSupervisor.zza zzaVar) { this.g = zzeVar; this.e = zzaVar; } public final void a(String str) { ConnectionTracker connectionTracker; Context context; Context context2; ConnectionTracker connectionTracker2; Context context3; Handler handler; Handler handler2; long j; this.b = 3; connectionTracker = this.g.f; context = this.g.d; GmsClientSupervisor.zza zzaVar = this.e; context2 = this.g.d; this.c = connectionTracker.a(context, str, zzaVar.a(context2), this, this.e.c()); if (this.c) { handler = this.g.e; Message obtainMessage = handler.obtainMessage(1, this.e); handler2 = this.g.e; j = this.g.h; handler2.sendMessageDelayed(obtainMessage, j); return; } this.b = 2; try { connectionTracker2 = this.g.f; context3 = this.g.d; connectionTracker2.a(context3, this); } catch (IllegalArgumentException unused) { } } public final void b(String str) { Handler handler; ConnectionTracker connectionTracker; Context context; handler = this.g.e; handler.removeMessages(1, this.e); connectionTracker = this.g.f; context = this.g.d; connectionTracker.a(context, this); this.c = false; this.b = 2; } public final int c() { return this.b; } public final boolean d() { return this.c; } public final boolean e() { return this.a.isEmpty(); } @Override // android.content.ServiceConnection public final void onServiceConnected(ComponentName componentName, IBinder iBinder) { HashMap hashMap; Handler handler; hashMap = this.g.c; synchronized (hashMap) { handler = this.g.e; handler.removeMessages(1, this.e); this.d = iBinder; this.f = componentName; Iterator it = this.a.iterator(); while (it.hasNext()) { it.next().onServiceConnected(componentName, iBinder); } this.b = 1; } } @Override // android.content.ServiceConnection public final void onServiceDisconnected(ComponentName componentName) { HashMap hashMap; Handler handler; hashMap = this.g.c; synchronized (hashMap) { handler = this.g.e; handler.removeMessages(1, this.e); this.d = null; this.f = componentName; Iterator it = this.a.iterator(); while (it.hasNext()) { it.next().onServiceDisconnected(componentName); } this.b = 2; } } public final void b(ServiceConnection serviceConnection, String str) { ConnectionTracker unused; Context unused2; unused = this.g.f; unused2 = this.g.d; this.a.remove(serviceConnection); } public final ComponentName b() { return this.f; } public final void a(ServiceConnection serviceConnection, String str) { Context context; ConnectionTracker unused; Context unused2; unused = this.g.f; unused2 = this.g.d; GmsClientSupervisor.zza zzaVar = this.e; context = this.g.d; zzaVar.a(context); this.a.add(serviceConnection); } public final boolean a(ServiceConnection serviceConnection) { return this.a.contains(serviceConnection); } public final IBinder a() { return this.d; } }