From eeb9e9dff46d1c545ca6abf15423f1068ce92cdc Mon Sep 17 00:00:00 2001 From: Sam Gao Date: Thu, 16 Mar 2023 07:43:24 -0700 Subject: [PATCH] Allow compilation without HS20/INTERWORKING CONFIG_HS20 and CONFIG_INTERWORKING are used in wpa_supplicant to enable or disable HotSpot 2.0 or ANQP respectively. These defines were not checked in AIDL code, which assumed that HS20 and INTERWORKING were enabled, and fails to compile when they are disabled. This patch compiles out the functions that require HS20 and INTERWORKING when they are not enabled in android.config. Upstream from Meta. Test: Modify android.config and build for all configurations of CONFIG_HS20 and CONFIG_INTERWORKING. WiFi continues to work fine. Bug: 280661640 Signed-off-by: Sam Gao Change-Id: Ib95b798ea80c375f6922b4b46576578ad7c112c2 --- wpa_supplicant/aidl/aidl_manager.cpp | 13 +++++++++++++ wpa_supplicant/aidl/sta_iface.cpp | 12 ++++++++++++ wpa_supplicant/aidl/sta_network.cpp | 8 ++++++++ wpa_supplicant/interworking.c | 2 ++ 4 files changed, 35 insertions(+) diff --git a/wpa_supplicant/aidl/aidl_manager.cpp b/wpa_supplicant/aidl/aidl_manager.cpp index da90c389..c115b788 100644 --- a/wpa_supplicant/aidl/aidl_manager.cpp +++ b/wpa_supplicant/aidl/aidl_manager.cpp @@ -757,6 +757,7 @@ int AidlManager::notifyNetworkRequest( return 1; } +#ifdef CONFIG_INTERWORKING /** * Notify all listeners about the end of an ANQP query. * @@ -803,6 +804,7 @@ void AidlManager::notifyAnqpQueryDone( } } +#ifdef CONFIG_HS20 aidl_hs20_anqp_data.operatorFriendlyName = misc_utils::convertWpaBufToVector( anqp->hs20_operator_friendly_name); @@ -814,6 +816,16 @@ void AidlManager::notifyAnqpQueryDone( aidl_hs20_anqp_data.osuProvidersList = misc_utils::convertWpaBufToVector( anqp->hs20_osu_providers_list); +#else + aidl_hs20_anqp_data.operatorFriendlyName = + misc_utils::convertWpaBufToVector(NULL); + aidl_hs20_anqp_data.wanMetrics = + misc_utils::convertWpaBufToVector(NULL); + aidl_hs20_anqp_data.connectionCapability = + misc_utils::convertWpaBufToVector(NULL); + aidl_hs20_anqp_data.osuProvidersList = + misc_utils::convertWpaBufToVector(NULL); +#endif /* CONFIG_HS20 */ } callWithEachStaIfaceCallback( @@ -822,6 +834,7 @@ void AidlManager::notifyAnqpQueryDone( std::placeholders::_1, macAddrToVec(bssid), aidl_anqp_data, aidl_hs20_anqp_data)); } +#endif /* CONFIG_INTERWORKING */ /** * Notify all listeners about the end of an HS20 icon query. diff --git a/wpa_supplicant/aidl/sta_iface.cpp b/wpa_supplicant/aidl/sta_iface.cpp index 7a07cc18..0c72abad 100644 --- a/wpa_supplicant/aidl/sta_iface.cpp +++ b/wpa_supplicant/aidl/sta_iface.cpp @@ -1045,6 +1045,7 @@ ndk::ScopedAStatus StaIface::initiateAnqpQueryInternal( if (info_elements.size() > kMaxAnqpElems) { return createStatus(SupplicantStatusCode::FAILURE_ARGS_INVALID); } +#ifdef CONFIG_INTERWORKING uint16_t info_elems_buf[kMaxAnqpElems]; uint32_t num_info_elems = 0; for (const auto &info_element : info_elements) { @@ -1065,11 +1066,15 @@ ndk::ScopedAStatus StaIface::initiateAnqpQueryInternal( return createStatus(SupplicantStatusCode::FAILURE_UNKNOWN); } return ndk::ScopedAStatus::ok(); +#else + return createStatus(SupplicantStatusCode::FAILURE_UNSUPPORTED); +#endif /* CONFIG_INTERWORKING */ } ndk::ScopedAStatus StaIface::initiateVenueUrlAnqpQueryInternal( const std::vector &mac_address) { +#ifdef CONFIG_INTERWORKING struct wpa_supplicant *wpa_s = retrieveIfacePtr(); uint16_t info_elems_buf[1] = {ANQP_VENUE_URL}; @@ -1078,11 +1083,15 @@ ndk::ScopedAStatus StaIface::initiateVenueUrlAnqpQueryInternal( return createStatus(SupplicantStatusCode::FAILURE_UNKNOWN); } return ndk::ScopedAStatus::ok(); +#else + return createStatus(SupplicantStatusCode::FAILURE_UNSUPPORTED); +#endif /* CONFIG_INTERWORKING */ } ndk::ScopedAStatus StaIface::initiateHs20IconQueryInternal( const std::vector &mac_address, const std::string &file_name) { +#ifdef CONFIG_HS20 struct wpa_supplicant *wpa_s = retrieveIfacePtr(); wpa_s->fetch_osu_icon_in_progress = 0; if (hs20_anqp_send_req( @@ -1092,6 +1101,9 @@ ndk::ScopedAStatus StaIface::initiateHs20IconQueryInternal( return createStatus(SupplicantStatusCode::FAILURE_UNKNOWN); } return ndk::ScopedAStatus::ok(); +#else + return createStatus(SupplicantStatusCode::FAILURE_UNSUPPORTED); +#endif /* CONFIG_HS20 */ } std::pair, ndk::ScopedAStatus> diff --git a/wpa_supplicant/aidl/sta_network.cpp b/wpa_supplicant/aidl/sta_network.cpp index 61c71a1c..5b4a3e38 100644 --- a/wpa_supplicant/aidl/sta_network.cpp +++ b/wpa_supplicant/aidl/sta_network.cpp @@ -1393,12 +1393,16 @@ ndk::ScopedAStatus StaNetwork::setIdStrInternal(const std::string &id_str) ndk::ScopedAStatus StaNetwork::setUpdateIdentifierInternal(uint32_t id) { +#ifdef CONFIG_HS20 struct wpa_ssid *wpa_ssid = retrieveNetworkPtr(); wpa_ssid->update_identifier = id; wpa_printf( MSG_MSGDUMP, "update_identifier: %d", wpa_ssid->update_identifier); resetInternalStateAfterParamsUpdate(); return ndk::ScopedAStatus::ok(); +#else + return createStatusWithMsg(SupplicantStatusCode::FAILURE_UNKNOWN, "Not implemented"); +#endif /* CONFIG_HS20 */ } ndk::ScopedAStatus StaNetwork::setWapiCertSuiteInternal(const std::string &suite) @@ -2252,6 +2256,7 @@ StaNetwork::getPairwiseCipherInternal() ndk::ScopedAStatus StaNetwork::setRoamingConsortiumSelectionInternal( const std::vector &selectedRcoi) { +#ifdef CONFIG_HS20 struct wpa_ssid *wpa_ssid = retrieveNetworkPtr(); if (wpa_ssid == NULL) { return createStatus(SupplicantStatusCode::FAILURE_NETWORK_INVALID); @@ -2267,6 +2272,9 @@ ndk::ScopedAStatus StaNetwork::setRoamingConsortiumSelectionInternal( resetInternalStateAfterParamsUpdate(); return ndk::ScopedAStatus::ok(); +#else + return createStatusWithMsg(SupplicantStatusCode::FAILURE_UNKNOWN, "Not implemented"); +#endif /* CONFIG_HS20 */ } /** diff --git a/wpa_supplicant/interworking.c b/wpa_supplicant/interworking.c index 9a459c2f..1b7c7dc7 100644 --- a/wpa_supplicant/interworking.c +++ b/wpa_supplicant/interworking.c @@ -1627,6 +1627,7 @@ static int interworking_connect_roaming_consortium( if (interworking_set_hs20_params(wpa_s, ssid) < 0) goto fail; +#ifdef CONFIG_HS20 ie = wpa_bss_get_ie(bss, WLAN_EID_ROAMING_CONSORTIUM); anqp = bss->anqp ? bss->anqp->roaming_consortium : NULL; for (i = 0; (ie || anqp) && i < cred->num_roaming_consortiums; i++) { @@ -1646,6 +1647,7 @@ static int interworking_connect_roaming_consortium( cred->roaming_consortiums_len[i]; break; } +#endif /* CONFIG_HS20 */ if (cred->eap_method == NULL) { wpa_msg(wpa_s, MSG_DEBUG,