Merge "set the hostapd channel bandwidth" into tm-dev am: 70a2d206f1 am: f11599d947

Original change: https://googleplex-android-review.googlesource.com/c/platform/external/wpa_supplicant_8/+/17796656

Change-Id: I3de0c6fa7abd33c76ae2899bd1f552400f018715
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
diff --git a/hostapd/aidl/hostapd.cpp b/hostapd/aidl/hostapd.cpp
index d973dae..f0fa687 100644
--- a/hostapd/aidl/hostapd.cpp
+++ b/hostapd/aidl/hostapd.cpp
@@ -321,6 +321,7 @@
 	// Encryption config string
 	uint32_t band = 0;
 	band |= static_cast<uint32_t>(channelParams.bandMask);
+	bool is_2Ghz_band_only = band == static_cast<uint32_t>(band2Ghz);
 	bool is_6Ghz_band_only = band == static_cast<uint32_t>(band6Ghz);
 	bool is_60Ghz_band_only = band == static_cast<uint32_t>(band60Ghz);
 	std::string encryption_config_as_string;
@@ -460,9 +461,7 @@
 	std::string hw_mode_as_string;
 	std::string enable_edmg_as_string;
 	std::string edmg_channel_as_string;
-#ifdef CONFIG_IEEE80211AX
 	bool is_60Ghz_used = false;
-#endif /* CONFIG_IEEE80211AX */
 
 	if (((band & band60Ghz) != 0)) {
 		hw_mode_as_string = "hw_mode=ad";
@@ -472,9 +471,7 @@
 				"edmg_channel=%d",
 				channelParams.channel);
 		}
-#ifdef CONFIG_IEEE80211AX
 		is_60Ghz_used = true;
-#endif /* CONFIG_IEEE80211AX */
 	} else if ((band & band2Ghz) != 0) {
 		if (((band & band5Ghz) != 0)
 		    || ((band & band6Ghz) != 0)) {
@@ -550,17 +547,17 @@
 			iface_params.hwModeParams.enable80211AC ? 2 : 0);
 		break;
 	default:
-		ht_cap_vht_oper_he_oper_chwidth_as_string = StringPrintf(
-			"ht_capab=[HT40+]\n"
+		if (!is_2Ghz_band_only && !is_60Ghz_used
+		    && iface_params.hwModeParams.enable80211AC) {
+			ht_cap_vht_oper_he_oper_chwidth_as_string =
+					"ht_capab=[HT40+]\n"
+					"vht_oper_chwidth=1\n";
+		}
 #ifdef CONFIG_IEEE80211AX
-			"he_oper_chwidth=%d\n"
+		if (iface_params.hwModeParams.enable80211AX && !is_60Ghz_used) {
+			ht_cap_vht_oper_he_oper_chwidth_as_string += "he_oper_chwidth=1";
+		}
 #endif
-			"vht_oper_chwidth=%d",
-#ifdef CONFIG_IEEE80211AX
-			(iface_params.hwModeParams.enable80211AX && !is_60Ghz_used) ? 1 : 0,
-#endif
-			((((band & band5Ghz) != 0) || ((band & band6Ghz) != 0))
-			&& iface_params.hwModeParams.enable80211AC) ? 1 : 0);
 		break;
 	}