diff options
author | Bruno Martins <bgcngm@gmail.com> | 2018-03-14 23:42:25 +0000 |
---|---|---|
committer | Cosme Domínguez Díaz <cosme.ddiaz@gmail.com> | 2018-03-16 00:50:43 +0100 |
commit | 122f2ed00414cf416b67c6dee10131b0f3e28bea (patch) | |
tree | 04057c48ef75a874573f880e5ea3a3ede58fdd95 /gps/android | |
parent | d725d2ed80359098e6b1952f942421cabd844b2a (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')
-rw-r--r-- | gps/android/AGnss.cpp | 25 | ||||
-rw-r--r-- | gps/android/AGnss.h | 6 | ||||
-rw-r--r-- | gps/android/AGnssRil.cpp | 32 | ||||
-rw-r--r-- | gps/android/location_api/GnssAPIClient.cpp | 31 | ||||
-rw-r--r-- | gps/android/location_api/GnssAPIClient.h | 5 | ||||
-rw-r--r-- | gps/android/location_api/MeasurementAPIClient.cpp | 10 | ||||
-rw-r--r-- | gps/android/location_api/MeasurementAPIClient.h | 4 |
7 files changed, 91 insertions, 22 deletions
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<IAGnssCallback> 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<void> AGnss::setCallback(const sp<IAGnssCallback>& 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<bool> 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<IAGnssCallback> sAGnssCbIface; + sp<IAGnssCallback> 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 <string> #include "Gnss.h" #include "AGnssRil.h" +#include <DataItemConcreteTypesBase.h> + typedef void* (getLocationInterface)(); namespace android { @@ -51,7 +53,35 @@ Return<bool> 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<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; }; |