Merge changes Ibb128999,I6a13a5d1 into main

* changes:
  wifi: check if there exists any non mld hostapd_iface
  aidl: Change the way of convert string to integer link_id
diff --git a/wpa_supplicant/Android.bp b/wpa_supplicant/Android.bp
index f2fb64f..fb74517 100644
--- a/wpa_supplicant/Android.bp
+++ b/wpa_supplicant/Android.bp
@@ -150,6 +150,7 @@
         "-DCONFIG_IPV6",
         "-DCONFIG_JSON",
         "-DCONFIG_MBO",
+        "-DCONFIG_NAN_USD",
         "-DCONFIG_NO_ACCOUNTING",
         "-DCONFIG_NO_RADIUS",
         "-DCONFIG_NO_RADIUS",
@@ -290,6 +291,7 @@
         "interworking.c",
         "main.c",
         "mbo.c",
+        "nan_usd.c",
         "notify.c",
         "offchannel.c",
         "op_classes.c",
@@ -326,6 +328,7 @@
         "src/ap/ieee802_11_vht.c",
         "src/ap/ieee802_1x.c",
         "src/ap/mbo_ap.c",
+        "src/ap/nan_usd_ap.c",
         "src/ap/neighbor_db.c",
         "src/ap/p2p_hostapd.c",
         "src/ap/pmksa_cache_auth.c",
@@ -351,6 +354,7 @@
         "src/common/gas_server.c",
         "src/common/hw_features_common.c",
         "src/common/ieee802_11_common.c",
+        "src/common/nan_de.c",
         "src/common/sae.c",
         "src/common/sae_pk.c",
         "src/common/wpa_common.c",
diff --git a/wpa_supplicant/aidl/vendor/aidl_manager.cpp b/wpa_supplicant/aidl/vendor/aidl_manager.cpp
index 89a4251..52ac6ab 100644
--- a/wpa_supplicant/aidl/vendor/aidl_manager.cpp
+++ b/wpa_supplicant/aidl/vendor/aidl_manager.cpp
@@ -2996,24 +2996,26 @@
 			&ISupplicantStaIfaceCallback::onUsdSubscribeStarted,
 			std::placeholders::_1, cmd_id, subscribe_id));
 }
-void AidlManager::notifyUsdPublishConfigFailed(struct wpa_supplicant *wpa_s, int cmd_id)
+void AidlManager::notifyUsdPublishConfigFailed(struct wpa_supplicant *wpa_s,
+	int cmd_id, ISupplicantStaIfaceCallback::UsdConfigErrorCode error_code)
 {
 	if (!wpa_s) return;
 	if (!areAidlServiceAndClientAtLeastVersion(4)) return;
 	callWithEachStaIfaceCallback(
 		misc_utils::charBufToString(wpa_s->ifname), std::bind(
 			&ISupplicantStaIfaceCallback::onUsdPublishConfigFailed,
-			std::placeholders::_1, cmd_id));
+			std::placeholders::_1, cmd_id, error_code));
 }
 
-void AidlManager::notifyUsdSubscribeConfigFailed(struct wpa_supplicant *wpa_s, int cmd_id)
+void AidlManager::notifyUsdSubscribeConfigFailed(struct wpa_supplicant *wpa_s,
+	int cmd_id, ISupplicantStaIfaceCallback::UsdConfigErrorCode error_code)
 {
 	if (!wpa_s) return;
 	if (!areAidlServiceAndClientAtLeastVersion(4)) return;
 	callWithEachStaIfaceCallback(
 		misc_utils::charBufToString(wpa_s->ifname), std::bind(
 			&ISupplicantStaIfaceCallback::onUsdSubscribeConfigFailed,
-			std::placeholders::_1, cmd_id));
+			std::placeholders::_1, cmd_id, error_code));
 }
 
 UsdServiceProtoType convertUsdServiceProtoTypeToAidl(nan_service_protocol_type type) {
diff --git a/wpa_supplicant/aidl/vendor/aidl_manager.h b/wpa_supplicant/aidl/vendor/aidl_manager.h
index d40837c..b217749 100644
--- a/wpa_supplicant/aidl/vendor/aidl_manager.h
+++ b/wpa_supplicant/aidl/vendor/aidl_manager.h
@@ -182,8 +182,10 @@
 			int cmd_id, int publish_id);
 	void notifyUsdSubscribeStarted(struct wpa_supplicant *wpa_s,
 			int cmd_id, int subscribe_id);
