New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[TIMOB-23135] Android: Modified "locationServicesEnabled" handling #9633
Conversation
Generated by 🚫 dangerJS |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
see above
@@ -106,7 +106,12 @@ public boolean getLocationServicesEnabled() | |||
} | |||
} | |||
|
|||
return providerNames.size() != 0 && getLastKnownLocation() != null; | |||
for (String providerName : providerNames) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We want to return true if any location provider is enabled, GPS
, NETWORK
etc..
return providerNames.size() > 0;
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Gary is right. We need to check all providers. His code change is the correct solution.
Also, we should check if the providerNames
collection is null after calling the LocationManager.getProviders()
method. If null, return false. (Odds are this isn't going to happen, but better safe than sorry. Especially on Android.)
@@ -106,7 +106,12 @@ public boolean getLocationServicesEnabled() | |||
} | |||
} | |||
|
|||
return providerNames.size() != 0 && getLastKnownLocation() != null; | |||
for (String providerName : providerNames) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Gary is right. We need to check all providers. His code change is the correct solution.
Also, we should check if the providerNames
collection is null after calling the LocationManager.getProviders()
method. If null, return false. (Odds are this isn't going to happen, but better safe than sorry. Especially on Android.)
for (String providerName : providerNames) { | ||
if (providerName.equals(LocationManager.GPS_PROVIDER)) { | ||
if (providerName.equals(LocationManager.GPS_PROVIDER) || providerName.equals(LocationManager.NETWORK_PROVIDER)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Question:
Is there a reason why we're limiting this to GPS and NETWORK? Does disabling location services on a phone not disable the PASSIVE provider?
I ask because our "GeolocationModule" reads from the PASSIVE location provider.
https://github.com/appcelerator/titanium_mobile/blob/master/android/modules/geolocation/src/java/ti/modules/titanium/geolocation/GeolocationModule.java#L200
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay, so @maggieaxway and I just talked about this. The PASSIVE provider will still provide data, even if location services is disabled. In fact, that was a customer complaint here...
https://jira.appcelerator.org/browse/TIMOB-23135
So, the real question here is should we provide PASSIVE location data at all? The GPS and NETWORK providers are the ones we really want. I'm starting to think reverting the code like Maggie just did now and removing PASSIVE provider support might be the way to go.
@garymathews, you've been playing around with this recently, what are your thoughts? How is this compared to Google Play Service's fused location provider?
return providerNames.size() != 0 && getLastKnownLocation() != null; | ||
//TIMOB-23135 Android: Ti.Geolocation.locationServicesEnabled returns false, but works | ||
for (String providerName : providerNames) { | ||
if (providerName.equals(LocationManager.GPS_PROVIDER) || providerName.equals(LocationManager.NETWORK_PROVIDER)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jquick-axway sounds good, could do:
return providerNames.contains(LocationManager.GPS_PROVIDER) || providerNames.contains(LocationManager.NETWORK_PROVIDER);
So my changes approved? @garymathews @jquick-axway |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
CR: Pass
Updated PR to pass Java code formatting rules. |
JIRA: https://jira.appcelerator.org/browse/TIMOB-23135
Summary:
true
for "passive" and "test" location providers when it shouldn't have.false
when if at least 1 location value hasn't been received yet, even if location services is enabled.Test:
Need manually test turning on/off the location service with the app running.