-
-
Notifications
You must be signed in to change notification settings - Fork 680
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
[geolocator_android] Introduce option to force a specific location provider Issue/1171 #1613
base: main
Are you sure you want to change the base?
Conversation
@mvanbeusekom not really sure how to get rid of the analyzer errors the proper way. Please advise, thanks. |
Thanks for the contribution. I cannot see the build log anymore... Is it possible to rebase onto main and then we can have a look at the build logs. Maybe the analyser warnings are resolved recently. Kind regards, |
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.
Nice work! I added some comments. Can we also add the feature to the android package example app so that we can easily test the feature?
|
||
private LocationOptions( | ||
LocationAccuracy accuracy, long distanceFilter, long timeInterval, boolean useMSLAltitude) { | ||
LocationAccuracy accuracy, long distanceFilter, long timeInterval, boolean useMSLAltitude, String 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.
can we keep the same name for the provider -> forceProvider
?
distanceFilter != null ? distanceFilter : 0, | ||
timeInterval != null ? timeInterval : 5000, | ||
useMSLAltitude != null && useMSLAltitude, | ||
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.
Same here. Perhaps forceProvider would be easier to understand for other developers.
/// Set this to use a specific [AndroidLocationProvider]. | ||
/// Set this value only in conjunction with [forceLocationManager] set to true. Be sure the provider is available on your targeted devices. | ||
/// Defaults to null. | ||
final AndroidLocationProvider? forceProvider; |
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.
If this only works in combination with the forceLocationManager, should desired provider perhaps be a more convenient name?
@@ -34,7 +34,7 @@ public String toDescription() { | |||
case errorWhileAcquiringPosition: | |||
return "An unexpected error occurred while trying to acquire the device's position."; | |||
case locationServicesDisabled: |
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.
I see this as a very helpful addition. However, I also see a lot of questions appearing when we "force" a provider, but if the provider is not available on the device we give an bit of misleading error back that the location services are disabled (or location provider is unavailable), although we actually mean that the "forcedProvider" is not available (we currently don't know if locationServicesDisabled or the forcedProvider is not available)... Can't we do this smarter by returning a more useful error? Then, we give the developer the option to decide how to "proceed". With the best "default" provider (or perhaps an other "forced" provider), or not al all...
Added an option
AndroidSettings.forceProvider
that forces the plugin to use a specific provider out of the currently four available Android location providers. As discussed with @mvanbeusekom, this option is to be used in conjunction withforceLocationManager = true
.Example use case: An app needs to ensure locations are derived exclusively from GNSS and hence has to make sure no other sources like mobile networks are used.
#1171
Pre-launch Checklist
pubspec.yaml
with an appropriate new version according to the pub versioning philosophy, or this PR is does not need version changes.CHANGELOG.md
to add a description of the change.///
).main
.dart format .
and committed any changes.flutter analyze
and fixed any errors.