Update the latest LocationOptions to LocationAPI

Call locAPIUpdateTrackingOptions in gnssSetPositionMode.
Update tracking options should update the tracking
sessions so that the smallest interval options are
set.

Change-Id: I24cefe4fb711a160d0a72ab7592d8e673ea2dd97
CRs-fixed: 2048231
This commit is contained in:
Baili Feng 2017-06-06 15:11:02 +08:00 committed by Dante Russo
parent 8bf78f55ae
commit 7b1d6ec5aa
4 changed files with 46 additions and 5 deletions

View file

@ -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;
}

View file

@ -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

View file

@ -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)==================================== */

View file

@ -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);
}