ig.java 24.9 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 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.IntentFilter;
import android.database.sqlite.SQLiteException;
import android.os.Handler;
import android.text.TextUtils;
import android.util.Pair;
import com.google.android.gms.analytics.CampaignTrackingReceiver;
import com.google.android.gms.analytics.CampaignTrackingService;
import com.google.android.gms.analytics.zza;
import com.google.android.gms.analytics.zzh;
import com.google.android.gms.common.internal.zzac;
import com.google.android.gms.internal.zzadf;
import com.google.android.gms.internal.zzadg;
import com.google.android.gms.internal.zzrk;
import com.google.android.gms.internal.zzrl;
import com.google.android.gms.internal.zzro;
import com.google.android.gms.internal.zzrt;
import com.google.android.gms.internal.zzsa;
import com.google.android.gms.internal.zzsc;
import com.google.android.gms.internal.zzsd;
import com.google.android.gms.internal.zzse;
import com.google.android.gms.internal.zzsf;
import com.google.android.gms.internal.zzsp;
import com.google.android.gms.internal.zzst;
import com.google.android.gms.internal.zzsu;
import com.google.android.gms.internal.zzsw;
import com.google.android.gms.internal.zzsw.zza;
import com.google.android.gms.internal.zzsz;
import com.google.android.gms.internal.zztd;
import com.google.android.gms.internal.zztg;
import com.google.android.gms.internal.zztg.zza;
import com.google.android.gms.internal.zzth;
import com.google.android.gms.internal.zzti;
import com.google.android.gms.internal.zztm;
import com.google.android.gms.internal.zztn;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;

