Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 67059aae authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

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

parents 6ad5af88 83c0e195
Loading
Loading
Loading
Loading
+9 −1
Original line number Diff line number Diff line
@@ -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();
+14 −1
Original line number Diff line number Diff line
@@ -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;