summaryrefslogtreecommitdiff
path: root/core/LocApiBase.cpp
diff options
context:
space:
mode:
authorLinux Build Service Account <lnxbuild@localhost>2019-08-31 08:33:04 -0700
committerLinux Build Service Account <lnxbuild@localhost>2019-08-31 08:33:04 -0700
commite0361a8c9a9b7f4e000966c8b78468aef8c18c95 (patch)
tree940f238e62741f3f20fa1b1dfbbb909dab6c839b /core/LocApiBase.cpp
parente38b50370b18bf8056c8120ef21e43223f60bc23 (diff)
parent5ee0b62e8c53ba6a57300541dbbae6b2e9cf9a8a (diff)
downloadgps-e0361a8c9a9b7f4e000966c8b78468aef8c18c95.tar.gz
Merge 5ee0b62e8c53ba6a57300541dbbae6b2e9cf9a8a on remote branch
Change-Id: I1d13d8eb58d08739700ec5bef4221b274dcc630d
Diffstat (limited to 'core/LocApiBase.cpp')
-rw-r--r--core/LocApiBase.cpp14
1 files changed, 8 insertions, 6 deletions
diff --git a/core/LocApiBase.cpp b/core/LocApiBase.cpp
index ef204ec..14472fa 100644
--- a/core/LocApiBase.cpp
+++ b/core/LocApiBase.cpp
@@ -148,7 +148,8 @@ struct LocCloseMsg : public LocMsg {
}
};
-MsgTask* LocApiBase::mMsgTask;
+MsgTask* LocApiBase::mMsgTask = nullptr;
+volatile int32_t LocApiBase::mMsgTaskRefCount = 0;
LocApiBase::LocApiBase(LOC_API_ADAPTER_EVENT_MASK_T excludedMask,
ContextBase* context) :
@@ -157,6 +158,7 @@ LocApiBase::LocApiBase(LOC_API_ADAPTER_EVENT_MASK_T excludedMask,
{
memset(mLocAdapters, 0, sizeof(mLocAdapters));
+ android_atomic_inc(&mMsgTaskRefCount);
if (nullptr == mMsgTask) {
mMsgTask = new MsgTask("LocApiMsgTask", false);
}
@@ -230,7 +232,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, adapter));
+ sendMsg(new LocOpenMsg(this, adapter));
break;
}
}
@@ -263,10 +265,10 @@ void LocApiBase::removeAdapter(LocAdapterBase* adapter)
// if we have an empty list of adapters
if (0 == i) {
- mMsgTask->sendMsg(new LocCloseMsg(this));
+ sendMsg(new LocCloseMsg(this));
} else {
// else we need to remove the bit
- mMsgTask->sendMsg(new LocOpenMsg(this));
+ sendMsg(new LocOpenMsg(this));
}
}
}
@@ -274,7 +276,7 @@ void LocApiBase::removeAdapter(LocAdapterBase* adapter)
void LocApiBase::updateEvtMask()
{
- mMsgTask->sendMsg(new LocOpenMsg(this));
+ sendMsg(new LocOpenMsg(this));
}
void LocApiBase::updateNmeaMask(uint32_t mask)
@@ -298,7 +300,7 @@ void LocApiBase::updateNmeaMask(uint32_t mask)
}
};
- mMsgTask->sendMsg(new LocSetNmeaMsg(this, mask));
+ sendMsg(new LocSetNmeaMsg(this, mask));
}
void LocApiBase::handleEngineUpEvent()