interval change should restart thread reporting locations
Also updates the mockLocation's bearing and speed to be non-zero, since
a real location rarely has exactly 0 bearing or 0 speed.
Bug: 384699906
Test: atest android.location.cts.gnss.GnssLocationUpdateIntervalTest#testLocationUpdatesAtVariousIntervals
Change-Id: I67d513eea50d1399b52aef3e07a73ff31db24ace
diff --git a/gnss/aidl/default/Gnss.cpp b/gnss/aidl/default/Gnss.cpp
index 41720c0..1fd21d8 100644
--- a/gnss/aidl/default/Gnss.cpp
+++ b/gnss/aidl/default/Gnss.cpp
@@ -298,8 +298,14 @@
ScopedAStatus Gnss::setPositionMode(const PositionModeOptions& options) {
ALOGD("setPositionMode. minIntervalMs:%d, lowPowerMode:%d", options.minIntervalMs,
(int)options.lowPowerMode);
- mMinIntervalMs = std::max(1000, options.minIntervalMs);
- mGnssMeasurementInterface->setLocationInterval(mMinIntervalMs);
+ if (std::max(1000, options.minIntervalMs) != mMinIntervalMs) {
+ mMinIntervalMs = std::max(1000, options.minIntervalMs);
+ mGnssMeasurementInterface->setLocationInterval(mMinIntervalMs);
+ if (mIsActive) {
+ stop();
+ start();
+ }
+ }
return ScopedAStatus::ok();
}