aboutsummaryrefslogtreecommitdiff
path: root/gps/android/location_api
diff options
context:
space:
mode:
authorBruno Martins <bgcngm@gmail.com>2018-03-14 23:42:25 +0000
committerCosme Domínguez Díaz <cosme.ddiaz@gmail.com>2018-03-16 00:50:43 +0100
commit122f2ed00414cf416b67c6dee10131b0f3e28bea (patch)
tree04057c48ef75a874573f880e5ea3a3ede58fdd95 /gps/android/location_api
parentd725d2ed80359098e6b1952f942421cabd844b2a (diff)
msm8996-common: Update GPS HIDL HAL from upstream
* Tag: LA.UM.6.6.r1-06700-89xx.0 Change-Id: If746b12bcbc3e414aa9ba9f421040edd0f815638
Diffstat (limited to 'gps/android/location_api')
-rw-r--r--gps/android/location_api/GnssAPIClient.cpp31
-rw-r--r--gps/android/location_api/GnssAPIClient.h5
-rw-r--r--gps/android/location_api/MeasurementAPIClient.cpp10
-rw-r--r--gps/android/location_api/MeasurementAPIClient.h4
4 files changed, 36 insertions, 14 deletions
diff --git a/gps/android/location_api/GnssAPIClient.cpp b/gps/android/location_api/GnssAPIClient.cpp
index 2745f56..2e44c2e 100644
--- a/gps/android/location_api/GnssAPIClient.cpp
+++ b/gps/android/location_api/GnssAPIClient.cpp
@@ -81,8 +81,10 @@ void GnssAPIClient::gnssUpdateCallbacks(const sp<IGnssCallback>& gpsCb,
{
LOC_LOGD("%s]: (%p %p)", __FUNCTION__, &gpsCb, &niCb);
+ mMutex.lock();
mGnssCbIface = gpsCb;
mGnssNiCbIface = niCb;
+ mMutex.unlock();
LocationCallbacks locationCallbacks;
memset(&locationCallbacks, 0, sizeof(LocationCallbacks));
@@ -278,7 +280,10 @@ void GnssAPIClient::onCapabilitiesCb(LocationCapabilitiesMask capabilitiesMask)
LOC_LOGD("%s]: (%02x)", __FUNCTION__, capabilitiesMask);
mLocationCapabilitiesMask = capabilitiesMask;
mLocationCapabilitiesCached = true;
- sp<IGnssCallback> gnssCbIface = mGnssCbIface;
+
+ mMutex.lock();
+ auto gnssCbIface(mGnssCbIface);
+ mMutex.unlock();
if (gnssCbIface != nullptr) {
uint32_t data = 0;
@@ -322,7 +327,9 @@ void GnssAPIClient::onCapabilitiesCb(LocationCapabilitiesMask capabilitiesMask)
void GnssAPIClient::onTrackingCb(Location location)
{
LOC_LOGD("%s]: (flags: %02x)", __FUNCTION__, location.flags);
- sp<IGnssCallback> gnssCbIface = mGnssCbIface;
+ mMutex.lock();
+ auto gnssCbIface(mGnssCbIface);
+ mMutex.unlock();
if (gnssCbIface != nullptr) {
GnssLocation gnssLocation;
@@ -338,7 +345,9 @@ void GnssAPIClient::onTrackingCb(Location location)
void GnssAPIClient::onGnssNiCb(uint32_t id, GnssNiNotification gnssNiNotification)
{
LOC_LOGD("%s]: (id: %d)", __FUNCTION__, id);
- sp<IGnssNiCallback> gnssNiCbIface = mGnssNiCbIface;
+ mMutex.lock();
+ auto gnssNiCbIface(mGnssNiCbIface);
+ mMutex.unlock();
if (gnssNiCbIface == nullptr) {
LOC_LOGE("%s]: mGnssNiCbIface is nullptr", __FUNCTION__);
@@ -411,7 +420,9 @@ void GnssAPIClient::onGnssNiCb(uint32_t id, GnssNiNotification gnssNiNotificatio
void GnssAPIClient::onGnssSvCb(GnssSvNotification gnssSvNotification)
{
LOC_LOGD("%s]: (count: %zu)", __FUNCTION__, gnssSvNotification.count);
- sp<IGnssCallback> gnssCbIface = mGnssCbIface;
+ mMutex.lock();
+ auto gnssCbIface(mGnssCbIface);
+ mMutex.unlock();
if (gnssCbIface != nullptr) {
IGnssCallback::GnssSvStatus svStatus;
@@ -426,7 +437,9 @@ void GnssAPIClient::onGnssSvCb(GnssSvNotification gnssSvNotification)
void GnssAPIClient::onGnssNmeaCb(GnssNmeaNotification gnssNmeaNotification)
{
- sp<IGnssCallback> gnssCbIface = mGnssCbIface;
+ mMutex.lock();
+ auto gnssCbIface(mGnssCbIface);
+ mMutex.unlock();
if (gnssCbIface != nullptr) {
android::hardware::hidl_string nmeaString;
@@ -443,7 +456,9 @@ void GnssAPIClient::onGnssNmeaCb(GnssNmeaNotification gnssNmeaNotification)
void GnssAPIClient::onStartTrackingCb(LocationError error)
{
LOC_LOGD("%s]: (%d)", __FUNCTION__, error);
- sp<IGnssCallback> gnssCbIface = mGnssCbIface;
+ mMutex.lock();
+ auto gnssCbIface(mGnssCbIface);
+ mMutex.unlock();
if (error == LOCATION_ERROR_SUCCESS && gnssCbIface != nullptr) {
auto r = gnssCbIface->gnssStatusCb(IGnssCallback::GnssStatusValue::ENGINE_ON);
@@ -462,7 +477,9 @@ void GnssAPIClient::onStartTrackingCb(LocationError error)
void GnssAPIClient::onStopTrackingCb(LocationError error)
{
LOC_LOGD("%s]: (%d)", __FUNCTION__, error);
- sp<IGnssCallback> gnssCbIface = mGnssCbIface;
+ mMutex.lock();
+ auto gnssCbIface(mGnssCbIface);
+ mMutex.unlock();
if (error == LOCATION_ERROR_SUCCESS && gnssCbIface != nullptr) {
auto r = gnssCbIface->gnssStatusCb(IGnssCallback::GnssStatusValue::SESSION_END);
diff --git a/gps/android/location_api/GnssAPIClient.h b/gps/android/location_api/GnssAPIClient.h
index 295a9e9..b5cffb1 100644
--- a/gps/android/location_api/GnssAPIClient.h
+++ b/gps/android/location_api/GnssAPIClient.h
@@ -30,7 +30,7 @@
#ifndef GNSS_API_CLINET_H
#define GNSS_API_CLINET_H
-
+#include <mutex>
#include <android/hardware/gnss/1.0/IGnss.h>
#include <android/hardware/gnss/1.0/IGnssCallback.h>
#include <android/hardware/gnss/1.0/IGnssNiCallback.h>
@@ -91,11 +91,10 @@ public:
private:
sp<IGnssCallback> mGnssCbIface;
sp<IGnssNiCallback> mGnssNiCbIface;
-
+ std::mutex mMutex;
LocationAPIControlClient* mControlClient;
LocationCapabilitiesMask mLocationCapabilitiesMask;
bool mLocationCapabilitiesCached;
-
LocationOptions mLocationOptions;
};
diff --git a/gps/android/location_api/MeasurementAPIClient.cpp b/gps/android/location_api/MeasurementAPIClient.cpp
index dd7ceac..731c7ed 100644
--- a/gps/android/location_api/MeasurementAPIClient.cpp
+++ b/gps/android/location_api/MeasurementAPIClient.cpp
@@ -66,7 +66,9 @@ MeasurementAPIClient::measurementSetCallback(const sp<IGnssMeasurementCallback>&
{
LOC_LOGD("%s]: (%p)", __FUNCTION__, &callback);
+ mMutex.lock();
mGnssMeasurementCbIface = callback;
+ mMutex.unlock();
LocationCallbacks locationCallbacks;
memset(&locationCallbacks, 0, sizeof(LocationCallbacks));
@@ -116,10 +118,14 @@ void MeasurementAPIClient::onGnssMeasurementsCb(
LOC_LOGD("%s]: (count: %zu active: %zu)",
__FUNCTION__, gnssMeasurementsNotification.count, mTracking);
if (mTracking) {
- if (mGnssMeasurementCbIface != nullptr) {
+ mMutex.lock();
+ auto gnssMeasurementCbIface(mGnssMeasurementCbIface);
+ mMutex.unlock();
+
+ if (gnssMeasurementCbIface != nullptr) {
IGnssMeasurementCallback::GnssData gnssData;
convertGnssData(gnssMeasurementsNotification, gnssData);
- auto r = mGnssMeasurementCbIface->GnssMeasurementCb(gnssData);
+ auto r = gnssMeasurementCbIface->GnssMeasurementCb(gnssData);
if (!r.isOk()) {
LOC_LOGE("%s] Error from GnssMeasurementCb description=%s",
__func__, r.description().c_str());
diff --git a/gps/android/location_api/MeasurementAPIClient.h b/gps/android/location_api/MeasurementAPIClient.h
index 422564d..8de1326 100644
--- a/gps/android/location_api/MeasurementAPIClient.h
+++ b/gps/android/location_api/MeasurementAPIClient.h
@@ -30,7 +30,7 @@
#ifndef MEASUREMENT_API_CLINET_H
#define MEASUREMENT_API_CLINET_H
-
+#include <mutex>
#include <android/hardware/gnss/1.0/IGnssMeasurement.h>
#include <android/hardware/gnss/1.0/IGnssMeasurementCallback.h>
#include <LocationAPIClientBase.h>
@@ -63,7 +63,7 @@ public:
private:
sp<IGnssMeasurementCallback> mGnssMeasurementCbIface;
-
+ std::mutex mMutex;
bool mTracking;
};