Merge "Link to death recipient for AIDL HAL" into tm-dev am: 67059aaeae

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/17511186

Change-Id: I548d1feccf505a2737ba99a0cb9b0890086ed975
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
TreeHugger Robot
2022-03-31 22:28:55 +00:00
committed by Automerger Merge Worker
2 changed files with 23 additions and 2 deletions

View File

@@ -170,7 +170,15 @@ jboolean GnssHal::isSupported() {
}
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) {
gnssHalDeathRecipient = new GnssDeathRecipient();

View File

@@ -28,6 +28,7 @@
#include <android/hardware/gnss/2.0/IGnss.h>
#include <android/hardware/gnss/2.1/IGnss.h>
#include <android/hardware/gnss/BnGnss.h>
#include <binder/IBinder.h>
#include <log/log.h>
#include "AGnss.h"
@@ -50,13 +51,24 @@ namespace android::gnss {
struct GnssDeathRecipient : virtual public hardware::hidl_death_recipient {
// hidl_death_recipient interface
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();
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 {
public:
GnssHal();
@@ -109,6 +121,7 @@ public:
private:
sp<GnssDeathRecipient> gnssHalDeathRecipient = nullptr;
sp<GnssDeathRecipientAidl> gnssHalDeathRecipientAidl = nullptr;
sp<hardware::gnss::V1_0::IGnss> gnssHal = nullptr;
sp<hardware::gnss::V1_1::IGnss> gnssHal_V1_1 = nullptr;
sp<hardware::gnss::V2_0::IGnss> gnssHal_V2_0 = nullptr;