From 23087aade7bc627d8a85854c4631d0286a8b9cfa Mon Sep 17 00:00:00 2001 From: Sunil Ravi Date: Wed, 8 Dec 2021 19:01:44 -0800 Subject: [PATCH] Send frequency changed event to framework When supplicant receives the channel change event (NL80211_CMD_CH_SWITCH_NOTIFY) from driver, send the new operating frequency information to framework. Bug: 202758240 Test: Manually triggered channel switch through hostapd command and verified the new frequency in p2p group info logs Change-Id: I05f10077ac497b934eb2c0560e179cdf4ed1497f --- wpa_supplicant/aidl/aidl.cpp | 15 +++++++++++++++ wpa_supplicant/aidl/aidl.h | 3 +++ wpa_supplicant/aidl/aidl_manager.cpp | 23 +++++++++++++++++++++++ wpa_supplicant/aidl/aidl_manager.h | 1 + wpa_supplicant/notify.c | 2 ++ 5 files changed, 44 insertions(+) diff --git a/wpa_supplicant/aidl/aidl.cpp b/wpa_supplicant/aidl/aidl.cpp index f3f04a38..c3ee8b6c 100644 --- a/wpa_supplicant/aidl/aidl.cpp +++ b/wpa_supplicant/aidl/aidl.cpp @@ -921,3 +921,18 @@ void wpas_aidl_notify_network_not_found(struct wpa_supplicant *wpa_s) aidl_manager->notifyNetworkNotFound(wpa_s); } + +void wpas_aidl_notify_bss_freq_changed(struct wpa_supplicant *wpa_s) +{ + if (!wpa_s) + return; + + AidlManager *aidl_manager = AidlManager::getInstance(); + if (!aidl_manager) + return; + + wpa_printf(MSG_DEBUG, "Notify %s frequency changed to %d", + wpa_s->ifname, wpa_s->assoc_freq); + + aidl_manager->notifyBssFreqChanged(wpa_s); +} diff --git a/wpa_supplicant/aidl/aidl.h b/wpa_supplicant/aidl/aidl.h index 899f99cd..8d2807d2 100644 --- a/wpa_supplicant/aidl/aidl.h +++ b/wpa_supplicant/aidl/aidl.h @@ -126,6 +126,7 @@ extern "C" void wpas_aidl_notify_transition_disable( struct wpa_supplicant *wpa_s, struct wpa_ssid *ssid, u8 bitmap); void wpas_aidl_notify_network_not_found(struct wpa_supplicant *wpa_s); + void wpas_aidl_notify_bss_freq_changed(struct wpa_supplicant *wpa_s); #else // CONFIG_CTRL_IFACE_AIDL static inline int wpas_aidl_register_interface(struct wpa_supplicant *wpa_s) { @@ -277,6 +278,8 @@ static void wpas_aidl_notify_transition_disable(struct wpa_supplicant *wpa_s, {} static void wpas_aidl_notify_network_not_found(struct wpa_supplicant *wpa_s) {} +void wpas_aidl_notify_bss_freq_changed(struct wpa_supplicant *wpa_s) +{} #endif // CONFIG_CTRL_IFACE_AIDL #ifdef _cplusplus diff --git a/wpa_supplicant/aidl/aidl_manager.cpp b/wpa_supplicant/aidl/aidl_manager.cpp index 1ce9326a..b1457b8a 100644 --- a/wpa_supplicant/aidl/aidl_manager.cpp +++ b/wpa_supplicant/aidl/aidl_manager.cpp @@ -1892,6 +1892,29 @@ void AidlManager::notifyNetworkNotFound(struct wpa_supplicant *wpa_s) callWithEachStaIfaceCallback(misc_utils::charBufToString(wpa_s->ifname), func); } +void AidlManager::notifyBssFreqChanged(struct wpa_supplicant *wpa_group_s) +{ + if (!wpa_group_s || !wpa_group_s->parent) + return; + + // For group notifications, need to use the parent iface for callbacks. + struct wpa_supplicant *wpa_s = getTargetP2pIfaceForGroup(wpa_group_s); + if (!wpa_s) { + wpa_printf(MSG_INFO, "Drop BSS frequency changed event"); + return; + } + + uint32_t aidl_freq = wpa_group_s->current_bss + ? wpa_group_s->current_bss->freq + : wpa_group_s->assoc_freq; + + const std::function< + ndk::ScopedAStatus(std::shared_ptr)> + func = std::bind(&ISupplicantP2pIfaceCallback::onGroupFrequencyChanged, + std::placeholders::_1, misc_utils::charBufToString(wpa_group_s->ifname), aidl_freq); + callWithEachP2pIfaceCallback(misc_utils::charBufToString(wpa_s->ifname), func); +} + /** * Retrieve the |ISupplicantP2pIface| aidl object reference using the provided * ifname. diff --git a/wpa_supplicant/aidl/aidl_manager.h b/wpa_supplicant/aidl/aidl_manager.h index b538e36a..912c817d 100644 --- a/wpa_supplicant/aidl/aidl_manager.h +++ b/wpa_supplicant/aidl/aidl_manager.h @@ -143,6 +143,7 @@ public: struct wpa_ssid *ssid, u8 bitmap); void notifyNetworkNotFound(struct wpa_supplicant *wpa_s); + void notifyBssFreqChanged(struct wpa_supplicant *wpa_s); // Methods called from aidl objects. void notifyExtRadioWorkStart(struct wpa_supplicant *wpa_s, uint32_t id); diff --git a/wpa_supplicant/notify.c b/wpa_supplicant/notify.c index b3cb2870..a2bd4882 100644 --- a/wpa_supplicant/notify.c +++ b/wpa_supplicant/notify.c @@ -467,6 +467,8 @@ void wpas_notify_bss_freq_changed(struct wpa_supplicant *wpa_s, return; wpas_dbus_bss_signal_prop_changed(wpa_s, WPAS_DBUS_BSS_PROP_FREQ, id); + + wpas_aidl_notify_bss_freq_changed(wpa_s); }