summaryrefslogtreecommitdiff
path: root/gnss
diff options
context:
space:
mode:
authorWei Chen <weic@codeaurora.org>2018-11-15 09:41:26 -0800
committerWei Chen <weic@codeaurora.org>2018-11-27 17:07:19 -0800
commite232986d84deb7178d1a57cc7f1e4d24cbaeeb3c (patch)
tree882a2a704ea4d27c8a40f0f1b2d661e5c96b5087 /gnss
parent9b0abcc59d3ea840c38b131d2c4d1c14028f29e1 (diff)
downloadgps-e232986d84deb7178d1a57cc7f1e4d24cbaeeb3c.tar.gz
GPS location API: support destroy with callback for completion
Support Location API destroy function with callback. Location API client that passes callback to Location API need to wait for the destroy complete callback to be invoked before releasing the memory that holds the callback Change-Id: I29b1c6d46feb79c789e6f1ec1500c941b022a3ac CRs-fixed: 2349398
Diffstat (limited to 'gnss')
-rw-r--r--gnss/GnssAdapter.cpp15
-rw-r--r--gnss/GnssAdapter.h5
-rw-r--r--gnss/location_gnss.cpp8
3 files changed, 19 insertions, 9 deletions
diff --git a/gnss/GnssAdapter.cpp b/gnss/GnssAdapter.cpp
index fc59c22..f7297d0 100644
--- a/gnss/GnssAdapter.cpp
+++ b/gnss/GnssAdapter.cpp
@@ -1859,25 +1859,32 @@ GnssAdapter::addClientCommand(LocationAPI* client, const LocationCallbacks& call
}
void
-GnssAdapter::removeClientCommand(LocationAPI* client)
+GnssAdapter::removeClientCommand(LocationAPI* client,
+ removeClientCompleteCallback rmClientCb)
{
LOC_LOGD("%s]: client %p", __func__, client);
struct MsgRemoveClient : public LocMsg {
GnssAdapter& mAdapter;
LocationAPI* mClient;
+ removeClientCompleteCallback mRmClientCb;
inline MsgRemoveClient(GnssAdapter& adapter,
- LocationAPI* client) :
+ LocationAPI* client,
+ removeClientCompleteCallback rmCb) :
LocMsg(),
mAdapter(adapter),
- mClient(client) {}
+ mClient(client),
+ mRmClientCb(rmCb){}
inline virtual void proc() const {
mAdapter.stopClientSessions(mClient);
mAdapter.eraseClient(mClient);
+ if (nullptr != mRmClientCb) {
+ mRmClientCb(mClient);
+ }
}
};
- sendMsg(new MsgRemoveClient(*this, client));
+ sendMsg(new MsgRemoveClient(*this, client, rmClientCb));
}
void
diff --git a/gnss/GnssAdapter.h b/gnss/GnssAdapter.h
index f382c6a..1682f02 100644
--- a/gnss/GnssAdapter.h
+++ b/gnss/GnssAdapter.h
@@ -128,6 +128,8 @@ typedef std::function<void(
uint64_t gnssEnergyConsumedFromFirstBoot
)> GnssEnergyConsumedCallback;
+typedef void (*removeClientCompleteCallback)(LocationAPI* client);
+
class GnssAdapter : public LocAdapterBase {
/* ==== Engine Hub ===================================================================== */
@@ -206,7 +208,8 @@ public:
/* ==== CLIENT ========================================================================= */
/* ======== COMMANDS ====(Called from Client Thread)==================================== */
void addClientCommand(LocationAPI* client, const LocationCallbacks& callbacks);
- void removeClientCommand(LocationAPI* client);
+ void removeClientCommand(LocationAPI* client,
+ removeClientCompleteCallback rmClientCb);
void requestCapabilitiesCommand(LocationAPI* client);
/* ======== UTILITIES ================================================================== */
void saveClient(LocationAPI* client, const LocationCallbacks& callbacks);
diff --git a/gnss/location_gnss.cpp b/gnss/location_gnss.cpp
index 5a7710a..f9fbddc 100644
--- a/gnss/location_gnss.cpp
+++ b/gnss/location_gnss.cpp
@@ -36,7 +36,7 @@ static void initialize();
static void deinitialize();
static void addClient(LocationAPI* client, const LocationCallbacks& callbacks);
-static void removeClient(LocationAPI* client);
+static void removeClient(LocationAPI* client, removeClientCompleteCallback rmClientCb);
static void requestCapabilities(LocationAPI* client);
static uint32_t startTracking(LocationAPI* client, TrackingOptions&);
@@ -140,10 +140,10 @@ static void addClient(LocationAPI* client, const LocationCallbacks& callbacks)
}
}
-static void removeClient(LocationAPI* client)
+static void removeClient(LocationAPI* client, removeClientCompleteCallback rmClientCb)
{
if (NULL != gGnssAdapter) {
- gGnssAdapter->removeClientCommand(client);
+ gGnssAdapter->removeClientCommand(client, rmClientCb);
}
}
@@ -345,4 +345,4 @@ static void getGnssEnergyConsumed(GnssEnergyConsumedCallback energyConsumedCb) {
if (NULL != gGnssAdapter) {
gGnssAdapter->getGnssEnergyConsumedCommand(energyConsumedCb);
}
-} \ No newline at end of file
+}