Do not clear callbacks during gnss hidl cleanup()
This allows HAL to request locations into AFW even when Location is disabled in Settings. Change-Id: I0c1d4fef55937f3094980dad29ff09d212f541fe CRs-fixed: 2475037
This commit is contained in:
parent
aadcd5f7dc
commit
32801f1c0c
1 changed files with 52 additions and 15 deletions
|
@ -170,6 +170,23 @@ const GnssInterface* Gnss::getGnssInterface() {
|
|||
|
||||
Return<bool> Gnss::setCallback(const sp<V1_0::IGnssCallback>& callback) {
|
||||
ENTRY_LOG_CALLFLOW();
|
||||
|
||||
// In case where previous call to setCallback_1_1 or setCallback_2_0, then
|
||||
// we need to cleanup these interfaces/callbacks here since we no longer
|
||||
// do so in cleanup() function to keep callbacks around after cleanup()
|
||||
if (mApi != nullptr) {
|
||||
mApi->gnssUpdateCallbacks_2_0(nullptr);
|
||||
}
|
||||
if (mGnssCbIface_1_1 != nullptr) {
|
||||
mGnssCbIface_1_1->unlinkToDeath(mGnssDeathRecipient);
|
||||
mGnssCbIface_1_1 = nullptr;
|
||||
}
|
||||
if (mGnssCbIface_2_0 != nullptr) {
|
||||
mGnssCbIface_2_0->unlinkToDeath(mGnssDeathRecipient);
|
||||
mGnssCbIface_2_0 = nullptr;
|
||||
}
|
||||
|
||||
|
||||
if (mGnssCbIface != nullptr) {
|
||||
mGnssCbIface->unlinkToDeath(mGnssDeathRecipient);
|
||||
}
|
||||
|
@ -291,21 +308,6 @@ Return<void> Gnss::cleanup() {
|
|||
if (mApi != nullptr) {
|
||||
mApi->gnssStop();
|
||||
mApi->gnssDisable();
|
||||
mApi->gnssUpdateCallbacks(nullptr, nullptr);
|
||||
mApi->gnssUpdateCallbacks_2_0(nullptr);
|
||||
}
|
||||
mGnssNiCbIface = nullptr;
|
||||
if (mGnssCbIface != nullptr) {
|
||||
mGnssCbIface->unlinkToDeath(mGnssDeathRecipient);
|
||||
mGnssCbIface = nullptr;
|
||||
}
|
||||
if (mGnssCbIface_1_1 != nullptr) {
|
||||
mGnssCbIface_1_1->unlinkToDeath(mGnssDeathRecipient);
|
||||
mGnssCbIface_1_1 = nullptr;
|
||||
}
|
||||
if (mGnssCbIface_2_0 != nullptr) {
|
||||
mGnssCbIface_2_0->unlinkToDeath(mGnssDeathRecipient);
|
||||
mGnssCbIface_2_0 = nullptr;
|
||||
}
|
||||
|
||||
return Void();
|
||||
|
@ -417,6 +419,23 @@ Return<bool> Gnss::setCallback_1_1(const sp<V1_1::IGnssCallback>& callback) {
|
|||
LOC_LOGE("%s] Error from gnssNameCb description=%s",
|
||||
__func__, r.description().c_str());
|
||||
}
|
||||
|
||||
// In case where previous call to setCallback or setCallback_2_1, then
|
||||
// we need to cleanup these interfaces/callbacks here since we no longer
|
||||
// do so in cleanup() function to keep callbacks around after cleanup()
|
||||
if (mApi != nullptr) {
|
||||
mApi->gnssUpdateCallbacks_2_0(nullptr);
|
||||
}
|
||||
if (mGnssCbIface != nullptr) {
|
||||
mGnssCbIface->unlinkToDeath(mGnssDeathRecipient);
|
||||
mGnssCbIface = nullptr;
|
||||
}
|
||||
if (mGnssCbIface_2_0 != nullptr) {
|
||||
mGnssCbIface_2_0->unlinkToDeath(mGnssDeathRecipient);
|
||||
mGnssCbIface_2_0 = nullptr;
|
||||
}
|
||||
|
||||
|
||||
if (mGnssCbIface_1_1 != nullptr) {
|
||||
mGnssCbIface_1_1->unlinkToDeath(mGnssDeathRecipient);
|
||||
}
|
||||
|
@ -497,6 +516,7 @@ void Gnss::odcpiRequestCb(const OdcpiRequestInfo& request) {
|
|||
// For emergency mode, request DBH (Device based hybrid) location
|
||||
// Mark Independent from GNSS flag to false.
|
||||
if (ODCPI_REQUEST_TYPE_START == request.type) {
|
||||
LOC_LOGd("gnssRequestLocationCb_2_0 isUserEmergency = %d", request.isEmergencyMode);
|
||||
auto r = mGnssCbIface_2_0->gnssRequestLocationCb_2_0(!request.isEmergencyMode,
|
||||
request.isEmergencyMode);
|
||||
if (!r.isOk()) {
|
||||
|
@ -529,6 +549,23 @@ Return<bool> Gnss::setCallback_2_0(const sp<V2_0::IGnssCallback>& callback) {
|
|||
LOC_LOGE("%s] Error from gnssNameCb description=%s",
|
||||
__func__, r.description().c_str());
|
||||
}
|
||||
|
||||
// In case where previous call to setCallback or setCallback_1_1, then
|
||||
// we need to cleanup these interfaces/callbacks here since we no longer
|
||||
// do so in cleanup() function to keep callbacks around after cleanup()
|
||||
if (mApi != nullptr) {
|
||||
mApi->gnssUpdateCallbacks(nullptr, nullptr);
|
||||
}
|
||||
mGnssNiCbIface = nullptr;
|
||||
if (mGnssCbIface != nullptr) {
|
||||
mGnssCbIface->unlinkToDeath(mGnssDeathRecipient);
|
||||
mGnssCbIface = nullptr;
|
||||
}
|
||||
if (mGnssCbIface_1_1 != nullptr) {
|
||||
mGnssCbIface_1_1->unlinkToDeath(mGnssDeathRecipient);
|
||||
mGnssCbIface_1_1 = nullptr;
|
||||
}
|
||||
|
||||
if (mGnssCbIface_2_0 != nullptr) {
|
||||
mGnssCbIface_2_0->unlinkToDeath(mGnssDeathRecipient);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue