zzaak.java 18.1 KB
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670
package com.google.android.gms.internal;

import android.app.PendingIntent;
import android.content.Context;
import android.os.Handler;
import android.os.Looper;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.v4.util.ArrayMap;
import android.util.Log;
import com.google.android.gms.common.ConnectionResult;
import com.google.android.gms.common.api.Api;
import com.google.android.gms.common.api.Api.zza;
import com.google.android.gms.common.api.Api.zzb;
import com.google.android.gms.common.api.Api.zzc;
import com.google.android.gms.common.api.Api.zze;
import com.google.android.gms.common.api.Result;
import com.google.android.gms.common.api.Status;
import com.google.android.gms.common.api.zzb;
import com.google.android.gms.common.internal.zzg;
import com.google.android.gms.common.zze;
import com.google.android.gms.tasks.OnCompleteListener;
import com.google.android.gms.tasks.Task;
import java.io.FileDescriptor;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Queue;
import java.util.Set;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.concurrent.locks.Condition;
import java.util.concurrent.locks.Lock;

public class zzaak
  implements zzabc
{
  private final Map<Api.zzc<?>, zzaaj<?>> a = new HashMap();
  private final Map<Api.zzc<?>, zzaaj<?>> b = new HashMap();
  private final Map<Api<?>, Boolean> c;
  private final zzaax d;
  private final zzaat e;
  private final Lock f;
  private final Looper g;
  private final zze h;
  private final Condition i;
  private final zzg j;
  private final boolean k;
  private final boolean l;
  private final Queue<zzaad.zza<?, ?>> m = new LinkedList();
  private boolean n;
  private Map<zzzz<?>, ConnectionResult> o;
  private Map<zzzz<?>, ConnectionResult> p;
  private b q;
  private ConnectionResult r;
  
  public zzaak(Context paramContext, Lock paramLock, Looper paramLooper, zze paramzze, Map<Api.zzc<?>, Api.zze> paramMap, zzg paramzzg, Map<Api<?>, Boolean> paramMap1, Api.zza<? extends zzbai, zzbaj> paramzza, ArrayList<zzaag> paramArrayList, zzaat paramzzaat, boolean paramBoolean)
  {
    this.f = paramLock;
    this.g = paramLooper;
    this.i = paramLock.newCondition();
    this.h = paramzze;
    this.e = paramzzaat;
    this.c = paramMap1;
    this.j = paramzzg;
    this.k = paramBoolean;
    paramLock = new HashMap();
    paramzze = paramMap1.keySet().iterator();
    while (paramzze.hasNext())
    {
      paramMap1 = (Api)paramzze.next();
      paramLock.put(paramMap1.zzvg(), paramMap1);
    }
    paramzze = new HashMap();
    paramMap1 = paramArrayList.iterator();
    while (paramMap1.hasNext())
    {
      paramArrayList = (zzaag)paramMap1.next();
      paramzze.put(paramArrayList.zzaxf, paramArrayList);
    }
    int i1 = 0;
    int i2 = 1;
    int i3 = 0;
    paramMap = paramMap.entrySet().iterator();
    if (paramMap.hasNext())
    {
      paramMap1 = (Map.Entry)paramMap.next();
      paramzzaat = (Api)paramLock.get(paramMap1.getKey());
      paramArrayList = (Api.zze)paramMap1.getValue();
      if (paramArrayList.zzvh())
      {
        if (((Boolean)this.c.get(paramzzaat)).booleanValue()) {
          break label475;
        }
        i1 = 1;
        i3 = 1;
      }
    }
    for (;;)
    {
      paramzzaat = new zzaaj(paramContext, paramzzaat, paramLooper, paramArrayList, (zzaag)paramzze.get(paramzzaat), paramzzg, paramzza);
      this.a.put((Api.zzc)paramMap1.getKey(), paramzzaat);
      if (paramArrayList.zzrd()) {
        this.b.put((Api.zzc)paramMap1.getKey(), paramzzaat);
      }
      int i4 = i3;
      i3 = i1;
      i1 = i4;
      break;
      i2 = i3;
      i4 = 0;
      i3 = i1;
      i1 = i2;
      i2 = i4;
      continue;
      if ((i3 != 0) && (i2 == 0) && (i1 == 0)) {}
      for (paramBoolean = true;; paramBoolean = false)
      {
        this.l = paramBoolean;
        this.d = zzaax.zzww();
        return;
      }
      label475:
      i4 = 1;
      i3 = i1;
      i1 = i4;
    }
  }
  
  @Nullable
  private ConnectionResult a(@NonNull Api.zzc<?> paramzzc)
  {
    this.f.lock();
    try
    {
      paramzzc = (zzaaj)this.a.get(paramzzc);
      if ((this.o != null) && (paramzzc != null))
      {
        paramzzc = (ConnectionResult)this.o.get(paramzzc.getApiKey());
        return paramzzc;
      }
      return null;
    }
    finally
    {
      this.f.unlock();
    }
  }
  
  private <T extends zzaad.zza<? extends Result, ? extends Api.zzb>> boolean a(@NonNull T paramT)
  {
    Object localObject1 = paramT.zzvg();
    Object localObject2 = a((Api.zzc)localObject1);
    if ((localObject2 != null) && (((ConnectionResult)localObject2).getErrorCode() == 4))
    {
      localObject2 = this.d;
      localObject1 = ((zzaaj)this.a.get(localObject1)).getApiKey();
      int i1 = this.e.getSessionId();
      if ((zzaax.zza)((zzaax)localObject2).d.get(localObject1) == null) {
        localObject1 = null;
      }
      for (;;)
      {
        paramT.zzB(new Status(4, null, (PendingIntent)localObject1));
        return true;
        localObject1 = (zzaax.zza)((zzaax)localObject2).d.get(localObject1);
        if (((zzaax.zza)localObject1).a == null) {}
        for (localObject1 = null;; localObject1 = ((zzaax.zza)localObject1).a.zzwO())
        {
          if (localObject1 != null) {
            break label136;
          }
          localObject1 = null;
          break;
        }
        label136:
        localObject1 = PendingIntent.getActivity(((zzaax)localObject2).b, i1, ((zzbai)localObject1).zzrs(), 134217728);
      }
    }
    return false;
  }
  
  public ConnectionResult blockingConnect()
  {
    connect();
    while (isConnecting()) {
      try
      {
        this.i.await();
      }
      catch (InterruptedException localInterruptedException)
      {
        Thread.currentThread().interrupt();
        return new ConnectionResult(15, null);
      }
    }
    if (isConnected()) {
      return ConnectionResult.zzayj;
    }
    if (this.r != null) {
      return this.r;
    }
    return new ConnectionResult(13, null);
  }
  
  public ConnectionResult blockingConnect(long paramLong, TimeUnit paramTimeUnit)
  {
    connect();
    for (paramLong = paramTimeUnit.toNanos(paramLong); isConnecting(); paramLong = this.i.awaitNanos(paramLong))
    {
      if (paramLong <= 0L) {}
      try
      {
        disconnect();
        return new ConnectionResult(14, null);
      }
      catch (InterruptedException paramTimeUnit)
      {
        Thread.currentThread().interrupt();
        return new ConnectionResult(15, null);
      }
    }
    if (isConnected()) {
      return ConnectionResult.zzayj;
    }
    if (this.r != null) {
      return this.r;
    }
    return new ConnectionResult(13, null);
  }
  
  public void connect()
  {
    this.f.lock();
    try
    {
      boolean bool = this.n;
      if (bool) {
        return;
      }
      this.n = true;
      this.o = null;
      this.p = null;
      this.q = null;
      this.r = null;
      this.d.zzvx();
      this.d.zza(this.a.values()).addOnCompleteListener(new zzadb(this.g), new a((byte)0));
      return;
    }
    finally
    {
      this.f.unlock();
    }
  }
  
  public void disconnect()
  {
    this.f.lock();
    try
    {
      this.n = false;
      this.o = null;
      this.p = null;
      if (this.q != null)
      {
        this.q.a();
        this.q = null;
      }
      this.r = null;
      while (!this.m.isEmpty())
      {
        zzaad.zza localzza = (zzaad.zza)this.m.remove();
        localzza.zza(null);
        localzza.cancel();
      }
      this.i.signalAll();
    }
    finally
    {
      this.f.unlock();
    }
    this.f.unlock();
  }
  
  public void dump(String paramString, FileDescriptor paramFileDescriptor, PrintWriter paramPrintWriter, String[] paramArrayOfString) {}
  
  @Nullable
  public ConnectionResult getConnectionResult(@NonNull Api<?> paramApi)
  {
    return a(paramApi.zzvg());
  }
  
  /* Error */
  public boolean isConnected()
  {
    // Byte code:
    //   0: aload_0
    //   1: getfield 63	com/google/android/gms/internal/zzaak:f	Ljava/util/concurrent/locks/Lock;
    //   4: invokeinterface 178 1 0
    //   9: aload_0
    //   10: getfield 180	com/google/android/gms/internal/zzaak:o	Ljava/util/Map;
    //   13: ifnull +25 -> 38
    //   16: aload_0
    //   17: getfield 195	com/google/android/gms/internal/zzaak:r	Lcom/google/android/gms/common/ConnectionResult;
    //   20: astore_2
    //   21: aload_2
    //   22: ifnonnull +16 -> 38
    //   25: iconst_1
    //   26: istore_1
    //   27: aload_0
    //   28: getfield 63	com/google/android/gms/internal/zzaak:f	Ljava/util/concurrent/locks/Lock;
    //   31: invokeinterface 189 1 0
    //   36: iload_1
    //   37: ireturn
    //   38: iconst_0
    //   39: istore_1
    //   40: goto -13 -> 27
    //   43: astore_2
    //   44: aload_0
    //   45: getfield 63	com/google/android/gms/internal/zzaak:f	Ljava/util/concurrent/locks/Lock;
    //   48: invokeinterface 189 1 0
    //   53: aload_2
    //   54: athrow
    // Local variable table:
    //   start	length	slot	name	signature
    //   0	55	0	this	zzaak
    //   26	14	1	bool	boolean
    //   20	2	2	localConnectionResult	ConnectionResult
    //   43	11	2	localObject	Object
    // Exception table:
    //   from	to	target	type
    //   9	21	43	finally
  }
  
  /* Error */
  public boolean isConnecting()
  {
    // Byte code:
    //   0: aload_0
    //   1: getfield 63	com/google/android/gms/internal/zzaak:f	Ljava/util/concurrent/locks/Lock;
    //   4: invokeinterface 178 1 0
    //   9: aload_0
    //   10: getfield 180	com/google/android/gms/internal/zzaak:o	Ljava/util/Map;
    //   13: ifnonnull +25 -> 38
    //   16: aload_0
    //   17: getfield 277	com/google/android/gms/internal/zzaak:n	Z
    //   20: istore_1
    //   21: iload_1
    //   22: ifeq +16 -> 38
    //   25: iconst_1
    //   26: istore_1
    //   27: aload_0
    //   28: getfield 63	com/google/android/gms/internal/zzaak:f	Ljava/util/concurrent/locks/Lock;
    //   31: invokeinterface 189 1 0
    //   36: iload_1
    //   37: ireturn
    //   38: iconst_0
    //   39: istore_1
    //   40: goto -13 -> 27
    //   43: astore_2
    //   44: aload_0
    //   45: getfield 63	com/google/android/gms/internal/zzaak:f	Ljava/util/concurrent/locks/Lock;
    //   48: invokeinterface 189 1 0
    //   53: aload_2
    //   54: athrow
    // Local variable table:
    //   start	length	slot	name	signature
    //   0	55	0	this	zzaak
    //   20	20	1	bool	boolean
    //   43	11	2	localObject	Object
    // Exception table:
    //   from	to	target	type
    //   9	21	43	finally
  }
  
  public <A extends Api.zzb, R extends Result, T extends zzaad.zza<R, A>> T zza(@NonNull T paramT)
  {
    if ((this.k) && (a(paramT))) {
      return paramT;
    }
    if (!isConnected())
    {
      this.m.add(paramT);
      return paramT;
    }
    this.e.i.a(paramT);
    return ((zzaaj)this.a.get(paramT.zzvg())).doRead(paramT);
  }
  
  public boolean zza(zzabq paramzzabq)
  {
    this.f.lock();
    try
    {
      if ((this.n) && (!zzvN()))
      {
        this.d.zzvx();
        this.q = new b(paramzzabq);
        this.d.zza(this.b.values()).addOnCompleteListener(new zzadb(this.g), this.q);
        return true;
      }
      return false;
    }
    finally
    {
      this.f.unlock();
    }
  }
  
  public <A extends Api.zzb, T extends zzaad.zza<? extends Result, A>> T zzb(@NonNull T paramT)
  {
    Api.zzc localzzc = paramT.zzvg();
    if ((this.k) && (a(paramT))) {
      return paramT;
    }
    this.e.i.a(paramT);
    return ((zzaaj)this.a.get(localzzc)).doWrite(paramT);
  }
  
  public void zzvM() {}
  
  public boolean zzvN()
  {
    this.f.lock();
    try
    {
      boolean bool;
      if (this.n)
      {
        bool = this.k;
        if (bool) {}
      }
      else
      {
        return false;
      }
      Iterator localIterator = this.b.keySet().iterator();
      while (localIterator.hasNext())
      {
        ConnectionResult localConnectionResult = a((Api.zzc)localIterator.next());
        if (localConnectionResult != null)
        {
          bool = localConnectionResult.isSuccess();
          if (bool) {
            break;
          }
        }
        else
        {
          return false;
        }
      }
      return true;
    }
    finally
    {
      this.f.unlock();
    }
  }
  
  public void zzvn()
  {
    this.f.lock();
    try
    {
      Object localObject1 = this.d;
      ((zzaax)localObject1).c.incrementAndGet();
      ((zzaax)localObject1).g.sendMessage(((zzaax)localObject1).g.obtainMessage(10));
      if (this.q != null)
      {
        this.q.a();
        this.q = null;
      }
      if (this.p == null) {
        this.p = new ArrayMap(this.b.size());
      }
      localObject1 = new ConnectionResult(4);
      Iterator localIterator = this.b.values().iterator();
      while (localIterator.hasNext())
      {
        zzaaj localzzaaj = (zzaaj)localIterator.next();
        this.p.put(localzzaaj.getApiKey(), localObject1);
      }
      if (this.o == null) {
        break label178;
      }
    }
    finally
    {
      this.f.unlock();
    }
    this.o.putAll(this.p);
    label178:
    this.f.unlock();
  }
  
  final class a
    implements OnCompleteListener<Void>
  {
    private a() {}
    
    public final void onComplete(@NonNull Task<Void> paramTask)
    {
      zzaak.a(zzaak.this).lock();
      Object localObject;
      try
      {
        boolean bool = zzaak.b(zzaak.this);
        if (!bool) {
          return;
        }
        if (paramTask.isSuccessful())
        {
          zzaak.a(zzaak.this, new ArrayMap(zzaak.c(zzaak.this).size()));
          paramTask = zzaak.c(zzaak.this).values().iterator();
          while (paramTask.hasNext())
          {
            localObject = (zzaaj)paramTask.next();
            zzaak.d(zzaak.this).put(((zzaaj)localObject).getApiKey(), ConnectionResult.zzayj);
          }
        }
        if (!(paramTask.getException() instanceof zzb)) {
          break label435;
        }
      }
      finally
      {
        zzaak.a(zzaak.this).unlock();
      }
      paramTask = (zzb)paramTask.getException();
      if (zzaak.e(zzaak.this))
      {
        zzaak.a(zzaak.this, new ArrayMap(zzaak.c(zzaak.this).size()));
        localObject = zzaak.c(zzaak.this).values().iterator();
        while (((Iterator)localObject).hasNext())
        {
          zzaaj localzzaaj = (zzaaj)((Iterator)localObject).next();
          zzzz localzzzz = localzzaaj.getApiKey();
          ConnectionResult localConnectionResult = paramTask.zza(localzzaaj);
          if (zzaak.a(zzaak.this, localzzaaj, localConnectionResult)) {
            zzaak.d(zzaak.this).put(localzzzz, new ConnectionResult(16));
          } else {
            zzaak.d(zzaak.this).put(localzzzz, localConnectionResult);
          }
        }
      }
      zzaak.a(zzaak.this, paramTask.zzvj());
      zzaak.a(zzaak.this, zzaak.f(zzaak.this));
      if (zzaak.g(zzaak.this) != null)
      {
        zzaak.d(zzaak.this).putAll(zzaak.g(zzaak.this));
        zzaak.a(zzaak.this, zzaak.f(zzaak.this));
      }
      if (zzaak.h(zzaak.this) == null)
      {
        zzaak.i(zzaak.this);
        zzaak.j(zzaak.this);
      }
      for (;;)
      {
        zzaak.m(zzaak.this).signalAll();
        zzaak.a(zzaak.this).unlock();
        return;
        label435:
        Log.e("ConnectionlessGAC", "Unexpected availability exception", paramTask.getException());
        zzaak.a(zzaak.this, Collections.emptyMap());
        zzaak.a(zzaak.this, new ConnectionResult(8));
        break;
        zzaak.k(zzaak.this);
        zzaak.l(zzaak.this).zzc(zzaak.h(zzaak.this));
      }
    }
  }
  
  final class b
    implements OnCompleteListener<Void>
  {
    private zzabq b;
    
    b(zzabq paramzzabq)
    {
      this.b = paramzzabq;
    }
    
    final void a()
    {
      this.b.zzrq();
    }
    
    public final void onComplete(@NonNull Task<Void> paramTask)
    {
      zzaak.a(zzaak.this).lock();
      Object localObject;
      try
      {
        if (!zzaak.b(zzaak.this))
        {
          this.b.zzrq();
          return;
        }
        if (paramTask.isSuccessful())
        {
          zzaak.b(zzaak.this, new ArrayMap(zzaak.n(zzaak.this).size()));
          paramTask = zzaak.n(zzaak.this).values().iterator();
          while (paramTask.hasNext())
          {
            localObject = (zzaaj)paramTask.next();
            zzaak.g(zzaak.this).put(((zzaaj)localObject).getApiKey(), ConnectionResult.zzayj);
          }
        }
        if (!(paramTask.getException() instanceof zzb)) {
          break label417;
        }
      }
      finally
      {
        zzaak.a(zzaak.this).unlock();
      }
      paramTask = (zzb)paramTask.getException();
      if (zzaak.e(zzaak.this))
      {
        zzaak.b(zzaak.this, new ArrayMap(zzaak.n(zzaak.this).size()));
        localObject = zzaak.n(zzaak.this).values().iterator();
        while (((Iterator)localObject).hasNext())
        {
          zzaaj localzzaaj = (zzaaj)((Iterator)localObject).next();
          zzzz localzzzz = localzzaaj.getApiKey();
          ConnectionResult localConnectionResult = paramTask.zza(localzzaaj);
          if (zzaak.a(zzaak.this, localzzaaj, localConnectionResult)) {
            zzaak.g(zzaak.this).put(localzzzz, new ConnectionResult(16));
          } else {
            zzaak.g(zzaak.this).put(localzzzz, localConnectionResult);
          }
        }
      }
      zzaak.b(zzaak.this, paramTask.zzvj());
      for (;;)
      {
        if (zzaak.this.isConnected())
        {
          zzaak.d(zzaak.this).putAll(zzaak.g(zzaak.this));
          if (zzaak.f(zzaak.this) == null)
          {
            zzaak.i(zzaak.this);
            zzaak.j(zzaak.this);
            zzaak.m(zzaak.this).signalAll();
          }
        }
        this.b.zzrq();
        zzaak.a(zzaak.this).unlock();
        return;
        label417:
        Log.e("ConnectionlessGAC", "Unexpected availability exception", paramTask.getException());
        zzaak.b(zzaak.this, Collections.emptyMap());
      }
    }
  }
}


/* Location:              /home/merong/decompile/hackery-dex2jar.jar!/com/google/android/gms/internal/zzaak.class
 * Java compiler version: 6 (50.0)
 * JD-Core Version:       0.7.1
 */