wpa: Terminate on callback client death
supplicant/hostapd are single client HAL's. So, the daemon should
terminate when the client is dead.
Also, removed a bunch of TODO's/#ifdef guarding death notification
handling in supplicant.
Bug: 169651797
Test: Manual
i) adb shell stop
ii) Ensure wpa_supplicant is killed (via ps-ef & lshal)
Change-Id: I0d32f2a91cbe807145fe0c544460467ff24fa2cc
diff --git a/hostapd/hidl/1.3/hostapd.cpp b/hostapd/hidl/1.3/hostapd.cpp
index 17dd7f5..668d8f4 100644
--- a/hostapd/hidl/1.3/hostapd.cpp
+++ b/hostapd/hidl/1.3/hostapd.cpp
@@ -20,7 +20,6 @@
extern "C"
{
#include "common/wpa_ctrl.h"
-#include "utils/eloop.h"
}
// The HIDL implementation for hostapd creates a hostapd.conf dynamically for
@@ -550,7 +549,8 @@
using hidl_return_util::call;
using namespace android::hardware::wifi::hostapd::V1_0;
-Hostapd::Hostapd(struct hapd_interfaces* interfaces) : interfaces_(interfaces)
+Hostapd::Hostapd(struct hapd_interfaces* interfaces)
+ : interfaces_(interfaces), death_notifier_(sp<DeathNotifier>::make())
{}
Return<void> Hostapd::addAccessPoint(
@@ -779,6 +779,13 @@
V1_2::HostapdStatus Hostapd::registerCallbackInternal_1_3(
const sp<V1_3::IHostapdCallback>& callback)
{
+ if (!callback->linkToDeath(death_notifier_, 0)) {
+ wpa_printf(
+ MSG_ERROR,
+ "Error registering for death notification for "
+ "hostapd callback object");
+ return {V1_2::HostapdStatusCode::FAILURE_UNKNOWN, ""};
+ }
callbacks_.push_back(callback);
return {V1_2::HostapdStatusCode::SUCCESS, ""};
}
diff --git a/hostapd/hidl/1.3/hostapd.h b/hostapd/hidl/1.3/hostapd.h
index 059e24a..79354d3 100644
--- a/hostapd/hidl/1.3/hostapd.h
+++ b/hostapd/hidl/1.3/hostapd.h
@@ -20,12 +20,26 @@
extern "C"
{
#include "utils/common.h"
+#include "utils/eloop.h"
#include "utils/includes.h"
#include "utils/wpa_debug.h"
#include "ap/hostapd.h"
#include "ap/sta_info.h"
}
+class DeathNotifier : public android::hardware::hidl_death_recipient
+{
+public:
+ void serviceDied(
+ uint64_t /*cookie*/,
+ const android::wp<android::hidl::base::V1_0::IBase>
+ & /* who */) override
+ {
+ wpa_printf(MSG_ERROR, "Client died. Terminating...");
+ eloop_terminate();
+ }
+};
+
namespace android {
namespace hardware {
namespace wifi {
@@ -104,6 +118,8 @@
struct hapd_interfaces* interfaces_;
// Callbacks registered.
std::vector<sp<V1_3::IHostapdCallback>> callbacks_;
+ // Death notifier.
+ android::sp<DeathNotifier> death_notifier_;
DISALLOW_COPY_AND_ASSIGN(Hostapd);
};
} // namespace implementation