翰林优商.apk(点击下载) / o.java


package com.iBookStar.utils;

import android.location.Location;
import android.location.LocationListener;
import android.location.LocationManager;
import android.os.Bundle;
import com.sigmob.sdk.base.mta.PointCategory;

public class o {
    private static Location a = null;
    private static LocationListener b = null;
    private static LocationListener c = null;
    private static boolean d = false;
    private static long e;

    /* access modifiers changed from: package-private */
    public class a implements LocationListener {
        final /* synthetic */ LocationManager a;

        a(LocationManager locationManager) {
            this.a = locationManager;
        }

        public void onLocationChanged(Location location) {
            if (o.b(location, o.a)) {
                Location unused = o.a = location;
            }
            o.b(this.a);
        }

        public void onProviderDisabled(String str) {
            if (PointCategory.NETWORK.equalsIgnoreCase(str)) {
                o.b(this.a);
            }
        }

        public void onProviderEnabled(String str) {
        }

        public void onStatusChanged(String str, int i, Bundle bundle) {
            if (i == 0 || i == 1) {
                o.b(this.a);
            }
        }
    }

    /* access modifiers changed from: package-private */
    public class b implements LocationListener {
        final /* synthetic */ LocationManager a;

        b(LocationManager locationManager) {
            this.a = locationManager;
        }

        public void onLocationChanged(Location location) {
            if (o.b(location, o.a)) {
                Location unused = o.a = location;
            }
        }

        public void onProviderDisabled(String str) {
            if ("gps".equalsIgnoreCase(str)) {
                o.b(this.a);
            }
        }

        public void onProviderEnabled(String str) {
        }

        public void onStatusChanged(String str, int i, Bundle bundle) {
            if (i == 0 || i == 1) {
                o.b(this.a);
            }
        }
    }

    private static boolean a(String str, String str2) {
        return str == null ? str2 == null : str.equals(str2);
    }

    /* JADX WARNING: Removed duplicated region for block: B:21:0x005d  */
    public static Location b() {
        Location lastKnownLocation;
        LocationListener bVar;
        String str;
        if (d) {
            return a;
        }
        long currentTimeMillis = System.currentTimeMillis();
        if (currentTimeMillis - e < 1200000) {
            return a;
        }
        e = currentTimeMillis;
        try {
            LocationManager locationManager = (LocationManager) com.iBookStar.b.a.k().getSystemService("location");
            if (locationManager.isProviderEnabled(PointCategory.NETWORK)) {
                bVar = new a(locationManager);
                c = bVar;
                str = PointCategory.NETWORK;
            } else {
                if (locationManager.isProviderEnabled("gps")) {
                    bVar = new b(locationManager);
                    b = bVar;
                    str = "gps";
                }
                lastKnownLocation = locationManager.getLastKnownLocation(PointCategory.NETWORK);
                a = lastKnownLocation;
                if (lastKnownLocation == null) {
                    a = locationManager.getLastKnownLocation("gps");
                }
                return a;
            }
            locationManager.requestLocationUpdates(str, 0, 0.0f, bVar);
            d = true;
            lastKnownLocation = locationManager.getLastKnownLocation(PointCategory.NETWORK);
            a = lastKnownLocation;
            if (lastKnownLocation == null) {
            }
        } catch (Exception unused) {
        }
        return a;
    }

    /* access modifiers changed from: private */
    public static void b(LocationManager locationManager) {
        d = false;
        LocationListener locationListener = b;
        if (locationListener != null) {
            locationManager.removeUpdates(locationListener);
            b = null;
        }
        LocationListener locationListener2 = c;
        if (locationListener2 != null) {
            locationManager.removeUpdates(locationListener2);
            c = null;
        }
    }

    /* access modifiers changed from: private */
    public static boolean b(Location location, Location location2) {
        if (location2 == null) {
            return true;
        }
        long time = location.getTime() - location2.getTime();
        boolean z = time > 120000;
        boolean z2 = time < -120000;
        boolean z3 = time > 0;
        if (z) {
            return true;
        }
        if (z2) {
            return false;
        }
        int accuracy = (int) (location.getAccuracy() - location2.getAccuracy());
        boolean z4 = accuracy > 0;
        boolean z5 = accuracy < 0;
        boolean z6 = accuracy > 200;
        boolean a2 = a(location.getProvider(), location2.getProvider());
        if (z5) {
            return true;
        }
        if (!z3 || z4) {
            return z3 && !z6 && a2;
        }
        return true;
    }
}