From 122f2ed00414cf416b67c6dee10131b0f3e28bea Mon Sep 17 00:00:00 2001 From: Bruno Martins Date: Wed, 14 Mar 2018 23:42:25 +0000 Subject: msm8996-common: Update GPS HIDL HAL from upstream * Tag: LA.UM.6.6.r1-06700-89xx.0 Change-Id: If746b12bcbc3e414aa9ba9f421040edd0f815638 --- gps/android/AGnss.cpp | 25 ++++++++++++++---- gps/android/AGnss.h | 6 +++-- gps/android/AGnssRil.cpp | 32 ++++++++++++++++++++++- gps/android/location_api/GnssAPIClient.cpp | 31 +++++++++++++++++----- gps/android/location_api/GnssAPIClient.h | 5 ++-- gps/android/location_api/MeasurementAPIClient.cpp | 10 +++++-- gps/android/location_api/MeasurementAPIClient.h | 4 +-- 7 files changed, 91 insertions(+), 22 deletions(-) (limited to 'gps/android') diff --git a/gps/android/AGnss.cpp b/gps/android/AGnss.cpp index 6213a08..3602e85 100644 --- a/gps/android/AGnss.cpp +++ b/gps/android/AGnss.cpp @@ -30,12 +30,23 @@ namespace gnss { namespace V1_0 { namespace implementation { -sp AGnss::sAGnssCbIface = nullptr; +static AGnss* spAGnss = nullptr; AGnss::AGnss(Gnss* gnss) : mGnss(gnss) { + spAGnss = this; +} + +AGnss::~AGnss() { + spAGnss = nullptr; } void AGnss::agnssStatusIpV4Cb(AGnssExtStatusIpV4 status){ + if (nullptr != spAGnss) { + spAGnss->statusIpV4Cb(status); + } +} + +void AGnss::statusIpV4Cb(AGnssExtStatusIpV4 status) { IAGnssCallback::AGnssStatusIpV4 st = {}; switch (status.type) { @@ -72,9 +83,13 @@ void AGnss::agnssStatusIpV4Cb(AGnssExtStatusIpV4 status){ } st.ipV4Addr = status.ipV4Addr; - auto r = sAGnssCbIface->agnssStatusIpV4Cb(st); - if (!r.isOk()) { - LOC_LOGE("Error invoking AGNSS status cb %s", r.description().c_str()); + if (mAGnssCbIface != nullptr) { + auto r = mAGnssCbIface->agnssStatusIpV4Cb(st); + if (!r.isOk()) { + LOC_LOGw("Error invoking AGNSS status cb %s", r.description().c_str()); + } + } else { + LOC_LOGw("setCallback has not been called yet"); } } @@ -86,7 +101,7 @@ Return AGnss::setCallback(const sp& callback) { } // Save the interface - sAGnssCbIface = callback; + mAGnssCbIface = callback; AgpsCbInfo cbInfo = {}; cbInfo.statusV4Cb = (void*)agnssStatusIpV4Cb; diff --git a/gps/android/AGnss.h b/gps/android/AGnss.h index a3f4a87..ead6416 100644 --- a/gps/android/AGnss.h +++ b/gps/android/AGnss.h @@ -43,7 +43,7 @@ struct Gnss; struct AGnss : public IAGnss { AGnss(Gnss* gnss); - ~AGnss() = default; + ~AGnss(); /* * Methods from ::android::hardware::gnss::V1_0::IAGnss interface follow. * These declarations were generated from IAGnss.hal. @@ -60,12 +60,14 @@ struct AGnss : public IAGnss { Return setServer(IAGnssCallback::AGnssType type, const hidl_string& hostname, int32_t port) override; + void statusIpV4Cb(AGnssExtStatusIpV4 status); + /* Data call setup callback passed down to GNSS HAL implementation */ static void agnssStatusIpV4Cb(AGnssExtStatusIpV4 status); private: Gnss* mGnss = nullptr; - static sp sAGnssCbIface; + sp mAGnssCbIface = nullptr; }; } // namespace implementation diff --git a/gps/android/AGnssRil.cpp b/gps/android/AGnssRil.cpp index bd4bb37..d790bae 100644 --- a/gps/android/AGnssRil.cpp +++ b/gps/android/AGnssRil.cpp @@ -29,6 +29,8 @@ #include #include "Gnss.h" #include "AGnssRil.h" +#include + typedef void* (getLocationInterface)(); namespace android { @@ -51,7 +53,35 @@ Return AGnssRil::updateNetworkState(bool connected, NetworkType type, bool // for XTRA if (nullptr != mGnss && ( nullptr != mGnss->getGnssInterface() )) { - mGnss->getGnssInterface()->updateConnectionStatus(connected, (uint8_t)type); + int8_t typeout = loc_core::NetworkInfoDataItemBase::TYPE_UNKNOWN; + switch(type) + { + case IAGnssRil::NetworkType::MOBILE: + typeout = loc_core::NetworkInfoDataItemBase::TYPE_MOBILE; + break; + case IAGnssRil::NetworkType::WIFI: + typeout = loc_core::NetworkInfoDataItemBase::TYPE_WIFI; + break; + case IAGnssRil::NetworkType::MMS: + typeout = loc_core::NetworkInfoDataItemBase::TYPE_MMS; + break; + case IAGnssRil::NetworkType::SUPL: + typeout = loc_core::NetworkInfoDataItemBase::TYPE_SUPL; + break; + case IAGnssRil::NetworkType::DUN: + typeout = loc_core::NetworkInfoDataItemBase::TYPE_DUN; + break; + case IAGnssRil::NetworkType::HIPRI: + typeout = loc_core::NetworkInfoDataItemBase::TYPE_HIPRI; + break; + case IAGnssRil::NetworkType::WIMAX: + typeout = loc_core::NetworkInfoDataItemBase::TYPE_WIMAX; + break; + default: + typeout = loc_core::NetworkInfoDataItemBase::TYPE_UNKNOWN; + break; + } + mGnss->getGnssInterface()->updateConnectionStatus(connected, typeout); } return true; } 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& 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 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 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 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 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 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 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 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 #include #include #include @@ -91,11 +91,10 @@ public: private: sp mGnssCbIface; sp 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& { 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 #include #include #include @@ -63,7 +63,7 @@ public: private: sp mGnssMeasurementCbIface; - + std::mutex mMutex; bool mTracking; }; -- cgit v1.2.3