react-native-background-geolocation
react-native-background-geolocation copied to clipboard
Android: altitude_accuracy
Your Environment
- Plugin version: 3.10.0
- Platform: Android
- OS version: 10
- Device manufacturer / model: Brand:samsung Model:Galaxy M21
- React Native version (
react-native -v
): error: unknown option `-v' - React Native version (
react-native --version
): 6.3.1 - Plugin config
{
reset: true,
disableElasticity: true,
desiredAccuracy: BackgroundGeolocation.DESIRED_ACCURACY_HIGH,
locationAuthorizationRequest: 'Always',
disableLocationAuthorizationAlert: false,
stopDetectionDelay: 0,
stopTimeout: 0,
stopOnStationary: false,
disableStopDetection: true,
pausesLocationUpdatesAutomatically: false,
heartbeatInterval: 60,
activityType: 4,
disableMotionActivityUpdates: false,
stopOnTerminate: true,
startOnBoot: false,
preventSuspend: true,
foregroundService: false,
enableHeadless: false,
debug: false,
logLevel: Config.environment === 'dev'
? BackgroundGeolocation.LOG_LEVEL_VERBOSE
: BackgroundGeolocation.LOG_LEVEL_INFO,
logMaxDays: 1,
persistMode: BackgroundGeolocation.PERSIST_MODE_NONE,
autoSync: false
};
Expected Behavior
The plugin works as on iOS: even if some location has altitude_accuracy >= 100, the majority are < 100.
Actual Behavior
Almost all location recorded on Android devices come with an altitude_accuracy < 100. But on some devices, though, the altitude_accuracy is almost all the time >= 100.
Here are some details of recorded locations grouped in activities of some hours:
Session ndgUy5vT6ezdKeCVIf7e has 292 locations recorded, 84.25% with altitude_accuracy >= 100
Session g9wzBGxmisIluhvXKeOP has 798 locations recorded, 83.08% with altitude_accuracy >= 100
Session cNYGDEJnF12MknQ2azoH has 1118 locations recorded, 67.8% with altitude_accuracy >= 100
Session F3ynfQKcrycvjed9uaWC has 1813 locations recorded, 98.9% with altitude_accuracy >= 100
Session LzgCijfWlP93wCvdPraJ has 1557 locations recorded, 99.94% with altitude_accuracy >= 100
Session arbDVv1Y7WvW9hZDRFZo has 1527 locations recorded, 99.67% with altitude_accuracy >= 100
Session TZ4foxR0p9mp0LmhZhqa has 2265 locations recorded, 80.97% with altitude_accuracy >= 100
Session WDjiIv0eOJITjAm2SWnw has 2433 locations recorded, 99.96% with altitude_accuracy >= 100
Session iLUfLZ6d2xwmMgauBAZ1 has 2616 locations recorded, 99.96% with altitude_accuracy >= 100
The percentage is alarming.
Consider that only these devices are giving this problem. More than 200 android's sessions have no locations with altitude_accuracy >= 100. On iOS the percentage is never above 5%.
Steps to Reproduce
- Start the geolocation services on a device as Samsung Galaxy M21 with Android 10
- Record onLocation events payload
- Check the altitude_accuracy field
Debug logs
Sadly it's impossible to attach debug logs since it's happening on production.
The plugin is only the messenger. It is not responsible for the accuracy. It receives location from the native Location API. That information is merely passed-on to you, in this case Location.getVerticalAccuracyMeters()
From the documentation linked:
This is only valid if hasVerticalAccuracy() is true.
So, how the plugin/messenger manage the hasVerticalAccuracy=false case?
altitudeAccuracy = -1; // <-- default is -1 when the Location is incapable of providing vertical accuracy
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
if (location.hasVerticalAccuracy() && !Double.isNaN(location.getVerticalAccuracyMeters())) {
altitudeAccuracy = location.getVerticalAccuracyMeters();
}
}
I see that on Android the location vertical accuracy heavly depends on how the location has been recorded: from GPS, wifi or Cellular positioning. There's any chance to got this info from the plugin/messenger?
how the location has been recorded: from GPS, wifi or Cellular positioning
No. The plugin uses the Fused Location Provider API from Google Play Services. It "fuses" information from all three providers together to provide the best possible location at any given time. There is no information about which provider it came from.
Generally, if the location accuracy is <= 10, it came from GPS.
Wifi and Cellular providers do not provide altudue
(or speed
). Only GPS provides that.
If the device is indoors (where GPS is impossible), there is no altitude
available.
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. You may also mark this issue as a "discussion" and I will leave this open.
Closing this issue after a prolonged period of inactivity. Fell free to reopen this issue, if this still affecting you.