diff options
author | Linux Build Service Account <lnxbuild@localhost> | 2022-08-13 02:46:31 -0700 |
---|---|---|
committer | Linux Build Service Account <lnxbuild@localhost> | 2022-08-13 02:46:31 -0700 |
commit | c259797d7567e8fb71d46fb69a0fa941cdd4b72c (patch) | |
tree | 786eb8a9cba7c325c44a52706dbe0919282b85d4 /batching/BatchingAdapter.cpp | |
parent | f6de500c9b9224e3c88b156cfb666eea036772a4 (diff) | |
parent | cf4eac65570a43c797a00abb68779f4757426499 (diff) |
Merge cf4eac65570a43c797a00abb68779f4757426499 on remote branch
Change-Id: I099746d2001e6e5bda1b2a20344d51a4d2ed170f
Diffstat (limited to 'batching/BatchingAdapter.cpp')
-rw-r--r-- | batching/BatchingAdapter.cpp | 105 |
1 files changed, 95 insertions, 10 deletions
diff --git a/batching/BatchingAdapter.cpp b/batching/BatchingAdapter.cpp index 4f1a43c..4fdacda 100644 --- a/batching/BatchingAdapter.cpp +++ b/batching/BatchingAdapter.cpp @@ -26,6 +26,43 @@ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * */ + +/* +Changes from Qualcomm Innovation Center are provided under the following license: + +Copyright (c) 2022 Qualcomm Innovation Center, Inc. All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted (subject to the limitations in the +disclaimer below) provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + + * Redistributions in binary form must reproduce the above + copyright notice, this list of conditions and the following + disclaimer in the documentation and/or other materials provided + with the distribution. + + * Neither the name of Qualcomm Innovation Center, Inc. nor the names of its + contributors may be used to endorse or promote products derived + from this software without specific prior written permission. + +NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE +GRANTED BY THIS LICENSE. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT +HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED +WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF +MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. +IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR +ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE +GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER +IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR +OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN +IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + #define LOG_NDEBUG 0 #define LOG_TAG "LocSvc_BatchingAdapter" @@ -163,6 +200,41 @@ BatchingAdapter::updateClientsEventMask() } void +BatchingAdapter::handleEngineLockStatusEvent(EngineLockState engineLockState) { + + LOC_LOGD("%s]: Old Engine state %d, New Engine state : %d,", __func__, + mLocApi->getEngineLockState(), engineLockState); + + struct MsgEngineLockStateEvent : public LocMsg { + BatchingAdapter& mAdapter; + EngineLockState mEngineLockState; + + inline MsgEngineLockStateEvent(BatchingAdapter& adapter, EngineLockState engineLockState) : + LocMsg(), + mAdapter(adapter), + mEngineLockState(engineLockState){} + + virtual void proc() const { + mAdapter.handleEngineLockStatus(mEngineLockState); + } + }; + + sendMsg(new MsgEngineLockStateEvent(*this, engineLockState)); +} + +void +BatchingAdapter::handleEngineLockStatus(EngineLockState engineLockState) { + + LOC_LOGd("lock state %d, pending msgs %zu", engineLockState, mPendingGnssEnabledMsgs.size()); + if (ENGINE_LOCK_STATE_ENABLED == engineLockState) { + for (auto msg: mPendingGnssEnabledMsgs) { + sendMsg(msg); + } + mPendingGnssEnabledMsgs.clear(); + } +} + +void BatchingAdapter::handleEngineUpEvent() { struct MsgSSREvent : public LocMsg { @@ -178,11 +250,13 @@ BatchingAdapter::handleEngineUpEvent() mAdapter.broadcastCapabilities(mAdapter.getCapabilities()); mApi.setBatchSize(mAdapter.getBatchSize()); mApi.setTripBatchSize(mAdapter.getTripBatchSize()); - mAdapter.restartSessions(); - for (auto msg: mAdapter.mPendingMsgs) { - mAdapter.sendMsg(msg); + if (ENGINE_LOCK_STATE_ENABLED == mApi.getEngineLockState()) { + mAdapter.restartSessions(); + for (auto msg: mAdapter.mPendingMsgs) { + mAdapter.sendMsg(msg); + } + mAdapter.mPendingMsgs.clear(); } - mAdapter.mPendingMsgs.clear(); } }; @@ -354,7 +428,8 @@ BatchingAdapter::startBatchingCommand( if (LOCATION_ERROR_SUCCESS == err) { if (mBatchingOptions.batchingMode == BATCHING_MODE_ROUTINE || mBatchingOptions.batchingMode == BATCHING_MODE_NO_AUTO_REPORT) { - mAdapter.startBatching(mClient, mSessionId, mBatchingOptions); + mAdapter.startBatching( + mClient, mSessionId, mBatchingOptions, new MsgStartBatching(*this)); } else if (mBatchingOptions.batchingMode == BATCHING_MODE_TRIP) { mAdapter.startTripBatchingMultiplex(mClient, mSessionId, mBatchingOptions); } else { @@ -371,7 +446,7 @@ BatchingAdapter::startBatchingCommand( void BatchingAdapter::startBatching(LocationAPI* client, uint32_t sessionId, - const BatchingOptions& batchingOptions) + const BatchingOptions& batchingOptions, LocMsg* pendingMsg) { if (batchingOptions.batchingMode != BATCHING_MODE_NO_AUTO_REPORT && 0 == autoReportBatchingSessionsCount()) { @@ -385,8 +460,9 @@ BatchingAdapter::startBatching(LocationAPI* client, uint32_t sessionId, saveBatchingSession(client, sessionId, batchingOptions); mLocApi->startBatching(sessionId, batchingOptions, getBatchingAccuracy(), getBatchingTimeout(), new LocApiResponse(*getContext(), - [this, client, sessionId, batchingOptions] (LocationError err) { - if (LOCATION_ERROR_SUCCESS != err) { + [this, client, sessionId, batchingOptions, pendingMsg] (LocationError err) { + if (ENGINE_LOCK_STATE_ENABLED == mLocApi->getEngineLockState() && + LOCATION_ERROR_SUCCESS != err) { eraseBatchingSession(client, sessionId); } @@ -399,6 +475,13 @@ BatchingAdapter::startBatching(LocationAPI* client, uint32_t sessionId, LOC_REGISTRATION_MASK_DISABLED); } + if (LOCATION_ERROR_GNSS_DISABLED == err && pendingMsg != nullptr) { + LOC_LOGd("GNSS_DISABLED, add request to pending queue"); + mPendingGnssEnabledMsgs.push_back(pendingMsg); + } else if (pendingMsg != nullptr) { + delete pendingMsg; + } + reportResponse(client, err, sessionId); })); } @@ -509,7 +592,8 @@ BatchingAdapter::stopBatching(LocationAPI* client, uint32_t sessionId, bool rest new LocApiResponse(*getContext(), [this, client, sessionId, flpOptions, restartNeeded, batchOptions] (LocationError err) { - if (LOCATION_ERROR_SUCCESS != err) { + if (ENGINE_LOCK_STATE_ENABLED == mLocApi->getEngineLockState() && + LOCATION_ERROR_SUCCESS != err) { saveBatchingSession(client, sessionId, batchOptions); } else { // if stopBatching is success, unregister for batch full event if this was the last @@ -766,7 +850,8 @@ BatchingAdapter::startTripBatchingMultiplex(LocationAPI* client, uint32_t sessio mLocApi->startOutdoorTripBatching(batchingOptions.minDistance, batchingOptions.minInterval, getBatchingTimeout(), new LocApiResponse(*getContext(), [this, client, sessionId, batchingOptions] (LocationError err) { - if (err == LOCATION_ERROR_SUCCESS) { + if (ENGINE_LOCK_STATE_DISABLED == mLocApi->getEngineLockState() || + err == LOCATION_ERROR_SUCCESS) { mOngoingTripDistance = batchingOptions.minDistance; mOngoingTripTBFInterval = batchingOptions.minInterval; LOC_LOGD("%s] New Trip started ...", __func__); |