0
0
Fork 0
mirror of https://github.com/YTVanced/VancedMicroG synced 2024-11-24 04:05:13 +00:00

Location: do not try to access network location provider if not present on system

Related to #269
This commit is contained in:
Marvin W 2017-01-18 17:35:01 +01:00
parent dde462c73a
commit 6766fa4d95
No known key found for this signature in database
GPG key ID: 072E9235DB996F2A
3 changed files with 13 additions and 15 deletions

2
extern/GmsApi vendored

@ -1 +1 @@
Subproject commit bfae24a17c11d9633fdce4f9b82dff0da4769f8d
Subproject commit 3dabc13028b56c792573743107b2a56f2fdd3148

View file

@ -1,5 +1,5 @@
/*
* Copyright 2013-2015 microG Project Team
* Copyright 2013-2017 microG Project Team
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -22,11 +22,7 @@ import android.content.Context;
import android.location.Location;
import android.location.LocationManager;
import android.os.RemoteException;
import android.support.v4.content.ContextCompat;
import android.util.Log;
import android.widget.Toast;
import com.google.android.gms.R;
import com.google.android.gms.location.ILocationListener;
import com.google.android.gms.location.LocationRequest;
import com.google.android.gms.location.internal.FusedLocationProviderResult;
@ -65,7 +61,12 @@ public class GoogleLocationManager implements LocationChangeListener {
this.gpsProvider = null;
}
if (Utils.hasSelfPermissionOrNotify(context, Manifest.permission.ACCESS_COARSE_LOCATION)) {
this.networkProvider = new RealLocationProvider(locationManager, NETWORK_PROVIDER, this);
if (locationManager.getAllProviders().contains(NETWORK_PROVIDER)) {
this.networkProvider = new RealLocationProvider(locationManager, NETWORK_PROVIDER, this);
} else {
// TODO: Add ability to directly contact UnifiedNlp without the system location provider
this.networkProvider = null;
}
} else {
this.networkProvider = null;
}
@ -119,14 +120,12 @@ public class GoogleLocationManager implements LocationChangeListener {
networkProvider.addRequest(request);
}
public void requestLocationUpdates(LocationRequest request, ILocationListener listener,
String packageName) {
public void requestLocationUpdates(LocationRequest request, ILocationListener listener, String packageName) {
requestLocationUpdates(new LocationRequestHelper(context, request, hasFineLocationPermission(),
hasCoarseLocationPermission(), packageName, listener));
}
public void requestLocationUpdates(LocationRequest request, PendingIntent intent,
String packageName) {
public void requestLocationUpdates(LocationRequest request, PendingIntent intent, String packageName) {
requestLocationUpdates(new LocationRequestHelper(context, request, hasFineLocationPermission(),
hasCoarseLocationPermission(), packageName, intent));
}

View file

@ -1,5 +1,5 @@
/*
* Copyright 2013-2015 microG Project Team
* Copyright 2013-2017 microG Project Team
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -63,8 +63,7 @@ public class RealLocationProvider {
}
};
public RealLocationProvider(LocationManager locationManager, String name,
LocationChangeListener changeListener) {
public RealLocationProvider(LocationManager locationManager, String name, LocationChangeListener changeListener) {
this.locationManager = locationManager;
this.name = name;
this.changeListener = changeListener;
@ -110,6 +109,7 @@ public class RealLocationProvider {
minTime = Math.min(request.locationRequest.getInterval(), minTime);
minDistance = Math.min(request.locationRequest.getSmallestDesplacement(), minDistance);
}
Log.d(TAG, name + ": requesting location updates. minTime=" + minTime + " minDistance=" + minDistance);
if (connected.get()) {
if (connectedMinTime != minTime || connectedMinDistance != minDistance) {
locationManager.removeUpdates(listener);
@ -119,7 +119,6 @@ public class RealLocationProvider {
} else {
locationManager.requestLocationUpdates(name, minTime, minDistance, listener, Looper.getMainLooper());
}
Log.d(TAG, name + ": requesting location updates. minTime=" + minTime + " minDistance=" + minDistance);
connected.set(true);
connectedMinTime = minTime;
connectedMinDistance = minDistance;