Repository navigation
fix(android): report compass heading in location updates - #4350
Merged
Merged
Conversation
Android filled both heading and course from the GPS bearing, so stationary fixes had no heading and moving ones reported the course as heading. Send course from the location bearing and heading from the Mapbox location plugin's compass (DefaultLocationProvider with PuckBearing.HEADING), only while location updates are subscribed. Fixes #4063
This branch was successfully deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Fixes #4063
On Android
headingandcoursewere both filled from the GPS bearing, so a stationary device reported noheadingand a moving one reported its course asheading. Android now sendscoursefrom the location bearing andheadingfrom the Mapbox location plugin's compass (DefaultLocationProviderwithPuckBearing.HEADING, the same source the puck uses). This matches iOS, whereheadingcomes from theHeadingProvider.The compass runs only while the location module is started (it is stopped on
stop()and when the app is paused). Like iOS, a heading change also emits an update with the last location. Mapbox throttles the compass to 2 Hz, and changes under 1° are skipped, matchingCLLocationManager's defaultheadingFilter.DefaultLocationProvideralso opens its own location request through Mapbox'sLocationService. That request uses the same high-accuracy, 1 s settings as ours, so the OS merges the two and the GPS hardware does no extra work.Behaviour change: on Android,
headingnow means the compass heading (0–360). Code that relied on it being the direction of travel should usecourse. Like the Mapbox puck, the value is relative to magnetic north (no declination correction).Checklist
CONTRIBUTING.mdyarn generatein the root folder/exampleapp./example)Screenshot OR Video
Evidence from an Android emulator: locations were set with
adb emu geo fix, and the compass was turned by rotating the virtual magnetic field (adb emu sensor set magnetic-field).Before, stationary: no
headingat all.Before, moving NE:
headingequalscourse(both GPS bearing).After, stationary, compass turned 0 → 90 → 200 → 300:
After, moving NE with the device pointing west:
After the screen unmounts, the
LocationCompassEnginesensor registration is removed (dumpsys sensorservice).Component to reproduce the issue you're fixing