fo.java 3.69 KB
import android.content.Context;
import android.location.Location;
import android.location.LocationManager;
import android.support.annotation.NonNull;
import android.support.annotation.VisibleForTesting;
import android.support.v4.content.PermissionChecker;
import android.util.Log;
import java.util.Calendar;

final class fo
{
  static fo a;
  private final Context b;
  private final LocationManager c;
  private final fo.a d = new fo.a();
  
  @VisibleForTesting
  fo(@NonNull Context paramContext, @NonNull LocationManager paramLocationManager)
  {
    this.b = paramContext;
    this.c = paramLocationManager;
  }
  
  private Location a(String paramString)
  {
    if (this.c != null) {
      try
      {
        if (this.c.isProviderEnabled(paramString))
        {
          paramString = this.c.getLastKnownLocation(paramString);
          return paramString;
        }
      }
      catch (Exception paramString) {}
    }
    return null;
  }
  
  final boolean a()
  {
    fo.a locala = this.d;
    if ((this.d != null) && (this.d.f > System.currentTimeMillis())) {}
    for (int i = 1; i != 0; i = 0) {
      return locala.a;
    }
    Object localObject1 = null;
    Object localObject2 = null;
    if (PermissionChecker.checkSelfPermission(this.b, "android.permission.ACCESS_COARSE_LOCATION") == 0) {
      localObject1 = a("network");
    }
    if (PermissionChecker.checkSelfPermission(this.b, "android.permission.ACCESS_FINE_LOCATION") == 0) {
      localObject2 = a("gps");
    }
    long l1;
    fn localfn;
    long l2;
    if ((localObject2 != null) && (localObject1 != null)) {
      if (((Location)localObject2).getTime() > ((Location)localObject1).getTime())
      {
        localObject1 = localObject2;
        if (localObject1 == null) {
          break label389;
        }
        localObject2 = this.d;
        l1 = System.currentTimeMillis();
        if (fn.a == null) {
          fn.a = new fn();
        }
        localfn = fn.a;
        localfn.a(l1 - 86400000L, ((Location)localObject1).getLatitude(), ((Location)localObject1).getLongitude());
        l2 = localfn.b;
        localfn.a(l1, ((Location)localObject1).getLatitude(), ((Location)localObject1).getLongitude());
        if (localfn.d != 1) {
          break label339;
        }
      }
    }
    long l3;
    long l4;
    long l5;
    label339:
    for (boolean bool = true;; bool = false)
    {
      l3 = localfn.c;
      l4 = localfn.b;
      localfn.a(86400000L + l1, ((Location)localObject1).getLatitude(), ((Location)localObject1).getLongitude());
      l5 = localfn.c;
      if ((l3 != -1L) && (l4 != -1L)) {
        break label345;
      }
      l1 = 43200000L + l1;
      ((fo.a)localObject2).a = bool;
      ((fo.a)localObject2).b = l2;
      ((fo.a)localObject2).c = l3;
      ((fo.a)localObject2).d = l4;
      ((fo.a)localObject2).e = l5;
      ((fo.a)localObject2).f = l1;
      return locala.a;
      break;
      if (localObject2 != null)
      {
        localObject1 = localObject2;
        break;
      }
      break;
    }
    label345:
    if (l1 > l4) {
      l1 = 0L + l5;
    }
    for (;;)
    {
      l1 += 60000L;
      break;
      if (l1 > l3) {
        l1 = 0L + l4;
      } else {
        l1 = 0L + l3;
      }
    }
    label389:
    Log.i("TwilightManager", "Could not get last known location. This is probably because the app does not have any location permissions. Falling back to hardcoded sunrise/sunset values.");
    i = Calendar.getInstance().get(11);
    return (i < 6) || (i >= 22);
  }
  
  static final class a
  {
    boolean a;
    long b;
    long c;
    long d;
    long e;
    long f;
  }
}


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