diff options
Diffstat (limited to 'gps/android/AGnss.cpp')
-rw-r--r-- | gps/android/AGnss.cpp | 31 |
1 files changed, 23 insertions, 8 deletions
diff --git a/gps/android/AGnss.cpp b/gps/android/AGnss.cpp index 6213a08..fe50c9a 100644 --- a/gps/android/AGnss.cpp +++ b/gps/android/AGnss.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, The Linux Foundation. All rights reserved. + * Copyright (c) 2017-2018, The Linux Foundation. All rights reserved. * Not a Contribution */ /* @@ -27,15 +27,26 @@ namespace android { namespace hardware { namespace gnss { -namespace V1_0 { +namespace V1_1 { 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; @@ -182,7 +197,7 @@ Return<bool> AGnss::setServer(IAGnssCallback::AGnssType type, } } // namespace implementation -} // namespace V1_0 +} // namespace V1_1 } // namespace gnss } // namespace hardware } // namespace android |