package com.appsflyer.internal;

import android.content.Context;
import android.location.Location;
import android.location.LocationManager;
import com.appsflyer.AFExecutor;
import com.facebook.places.model.PlaceFields;

public final class r {

    public static final class d {

        /* renamed from: ॱ  reason: contains not printable characters */
        public static final r f2117 = new r();
    }

    /* renamed from: ˏ  reason: contains not printable characters */
    public static boolean m1238(Context context, String[] strArr) {
        for (String str : strArr) {
            if (AFExecutor.AnonymousClass4.AnonymousClass3.m1073(context, str)) {
                return true;
            }
        }
        return false;
    }

    /* JADX WARNING: Code restructure failed: missing block: B:17:0x003e, code lost:
        if (r8 != null) goto L_0x0051;
     */
    /* JADX WARNING: Code restructure failed: missing block: B:20:0x004e, code lost:
        if (com.facebook.places.internal.LocationPackageRequestParams.DEFAULT_LAST_LOCATION_MAX_AGE_MS >= (r3.getTime() - r8.getTime())) goto L_0x0051;
     */
    /* renamed from: ॱ  reason: contains not printable characters */
    public static Location m1239(Context context) {
        try {
            LocationManager locationManager = (LocationManager) context.getSystemService(PlaceFields.LOCATION);
            Location lastKnownLocation = m1238(context, new String[]{"android.permission.ACCESS_FINE_LOCATION", "android.permission.ACCESS_COARSE_LOCATION"}) ? locationManager.getLastKnownLocation("network") : null;
            Location lastKnownLocation2 = m1238(context, new String[]{"android.permission.ACCESS_FINE_LOCATION"}) ? locationManager.getLastKnownLocation("gps") : null;
            if (lastKnownLocation2 == null && lastKnownLocation == null) {
                lastKnownLocation2 = null;
            } else {
                if (lastKnownLocation2 != null || lastKnownLocation == null) {
                    if (lastKnownLocation == null) {
                    }
                }
                lastKnownLocation2 = lastKnownLocation;
            }
            if (lastKnownLocation2 != null) {
                return lastKnownLocation2;
            }
            return null;
        } catch (Throwable unused) {
            return null;
        }
    }
}
