Send network not found event to framework
When supplicant is not able to find a suitable
network to connect, inform framework through
onNetworkNotFound() callback function.
Bug: 161196120
Test: VTS test
Test: Manual - Created a test scenario for not finding a suitable
network.
Change-Id: I35199e003cfd5f8e9a98a0357e0094665a115f96
diff --git a/wpa_supplicant/events.c b/wpa_supplicant/events.c
index dda958b..3165903 100644
--- a/wpa_supplicant/events.c
+++ b/wpa_supplicant/events.c
@@ -2372,6 +2372,7 @@
wpa_msg_ctrl(wpa_s, MSG_INFO,
WPA_EVENT_NETWORK_NOT_FOUND);
+ wpas_notify_network_not_found(wpa_s);
}
}
return 0;
diff --git a/wpa_supplicant/hidl/1.4/hidl.cpp b/wpa_supplicant/hidl/1.4/hidl.cpp
index fc464b6..1a75123 100644
--- a/wpa_supplicant/hidl/1.4/hidl.cpp
+++ b/wpa_supplicant/hidl/1.4/hidl.cpp
@@ -907,3 +907,17 @@
hidl_manager->notifyTransitionDisable(wpa_s, ssid, bitmap);
}
+
+void wpas_hidl_notify_network_not_found(struct wpa_supplicant *wpa_s)
+{
+ if (!wpa_s)
+ return;
+
+ HidlManager *hidl_manager = HidlManager::getInstance();
+ if (!hidl_manager)
+ return;
+
+ wpa_printf(MSG_DEBUG, "Notify network not found");
+
+ hidl_manager->notifyNetworkNotFound(wpa_s);
+}
diff --git a/wpa_supplicant/hidl/1.4/hidl.h b/wpa_supplicant/hidl/1.4/hidl.h
index 9f9da17..1d67d82 100644
--- a/wpa_supplicant/hidl/1.4/hidl.h
+++ b/wpa_supplicant/hidl/1.4/hidl.h
@@ -125,6 +125,7 @@
void wpas_hidl_notify_bss_tm_status(struct wpa_supplicant *wpa_s);
void wpas_hidl_notify_transition_disable(
struct wpa_supplicant *wpa_s, struct wpa_ssid *ssid, u8 bitmap);
+ void wpas_hidl_notify_network_not_found(struct wpa_supplicant *wpa_s);
#else // CONFIG_CTRL_IFACE_HIDL
static inline int wpas_hidl_register_interface(struct wpa_supplicant *wpa_s)
{
@@ -274,6 +275,9 @@
struct wpa_ssid *ssid,
u8 bitmap)
{}
+static void wpas_hidl_notify_network_not_found(struct wpa_supplicant *wpa_s)
+{}
+}
#endif // CONFIG_CTRL_IFACE_HIDL
#ifdef _cplusplus
diff --git a/wpa_supplicant/hidl/1.4/hidl_manager.cpp b/wpa_supplicant/hidl/1.4/hidl_manager.cpp
index 1a00275..b57988d 100644
--- a/wpa_supplicant/hidl/1.4/hidl_manager.cpp
+++ b/wpa_supplicant/hidl/1.4/hidl_manager.cpp
@@ -1920,6 +1920,26 @@
callWithEachStaNetworkCallbackDerived(wpa_s->ifname, ssid->id, func);
}
+void HidlManager::notifyNetworkNotFound(struct wpa_supplicant *wpa_s)
+{
+ std::vector<uint8_t> hidl_ssid;
+
+ if (!wpa_s->current_ssid) {
+ wpa_printf(MSG_ERROR, "Current network NULL. Drop WPA_EVENT_NETWORK_NOT_FOUND!");
+ return;
+ }
+
+ hidl_ssid.assign(
+ wpa_s->current_ssid->ssid,
+ wpa_s->current_ssid->ssid + wpa_s->current_ssid->ssid_len);
+
+ const std::function<
+ Return<void>(android::sp<V1_4::ISupplicantStaIfaceCallback>)>
+ func = std::bind(
+ &V1_4::ISupplicantStaIfaceCallback::onNetworkNotFound,
+ std::placeholders::_1, hidl_ssid);
+ callWithEachStaIfaceCallbackDerived(wpa_s->ifname, func);
+}
/**
* Retrieve the |ISupplicantP2pIface| hidl object reference using the provided
diff --git a/wpa_supplicant/hidl/1.4/hidl_manager.h b/wpa_supplicant/hidl/1.4/hidl_manager.h
index ff59277..21b2ed4 100644
--- a/wpa_supplicant/hidl/1.4/hidl_manager.h
+++ b/wpa_supplicant/hidl/1.4/hidl_manager.h
@@ -172,6 +172,7 @@
void notifyTransitionDisable(struct wpa_supplicant *wpa_s,
struct wpa_ssid *ssid,
u8 bitmap);
+ void notifyNetworkNotFound(struct wpa_supplicant *wpa_s);
// Methods called from hidl objects.
void notifyExtRadioWorkStart(struct wpa_supplicant *wpa_s, uint32_t id);
diff --git a/wpa_supplicant/notify.c b/wpa_supplicant/notify.c
index bcfdb90..c01a6ee 100644
--- a/wpa_supplicant/notify.c
+++ b/wpa_supplicant/notify.c
@@ -1231,3 +1231,11 @@
wpas_hidl_notify_transition_disable(wpa_s, ssid, bitmap);
}
+
+void wpas_notify_network_not_found(struct wpa_supplicant *wpa_s)
+{
+ if (!wpa_s)
+ return;
+
+ wpas_hidl_notify_network_not_found(wpa_s);
+}
diff --git a/wpa_supplicant/notify.h b/wpa_supplicant/notify.h
index a1a5d6b..a2b3183 100644
--- a/wpa_supplicant/notify.h
+++ b/wpa_supplicant/notify.h
@@ -199,5 +199,6 @@
void wpas_notify_transition_disable(struct wpa_supplicant *wpa_s,
struct wpa_ssid *ssid,
u8 bitmap);
+void wpas_notify_network_not_found(struct wpa_supplicant *wpa_s);
#endif /* NOTIFY_H */