From d30c1cea07e7de45a3cb4b0a204a08242163d974 Mon Sep 17 00:00:00 2001 From: Yu-Han Yang Date: Mon, 17 Oct 2022 23:37:09 +0000 Subject: [PATCH] Always call stopMeasurementCollection before startMeasurementCollection Bug: 253453668 Test: manual Change-Id: I9f85c6be7a79540fd5fd8b851695c0de1742853d --- .../server/location/gnss/GnssMeasurementsProvider.java | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/services/core/java/com/android/server/location/gnss/GnssMeasurementsProvider.java b/services/core/java/com/android/server/location/gnss/GnssMeasurementsProvider.java index 07e9fe6ad5419..6c4c829b051d9 100644 --- a/services/core/java/com/android/server/location/gnss/GnssMeasurementsProvider.java +++ b/services/core/java/com/android/server/location/gnss/GnssMeasurementsProvider.java @@ -115,6 +115,16 @@ public final class GnssMeasurementsProvider extends if (request.getIntervalMillis() == GnssMeasurementRequest.PASSIVE_INTERVAL) { return true; } + // 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())) {