summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--android/location_api/GnssAPIClient.cpp1
-rw-r--r--gnss/GnssAdapter.cpp44
-rw-r--r--gnss/GnssAdapter.h2
-rw-r--r--location/LocationAPI.cpp4
4 files changed, 46 insertions, 5 deletions
diff --git a/android/location_api/GnssAPIClient.cpp b/android/location_api/GnssAPIClient.cpp
index e0e90c0..c940597 100644
--- a/android/location_api/GnssAPIClient.cpp
+++ b/android/location_api/GnssAPIClient.cpp
@@ -194,6 +194,7 @@ bool GnssAPIClient::gnssSetPositionMode(IGnss::GnssPositionMode mode,
mLocationOptions.mode = GNSS_SUPL_MODE_MSB;
else if (mode == IGnss::GnssPositionMode::MS_ASSISTED)
mLocationOptions.mode = GNSS_SUPL_MODE_MSA;
+ locAPIUpdateTrackingOptions(mLocationOptions);
return retVal;
}
diff --git a/gnss/GnssAdapter.cpp b/gnss/GnssAdapter.cpp
index 2117c73..3ab9254 100644
--- a/gnss/GnssAdapter.cpp
+++ b/gnss/GnssAdapter.cpp
@@ -1294,7 +1294,6 @@ LocationError
GnssAdapter::startTrackingMultiplex(const LocationOptions& options)
{
LocationError err = LOCATION_ERROR_SUCCESS;
- bool updateTrackingSession = false;
if (mTrackingSessions.empty()) {
err = startTracking(options);
@@ -1420,7 +1419,7 @@ GnssAdapter::updateTrackingOptionsCommand(LocationAPI* client, uint32_t id,
err = LOCATION_ERROR_INVALID_PARAMETER;
} else {
// Api doesn't support multiple clients for time based tracking, so mutiplex
- err = mAdapter.startTrackingMultiplex(mOptions);
+ err = mAdapter.updateTrackingMultiplex(mClient, mSessionId, mOptions);
if (LOCATION_ERROR_SUCCESS == err) {
mAdapter.saveTrackingSession(mClient, mSessionId, mOptions);
}
@@ -1436,6 +1435,45 @@ GnssAdapter::updateTrackingOptionsCommand(LocationAPI* client, uint32_t id,
sendMsg(new MsgUpdateTracking(*this, *mLocApi, client, id, options));
}
+LocationError
+GnssAdapter::updateTrackingMultiplex(LocationAPI* client, uint32_t id,
+ const LocationOptions& options)
+{
+ LocationError err = LOCATION_ERROR_SUCCESS;
+
+ if (1 == mTrackingSessions.size()) {
+ err = startTracking(options);
+ } else {
+ LocationSessionKey key(client, id);
+
+ // get the session we are updating
+ auto it = mTrackingSessions.find(key);
+ if (it != mTrackingSessions.end()) {
+ // find the smallest interval, other than the session we are updating
+ LocationOptions smallestIntervalOptions = {}; // size is 0 until set for the first time
+ for (auto it2 = mTrackingSessions.begin(); it2 != mTrackingSessions.end(); ++it2) {
+ // if session is not the one we are updating and either smallest interval is not set
+ // or there is a new smallest interval, then set the new smallest interval
+ if (it2->first != key && (0 == smallestIntervalOptions.size ||
+ it2->second.minInterval < smallestIntervalOptions.minInterval)) {
+ smallestIntervalOptions = it2->second;
+ }
+ }
+ // if session we are updating has smaller interval then next smallest
+ if (options.minInterval < smallestIntervalOptions.minInterval) {
+ // restart time based tracking with the newly updated interval
+ err = startTracking(options);
+ // else if the session we are updating used to be the smallest
+ } else if (it->second.minInterval < smallestIntervalOptions.minInterval) {
+ // restart time based tracking with the next smallest
+ err = startTracking(smallestIntervalOptions);
+ }
+ }
+ }
+
+ return err;
+}
+
void
GnssAdapter::stopTrackingCommand(LocationAPI* client, uint32_t id)
{
@@ -1489,7 +1527,7 @@ GnssAdapter::stopTrackingMultiplex(LocationAPI* client, uint32_t id)
auto it = mTrackingSessions.find(key);
if (it != mTrackingSessions.end()) {
// find the next smallest interval, other than the session we are stopping
- LocationOptions smallestIntervalOptions; // size will be zero until set for the first time
+ LocationOptions smallestIntervalOptions = {}; // size is 0 until set for the first time
for (auto it2 = mTrackingSessions.begin(); it2 != mTrackingSessions.end(); ++it2) {
// if session is not the one we are stopping and either smallest interval is not set
// or there is a new smallest interval, then set the new smallest interval
diff --git a/gnss/GnssAdapter.h b/gnss/GnssAdapter.h
index 429bcb3..3d27e42 100644
--- a/gnss/GnssAdapter.h
+++ b/gnss/GnssAdapter.h
@@ -163,6 +163,8 @@ public:
LocationError startTracking(const LocationOptions& options);
LocationError stopTrackingMultiplex(LocationAPI* client, uint32_t id);
LocationError stopTracking();
+ LocationError updateTrackingMultiplex(LocationAPI* client, uint32_t id,
+ const LocationOptions& options);
/* ==== NI ============================================================================= */
/* ======== COMMANDS ====(Called from Client Thread)==================================== */
diff --git a/location/LocationAPI.cpp b/location/LocationAPI.cpp
index 60a46fe..ed3cc6b 100644
--- a/location/LocationAPI.cpp
+++ b/location/LocationAPI.cpp
@@ -330,7 +330,7 @@ LocationAPI::stopTracking(uint32_t id)
if (gData.flpInterface != NULL) {
gData.flpInterface->stopTracking(this, id);
}
- if (gData.flpInterface != NULL && gData.gnssInterface != NULL) {
+ if (gData.flpInterface == NULL && gData.gnssInterface == NULL) {
LOC_LOGE("%s:%d]: No gnss/flp interface available for Location API client %p ",
__func__, __LINE__, this);
}
@@ -357,7 +357,7 @@ LocationAPI::updateTrackingOptions(uint32_t id, LocationOptions& locationOptions
if (gData.flpInterface != NULL) {
gData.flpInterface->updateTrackingOptions(this, id, locationOptions);
}
- if (gData.flpInterface != NULL && gData.gnssInterface != NULL) {
+ if (gData.flpInterface == NULL && gData.gnssInterface == NULL) {
LOC_LOGE("%s:%d]: No gnss/flp interface available for Location API client %p ",
__func__, __LINE__, this);
}