-	void notifyUsdPublishConfigFailed(struct wpa_supplicant *wpa_s, int cmd_id);
-	void notifyUsdSubscribeConfigFailed(struct wpa_supplicant *wpa_s, int cmd_id);
+	void notifyUsdPublishConfigFailed(struct wpa_supplicant *wpa_s,
+			int cmd_id, ISupplicantStaIfaceCallback::UsdConfigErrorCode error_code);
+	void notifyUsdSubscribeConfigFailed(struct wpa_supplicant *wpa_s,
+			int cmd_id, ISupplicantStaIfaceCallback::UsdConfigErrorCode error_code);
 	void notifyUsdServiceDiscovered(struct wpa_supplicant *wpa_s,
 			enum nan_service_protocol_type srv_proto_type,
 			int subscribe_id, int peer_publish_id, const u8 *peer_addr,
diff --git a/wpa_supplicant/aidl/vendor/sta_iface.cpp b/wpa_supplicant/aidl/vendor/sta_iface.cpp
index aebd92a..9e76f56 100644
--- a/wpa_supplicant/aidl/vendor/sta_iface.cpp
+++ b/wpa_supplicant/aidl/vendor/sta_iface.cpp
@@ -2763,9 +2763,6 @@
 	return {capabilities, ndk::ScopedAStatus::ok()};
 }
 
-// TODO (b/384527237): Fix linker error to avoid having a separate default implementation
-#ifdef CONFIG_NAN_USD
-
 ndk::ScopedAStatus StaIface::startUsdPublishInternal(
 		int32_t cmdId, const UsdPublishConfig& usdPublishConfig) {
 	if (!validateUsdPublishConfig(usdPublishConfig)) {
@@ -2795,7 +2792,8 @@
 	WPA_ASSERT(aidl_manager);
 	if (publishId < 0) {
 		wpa_printf(MSG_INFO, "Failed to configure USD publish");
-		aidl_manager->notifyUsdPublishConfigFailed(wpa_s, cmdId);
+		aidl_manager->notifyUsdPublishConfigFailed(
+			wpa_s, cmdId, ISupplicantStaIfaceCallback::UsdConfigErrorCode::FAILURE_UNKNOWN);
 		return createStatus(SupplicantStatusCode::FAILURE_UNKNOWN);
 	}
 	aidl_manager->notifyUsdPublishStarted(wpa_s, cmdId, publishId);
@@ -2829,7 +2827,8 @@
 	WPA_ASSERT(aidl_manager);
 	if (subscribeId < 0) {
 		wpa_printf(MSG_INFO, "Failed to configure USD subscribe");
-		aidl_manager->notifyUsdSubscribeConfigFailed(wpa_s, cmdId);
+		aidl_manager->notifyUsdSubscribeConfigFailed(
+			wpa_s, cmdId, ISupplicantStaIfaceCallback::UsdConfigErrorCode::FAILURE_UNKNOWN);
 		return createStatus(SupplicantStatusCode::FAILURE_UNKNOWN);
 	}
 	aidl_manager->notifyUsdSubscribeStarted(wpa_s, cmdId, subscribeId);
@@ -2893,37 +2892,6 @@
 	return ndk::ScopedAStatus::ok();
 }
 
-#else /* CONFIG_NAN_USD */
-
-ndk::ScopedAStatus StaIface::startUsdPublishInternal(
-		int32_t cmdId, const UsdPublishConfig& usdPublishConfig) {
-	return createStatus(SupplicantStatusCode::FAILURE_UNSUPPORTED);
-}
-
-ndk::ScopedAStatus StaIface::startUsdSubscribeInternal(
-		int32_t cmdId, const UsdSubscribeConfig& usdSubscribeConfig) {
-	return createStatus(SupplicantStatusCode::FAILURE_UNSUPPORTED);
-}
-
-::ndk::ScopedAStatus StaIface::updateUsdPublishInternal(int32_t publishId,
-		const std::vector<uint8_t>& serviceSpecificInfo) {
-	return createStatus(SupplicantStatusCode::FAILURE_UNSUPPORTED);
-}
-
-::ndk::ScopedAStatus StaIface::cancelUsdPublishInternal(int32_t publishId) {
-	return createStatus(SupplicantStatusCode::FAILURE_UNSUPPORTED);
-}
-
-::ndk::ScopedAStatus StaIface::cancelUsdSubscribeInternal(int32_t subscribeId) {
-	return createStatus(SupplicantStatusCode::FAILURE_UNSUPPORTED);
-}
-
-::ndk::ScopedAStatus StaIface::sendUsdMessageInternal(const UsdMessageInfo& messageInfo) {
-	return createStatus(SupplicantStatusCode::FAILURE_UNSUPPORTED);
-}
-
-#endif /* CONFIG_NAN_USD */
-
 /**
  * Retrieve the underlying |wpa_supplicant| struct
  * pointer for this iface.