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


package com.kwad.sdk.utils;

import android.content.Context;
import android.location.Location;
import android.location.LocationManager;
import androidx.core.content.ContextCompat;
import com.kuaishou.weapon.p0.h;
import com.kwad.sdk.core.e.b;
import com.kwad.sdk.service.ServiceProvider;
import com.kwad.sdk.service.kwai.f;
import com.sigmob.sdk.base.mta.PointCategory;

public final class q {
    private static boolean bBn;
    private static Location bBo;

    private static Location a(Context context, LocationManager locationManager) {
        try {
            if (ContextCompat.checkSelfPermission(context, h.g) != 0) {
                return null;
            }
            Location lastKnownLocation = locationManager.getLastKnownLocation("gps");
            if (lastKnownLocation == null) {
                bBn = true;
            }
            return lastKnownLocation;
        } catch (Exception e) {
            bBn = true;
            b.printStackTraceOnly(e);
            return null;
        }
    }

    private static Location b(Context context, LocationManager locationManager) {
        try {
            if (ContextCompat.checkSelfPermission(context, h.g) != 0 && ContextCompat.checkSelfPermission(context, h.h) != 0) {
                return null;
            }
            Location lastKnownLocation = locationManager.getLastKnownLocation(PointCategory.NETWORK);
            if (lastKnownLocation == null) {
                bBn = true;
            }
            return lastKnownLocation;
        } catch (Exception e) {
            bBn = true;
            b.printStackTraceOnly(e);
            return null;
        }
    }

    private static Location c(Context context, LocationManager locationManager) {
        try {
            if (ContextCompat.checkSelfPermission(context, h.h) != 0) {
                return null;
            }
            Location lastKnownLocation = locationManager.getLastKnownLocation("passive");
            if (lastKnownLocation == null) {
                bBn = true;
            }
            return lastKnownLocation;
        } catch (Exception e) {
            bBn = true;
            b.printStackTraceOnly(e);
            return null;
        }
    }

    public static Location cs(Context context) {
        if (at.YR() && at.YS() != null) {
            return at.YS();
        }
        if (bBn || bBo != null || context == null) {
            return bBo;
        }
        if (!at.YR() && !((f) ServiceProvider.get(f.class)).R(64)) {
            try {
                LocationManager locationManager = (LocationManager) context.getSystemService("location");
                if (locationManager.isProviderEnabled("gps")) {
                    bBo = a(context, locationManager);
                }
                if (bBo == null && locationManager.isProviderEnabled(PointCategory.NETWORK)) {
                    bBo = b(context, locationManager);
                }
                if (bBo == null && locationManager.isProviderEnabled("passive")) {
                    bBo = c(context, locationManager);
                }
                return bBo;
            } catch (Exception e) {
                bBn = true;
                b.printStackTraceOnly(e);
            }
        }
        return null;
    }
}