summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLinux Build Service Account <lnxbuild@localhost>2021-11-09 06:46:43 -0800
committerLinux Build Service Account <lnxbuild@localhost>2021-11-09 06:46:43 -0800
commitd5766857ffb9418e775d4092ff75d7c077ea4586 (patch)
treeea6ab0e001d0dc41ec6ceaecfcdfb1b885a576f0
parentfc7bb47644ebb4f72811e4b42a2f44f1f88f0e5b (diff)
parent3e77a82004fff2f40dbae73536cbfc687f235b1c (diff)
Merge 3e77a82004fff2f40dbae73536cbfc687f235b1c on remote branch
Change-Id: I4f85ba4dfb44293d9ac3919b21bffff7a35b1ef2
-rw-r--r--android/1.0/Gnss.cpp13
-rw-r--r--android/1.0/Gnss.h2
-rw-r--r--android/1.0/GnssBatching.cpp11
-rw-r--r--android/1.0/GnssBatching.h2
-rw-r--r--android/1.0/GnssGeofencing.cpp11
-rw-r--r--android/1.0/GnssGeofencing.h2
-rw-r--r--android/1.0/GnssMeasurement.cpp11
-rw-r--r--android/1.0/GnssMeasurement.h2
-rw-r--r--android/1.1/Gnss.cpp14
-rw-r--r--android/1.1/Gnss.h2
-rw-r--r--android/1.1/GnssBatching.cpp11
-rw-r--r--android/1.1/GnssBatching.h2
-rw-r--r--android/1.1/GnssGeofencing.cpp11
-rw-r--r--android/1.1/GnssGeofencing.h2
-rw-r--r--android/1.1/GnssMeasurement.cpp13
-rw-r--r--android/1.1/GnssMeasurement.h2
-rw-r--r--android/2.0/Gnss.cpp16
-rw-r--r--android/2.0/Gnss.h4
-rw-r--r--android/2.0/GnssBatching.cpp16
-rw-r--r--android/2.0/GnssBatching.h10
-rw-r--r--android/2.0/GnssGeofencing.cpp11
-rw-r--r--android/2.0/GnssGeofencing.h2
-rw-r--r--android/2.0/GnssMeasurement.cpp15
-rw-r--r--android/2.0/GnssMeasurement.h2
-rw-r--r--android/2.1/Gnss.cpp18
-rw-r--r--android/2.1/Gnss.h4
-rw-r--r--android/2.1/GnssBatching.cpp14
-rw-r--r--android/2.1/GnssBatching.h10
-rw-r--r--android/2.1/GnssGeofencing.cpp11
-rw-r--r--android/2.1/GnssGeofencing.h1
-rw-r--r--android/2.1/GnssMeasurement.cpp17
-rw-r--r--android/2.1/GnssMeasurement.h2
-rw-r--r--android/aidl-impl/Gnss.cpp11
-rw-r--r--android/aidl-impl/Gnss.h2
34 files changed, 243 insertions, 34 deletions
diff --git a/android/1.0/Gnss.cpp b/android/1.0/Gnss.cpp
index c7fca33..b220908 100644
--- a/android/1.0/Gnss.cpp
+++ b/android/1.0/Gnss.cpp
@@ -44,8 +44,7 @@ void Gnss::GnssDeathRecipient::serviceDied(uint64_t cookie, const wp<IBase>& who
__FUNCTION__, static_cast<unsigned long long>(cookie), &who);
auto gnss = mGnss.promote();
if (gnss != nullptr) {
- gnss->getGnssInterface()->resetNetworkInfo();
- gnss->cleanup();
+ gnss->handleClientDeath();
}
}
@@ -77,6 +76,16 @@ Gnss::~Gnss() {
sGnss = nullptr;
}
+void Gnss::handleClientDeath() {
+ getGnssInterface()->resetNetworkInfo();
+ cleanup();
+ if (mApi != nullptr) {
+ mApi->gnssUpdateCallbacks(nullptr, nullptr);
+ }
+ mGnssCbIface = nullptr;
+ mGnssNiCbIface = nullptr;
+}
+
GnssAPIClient* Gnss::getApi() {
if (mApi == nullptr && (mGnssCbIface != nullptr || mGnssNiCbIface != nullptr)) {
mApi = new GnssAPIClient(mGnssCbIface, mGnssNiCbIface);
diff --git a/android/1.0/Gnss.h b/android/1.0/Gnss.h
index 6e88509..7cbfd51 100644
--- a/android/1.0/Gnss.h
+++ b/android/1.0/Gnss.h
@@ -113,6 +113,8 @@ struct Gnss : public IGnss {
const wp<Gnss> mGnss;
};
+ void handleClientDeath();
+
private:
sp<GnssDeathRecipient> mGnssDeathRecipient = nullptr;
diff --git a/android/1.0/GnssBatching.cpp b/android/1.0/GnssBatching.cpp
index 1d2d378..2e1f8a8 100644
--- a/android/1.0/GnssBatching.cpp
+++ b/android/1.0/GnssBatching.cpp
@@ -36,8 +36,7 @@ void GnssBatching::GnssBatchingDeathRecipient::serviceDied(
__FUNCTION__, static_cast<unsigned long long>(cookie), &who);
auto gnssBatching = mGnssBatching.promote();
if (gnssBatching != nullptr) {
- gnssBatching->stop();
- gnssBatching->cleanup();
+ gnssBatching->handleClientDeath();
}
}
@@ -48,6 +47,14 @@ GnssBatching::~GnssBatching() {
}
}
+GnssBatching::handleClientDeath() {
+ stop();
+ cleanup();
+ if (mApi != nullptr) {
+ mApi->gnssUpdateCallbacks(nullptr);
+ }
+ mGnssBatchingCbIface = nullptr;
+}
// Methods from ::android::hardware::gnss::V1_0::IGnssBatching follow.
Return<bool> GnssBatching::init(const sp<IGnssBatchingCallback>& callback) {
diff --git a/android/1.0/GnssBatching.h b/android/1.0/GnssBatching.h
index 1bd102b..4428edc 100644
--- a/android/1.0/GnssBatching.h
+++ b/android/1.0/GnssBatching.h
@@ -65,6 +65,8 @@ struct GnssBatching : public IGnssBatching {
const wp<GnssBatching> mGnssBatching;
};
+ void handleClientDeath();
+
private:
// this has to be a reference, not a copy
// because the pointer is not set when mSelf is assigned
diff --git a/android/1.0/GnssGeofencing.cpp b/android/1.0/GnssGeofencing.cpp
index 5accd5c..ca5594a 100644
--- a/android/1.0/GnssGeofencing.cpp
+++ b/android/1.0/GnssGeofencing.cpp
@@ -36,7 +36,7 @@ void GnssGeofencing::GnssGeofencingDeathRecipient::serviceDied(
__FUNCTION__, static_cast<unsigned long long>(cookie), &who);
auto gnssGeofencing = mGnssGeofencing.promote();
if (gnssGeofencing != nullptr) {
- gnssGeofencing->removeAllGeofences();
+ gnssGeofencing->handleClientDeath();
}
}
@@ -47,6 +47,15 @@ GnssGeofencing::~GnssGeofencing() {
}
}
+void GnssGeofencing::handleClientDeath() {
+
+ removeAllGeofences();
+ if (mApi != nullptr) {
+ mApi->upcateCallback(nullptr);
+ }
+ mGnssGeofencingCbIface = nullptr;
+}
+
// Methods from ::android::hardware::gnss::V1_0::IGnssGeofencing follow.
Return<void> GnssGeofencing::setCallback(const sp<IGnssGeofenceCallback>& callback) {
if (mGnssGeofencingDeathRecipient == nullptr) {
diff --git a/android/1.0/GnssGeofencing.h b/android/1.0/GnssGeofencing.h
index 64f74a9..12037e5 100644
--- a/android/1.0/GnssGeofencing.h
+++ b/android/1.0/GnssGeofencing.h
@@ -76,6 +76,8 @@ struct GnssGeofencing : public IGnssGeofencing {
const wp<GnssGeofencing> mGnssGeofencing;
};
+ void handleClientDeath();
+
private:
// this has to be a reference, not a copy
// because the pointer is not set when mSelf is assigned
diff --git a/android/1.0/GnssMeasurement.cpp b/android/1.0/GnssMeasurement.cpp
index 6ee9c76..cb77a2b 100644
--- a/android/1.0/GnssMeasurement.cpp
+++ b/android/1.0/GnssMeasurement.cpp
@@ -36,7 +36,7 @@ void GnssMeasurement::GnssMeasurementDeathRecipient::serviceDied(
__FUNCTION__, static_cast<unsigned long long>(cookie), &who);
auto gssMeasurement = mGnssMeasurement.promote();
if (gssMeasurement != nullptr) {
- gssMeasurement->close();
+ gssMeasurement->handleClientDeath();
}
}
@@ -51,6 +51,15 @@ GnssMeasurement::~GnssMeasurement() {
}
}
+void GnssMeasurement::handleClientDeath() {
+
+ close();
+ if (mApi != nullptr) {
+ mApi->measurementSetCallback(nullptr);
+ }
+ mGnssMeasurementCbIface = nullptr;
+}
+
// Methods from ::android::hardware::gnss::V1_0::IGnssMeasurement follow.
Return<IGnssMeasurement::GnssMeasurementStatus> GnssMeasurement::setCallback(
diff --git a/android/1.0/GnssMeasurement.h b/android/1.0/GnssMeasurement.h
index 3cf962a..8c923f3 100644
--- a/android/1.0/GnssMeasurement.h
+++ b/android/1.0/GnssMeasurement.h
@@ -62,6 +62,8 @@ struct GnssMeasurement : public IGnssMeasurement {
const wp<GnssMeasurement> mGnssMeasurement;
};
+ void handleClientDeath();
+
private:
// this has to be a reference, not a copy
// because the pointer is not set when mSelf is assigned
diff --git a/android/1.1/Gnss.cpp b/android/1.1/Gnss.cpp
index 39e7128..e67d877 100644
--- a/android/1.1/Gnss.cpp
+++ b/android/1.1/Gnss.cpp
@@ -85,8 +85,7 @@ void Gnss::GnssDeathRecipient::serviceDied(uint64_t cookie, const wp<IBase>& who
__FUNCTION__, static_cast<unsigned long long>(cookie), &who);
auto gnss = mGnss.promote();
if (gnss != nullptr) {
- gnss->getGnssInterface()->resetNetworkInfo();
- gnss->cleanup();
+ gnss->handleClientDeath();
}
}
@@ -118,6 +117,17 @@ Gnss::~Gnss() {
sGnss = nullptr;
}
+void Gnss::handleClientDeath() {
+ getGnssInterface()->resetNetworkInfo();
+ cleanup();
+ if (mApi != nullptr) {
+ mApi->gnssUpdateCallbacks(nullptr, nullptr);
+ }
+ mGnssCbIface = nullptr;
+ mGnssNiCbIface = nullptr;
+ mGnssCbIface_1_1 = nullptr;
+}
+
GnssAPIClient* Gnss::getApi() {
if (mApi == nullptr && (mGnssCbIface != nullptr || mGnssNiCbIface != nullptr)) {
mApi = new GnssAPIClient(mGnssCbIface, mGnssNiCbIface);
diff --git a/android/1.1/Gnss.h b/android/1.1/Gnss.h
index 31d8823..83129ff 100644
--- a/android/1.1/Gnss.h
+++ b/android/1.1/Gnss.h
@@ -123,6 +123,8 @@ struct Gnss : public IGnss {
const wp<Gnss> mGnss;
};
+ void handleClientDeath();
+
private:
sp<GnssDeathRecipient> mGnssDeathRecipient = nullptr;
diff --git a/android/1.1/GnssBatching.cpp b/android/1.1/GnssBatching.cpp
index b78e3b3..90362da 100644
--- a/android/1.1/GnssBatching.cpp
+++ b/android/1.1/GnssBatching.cpp
@@ -36,8 +36,7 @@ void GnssBatching::GnssBatchingDeathRecipient::serviceDied(
__FUNCTION__, static_cast<unsigned long long>(cookie), &who);
auto gnssBatching = mGnssBatching.promote();
if (gnssBatching != nullptr) {
- gnssBatching->stop();
- gnssBatching->cleanup();
+ gnssBatching->handleClientDeath();
}
}
@@ -48,6 +47,14 @@ GnssBatching::~GnssBatching() {
}
}
+GnssBatching::handleClientDeath() {
+ stop();
+ cleanup();
+ if (mApi != nullptr) {
+ mApi->gnssUpdateCallbacks(nullptr);
+ }
+ mGnssBatchingCbIface = nullptr;
+}
// Methods from ::android::hardware::gnss::V1_0::IGnssBatching follow.
Return<bool> GnssBatching::init(const sp<IGnssBatchingCallback>& callback) {
diff --git a/android/1.1/GnssBatching.h b/android/1.1/GnssBatching.h
index 0697ecb..309dc4a 100644
--- a/android/1.1/GnssBatching.h
+++ b/android/1.1/GnssBatching.h
@@ -65,6 +65,8 @@ struct GnssBatching : public IGnssBatching {
const wp<GnssBatching> mGnssBatching;
};
+ void handleClientDeath();
+
private:
// this has to be a reference, not a copy
// because the pointer is not set when mSelf is assigned
diff --git a/android/1.1/GnssGeofencing.cpp b/android/1.1/GnssGeofencing.cpp
index 4e45ae0..6691ace 100644
--- a/android/1.1/GnssGeofencing.cpp
+++ b/android/1.1/GnssGeofencing.cpp
@@ -36,7 +36,7 @@ void GnssGeofencing::GnssGeofencingDeathRecipient::serviceDied(
__FUNCTION__, static_cast<unsigned long long>(cookie), &who);
auto gnssGeofencing = mGnssGeofencing.promote();
if (gnssGeofencing != nullptr) {
- gnssGeofencing->removeAllGeofences();
+ gnssGeofencing->handleClientDeath();
}
}
@@ -47,6 +47,15 @@ GnssGeofencing::~GnssGeofencing() {
}
}
+void GnssGeofencing::handleClientDeath() {
+
+ removeAllGeofences();
+ if (mApi != nullptr) {
+ mApi->upcateCallback(nullptr);
+ }
+ mGnssGeofencingCbIface = nullptr;
+}
+
// Methods from ::android::hardware::gnss::V1_0::IGnssGeofencing follow.
Return<void> GnssGeofencing::setCallback(const sp<IGnssGeofenceCallback>& callback) {
if (mGnssGeofencingDeathRecipient == nullptr) {
diff --git a/android/1.1/GnssGeofencing.h b/android/1.1/GnssGeofencing.h
index 892bae4..59c072a 100644
--- a/android/1.1/GnssGeofencing.h
+++ b/android/1.1/GnssGeofencing.h
@@ -76,6 +76,8 @@ struct GnssGeofencing : public IGnssGeofencing {
const wp<GnssGeofencing> mGnssGeofencing;
};
+ void handleClientDeath();
+
private:
// this has to be a reference, not a copy
// because the pointer is not set when mSelf is assigned
diff --git a/android/1.1/GnssMeasurement.cpp b/android/1.1/GnssMeasurement.cpp
index a43dc11..c44058d 100644
--- a/android/1.1/GnssMeasurement.cpp
+++ b/android/1.1/GnssMeasurement.cpp
@@ -36,7 +36,7 @@ void GnssMeasurement::GnssMeasurementDeathRecipient::serviceDied(
__FUNCTION__, static_cast<unsigned long long>(cookie), &who);
auto gssMeasurement = mGnssMeasurement.promote();
if (gssMeasurement != nullptr) {
- gssMeasurement->close();
+ gssMeasurement->handleClientDeath();
}
}
@@ -51,6 +51,17 @@ GnssMeasurement::~GnssMeasurement() {
}
}
+void GnssMeasurement::handleClientDeath() {
+
+ close();
+ if (mApi != nullptr) {
+ mApi->measurementSetCallback(nullptr);
+ mApi->measurementSetCallback_1_1(nullptr);
+ }
+ mGnssMeasurementCbIface = nullptr;
+ mGnssMeasurementCbIface_1_1 = nullptr;
+}
+
// Methods from ::android::hardware::gnss::V1_0::IGnssMeasurement follow.
Return<IGnssMeasurement::GnssMeasurementStatus> GnssMeasurement::setCallback(
diff --git a/android/1.1/GnssMeasurement.h b/android/1.1/GnssMeasurement.h
index bb0d10f..509338c 100644
--- a/android/1.1/GnssMeasurement.h
+++ b/android/1.1/GnssMeasurement.h
@@ -67,6 +67,8 @@ struct GnssMeasurement : public IGnssMeasurement {
const wp<GnssMeasurement> mGnssMeasurement;
};
+ void handleClientDeath();
+
private:
// this has to be a reference, not a copy
// because the pointer is not set when mSelf is assigned
diff --git a/android/2.0/Gnss.cpp b/android/2.0/Gnss.cpp
index 48afc1e..dfdbe1b 100644
--- a/android/2.0/Gnss.cpp
+++ b/android/2.0/Gnss.cpp
@@ -85,8 +85,7 @@ void Gnss::GnssDeathRecipient::serviceDied(uint64_t cookie, const wp<IBase>& who
__FUNCTION__, static_cast<unsigned long long>(cookie), &who);
auto gnss = mGnss.promote();
if (gnss != nullptr) {
- gnss->getGnssInterface()->resetNetworkInfo();
- gnss->cleanup();
+ gnss->handleClientDeath();
}
}
@@ -117,6 +116,19 @@ Gnss::~Gnss() {
sGnss = nullptr;
}
+void Gnss::handleClientDeath() {
+ getGnssInterface()->resetNetworkInfo();
+ cleanup();
+ if (mApi != nullptr) {
+ mApi->gnssUpdateCallbacks(nullptr, nullptr);
+ mApi->gnssUpdateCallbacks_2_0(nullptr);
+ }
+ mGnssCbIface = nullptr;
+ mGnssNiCbIface = nullptr;
+ mGnssCbIface_1_1 = nullptr;
+ mGnssCbIface_2_0 = nullptr;
+}
+
GnssAPIClient* Gnss::getApi() {
if (mApi != nullptr) {
return mApi;
diff --git a/android/2.0/Gnss.h b/android/2.0/Gnss.h
index d1eefea..6391a63 100644
--- a/android/2.0/Gnss.h
+++ b/android/2.0/Gnss.h
@@ -152,6 +152,8 @@ struct Gnss : public IGnss {
const wp<Gnss> mGnss;
};
+ void handleClientDeath();
+
private:
sp<GnssDeathRecipient> mGnssDeathRecipient = nullptr;
@@ -165,7 +167,7 @@ struct Gnss : public IGnss {
sp<V2_0::IAGnssRil> mGnssRil = nullptr;
sp<GnssMeasurement> mGnssMeasurement = nullptr;
sp<V2_0::IGnssConfiguration> mGnssConfig = nullptr;
- sp<V2_0::IGnssBatching> mGnssBatching = nullptr;
+ sp<GnssBatching> mGnssBatching = nullptr;
sp<V2_0::IGnssDebug> mGnssDebug = nullptr;
sp<V2_0::IGnssCallback> mGnssCbIface_2_0 = nullptr;
sp<IMeasurementCorrections> mGnssMeasCorr = nullptr;
diff --git a/android/2.0/GnssBatching.cpp b/android/2.0/GnssBatching.cpp
index 6bc79b2..70a8744 100644
--- a/android/2.0/GnssBatching.cpp
+++ b/android/2.0/GnssBatching.cpp
@@ -34,6 +34,11 @@ void GnssBatching::GnssBatchingDeathRecipient::serviceDied(
uint64_t cookie, const wp<IBase>& who) {
LOC_LOGE("%s] service died. cookie: %llu, who: %p",
__FUNCTION__, static_cast<unsigned long long>(cookie), &who);
+
+ auto gnssBatching = mGnssBatching.promote();
+ if (gnssBatching != nullptr) {
+ gnssBatching->handleClientDeath();
+ }
}
GnssBatching::~GnssBatching() {
@@ -43,6 +48,17 @@ GnssBatching::~GnssBatching() {
}
}
+GnssBatching::handleClientDeath() {
+
+ stop();
+ cleanup();
+ if (mApi != nullptr) {
+ mApi->gnssUpdateCallbacks_2_0(nullptr);
+ mApi->gnssUpdateCallbacks(nullptr);
+ }
+ mGnssBatchingCbIface_2_0 = nullptr;
+ mGnssBatchingCbIface = nullptr;
+}
// Methods from ::android::hardware::gnss::V1_0::IGnssBatching follow.
Return<bool> GnssBatching::init(const sp<V1_0::IGnssBatchingCallback>& callback) {
diff --git a/android/2.0/GnssBatching.h b/android/2.0/GnssBatching.h
index d8d689d..a3e78bc 100644
--- a/android/2.0/GnssBatching.h
+++ b/android/2.0/GnssBatching.h
@@ -44,7 +44,7 @@ using ::android::sp;
class BatchingAPIClient;
struct GnssBatching : public IGnssBatching {
- inline GnssBatching(const sp<IGnssBatching>& self) : mSelf(self), mApi(nullptr) {}
+ inline GnssBatching(const sp<GnssBatching>& self) : mSelf(self), mApi(nullptr) {}
~GnssBatching();
// Methods from ::android::hardware::gnss::V1_0::IGnssBatching follow.
@@ -60,18 +60,20 @@ struct GnssBatching : public IGnssBatching {
private:
struct GnssBatchingDeathRecipient : hidl_death_recipient {
- GnssBatchingDeathRecipient(const sp<IGnssBatching>& gnssBatching) :
+ GnssBatchingDeathRecipient(const sp<GnssBatching>& gnssBatching) :
mGnssBatching(gnssBatching) {
}
~GnssBatchingDeathRecipient() = default;
virtual void serviceDied(uint64_t cookie, const wp<IBase>& who) override;
- const wp<IGnssBatching> mGnssBatching;
+ const wp<GnssBatching> mGnssBatching;
};
+ void handleClientDeath();
+
private:
// this has to be a reference, not a copy
// because the pointer is not set when mSelf is assigned
- const sp<IGnssBatching>& mSelf;
+ const sp<GnssBatching>& mSelf;
sp<GnssBatchingDeathRecipient> mGnssBatchingDeathRecipient = nullptr;
sp<V1_0::IGnssBatchingCallback> mGnssBatchingCbIface = nullptr;
BatchingAPIClient* mApi = nullptr;
diff --git a/android/2.0/GnssGeofencing.cpp b/android/2.0/GnssGeofencing.cpp
index 44c514b..8d53c59 100644
--- a/android/2.0/GnssGeofencing.cpp
+++ b/android/2.0/GnssGeofencing.cpp
@@ -36,7 +36,7 @@ void GnssGeofencing::GnssGeofencingDeathRecipient::serviceDied(
__FUNCTION__, static_cast<unsigned long long>(cookie), &who);
auto gnssGeofencing = mGnssGeofencing.promote();
if (gnssGeofencing != nullptr) {
- gnssGeofencing->removeAllGeofences();
+ gnssGeofencing->handleClientDeath();
}
}
@@ -47,6 +47,15 @@ GnssGeofencing::~GnssGeofencing() {
}
}
+void GnssGeofencing::handleClientDeath() {
+
+ removeAllGeofences();
+ if (mApi != nullptr) {
+ mApi->upcateCallback(nullptr);
+ }
+ mGnssGeofencingCbIface = nullptr;
+}
+
// Methods from ::android::hardware::gnss::V1_0::IGnssGeofencing follow.
Return<void> GnssGeofencing::setCallback(const sp<IGnssGeofenceCallback>& callback) {
if (mGnssGeofencingDeathRecipient == nullptr) {
diff --git a/android/2.0/GnssGeofencing.h b/android/2.0/GnssGeofencing.h
index 42b22ac..97110d3 100644
--- a/android/2.0/GnssGeofencing.h
+++ b/android/2.0/GnssGeofencing.h
@@ -76,6 +76,8 @@ struct GnssGeofencing : public IGnssGeofencing {
const wp<GnssGeofencing> mGnssGeofencing;
};
+ void handleClientDeath();
+
private:
// this has to be a reference, not a copy
// because the pointer is not set when mSelf is assigned
diff --git a/android/2.0/GnssMeasurement.cpp b/android/2.0/GnssMeasurement.cpp
index a1c22cf..a78fca3 100644
--- a/android/2.0/GnssMeasurement.cpp
+++ b/android/2.0/GnssMeasurement.cpp
@@ -36,7 +36,7 @@ void GnssMeasurement::GnssMeasurementDeathRecipient::serviceDied(
__FUNCTION__, static_cast<unsigned long long>(cookie), &who);
auto gssMeasurement = mGnssMeasurement.promote();
if (gssMeasurement != nullptr) {
- gssMeasurement->close();
+ gssMeasurement->handleClientDeath();
}
}
@@ -51,6 +51,19 @@ GnssMeasurement::~GnssMeasurement() {
}
}
+void GnssMeasurement::handleClientDeath() {
+
+ close();
+ if (mApi != nullptr) {
+ mApi->measurementSetCallback(nullptr);
+ mApi->measurementSetCallback_1_1(nullptr);
+ mApi->measurementSetCallback_2_0(nullptr);
+ }
+ mGnssMeasurementCbIface = nullptr;
+ mGnssMeasurementCbIface_1_1 = nullptr;
+ mGnssMeasurementCbIface_2_0 = nullptr;
+}
+
// Methods from ::android::hardware::gnss::V1_0::IGnssMeasurement follow.
Return<GnssMeasurement::GnssMeasurementStatus> GnssMeasurement::setCallback(
const sp<V1_0::IGnssMeasurementCallback>& callback) {
diff --git a/android/2.0/GnssMeasurement.h b/android/2.0/GnssMeasurement.h
index 95abc97..55c1578 100644
--- a/android/2.0/GnssMeasurement.h
+++ b/android/2.0/GnssMeasurement.h
@@ -69,6 +69,8 @@ struct GnssMeasurement : public V2_0::IGnssMeasurement {
const wp<GnssMeasurement> mGnssMeasurement;
};
+ void handleClientDeath();
+
private:
// this has to be a reference, not a copy
// because the pointer is not set when mSelf is assigned
diff --git a/android/2.1/Gnss.cpp b/android/2.1/Gnss.cpp
index ec297f9..cbdb5d8 100644
--- a/android/2.1/Gnss.cpp
+++ b/android/2.1/Gnss.cpp
@@ -87,8 +87,7 @@ void Gnss::GnssDeathRecipient::serviceDied(uint64_t cookie, const wp<IBase>& who
__FUNCTION__, static_cast<unsigned long long>(cookie), &who);
auto gnss = mGnss.promote();
if (gnss != nullptr) {
- gnss->getGnssInterface()->resetNetworkInfo();
- gnss->cleanup();
+ gnss->handleClientDeath();
}
}
@@ -119,6 +118,21 @@ Gnss::~Gnss() {
sGnss = nullptr;
}
+void Gnss::handleClientDeath() {
+ getGnssInterface()->resetNetworkInfo();
+ cleanup();
+ if (mApi != nullptr) {
+ mApi->gnssUpdateCallbacks(nullptr, nullptr);
+ mApi->gnssUpdateCallbacks_2_0(nullptr);
+ mApi->gnssUpdateCallbacks_2_1(nullptr);
+ }
+ mGnssCbIface = nullptr;
+ mGnssNiCbIface = nullptr;
+ mGnssCbIface_1_1 = nullptr;
+ mGnssCbIface_2_0 = nullptr;
+ mGnssCbIface_2_1 = nullptr;
+}
+
GnssAPIClient* Gnss::getApi() {
if (mApi != nullptr) {
return mApi;
diff --git a/android/2.1/Gnss.h b/android/2.1/Gnss.h
index 885191c..28b1959 100644
--- a/android/2.1/Gnss.h
+++ b/android/2.1/Gnss.h
@@ -156,6 +156,8 @@ struct Gnss : public IGnss {
const wp<Gnss> mGnss;
};
+ void handleClientDeath();
+
private:
sp<GnssDeathRecipient> mGnssDeathRecipient = nullptr;
@@ -167,7 +169,7 @@ struct Gnss : public IGnss {
sp<V1_1::IGnssCallback> mGnssCbIface_1_1 = nullptr;
sp<V2_0::IAGnss> mAGnssIface_2_0 = nullptr;
sp<V2_0::IAGnssRil> mGnssRil = nullptr;
- sp<V2_0::IGnssBatching> mGnssBatching = nullptr;
+ sp<GnssBatching> mGnssBatching = nullptr;
sp<V2_0::IGnssDebug> mGnssDebug = nullptr;
sp<V2_0::IGnssCallback> mGnssCbIface_2_0 = nullptr;
sp<V2_1::IGnssCallback> mGnssCbIface_2_1 = nullptr;
diff --git a/android/2.1/GnssBatching.cpp b/android/2.1/GnssBatching.cpp
index 1165bd8..a5513a6 100644
--- a/android/2.1/GnssBatching.cpp
+++ b/android/2.1/GnssBatching.cpp
@@ -36,8 +36,7 @@ void GnssBatching::GnssBatchingDeathRecipient::serviceDied(
__FUNCTION__, static_cast<unsigned long long>(cookie), &who);
auto gnssBatching = mGnssBatching.promote();
if (gnssBatching != nullptr) {
- gnssBatching->stop();
- gnssBatching->cleanup();
+ gnssBatching->handleClientDeath();
}
}
@@ -48,6 +47,17 @@ GnssBatching::~GnssBatching() {
}
}
+void GnssBatching::handleClientDeath() {
+
+ stop();
+ cleanup();
+ if (mApi != nullptr) {
+ mApi->gnssUpdateCallbacks_2_0(nullptr);
+ mApi->gnssUpdateCallbacks(nullptr);
+ }
+ mGnssBatchingCbIface_2_0 = nullptr;
+ mGnssBatchingCbIface = nullptr;
+}
// Methods from ::android::hardware::gnss::V1_0::IGnssBatching follow.
Return<bool> GnssBatching::init(const sp<V1_0::IGnssBatchingCallback>& callback) {
diff --git a/android/2.1/GnssBatching.h b/android/2.1/GnssBatching.h
index 84cbd91..7609245 100644
--- a/android/2.1/GnssBatching.h
+++ b/android/2.1/GnssBatching.h
@@ -44,7 +44,7 @@ using ::android::sp;
class BatchingAPIClient;
struct GnssBatching : public IGnssBatching {
- inline GnssBatching(const sp<IGnssBatching>& self) : mSelf(self), mApi(nullptr) {}
+ inline GnssBatching(const sp<GnssBatching>& self) : mSelf(self), mApi(nullptr) {}
~GnssBatching();
// Methods from ::android::hardware::gnss::V1_0::IGnssBatching follow.
@@ -60,18 +60,20 @@ struct GnssBatching : public IGnssBatching {
private:
struct GnssBatchingDeathRecipient : hidl_death_recipient {
- GnssBatchingDeathRecipient(const sp<IGnssBatching>& gnssBatching) :
+ GnssBatchingDeathRecipient(const sp<GnssBatching>& gnssBatching) :
mGnssBatching(gnssBatching) {
}
~GnssBatchingDeathRecipient() = default;
virtual void serviceDied(uint64_t cookie, const wp<IBase>& who) override;
- const wp<IGnssBatching> mGnssBatching;
+ const wp<GnssBatching> mGnssBatching;
};
+ void handleClientDeath();
+
private:
// this has to be a reference, not a copy
// because the pointer is not set when mSelf is assigned
- const sp<IGnssBatching>& mSelf;
+ const sp<GnssBatching>& mSelf;
sp<GnssBatchingDeathRecipient> mGnssBatchingDeathRecipient = nullptr;
sp<V1_0::IGnssBatchingCallback> mGnssBatchingCbIface = nullptr;
BatchingAPIClient* mApi = nullptr;
diff --git a/android/2.1/GnssGeofencing.cpp b/android/2.1/GnssGeofencing.cpp
index d309731..35a641a 100644
--- a/android/2.1/GnssGeofencing.cpp
+++ b/android/2.1/GnssGeofencing.cpp
@@ -36,7 +36,7 @@ void GnssGeofencing::GnssGeofencingDeathRecipient::serviceDied(
__FUNCTION__, static_cast<unsigned long long>(cookie), &who);
auto gnssGeofencing = mGnssGeofencing.promote();
if (gnssGeofencing != nullptr) {
- gnssGeofencing->removeAllGeofences();
+ gnssGeofencing->handleClientDeath();
}
}
@@ -47,6 +47,15 @@ GnssGeofencing::~GnssGeofencing() {
}
}
+void GnssGeofencing::handleClientDeath() {
+
+ removeAllGeofences();
+ if (mApi != nullptr) {
+ mApi->upcateCallback(nullptr);
+ }
+ mGnssGeofencingCbIface = nullptr;
+}
+
// Methods from ::android::hardware::gnss::V1_0::IGnssGeofencing follow.
Return<void> GnssGeofencing::setCallback(const sp<IGnssGeofenceCallback>& callback) {
if (mGnssGeofencingDeathRecipient == nullptr) {
diff --git a/android/2.1/GnssGeofencing.h b/android/2.1/GnssGeofencing.h
index 2860134..9d0330c 100644
--- a/android/2.1/GnssGeofencing.h
+++ b/android/2.1/GnssGeofencing.h
@@ -65,6 +65,7 @@ struct GnssGeofencing : public IGnssGeofencing {
// This method is not part of the IGnss base class.
// It is called by GnssGeofencingDeathRecipient to remove all geofences added so far.
Return<void> removeAllGeofences();
+ void handleClientDeath();
private:
struct GnssGeofencingDeathRecipient : hidl_death_recipient {
diff --git a/android/2.1/GnssMeasurement.cpp b/android/2.1/GnssMeasurement.cpp
index dfb464d..b6b3e59 100644
--- a/android/2.1/GnssMeasurement.cpp
+++ b/android/2.1/GnssMeasurement.cpp
@@ -36,7 +36,7 @@ void GnssMeasurement::GnssMeasurementDeathRecipient::serviceDied(
__FUNCTION__, static_cast<unsigned long long>(cookie), &who);
auto gssMeasurement = mGnssMeasurement.promote();
if (gssMeasurement != nullptr) {
- gssMeasurement->close();
+ gssMeasurement->handleClientDeath();
}
}
@@ -51,6 +51,21 @@ GnssMeasurement::~GnssMeasurement() {
}
}
+void GnssMeasurement::handleClientDeath() {
+
+ close();
+ if (mApi != nullptr) {
+ mApi->measurementSetCallback(nullptr);
+ mApi->measurementSetCallback_1_1(nullptr);
+ mApi->measurementSetCallback_2_0(nullptr);
+ mApi->measurementSetCallback_2_1(nullptr);
+ }
+ mGnssMeasurementCbIface = nullptr;
+ mGnssMeasurementCbIface_1_1 = nullptr;
+ mGnssMeasurementCbIface_2_0 = nullptr;
+ mGnssMeasurementCbIface_2_1 = nullptr;
+}
+
// Methods from ::android::hardware::gnss::V1_0::IGnssMeasurement follow.
Return<GnssMeasurement::GnssMeasurementStatus> GnssMeasurement::setCallback(
const sp<V1_0::IGnssMeasurementCallback>& callback) {
diff --git a/android/2.1/GnssMeasurement.h b/android/2.1/GnssMeasurement.h
index 65e4ee3..7111579 100644
--- a/android/2.1/GnssMeasurement.h
+++ b/android/2.1/GnssMeasurement.h
@@ -74,6 +74,8 @@ struct GnssMeasurement : public V2_1::IGnssMeasurement {
const wp<GnssMeasurement> mGnssMeasurement;
};
+ void handleClientDeath();
+
private:
// this has to be a reference, not a copy
// because the pointer is not set when mSelf is assigned
diff --git a/android/aidl-impl/Gnss.cpp b/android/aidl-impl/Gnss.cpp
index 9dcb1bb..4e2c2e6 100644
--- a/android/aidl-impl/Gnss.cpp
+++ b/android/aidl-impl/Gnss.cpp
@@ -34,9 +34,8 @@ namespace implementation {
void gnssCallbackDied(void* cookie) {
LOC_LOGe("IGnssCallback AIDL service died");
Gnss* iface = static_cast<Gnss*>(cookie);
- //clean up, i.e. iface->close();
if (iface != nullptr) {
- iface->close();
+ iface->handleClientDeath();
}
}
ndk::ScopedAStatus Gnss::setCallback(const std::shared_ptr<IGnssCallback>& callback) {
@@ -82,6 +81,14 @@ Gnss::~Gnss() {
}
}
+void Gnss::handleClientDeath() {
+ close();
+ if (mApi != nullptr) {
+ mApi->gnssUpdateCallbacks(mGnssCallback);
+ }
+ mGnssCallback = nullptr;
+}
+
ndk::ScopedAStatus Gnss::updateConfiguration(GnssConfig& gnssConfig) {
ENTRY_LOG_CALLFLOW();
GnssAPIClient* api = getApi();
diff --git a/android/aidl-impl/Gnss.h b/android/aidl-impl/Gnss.h
index 3e87707..4063180 100644
--- a/android/aidl-impl/Gnss.h
+++ b/android/aidl-impl/Gnss.h
@@ -68,6 +68,8 @@ struct Gnss : public BnGnss {
// These methods are not part of the IGnss base class.
GnssAPIClient* getApi();
ndk::ScopedAStatus updateConfiguration(GnssConfig& gnssConfig);
+ void handleClientDeath();
+
private:
GnssAPIClient* mApi;
shared_ptr<GnssConfiguration> mGnssConfiguration = nullptr;