Merge "cumilative patch from commit 795075444" into main
diff --git a/hostapd/Android.bp b/hostapd/Android.bp
index 5b08d3e..533a917 100644
--- a/hostapd/Android.bp
+++ b/hostapd/Android.bp
@@ -12,6 +12,11 @@
 // See the License for the specific language governing permissions and
 // limitations under the License.
 
+// The hostapd related modules are split into 2 sections:
+// 1. For cuttlefish series products, start from `hostapd_headers` to `hostapd_cli_srcs`.
+// 2. For non-cuttlefish series products, ex: physical devices created by oems,
+//    the section starts from `hostapd_driver_srcs_default` to the end of this file.
+
 package {
     default_applicable_licenses: [
         "external_wpa_supplicant_8_license",
@@ -29,6 +34,9 @@
     ],
 }
 
+// The section below is for cuttlefish series products. For non-cuttlefish
+// products please update the section starting at `hostapd_driver_srcs_default`.
+// Start of cuttlefish section.
 cc_library_headers {
     name: "hostapd_headers",
     export_include_dirs: [
@@ -363,7 +371,29 @@
     installable: false,
 }
 
-// For converting the default to soong
+// End of cuttlefish section.
+
+// The section starting below is for non-cuttlefish products.
+// For cuttlefish series please update the section starting from `hostapd_headers`.
+
+// If you need to add a new build setting based on a product config, ex:
+// ifeq ($(BOARD_HOSTAPD_CONFIG_80211W_MFP_OPTIONAL),true)
+//   L_CFLAGS += -DENABLE_HOSTAPD_CONFIG_80211W_MFP_OPTIONAL
+// endif
+
+// In order to export the Makefile variable to soong, you will need to use a `soong_config_set` method
+// under `build/core/board_config_wpa_supplicant.mk`. Ex:
+// ifeq ($(BOARD_HOSTAPD_CONFIG_80211W_MFP_OPTIONAL),true)
+//   $(call soong_config_set_bool,wpa_supplicant_8,board_hostapd_config_80211w_mfp_optional,true)
+// endif
+
+// And then use the select statement in Android.bp to reflect the condition you need, ex:
+// select(soong_config_variable("wpa_supplicant_8", "board_hostapd_config_80211w_mfp_optional"), {
+//     true: ["-DENABLE_HOSTAPD_CONFIG_80211W_MFP_OPTIONAL"],
+//     default: [],
+// })
+
+// Start of non-cuttlefish section
 cc_defaults {
     name: "hostapd_driver_srcs_default",
     srcs: [
@@ -711,3 +741,5 @@
         "hostapd_includes_default",
     ],
 }
+
+// End of non-cuttlefish section
diff --git a/wpa_supplicant/Android.bp b/wpa_supplicant/Android.bp
index fb74517..2aa7530 100644
--- a/wpa_supplicant/Android.bp
+++ b/wpa_supplicant/Android.bp
@@ -12,6 +12,11 @@
 // See the License for the specific language governing permissions and
 // limitations under the License.
 
+// The wpa_supplicant related modules are split into 2 sections:
+// 1. For cuttlefish series products, start from `wpa_supplicant_headers` to `libpasn`.
+// 2. For non-cuttlefish series products, ex: physical devices created by oems,
+//    the section starts from `wpa_supplicant_driver_srcs_default` to the end of this file.
+
 package {
     default_applicable_licenses: [
         // Inherits SPDX-license-identifier-BSD-3-Clause
@@ -36,6 +41,9 @@
     ],
 }
 
+// The section below is for cuttlefish series products. For non-cuttlefish
+// products please update the section starting at `wpa_supplicant_driver_srcs_default`.
+// Start of cuttlefish section
 cc_library_headers {
     name: "wpa_supplicant_headers",
     export_include_dirs: [
@@ -706,7 +714,29 @@
     },
 }
 
-// For converting the default to soong
+// End of cuttlefish section
+
+// The section starting below is for non-cuttlefish products.
+// For cuttlefish series please update the section starting from `wpa_supplicant_headers`.
+
+// If you need to add a new build setting based on a product config, ex:
+// ifeq ($(WIFI_PRIV_CMD_UPDATE_MBO_CELL_STATUS), enabled)
+//   L_CFLAGS += -DENABLE_PRIV_CMD_UPDATE_MBO_CELL_STATUS
+// endif
+
+// In order to export the Makefile variable to soong, you will need to use a `soong_config_set` method
+// under `build/core/board_config_wpa_supplicant.mk`. Ex:
+// ifeq ($(WIFI_PRIV_CMD_UPDATE_MBO_CELL_STATUS), enabled)
+//   $(call soong_config_set_bool,wpa_supplicant_8,wifi_priv_cmd_update_mbo_cell_status,true)
+// endif
+
+// And then use the select statement in Android.bp to reflect the condition you need, ex:
+// select(soong_config_variable("wpa_supplicant_8", "wifi_priv_cmd_update_mbo_cell_status"), {
+//     true: ["-DENABLE_PRIV_CMD_UPDATE_MBO_CELL_STATUS"],
+//     default: [],
+// })
+
+// Start of non-cuttlefish section
 cc_defaults {
     name: "wpa_supplicant_driver_srcs_default",
     srcs: [
@@ -874,18 +904,12 @@
     ] + select(soong_config_variable("wpa_supplicant_8", "wpa_supplicant_use_stub_lib"), {
         true: ["-DANDROID_LIB_STUB"],
         default: [],
-    }) + select(soong_config_variable("wpa_supplicant_8", "board_hostapd_config_80211w_mfp_optional"), {
-        true: ["-DENABLE_HOSTAPD_CONFIG_80211W_MFP_OPTIONAL"],
-        default: [],
     }) + select(soong_config_variable("wpa_supplicant_8", "board_wpa_supplicant_private_lib_event"), {
         true: ["-DANDROID_LIB_EVENT"],
         default: [],
     }) + select(soong_config_variable("wpa_supplicant_8", "wifi_priv_cmd_update_mbo_cell_status"), {
         true: ["-DENABLE_PRIV_CMD_UPDATE_MBO_CELL_STATUS"],
         default: [],
-    }) + select(soong_config_variable("wpa_supplicant_8", "hostapd_11ax"), {
-        true: ["-DCONFIG_IEEE80211AX"],
-        default: [],
     }) + select(soong_config_variable("wpa_supplicant_8", "wifi_brcm_open_source_multi_akm"), {
         true: ["-DWIFI_BRCM_OPEN_SOURCE_MULTI_AKM"],
         default: [],
@@ -1161,10 +1185,7 @@
         "src/wps/wps_upnp_event.c",
         "src/wps/wps_upnp_ssdp.c",
         "src/wps/wps_upnp_web.c",
-    ] + select(soong_config_variable("wpa_supplicant_8", "hostapd_11ax"), {
-        true: ["src/ap/ieee802_11_he.c"],
-        default: [],
-    }),
+    ],
     defaults: [
         "wpa_supplicant_driver_srcs_default",
     ],
@@ -1465,6 +1486,7 @@
     name: "libwpa_aidl",
     vendor: true,
     cppflags: [
+        "-DCONFIG_NAN_USD",
         "-Wall",
         "-Werror",
         "-Wno-unused-parameter",
@@ -1497,3 +1519,5 @@
         "wpa_supplicant_includes_default",
     ],
 }
+
+// End of non-cuttlefish section
diff --git a/wpa_supplicant/aidl/mainline/config/mainline_supplicant.rc b/wpa_supplicant/aidl/mainline/config/mainline_supplicant.rc
index 8c436c6..018df1c 100644
--- a/wpa_supplicant/aidl/mainline/config/mainline_supplicant.rc
+++ b/wpa_supplicant/aidl/mainline/config/mainline_supplicant.rc
@@ -3,7 +3,9 @@
     -g@android:wpa_wlan0
     interface aidl wifi_mainline_supplicant
     class main
-    user root
+    user wifi
+    group wifi net_raw net_admin
+    capabilities NET_RAW NET_ADMIN
     socket wpa_wlan0 dgram 660 wifi wifi
     disabled
     oneshot
diff --git a/wpa_supplicant/wpa_supplicant_template.conf b/wpa_supplicant/wpa_supplicant_template.conf
index cec26c4..6a45d4a 100644
--- a/wpa_supplicant/wpa_supplicant_template.conf
+++ b/wpa_supplicant/wpa_supplicant_template.conf
@@ -9,3 +9,4 @@
 sae_pwe=2
 p2p_optimize_listen_chan=1
 wowlan_disconnect_on_deinit=1
+rsn_overriding=1