Merge "moving AGnssCbIface from static to class member"

This commit is contained in:
Linux Build Service Account 2018-02-26 13:28:20 -08:00 committed by Gerrit - the friendly Code Review server
commit 92b643d3ba
2 changed files with 24 additions and 7 deletions

View file

@ -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 (mAGnssCbIface != nullptr) {
auto r = mAGnssCbIface->agnssStatusIpV4Cb(st);
if (!r.isOk()) {
LOC_LOGE("Error invoking AGNSS status cb %s", r.description().c_str());
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;

View file

@ -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