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 ++++++++++++++++++++----- 1 file changed, 20 insertions(+), 5 deletions(-) (limited to 'gps/android/AGnss.cpp') 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; -- cgit v1.2.3