mirror of
https://github.com/TeamVanced/VancedMicroG
synced 2024-12-23 02:57:47 +01:00
Fix NLP when no network location is present
This commit is contained in:
parent
88c3cb0c19
commit
86121f1208
@ -33,6 +33,7 @@ import static android.location.LocationManager.NETWORK_PROVIDER;
|
|||||||
|
|
||||||
public class GoogleLocationManager implements LocationChangeListener {
|
public class GoogleLocationManager implements LocationChangeListener {
|
||||||
private static final String MOCK_PROVIDER = "mock";
|
private static final String MOCK_PROVIDER = "mock";
|
||||||
|
private static final long SWITCH_ON_FRESHNESS_CLIFF_MS = 30000; // 30 seconds
|
||||||
|
|
||||||
private Context context;
|
private Context context;
|
||||||
private LocationManager locationManager;
|
private LocationManager locationManager;
|
||||||
@ -63,12 +64,12 @@ public class GoogleLocationManager implements LocationChangeListener {
|
|||||||
return gps;
|
return gps;
|
||||||
if (gps == null)
|
if (gps == null)
|
||||||
return network;
|
return network;
|
||||||
if (gps.getTime() > network.getTime() - 10000)
|
if (gps.getTime() > network.getTime() - SWITCH_ON_FRESHNESS_CLIFF_MS)
|
||||||
return gps;
|
return gps;
|
||||||
return network;
|
return network;
|
||||||
} else if (networkPermission) {
|
} else if (networkPermission) {
|
||||||
Location network = networkProvider.getLastLocation();
|
Location network = networkProvider.getLastLocation();
|
||||||
if (network.getExtras() != null &&
|
if (network != null && network.getExtras() != null &&
|
||||||
network.getExtras().getParcelable("no_gps_location") instanceof Location) {
|
network.getExtras().getParcelable("no_gps_location") instanceof Location) {
|
||||||
network = network.getExtras().getParcelable("no_gps_location");
|
network = network.getExtras().getParcelable("no_gps_location");
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user