wifi: Add the connected frequency in the state change event
Currently framework gets the connected AP frequency
information by checking the scan cache & through signal
poll command. But these mechanisms doesn't work if framework
scan cache is not updated with the connected AP information
(For example in case of roaming and force connection without scan).
To fix this modified supplicant state change interface
and included the frequency of the connected channel in the
state change event.
Bug: 240299862
Test: Manual - Tested STA - AP connection and verfied the data
from debug logs.
Change-Id: I5b6b375edea1bc645d0745bb0d718322917ad585
diff --git a/wpa_supplicant/aidl/aidl_manager.cpp b/wpa_supplicant/aidl/aidl_manager.cpp
index 9a1a83d..f5a42ed 100644
--- a/wpa_supplicant/aidl/aidl_manager.cpp
+++ b/wpa_supplicant/aidl/aidl_manager.cpp
@@ -656,40 +656,46 @@
return 1;
// Invoke the |onStateChanged| method on all registered callbacks.
- uint32_t aidl_network_id = UINT32_MAX;
- std::vector<uint8_t> aidl_ssid;
+ SupplicantStateChangeData aidl_state_change_data = {};
+ aidl_state_change_data.id = UINT32_MAX;
+ aidl_state_change_data.newState = static_cast<StaIfaceCallbackState>(wpa_s->wpa_state);
+
if (wpa_s->current_ssid) {
- aidl_network_id = wpa_s->current_ssid->id;
- aidl_ssid.assign(
+ aidl_state_change_data.id = wpa_s->current_ssid->id;
+ std::vector<uint8_t> aidl_ssid(
wpa_s->current_ssid->ssid,
wpa_s->current_ssid->ssid + wpa_s->current_ssid->ssid_len);
+ aidl_state_change_data.ssid = aidl_ssid;
wpa_printf(MSG_INFO, "assoc key_mgmt 0x%x network key_mgmt 0x%x",
wpa_s->key_mgmt, wpa_s->current_ssid->key_mgmt);
}
- std::vector<uint8_t> bssid;
+ std::vector<uint8_t> aidl_bssid;
// wpa_supplicant sets the |pending_bssid| field when it starts a
// connection. Only after association state does it update the |bssid|
// field. So, in the AIDL callback send the appropriate bssid.
if (wpa_s->wpa_state <= WPA_ASSOCIATED) {
- bssid = macAddrToVec(wpa_s->pending_bssid);
+ aidl_bssid = macAddrToVec(wpa_s->pending_bssid);
} else {
- bssid = macAddrToVec(wpa_s->bssid);
+ aidl_bssid = macAddrToVec(wpa_s->bssid);
}
- bool fils_hlp_sent =
+ aidl_state_change_data.bssid = aidl_bssid;
+
+ aidl_state_change_data.filsHlpSent =
(wpa_auth_alg_fils(wpa_s->auth_alg) &&
!dl_list_empty(&wpa_s->fils_hlp_req) &&
(wpa_s->wpa_state == WPA_COMPLETED)) ? true : false;
+ aidl_state_change_data.keyMgmtMask = (KeyMgmtMask) wpa_s->key_mgmt;
+ // wpa_supplicant sets the frequency on receiving the EVENT_ASSOC.
+ aidl_state_change_data.frequencyMhz =
+ wpa_s->wpa_state >= WPA_ASSOCIATED ? wpa_s->assoc_freq : 0;
// Invoke the |onStateChanged| method on all registered callbacks.
std::function<
ndk::ScopedAStatus(std::shared_ptr<ISupplicantStaIfaceCallback>)>
func = std::bind(
- &ISupplicantStaIfaceCallback::onStateChangedWithAkm,
+ &ISupplicantStaIfaceCallback::onSupplicantStateChanged,
std::placeholders::_1,
- static_cast<StaIfaceCallbackState>(
- wpa_s->wpa_state),
- bssid, aidl_network_id, aidl_ssid,
- fils_hlp_sent, (KeyMgmtMask) wpa_s->key_mgmt);
+ aidl_state_change_data);
callWithEachStaIfaceCallback(
misc_utils::charBufToString(wpa_s->ifname), func);
return 0;