diff options
author | Kevin Tang <zhikait@codeaurora.org> | 2019-02-12 18:44:00 -0800 |
---|---|---|
committer | Gerrit - the friendly Code Review server <code-review@localhost> | 2019-02-17 12:32:50 -0800 |
commit | 9a055d5208d598a841404ba5276c00e060f62fca (patch) | |
tree | b59635df9bf058fa0f3dde5025488ca7b0e5f368 /core/LocApiBase.cpp | |
parent | 1d823b05ec27ec6ed5a0565213aae66321e9812d (diff) | |
download | gps-9a055d5208d598a841404ba5276c00e060f62fca.tar.gz |
Fix race condition that adapter does not get handleEngineUp
- Removed redundant injectFeatureConfig() call, as it this
happens twice, once when the first context is created which
would have been too early and once when LocApi open success.
- Resolved a race condition that second adapter added may not
have been in LocApi's adapter list yet when handleEngineUp()
is broadcast.
Change-Id: I8ecc18eab6b450c326c0be1abc011f70285439aa
CRs-Fixed: 2397902
Diffstat (limited to 'core/LocApiBase.cpp')
-rw-r--r-- | core/LocApiBase.cpp | 20 |
1 files changed, 13 insertions, 7 deletions
diff --git a/core/LocApiBase.cpp b/core/LocApiBase.cpp index c2ee411..13b1c71 100644 --- a/core/LocApiBase.cpp +++ b/core/LocApiBase.cpp @@ -31,6 +31,7 @@ #include <dlfcn.h> #include <inttypes.h> +#include <gps_extended_c.h> #include <LocApiBase.h> #include <LocAdapterBase.h> #include <log_util.h> @@ -95,7 +96,10 @@ struct LocSsrMsg : public LocMsg { } inline virtual void proc() const { mLocApi->close(); - mLocApi->open(mLocApi->getEvtMask()); + if (LOC_API_ADAPTER_ERR_SUCCESS == mLocApi->open(mLocApi->getEvtMask())) { + // Notify adapters that engine up after SSR + mLocApi->handleEngineUpEvent(); + } } inline void locallog() const { LOC_LOGV("LocSsrMsg"); @@ -107,13 +111,17 @@ struct LocSsrMsg : public LocMsg { struct LocOpenMsg : public LocMsg { LocApiBase* mLocApi; - inline LocOpenMsg(LocApiBase* locApi) : - LocMsg(), mLocApi(locApi) + LocAdapterBase* mAdapter; + inline LocOpenMsg(LocApiBase* locApi, LocAdapterBase* adapter = nullptr) : + LocMsg(), mLocApi(locApi), mAdapter(adapter) { locallog(); } inline virtual void proc() const { - mLocApi->open(mLocApi->getEvtMask()); + if (LOC_API_ADAPTER_ERR_SUCCESS == mLocApi->open(mLocApi->getEvtMask()) && + nullptr != mAdapter) { + mAdapter->handleEngineUpEvent(); + } } inline void locallog() const { LOC_LOGv("LocOpen Mask: %" PRIx64 "\n", mLocApi->getEvtMask()); @@ -222,7 +230,7 @@ void LocApiBase::addAdapter(LocAdapterBase* adapter) for (int i = 0; i < MAX_ADAPTERS && mLocAdapters[i] != adapter; i++) { if (mLocAdapters[i] == NULL) { mLocAdapters[i] = adapter; - mMsgTask->sendMsg(new LocOpenMsg(this)); + mMsgTask->sendMsg(new LocOpenMsg(this, adapter)); break; } } @@ -295,8 +303,6 @@ void LocApiBase::updateNmeaMask(uint32_t mask) void LocApiBase::handleEngineUpEvent() { - LocDualContext::injectFeatureConfig(mContext); - // loop through adapters, and deliver to all adapters. TO_ALL_LOCADAPTERS(mLocAdapters[i]->handleEngineUpEvent()); } |