ho.java 7.17 KB
import android.content.ComponentName;
import android.content.Context;
import android.content.ServiceConnection;
import android.os.Handler;
import android.os.Handler.Callback;
import android.os.IBinder;
import android.os.Message;
import android.util.Log;
import com.google.android.gms.common.internal.zzac;
import com.google.android.gms.common.internal.zzn;
import com.google.android.gms.common.internal.zzn.zza;
import com.google.android.gms.common.stats.zza;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.Set;

public final class ho
  extends zzn
  implements Handler.Callback
{
  private final HashMap<zzn.zza, ho.a> a = new HashMap();
  private final Context b;
  private final Handler c;
  private final zza d;
  private final long e;
  private final long f;
  
  public ho(Context paramContext)
  {
    this.b = paramContext.getApplicationContext();
    this.c = new Handler(paramContext.getMainLooper(), this);
    this.d = zza.zzyJ();
    this.e = 5000L;
    this.f = 300000L;
  }
  
  public final boolean handleMessage(Message paramMessage)
  {
    switch (paramMessage.what)
    {
    default: 
      return false;
    case 0: 
      synchronized (this.a)
      {
        paramMessage = (zzn.zza)paramMessage.obj;
        ??? = (ho.a)this.a.get(paramMessage);
        if ((??? != null) && (((ho.a)???).a()))
        {
          if (((ho.a)???).c)
          {
            ((ho.a)???).g.c.removeMessages(1, ((ho.a)???).e);
            ((ho.a)???).g.d.zza(((ho.a)???).g.b, (ServiceConnection)???);
            ((ho.a)???).c = false;
            ((ho.a)???).b = 2;
          }
          this.a.remove(paramMessage);
        }
        return true;
      }
    }
    for (;;)
    {
      synchronized (this.a)
      {
        zzn.zza localzza = (zzn.zza)paramMessage.obj;
        ho.a locala = (ho.a)this.a.get(localzza);
        if ((locala != null) && (locala.b == 3))
        {
          paramMessage = String.valueOf(localzza);
          Log.wtf("GmsClientSupervisor", String.valueOf(paramMessage).length() + 47 + "Timeout waiting for ServiceConnection callback " + paramMessage, new Exception());
          ??? = locala.f;
          paramMessage = (Message)???;
          if (??? == null) {
            paramMessage = localzza.getComponentName();
          }
          if (paramMessage == null)
          {
            paramMessage = new ComponentName(localzza.getPackage(), "unknown");
            locala.onServiceDisconnected(paramMessage);
          }
        }
        else
        {
          return true;
        }
      }
    }
  }
  
  protected final boolean zza(zzn.zza paramzza, ServiceConnection paramServiceConnection, String paramString)
  {
    zzac.zzb(paramServiceConnection, "ServiceConnection must not be null");
    for (;;)
    {
      ho.a locala;
      synchronized (this.a)
      {
        locala = (ho.a)this.a.get(paramzza);
        if (locala == null)
        {
          locala = new ho.a(paramzza);
          locala.a(paramServiceConnection, paramString);
          locala.a(paramString);
          this.a.put(paramzza, locala);
          paramzza = locala;
          boolean bool = paramzza.c;
          return bool;
        }
        this.c.removeMessages(0, paramzza);
        if (locala.a(paramServiceConnection))
        {
          paramzza = String.valueOf(paramzza);
          throw new IllegalStateException(String.valueOf(paramzza).length() + 81 + "Trying to bind a GmsServiceConnection that was already connected before.  config=" + paramzza);
        }
      }
      locala.a(paramServiceConnection, paramString);
      switch (locala.b)
      {
      case 1: 
        paramServiceConnection.onServiceConnected(locala.f, locala.d);
        paramzza = locala;
        break;
      case 2: 
        locala.a(paramString);
        paramzza = locala;
        break;
      default: 
        paramzza = locala;
      }
    }
  }
  
  protected final void zzb(zzn.zza paramzza, ServiceConnection paramServiceConnection, String arg3)
  {
    zzac.zzb(paramServiceConnection, "ServiceConnection must not be null");
    ho.a locala;
    synchronized (this.a)
    {
      locala = (ho.a)this.a.get(paramzza);
      if (locala == null)
      {
        paramzza = String.valueOf(paramzza);
        throw new IllegalStateException(String.valueOf(paramzza).length() + 50 + "Nonexistent connection status for service config: " + paramzza);
      }
    }
    if (!locala.a(paramServiceConnection))
    {
      paramzza = String.valueOf(paramzza);
      throw new IllegalStateException(String.valueOf(paramzza).length() + 76 + "Trying to unbind a GmsServiceConnection  that was not bound before.  config=" + paramzza);
    }
    locala.g.d.zzb(locala.g.b, paramServiceConnection);
    locala.a.remove(paramServiceConnection);
    if (locala.a())
    {
      paramzza = this.c.obtainMessage(0, paramzza);
      this.c.sendMessageDelayed(paramzza, this.e);
    }
  }
  
  final class a
    implements ServiceConnection
  {
    final Set<ServiceConnection> a;
    int b;
    boolean c;
    IBinder d;
    final zzn.zza e;
    ComponentName f;
    
    public a(zzn.zza paramzza)
    {
      this.e = paramzza;
      this.a = new HashSet();
      this.b = 2;
    }
    
    public final void a(ServiceConnection paramServiceConnection, String paramString)
    {
      ho.d(ho.this).zza(ho.c(ho.this), paramServiceConnection, paramString, this.e.zzxZ());
      this.a.add(paramServiceConnection);
    }
    
    public final void a(String paramString)
    {
      this.b = 3;
      this.c = ho.d(ho.this).zza(ho.c(ho.this), paramString, this.e.zzxZ(), this, 129);
      if (this.c)
      {
        paramString = ho.b(ho.this).obtainMessage(1, this.e);
        ho.b(ho.this).sendMessageDelayed(paramString, ho.e(ho.this));
        return;
      }
      this.b = 2;
      try
      {
        ho.d(ho.this).zza(ho.c(ho.this), this);
        return;
      }
      catch (IllegalArgumentException paramString) {}
    }
    
    public final boolean a()
    {
      return this.a.isEmpty();
    }
    
    public final boolean a(ServiceConnection paramServiceConnection)
    {
      return this.a.contains(paramServiceConnection);
    }
    
    public final void onServiceConnected(ComponentName paramComponentName, IBinder paramIBinder)
    {
      synchronized (ho.a(ho.this))
      {
        ho.b(ho.this).removeMessages(1, this.e);
        this.d = paramIBinder;
        this.f = paramComponentName;
        Iterator localIterator = this.a.iterator();
        if (localIterator.hasNext()) {
          ((ServiceConnection)localIterator.next()).onServiceConnected(paramComponentName, paramIBinder);
        }
      }
      this.b = 1;
    }
    
    public final void onServiceDisconnected(ComponentName paramComponentName)
    {
      synchronized (ho.a(ho.this))
      {
        ho.b(ho.this).removeMessages(1, this.e);
        this.d = null;
        this.f = paramComponentName;
        Iterator localIterator = this.a.iterator();
        if (localIterator.hasNext()) {
          ((ServiceConnection)localIterator.next()).onServiceDisconnected(paramComponentName);
        }
      }
      this.b = 2;
    }
  }
}


/* Location:              /home/merong/decompile/hackery-dex2jar.jar!/ho.class
 * Java compiler version: 6 (50.0)
 * JD-Core Version:       0.7.1
 */