Merge "Link to death recipient for AIDL HAL" into tm-dev

This commit is contained in:
TreeHugger Robot
2022-03-31 22:14:10 +00:00
committed by Android (Google) Code Review
2 changed files with 23 additions and 2 deletions

View File

@@ -170,7 +170,15 @@ jboolean GnssHal::isSupported() {
} }
void GnssHal::linkToDeath() { void GnssHal::linkToDeath() {
// TODO: linkToDeath for AIDL HAL if (gnssHalAidl != nullptr) {
gnssHalDeathRecipientAidl = new GnssDeathRecipientAidl();
status_t linked = IInterface::asBinder(gnssHalAidl)->linkToDeath(gnssHalDeathRecipientAidl);
if (linked != OK) {
ALOGE("Unable to link to GNSS AIDL HAL death notification");
} else {
ALOGD("Successfully linked to GNSS AIDL HAl death notification");
}
}
if (gnssHal != nullptr) { if (gnssHal != nullptr) {
gnssHalDeathRecipient = new GnssDeathRecipient(); gnssHalDeathRecipient = new GnssDeathRecipient();

View File

@@ -28,6 +28,7 @@
#include <android/hardware/gnss/2.0/IGnss.h> #include <android/hardware/gnss/2.0/IGnss.h>
#include <android/hardware/gnss/2.1/IGnss.h> #include <android/hardware/gnss/2.1/IGnss.h>
#include <android/hardware/gnss/BnGnss.h> #include <android/hardware/gnss/BnGnss.h>
#include <binder/IBinder.h>
#include <log/log.h> #include <log/log.h>
#include "AGnss.h" #include "AGnss.h"
@@ -50,13 +51,24 @@ namespace android::gnss {
struct GnssDeathRecipient : virtual public hardware::hidl_death_recipient { struct GnssDeathRecipient : virtual public hardware::hidl_death_recipient {
// hidl_death_recipient interface // hidl_death_recipient interface
virtual void serviceDied(uint64_t cookie, const wp<hidl::base::V1_0::IBase>& who) override { virtual void serviceDied(uint64_t cookie, const wp<hidl::base::V1_0::IBase>& who) override {
ALOGE("IGNSS hidl service failed, trying to recover..."); ALOGE("GNSS HIDL service failed, trying to recover...");
onServiceDied();
}
static void onServiceDied() {
JNIEnv* env = android::AndroidRuntime::getJNIEnv(); JNIEnv* env = android::AndroidRuntime::getJNIEnv();
env->CallVoidMethod(android::mCallbacksObj, method_reportGnssServiceDied); env->CallVoidMethod(android::mCallbacksObj, method_reportGnssServiceDied);
} }
}; };
struct GnssDeathRecipientAidl : virtual public IBinder::DeathRecipient {
// IBinder::DeathRecipient implementation
virtual void binderDied(const wp<IBinder>& who) override {
ALOGE("GNSS AIDL service failed, trying to recover...");
GnssDeathRecipient::onServiceDied();
}
};
class GnssHal { class GnssHal {
public: public:
GnssHal(); GnssHal();
@@ -109,6 +121,7 @@ public:
private: private:
sp<GnssDeathRecipient> gnssHalDeathRecipient = nullptr; sp<GnssDeathRecipient> gnssHalDeathRecipient = nullptr;
sp<GnssDeathRecipientAidl> gnssHalDeathRecipientAidl = nullptr;
sp<hardware::gnss::V1_0::IGnss> gnssHal = nullptr; sp<hardware::gnss::V1_0::IGnss> gnssHal = nullptr;
sp<hardware::gnss::V1_1::IGnss> gnssHal_V1_1 = nullptr; sp<hardware::gnss::V1_1::IGnss> gnssHal_V1_1 = nullptr;
sp<hardware::gnss::V2_0::IGnss> gnssHal_V2_0 = nullptr; sp<hardware::gnss::V2_0::IGnss> gnssHal_V2_0 = nullptr;