Always call stopMeasurementCollection before startMeasurementCollection

Bug: 253453668
Test: manual
Change-Id: I9f85c6be7a79540fd5fd8b851695c0de1742853d
Merged-In: I9f85c6be7a79540fd5fd8b851695c0de1742853d
(cherry picked from commit d30c1cea07)
This commit is contained in:
Yu-Han Yang
2022-10-17 23:37:09 +00:00
parent a1cd1e098c
commit d4ebf01621

View File

@@ -113,6 +113,16 @@ public final class GnssMeasurementsProvider extends
@Override
protected boolean registerWithService(GnssMeasurementRequest request,
Collection<GnssListenerRegistration> registrations) {
// The HAL doc does not specify if consecutive start() calls will be allowed.
// Some vendors may ignore the 2nd start() call if stop() is not called.
// Thus, here we always call stop() before calling start() to avoid being ignored.
if (mGnssNative.stopMeasurementCollection()) {
if (D) {
Log.d(TAG, "stopping gnss measurements");
}
} else {
Log.e(TAG, "error stopping gnss measurements");
}
if (mGnssNative.startMeasurementCollection(request.isFullTracking(),
request.isCorrelationVectorOutputsEnabled(),
request.getIntervalMillis())) {