fix: Apply bitmask to determine if ADR is valid #29
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.
GnssLogger currently uses a test of equality to
1
(GnssMeasurement.ADR_STATE_VALID
) forGnssMeasurement.getAccumulatedDeltaRangeState()
to determine if the ADR is valid for a particular measurement.This no longer works with newer devices >= API 28, as the ADR is now a bitmask of the various constants listed at:
https://developer.android.com/reference/android/location/GnssMeasurement#constants_1
For example, the ADR state can be both
ADR_STATE_HALF_CYCLE_RESOLVED
logical OR'd withADR_STATE_VALID
, with gives you1001
in binary or9
in decimal. So this is a valid ADR state, but is not equal to1
.You can see these valid ADR state values that aren't equal to
1
in the data from the Google "Smartphone Decimeter Challenge" here:https://www.kaggle.com/google/android-smartphones-high-accuracy-datasets
This PR changes the GnssLogger code to correctly apply the bitmask to the
GnssMeasurement.getAccumulatedDeltaRangeState()
value to determine if it is a valid ADR state.It also substitutes a check for an unknown ADR state by using the constant
GnssMeasurement.ADR_STATE_UNKNOWN
instead of just0
. Note that Lint incorrectly flags the use of this constant currently as an error - I've opened an issue on the Google issue tracker here about this:https://issuetracker.google.com/issues/174553586