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 <ssgao@meta.com>
Change-Id: Ib95b798ea80c375f6922b4b46576578ad7c112c2
diff --git a/wpa_supplicant/aidl/aidl_manager.cpp b/wpa_supplicant/aidl/aidl_manager.cpp
index da90c38..c115b78 100644
--- a/wpa_supplicant/aidl/aidl_manager.cpp
+++ b/wpa_supplicant/aidl/aidl_manager.cpp
@@ -757,6 +757,7 @@
return 1;
}
+#ifdef CONFIG_INTERWORKING
/**
* Notify all listeners about the end of an ANQP query.
*
@@ -803,6 +804,7 @@
}
}
+#ifdef CONFIG_HS20
aidl_hs20_anqp_data.operatorFriendlyName =
misc_utils::convertWpaBufToVector(
anqp->hs20_operator_friendly_name);
@@ -814,6 +816,16 @@
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 @@
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 7a07cc1..0c72aba 100644
--- a/wpa_supplicant/aidl/sta_iface.cpp
+++ b/wpa_supplicant/aidl/sta_iface.cpp
@@ -1045,6 +1045,7 @@
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 @@
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<uint8_t> &mac_address)
{
+#ifdef CONFIG_INTERWORKING
struct wpa_supplicant *wpa_s = retrieveIfacePtr();
uint16_t info_elems_buf[1] = {ANQP_VENUE_URL};
@@ -1078,11 +1083,15 @@
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<uint8_t> &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 @@
return createStatus(SupplicantStatusCode::FAILURE_UNKNOWN);
}
return ndk::ScopedAStatus::ok();
+#else
+ return createStatus(SupplicantStatusCode::FAILURE_UNSUPPORTED);
+#endif /* CONFIG_HS20 */
}
std::pair<std::vector<uint8_t>, ndk::ScopedAStatus>
diff --git a/wpa_supplicant/aidl/sta_network.cpp b/wpa_supplicant/aidl/sta_network.cpp
index 61c71a1..5b4a3e3 100644
--- a/wpa_supplicant/aidl/sta_network.cpp
+++ b/wpa_supplicant/aidl/sta_network.cpp
@@ -1393,12 +1393,16 @@
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 @@
ndk::ScopedAStatus StaNetwork::setRoamingConsortiumSelectionInternal(
const std::vector<uint8_t> &selectedRcoi)
{
+#ifdef CONFIG_HS20
struct wpa_ssid *wpa_ssid = retrieveNetworkPtr();
if (wpa_ssid == NULL) {
return createStatus(SupplicantStatusCode::FAILURE_NETWORK_INVALID);
@@ -2267,6 +2272,9 @@
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 9a459c2..1b7c7dc 100644
--- a/wpa_supplicant/interworking.c
+++ b/wpa_supplicant/interworking.c
@@ -1627,6 +1627,7 @@
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 @@
cred->roaming_consortiums_len[i];
break;
}
+#endif /* CONFIG_HS20 */
if (cred->eap_method == NULL) {
wpa_msg(wpa_s, MSG_DEBUG,