public final class ig
  extends zzsa
{
  private boolean a;
  private final if b;
  private final il c;
  private final ik d;
  private final zzsf e;
  private long f;
  private final ij g;
  private final ij h;
  private final im i;
  private long j;
  private boolean k;
  
  public ig(zzsc paramzzsc, zzsd paramzzsd)
  {
    super(paramzzsc);
    zzac.zzw(paramzzsd);
    this.f = Long.MIN_VALUE;
    this.d = zzsd.b(paramzzsc);
    this.b = paramzzsd.zzm(paramzzsc);
    this.c = paramzzsd.zzn(paramzzsc);
    this.e = paramzzsd.zzo(paramzzsc);
    this.i = new im(zznR());
    this.g = new ij(paramzzsc)
    {
      public final void a()
      {
        ig.a(ig.this);
      }
    };
    this.h = new ij(paramzzsc)
    {
      public final void a()
      {
        ig.b(ig.this);
      }
    };
  }
  
  private void a(zzse paramzzse, zzrl paramzzrl)
  {
    zzac.zzw(paramzzse);
    zzac.zzw(paramzzrl);
    Object localObject1 = new zza(zznQ());
    ((zza)localObject1).zzbo(paramzzse.zzok());
    ((zza)localObject1).enableAdvertisingIdCollection(paramzzse.zzol());
    localObject1 = ((zza)localObject1).zzmo();
    zzrt localzzrt = (zzrt)((com.google.android.gms.analytics.zze)localObject1).zzb(zzrt.class);
    localzzrt.zzbE("data");
    localzzrt.zzT(true);
    ((com.google.android.gms.analytics.zze)localObject1).zza(paramzzrl);
    zzro localzzro = (zzro)((com.google.android.gms.analytics.zze)localObject1).zzb(zzro.class);
    zzrk localzzrk = (zzrk)((com.google.android.gms.analytics.zze)localObject1).zzb(zzrk.class);
    Iterator localIterator = paramzzse.zzfE().entrySet().iterator();
    while (localIterator.hasNext())
    {
      Object localObject2 = (Map.Entry)localIterator.next();
      String str = (String)((Map.Entry)localObject2).getKey();
      localObject2 = (String)((Map.Entry)localObject2).getValue();
      if ("an".equals(str)) {
        localzzrk.setAppName((String)localObject2);
      } else if ("av".equals(str)) {
        localzzrk.setAppVersion((String)localObject2);
      } else if ("aid".equals(str)) {
        localzzrk.setAppId((String)localObject2);
      } else if ("aiid".equals(str)) {
        localzzrk.setAppInstallerId((String)localObject2);
      } else if ("uid".equals(str)) {
        localzzrt.setUserId((String)localObject2);
      } else {
        localzzro.set(str, (String)localObject2);
      }
    }
    zzb("Sending installation campaign to", paramzzse.zzok(), paramzzrl);
    ((com.google.android.gms.analytics.zze)localObject1).zzq(zznW().zzqe());
    ((com.google.android.gms.analytics.zze)localObject1).zzmG();
  }
  
  private boolean b(String paramString)
  {
    return zzadg.zzbi(getContext()).checkCallingOrSelfPermission(paramString) == 0;
  }
  
  private void i()
  {
    if (this.k) {}
    do
    {
      long l;
      do
      {
        do
        {
          return;
        } while ((!zznT().zzoX()) || (this.e.isConnected()));
        l = zznT().zzps();
      } while (!this.i.a(l));
      this.i.a();
      zzbP("Connecting to service");
    } while (!this.e.connect());
    zzbP("Connected to service");
    this.i.a = 0L;
    d();
  }
  
  private boolean j()
  {
    int n = 1;
    zzh.zzmR();
    zzob();
    zzbP("Dispatching a batch of local hits");
    int m;
    if (!this.e.isConnected())
    {
      m = 1;
      if (this.c.a()) {
        break label60;
      }
    }
    for (;;)
    {
      if ((m == 0) || (n == 0)) {
        break label65;
      }
      zzbP("No network or service available. Will retry later");
      return false;
      m = 0;
      break;
      label60:
      n = 0;
    }
    label65:
    long l3 = Math.max(zznT().zzpg(), zznT().zzph());
    ArrayList localArrayList = new ArrayList();
    long l1 = 0L;
    try
    {
      for (;;)
      {
        this.b.a();
        localArrayList.clear();
        try
        {
          localList = this.b.a(l3);
          if (localList.isEmpty())
          {
            zzbP("Store is empty, nothing to dispatch");
            m();
            try
            {
              this.b.b();
              this.b.c();
              return false;
            }
            catch (SQLiteException localSQLiteException1)
            {
              zze("Failed to commit local dispatch transaction", localSQLiteException1);
              m();
              return false;
            }
          }
          zza("Hits loaded from store. count", Integer.valueOf(localList.size()));
          localObject2 = localList.iterator();
          for (;;)
          {
            if (((Iterator)localObject2).hasNext()) {
              if (((zzsz)((Iterator)localObject2).next()).zzpP() == l1)
              {
                zzd("Database contains successfully uploaded hit", Long.valueOf(l1), Integer.valueOf(localList.size()));
                m();
                try
                {
                  this.b.b();
                  this.b.c();
                  return false;
                }
                catch (SQLiteException localSQLiteException2)
                {
                  zze("Failed to commit local dispatch transaction", localSQLiteException2);
                  m();
                  return false;
                }
              }
            }
          }
        }
        catch (SQLiteException localSQLiteException3)
        {
          List localList;
          Object localObject2;
          zzd("Failed to read hits from persisted store", localSQLiteException3);
          m();
          try
          {
            this.b.b();
            this.b.c();
            return false;
          }
          catch (SQLiteException localSQLiteException4)
          {
            zze("Failed to commit local dispatch transaction", localSQLiteException4);
            m();
            return false;
          }
          long l2 = l1;
          if (this.e.isConnected())
          {
            zzbP("Service connected, sending hits to the service");
            for (;;)
            {
              l2 = l1;
              if (!localList.isEmpty())
              {
                localObject2 = (zzsz)localList.get(0);
                l2 = l1;
                if (this.e.zzb((zzsz)localObject2))
                {
                  l1 = Math.max(l1, ((zzsz)localObject2).zzpP());
                  localList.remove(localObject2);
                  zzb("Hit sent do device AnalyticsService for delivery", localObject2);
                  try
                  {
                    this.b.b(((zzsz)localObject2).zzpP());
                    localSQLiteException4.add(Long.valueOf(((zzsz)localObject2).zzpP()));
                  }
                  catch (SQLiteException localSQLiteException5)
                  {
                    zze("Failed to remove hit that was send for delivery", localSQLiteException5);
                    m();
                    try
                    {
                      this.b.b();
                      this.b.c();
                      return false;
                    }
                    catch (SQLiteException localSQLiteException6)
                    {
                      zze("Failed to commit local dispatch transaction", localSQLiteException6);
                      m();
                      return false;
                    }
                  }
                }
              }
            }
          }
          l1 = l2;
          if (this.c.a())
          {
            localList = this.c.a(localList);
            localObject2 = localList.iterator();
            for (l1 = l2; ((Iterator)localObject2).hasNext(); l1 = Math.max(l1, ((Long)((Iterator)localObject2).next()).longValue())) {}
          }
          try
          {
            this.b.a(localList);
            localSQLiteException6.addAll(localList);
            boolean bool = localSQLiteException6.isEmpty();
            if (bool) {
              try
              {
                this.b.b();
                this.b.c();
                return false;
              }
              catch (SQLiteException localSQLiteException7)
              {
                zze("Failed to commit local dispatch transaction", localSQLiteException7);
                m();
                return false;
              }
            }
          }
          catch (SQLiteException localSQLiteException8)
          {
            zze("Failed to remove successfully uploaded hits", localSQLiteException8);
            m();
            try
            {
              this.b.b();
              this.b.c();
              return false;
            }
            catch (SQLiteException localSQLiteException9)
            {
              zze("Failed to commit local dispatch transaction", localSQLiteException9);
              m();
              return false;
            }
            try
            {
              this.b.b();
              this.b.c();
            }
            catch (SQLiteException localSQLiteException10)
            {
              zze("Failed to commit local dispatch transaction", localSQLiteException10);
              m();
              return false;
            }
          }
        }
      }
      return false;
    }
    finally
    {
      try
      {
        this.b.b();
        this.b.c();
        throw ((Throwable)localObject1);
      }
      catch (SQLiteException localSQLiteException11)
      {
        zze("Failed to commit local dispatch transaction", localSQLiteException11);
        m();
      }
    }
  }
  
  private long k()
  {
    zzh.zzmR();
    zzob();
    try
    {
      long l = this.b.h();
      return l;
    }
    catch (SQLiteException localSQLiteException)
    {
      zze("Failed to get min/max hit times from local store", localSQLiteException);
    }
    return 0L;
  }
  
  private void l()
  {
    zzst localzzst = zznV();
    if (!localzzst.zzpD()) {}
    long l;
    do
    {
      do
      {
        return;
      } while (localzzst.zzcy());
      l = k();
    } while ((l == 0L) || (Math.abs(zznR().currentTimeMillis() - l) > zznT().zzpf()));
    zza("Dispatch alarm scheduled (ms)", Long.valueOf(zznT().zzpe()));
    localzzst.schedule();
  }
  
  private void m()
  {
    if (this.g.b()) {
      zzbP("All hits dispatched or no network/service. Going to power save mode");
    }
    this.g.c();
    zzst localzzst = zznV();
    if (localzzst.zzcy()) {
      localzzst.cancel();
    }
  }
  
  private long n()
  {
    long l;
    if (this.f != Long.MIN_VALUE) {
      l = this.f;
    }
    do
    {
      return l;
      l = zznT().zzpd();
    } while (!zzmB().zzpK());
    return zzmB().zzqB() * 1000L;
  }
  
  private void o()
  {
    zzob();
    zzmR();
    this.k = true;
    this.e.disconnect();
    h();
  }
  
  public final void a()
  {
    zzob();
    if (!this.a) {}
    for (boolean bool = true;; bool = false)
    {
      zzac.zza(bool, "Analytics backend already started");
      this.a = true;
      zznU().zzg(new Runnable()
      {
        public final void run()
        {
          ig.this.b();
        }
      });
      return;
    }
  }
  
  public final void a(long paramLong)
  {
    zzh.zzmR();
    zzob();
    long l = paramLong;
    if (paramLong < 0L) {
      l = 0L;
    }
    this.f = l;
    h();
  }
  
  public final void a(zzse paramzzse)
  {
    zzmR();
    zzb("Sending first hit to property", paramzzse.zzok());
    if (zznW().zzqf().a(zznT().zzpy())) {}
    do
    {
      return;
      localObject = zznW().zzqi();
    } while (TextUtils.isEmpty((CharSequence)localObject));
    Object localObject = zztm.zza(zznS(), (String)localObject);
    zzb("Found relevant installation campaign", localObject);
    a(paramzzse, (zzrl)localObject);
  }
  
  public final void a(zzsu paramzzsu)
  {
    long l2 = this.j;
    zzh.zzmR();
    zzob();
    long l1 = -1L;
    long l3 = zznW().zzqg();
    if (l3 != 0L) {
      l1 = Math.abs(zznR().currentTimeMillis() - l3);
    }
    zzb("Dispatching local hits. Elapsed time since last dispatch (ms)", Long.valueOf(l1));
    i();
    try
    {
      j();
      zznW().zzqh();
      h();
      if (paramzzsu != null) {
        paramzzsu.zzf(null);
      }
      if (this.j != l2) {
        this.d.c();
      }
      return;
    }
    catch (Throwable localThrowable)
    {
      do
      {
        zze("Local dispatch failed", localThrowable);
        zznW().zzqh();
        h();
      } while (paramzzsu == null);
      paramzzsu.zzf(localThrowable);
    }
  }
  
  public final void a(zzsz paramzzsz)
  {
    zzac.zzw(paramzzsz);
    zzh.zzmR();
    zzob();
    Object localObject1;
    if (this.k)
    {
      zzbQ("Hit delivery not possible. Missing network permissions. See http://goo.gl/8Rd3yj for instructions");
      if (TextUtils.isEmpty(paramzzsz.zzpU())) {
        break label72;
      }
      localObject1 = paramzzsz;
    }
    for (;;)
    {
      i();
      if (!this.e.zzb((zzsz)localObject1)) {
        break label185;
      }
      zzbQ("Hit sent to the device AnalyticsService for delivery");
      return;
      zza("Delivering hit", paramzzsz);
      break;
      label72:
      Object localObject2 = zznW().zzqj().zzqm();
      localObject1 = paramzzsz;
      if (localObject2 != null)
      {
        localObject1 = (Long)((Pair)localObject2).second;
        localObject2 = (String)((Pair)localObject2).first;
        localObject1 = String.valueOf(localObject1);
        localObject1 = String.valueOf(localObject1).length() + 1 + String.valueOf(localObject2).length() + (String)localObject1 + ":" + (String)localObject2;
        localObject2 = new HashMap(paramzzsz.zzfE());
        ((Map)localObject2).put("_m", localObject1);
        localObject1 = zzsz.zza(this, paramzzsz, (Map)localObject2);
      }
    }
    try
    {
      label185:
      this.b.a((zzsz)localObject1);
      h();
      return;
    }
    catch (SQLiteException paramzzsz)
    {
      zze("Delivery failed to save hit to a database", paramzzsz);
      zznS().zza((zzsz)localObject1, "deliver: failed to insert hit to database");
    }
  }
  
  public final void a(String paramString)
  {
    zzac.zzdr(paramString);
    zzmR();
    zzrl localzzrl = zztm.zza(zznS(), paramString);
    if (localzzrl == null) {
      zzd("Parsing failed. Ignoring invalid campaign data", paramString);
    }
    for (;;)
    {
      return;
      String str = zznW().zzqi();
      if (paramString.equals(str))
      {
        zzbS("Ignoring duplicate install campaign");
        return;
      }
      if (!TextUtils.isEmpty(str))
      {
        zzd("Ignoring multiple install campaigns. original, new", str, paramString);
        return;
      }
      zznW().zzcb(paramString);
      if (zznW().zzqf().a(zznT().zzpy()))
      {
        zzd("Campaign received too late, ignoring", localzzrl);
        return;
      }
      zzb("Received installation campaign", localzzrl);
      paramString = this.b.i().iterator();
      while (paramString.hasNext()) {
        a((zzse)paramString.next(), localzzrl);
      }
    }
  }
  
  public final long b(zzse paramzzse)
  {
    zzac.zzw(paramzzse);
    zzob();
    zzmR();
    try
    {
      this.b.a();
      this.b.a(paramzzse.zzoj(), paramzzse.zzmy());
      long l = this.b.a(paramzzse.zzoj(), paramzzse.zzmy(), paramzzse.zzok());
      paramzzse.zzs(1L + l);
      this.b.a(paramzzse);
      this.b.b();
      try
      {
        this.b.c();
        return l;
      }
      catch (SQLiteException paramzzse)
      {
        zze("Failed to end transaction", paramzzse);
        return l;
      }
      try
      {
        this.b.c();
        throw paramzzse;
      }
      catch (SQLiteException localSQLiteException)
      {
        for (;;)
        {
          zze("Failed to end transaction", localSQLiteException);
        }
      }
    }
    catch (SQLiteException paramzzse)
    {
      paramzzse = paramzzse;
      zze("Failed to update Analytics property", paramzzse);
      try
      {
        this.b.c();
        return -1L;
      }
      catch (SQLiteException paramzzse)
      {
        for (;;)
        {
          zze("Failed to end transaction", paramzzse);
        }
      }
    }
    finally {}
  }
  
  protected final void b()
  {
    zzob();
    zzmR();
    Context localContext = zznQ().getContext();
    if (!zzth.zzak(localContext))
    {
      zzbS("AnalyticsReceiver is not registered or is disabled. Register the receiver for reliable dispatching on non-Google Play devices. See http://goo.gl/8Rd3yj for instructions.");
      if (CampaignTrackingReceiver.zzak(localContext)) {
        break label154;
      }
      zzbS("CampaignTrackingReceiver is not registered, not exported or is disabled. Installation campaign tracking is not possible. See http://goo.gl/8Rd3yj for instructions.");
      label44:
      zznW().zzqe();
      if (!b("android.permission.ACCESS_NETWORK_STATE"))
      {
        zzbT("Missing required android.permission.ACCESS_NETWORK_STATE. Google Analytics disabled. See http://goo.gl/8Rd3yj for instructions");
        o();
      }
      if (!b("android.permission.INTERNET"))
      {
        zzbT("Missing required android.permission.INTERNET. Google Analytics disabled. See http://goo.gl/8Rd3yj for instructions");
        o();
      }
      if (!zzti.zzal(getContext())) {
        break label171;
      }
      zzbP("AnalyticsService registered in the app manifest and enabled");
    }
    for (;;)
    {
      if ((!this.k) && (!this.b.f())) {
        i();
      }
      h();
      return;
      if (zzti.zzal(localContext)) {
        break;
      }
      zzbT("AnalyticsService is not registered or is disabled. Analytics service at risk of not starting. See http://goo.gl/8Rd3yj for instructions.");
      break;
      label154:
      if (CampaignTrackingService.zzal(localContext)) {
        break label44;
      }
      zzbS("CampaignTrackingService is not registered or is disabled. Installation campaign tracking is not possible. See http://goo.gl/8Rd3yj for instructions.");
      break label44;
      label171:
      zzbS("AnalyticsService not registered in the app manifest. Hits might not be delivered reliably. See http://goo.gl/8Rd3yj for instructions.");
    }
  }
  
  public final void c()
  {
    zzmR();
    this.j = zznR().currentTimeMillis();
  }
  
  public final void d()
  {
    zzmR();
    zzh.zzmR();
    zzob();
    if (!zznT().zzoX()) {
      zzbS("Service client disabled. Can't dispatch local hits to device AnalyticsService");
    }
    if (!this.e.isConnected()) {
      zzbP("Service not connected");
    }
    while (this.b.f()) {
      return;
    }
    zzbP("Dispatching local hits to device AnalyticsService");
    for (;;)
    {
      try
      {
        List localList = this.b.a(zznT().zzpg());
        if (!localList.isEmpty()) {
          break label126;
        }
        h();
        return;
      }
      catch (SQLiteException localSQLiteException1)
      {
        zze("Failed to read hits from store", localSQLiteException1);
        m();
        return;
      }
      label107:
      Object localObject;
      localSQLiteException1.remove(localObject);
      try
      {
        this.b.b(((zzsz)localObject).zzpP());
        label126:
        if (!localSQLiteException1.isEmpty())
        {
          localObject = (zzsz)localSQLiteException1.get(0);
          if (this.e.zzb((zzsz)localObject)) {
            break label107;
          }
          h();
          return;
        }
      }
      catch (SQLiteException localSQLiteException2)
      {
        zze("Failed to remove hit that was send for delivery", localSQLiteException2);
        m();
      }
    }
  }
  
  public final void e()
  {
    zzh.zzmR();
    zzob();
    zzbP("Service disconnected");
  }
  
  public final void f()
  {
    zzh.zzmR();
    zzob();
    zzbP("Delete all hits from local store");
    try
    {
      this.b.d();
      this.b.e();
      h();
      i();
      if (this.e.zzon()) {
        zzbP("Device service unavailable. Can't clear hits stored on the device service.");
      }
      return;
    }
    catch (SQLiteException localSQLiteException)
    {
      for (;;)
      {
        zzd("Failed to delete hits from store", localSQLiteException);
      }
    }
  }
  
  public final void g()
  {
    zzh.zzmR();
    zzob();
    zzbQ("Sync dispatching local hits");
    long l = this.j;
    i();
    try
    {
      j();
      zznW().zzqh();
      h();
      if (this.j != l) {
        this.d.c();
      }
      return;
    }
    catch (Throwable localThrowable)
    {
      zze("Sync local dispatch failed", localThrowable);
      h();
    }
  }
  
  public final void h()
  {
    long l3 = 0L;
    zznQ().zzmR();
    zzob();
    if ((!this.k) && (n() > 0L)) {}
    for (int m = 1; m == 0; m = 0)
    {
      this.d.b();
      m();
      return;
    }
    if (this.b.f())
    {
      this.d.b();
      m();
      return;
    }
    Object localObject;
    boolean bool;
    label242:
    long l1;
    if (!((Boolean)zzsw.zzafS.get()).booleanValue())
    {
      localObject = this.d;
      ((ik)localObject).a();
      if (!((ik)localObject).c)
      {
        Context localContext = ((ik)localObject).b.getContext();
        localContext.registerReceiver((BroadcastReceiver)localObject, new IntentFilter("android.net.conn.CONNECTIVITY_CHANGE"));
        IntentFilter localIntentFilter = new IntentFilter("com.google.analytics.RADIO_POWERED");
        localIntentFilter.addCategory(localContext.getPackageName());
        localContext.registerReceiver((BroadcastReceiver)localObject, localIntentFilter);
        ((ik)localObject).d = ((ik)localObject).d();
        ((ik)localObject).b.zznS().zza("Registering connectivity change receiver. Network connected", Boolean.valueOf(((ik)localObject).d));
        ((ik)localObject).c = true;
      }
      localObject = this.d;
      if (!((ik)localObject).c) {
        ((ik)localObject).b.zznS().zzbS("Connectivity unknown. Receiver not registered");
      }
      bool = ((ik)localObject).d;
      if (!bool) {
        break label527;
      }
      l();
      l2 = n();
      l1 = zznW().zzqg();
      if (l1 == 0L) {
        break label392;
      }
      l1 = l2 - Math.abs(zznR().currentTimeMillis() - l1);
      if (l1 <= 0L) {
        break label376;
      }
      label295:
      zza("Dispatch scheduled (ms)", Long.valueOf(l1));
      if (!this.g.b()) {
        break label518;
      }
      localObject = this.g;
      if (((ij)localObject).d != 0L) {
        break label408;
      }
    }
    label376:
    label392:
    label408:
    for (long l2 = 0L;; l2 = Math.abs(((ij)localObject).b.zznR().currentTimeMillis() - ((ij)localObject).d))
    {
      l1 = Math.max(1L, l1 + l2);
      localObject = this.g;
      if (!((ij)localObject).b()) {
        break;
      }
      if (l1 >= 0L) {
        break label435;
      }
      ((ij)localObject).c();
      return;
      bool = true;
      break label242;
      l1 = Math.min(zznT().zzpc(), l2);
      break label295;
      l1 = Math.min(zznT().zzpc(), l2);
      break label295;
    }
    label435:
    l1 -= Math.abs(((ij)localObject).b.zznR().currentTimeMillis() - ((ij)localObject).d);
    if (l1 < 0L) {
      l1 = l3;
    }
    for (;;)
    {
      ((ij)localObject).d().removeCallbacks(((ij)localObject).c);
      if (((ij)localObject).d().postDelayed(((ij)localObject).c, l1)) {
        break;
      }
      ((ij)localObject).b.zznS().zze("Failed to adjust delayed post. time", Long.valueOf(l1));
      return;
      label518:
      this.g.a(l1);
      return;
      label527:
      m();
      l();
      return;
    }
  }
  
  protected final void zzmS()
  {
    this.b.initialize();
    this.c.initialize();
    this.e.initialize();
  }
}


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