Snap for 11308440 from 7123990c79fe7d33e82a57eac61bf348ff951851 to 24Q2-release

Change-Id: Ib3e28f38b153390fce6e700540b6097cd3a03d70
diff --git a/wpa_supplicant/Android.bp b/wpa_supplicant/Android.bp
index ca56d14..a1c28b4 100644
--- a/wpa_supplicant/Android.bp
+++ b/wpa_supplicant/Android.bp
@@ -67,6 +67,7 @@
     defaults: ["wpa_supplicant_cflags_defaults"],
     srcs: [":wpa_supplicant_srcs"],
     shared_libs: [
+        "android.hardware.wifi-V2-ndk",
         "android.hardware.wifi.supplicant-V3-ndk",
         "android.system.keystore2-V1-ndk",
         "libbase",
diff --git a/wpa_supplicant/Android.mk b/wpa_supplicant/Android.mk
index 509dbbc..3433586 100644
--- a/wpa_supplicant/Android.mk
+++ b/wpa_supplicant/Android.mk
@@ -1962,6 +1962,7 @@
 LOCAL_MODULE := wpa_supplicant
 
 ifeq ($(WPA_SUPPLICANT_USE_AIDL), y)
+LOCAL_SHARED_LIBRARIES += android.hardware.wifi-V2-ndk
 LOCAL_SHARED_LIBRARIES += android.hardware.wifi.supplicant-V3-ndk
 LOCAL_SHARED_LIBRARIES += android.system.keystore2-V1-ndk
 LOCAL_SHARED_LIBRARIES += libutils libbase
@@ -2066,6 +2067,7 @@
     aidl/sta_network.cpp \
     aidl/supplicant.cpp
 LOCAL_SHARED_LIBRARIES := \
+    android.hardware.wifi-V2-ndk \
     android.hardware.wifi.supplicant-V3-ndk \
     android.system.keystore2-V1-ndk \
     libbinder_ndk \
diff --git a/wpa_supplicant/aidl/Android.bp b/wpa_supplicant/aidl/Android.bp
index 481ad0b..7188dbe 100644
--- a/wpa_supplicant/aidl/Android.bp
+++ b/wpa_supplicant/aidl/Android.bp
@@ -33,6 +33,7 @@
     defaults: ["wpa_supplicant_cflags_defaults"],
     soc_specific: true,
     shared_libs: [
+        "android.hardware.wifi-V2-ndk",
         "android.hardware.wifi.supplicant-V3-ndk",
         "android.system.keystore2-V1-ndk",
         "libbinder_ndk",
diff --git a/wpa_supplicant/aidl/p2p_iface.cpp b/wpa_supplicant/aidl/p2p_iface.cpp
index e98ddb0..8c117d3 100644
--- a/wpa_supplicant/aidl/p2p_iface.cpp
+++ b/wpa_supplicant/aidl/p2p_iface.cpp
@@ -838,6 +838,13 @@
 		&P2pIface::configureExtListenWithParamsInternal, in_extListenInfo);
 }
 
+::ndk::ScopedAStatus P2pIface::addGroupWithConfigurationParams(
+		const P2pAddGroupConfigurationParams& in_groupConfigurationParams)
+{
+	return validateAndCall(
+		this, SupplicantStatusCode::FAILURE_IFACE_INVALID,
+		&P2pIface::addGroupWithConfigurationParamsInternal, in_groupConfigurationParams);
+}
 std::pair<std::string, ndk::ScopedAStatus> P2pIface::getNameInternal()
 {
 	return {ifname_, ndk::ScopedAStatus::ok()};
@@ -1908,6 +1915,19 @@
 	return configureExtListenInternal(extListenInfo.periodMs, extListenInfo.intervalMs);
 }
 
+ndk::ScopedAStatus P2pIface::addGroupWithConfigurationParamsInternal(
+	const P2pAddGroupConfigurationParams& groupConfigurationParams)
+{
+	std::vector<uint8_t> goInterfaceAddressVec {
+		groupConfigurationParams.goInterfaceAddress.begin(),
+		groupConfigurationParams.goInterfaceAddress.end()};
+	return addGroupWithConfigInternal(
+		groupConfigurationParams.ssid, groupConfigurationParams.passphrase,
+		groupConfigurationParams.isPersistent, groupConfigurationParams.frequencyMHzOrBand,
+		goInterfaceAddressVec,
+		groupConfigurationParams.joinExistingGroup);
+}
+
 /**
  * Retrieve the underlying |wpa_supplicant| struct
  * pointer for this iface.
diff --git a/wpa_supplicant/aidl/p2p_iface.h b/wpa_supplicant/aidl/p2p_iface.h
index 22d88eb..252abc4 100644
--- a/wpa_supplicant/aidl/p2p_iface.h
+++ b/wpa_supplicant/aidl/p2p_iface.h
@@ -180,6 +180,8 @@
 	::ndk::ScopedAStatus findWithParams(const P2pDiscoveryInfo& in_discoveryInfo) override;
 	::ndk::ScopedAStatus configureExtListenWithParams(
 		const P2pExtListenInfo& in_extListenInfo) override;
+	::ndk::ScopedAStatus addGroupWithConfigurationParams(
+		const P2pAddGroupConfigurationParams& in_groupConfigurationParams) override;
 
 
 private:
@@ -308,6 +310,8 @@
 		const P2pConnectInfo& connectInfo);
 	ndk::ScopedAStatus findWithParamsInternal(const P2pDiscoveryInfo& discoveryInfo);
 	ndk::ScopedAStatus configureExtListenWithParamsInternal(const P2pExtListenInfo& extListenInfo);
+	ndk::ScopedAStatus addGroupWithConfigurationParamsInternal(
+		const P2pAddGroupConfigurationParams& groupConfigurationParams);
 
 	struct wpa_supplicant* retrieveIfacePtr();
 	struct wpa_supplicant* retrieveGroupIfacePtr(
diff --git a/wpa_supplicant/aidl/sta_iface.cpp b/wpa_supplicant/aidl/sta_iface.cpp
index 78e6cd3..f85ef44 100644
--- a/wpa_supplicant/aidl/sta_iface.cpp
+++ b/wpa_supplicant/aidl/sta_iface.cpp
@@ -26,6 +26,7 @@
 }
 
 namespace {
+using aidl::android::hardware::wifi::WifiChannelWidthInMhz;
 using aidl::android::hardware::wifi::supplicant::AidlManager;
 using aidl::android::hardware::wifi::supplicant::BtCoexistenceMode;
 using aidl::android::hardware::wifi::supplicant::ConnectionCapabilities;
@@ -41,19 +42,6 @@
 using aidl::android::hardware::wifi::supplicant::WifiTechnology;
 using aidl::android::hardware::wifi::supplicant::misc_utils::createStatus;
 
-// TODO (b/204810426): Import from wifi vendor AIDL interface when it exists
-enum WifiChannelWidthInMhz {
-  WIDTH_20	= 0,
-  WIDTH_40	= 1,
-  WIDTH_80	= 2,
-  WIDTH_160   = 3,
-  WIDTH_80P80 = 4,
-  WIDTH_5	 = 5,
-  WIDTH_10	= 6,
-  WIDTH_320	= 7,
-  WIDTH_INVALID = -1
-};
-
 constexpr uint32_t kMaxAnqpElems = 100;
 constexpr char kGetMacAddress[] = "MACADDR";
 constexpr char kStartRxFilter[] = "RXFILTER-START";
@@ -1857,32 +1845,32 @@
 		}
 		switch (wpa_s->connection_channel_bandwidth) {
 		case CHAN_WIDTH_20:
-			capa.channelBandwidth = WifiChannelWidthInMhz::WIDTH_20;
+			capa.channelBandwidth = static_cast<int32_t>(WifiChannelWidthInMhz::WIDTH_20);
 			break;
 		case CHAN_WIDTH_40:
-			capa.channelBandwidth = WifiChannelWidthInMhz::WIDTH_40;
+			capa.channelBandwidth = static_cast<int32_t>(WifiChannelWidthInMhz::WIDTH_40);
 			break;
 		case CHAN_WIDTH_80:
-			capa.channelBandwidth = WifiChannelWidthInMhz::WIDTH_80;
+			capa.channelBandwidth = static_cast<int32_t>(WifiChannelWidthInMhz::WIDTH_80);
 			break;
 		case CHAN_WIDTH_160:
-			capa.channelBandwidth = WifiChannelWidthInMhz::WIDTH_160;
+			capa.channelBandwidth = static_cast<int32_t>(WifiChannelWidthInMhz::WIDTH_160);
 			break;
 		case CHAN_WIDTH_80P80:
-			capa.channelBandwidth = WifiChannelWidthInMhz::WIDTH_80P80;
+			capa.channelBandwidth = static_cast<int32_t>(WifiChannelWidthInMhz::WIDTH_80P80);
 			break;
 		case CHAN_WIDTH_320:
-			capa.channelBandwidth = WifiChannelWidthInMhz::WIDTH_320;
+			capa.channelBandwidth = static_cast<int32_t>(WifiChannelWidthInMhz::WIDTH_320);
 			break;
 		default:
-			capa.channelBandwidth = WifiChannelWidthInMhz::WIDTH_20;
+			capa.channelBandwidth = static_cast<int32_t>(WifiChannelWidthInMhz::WIDTH_20);
 			break;
 		}
 		capa.maxNumberRxSpatialStreams = wpa_s->connection_max_nss_rx;
 		capa.maxNumberTxSpatialStreams = wpa_s->connection_max_nss_tx;
 	} else {
 		capa.technology = WifiTechnology::UNKNOWN;
-		capa.channelBandwidth = WifiChannelWidthInMhz::WIDTH_20;
+		capa.channelBandwidth = static_cast<int32_t>(WifiChannelWidthInMhz::WIDTH_20);
 		capa.maxNumberTxSpatialStreams = 1;
 		capa.maxNumberRxSpatialStreams = 1;
 		capa.legacyMode = LegacyMode::UNKNOWN;
diff --git a/wpa_supplicant/aidl/sta_iface.h b/wpa_supplicant/aidl/sta_iface.h
index b52c6b0..d2eb11b 100644
--- a/wpa_supplicant/aidl/sta_iface.h
+++ b/wpa_supplicant/aidl/sta_iface.h
@@ -14,6 +14,7 @@
 
 #include <android-base/macros.h>
 
+#include <aidl/android/hardware/wifi/WifiChannelWidthInMhz.h>
 #include <aidl/android/hardware/wifi/supplicant/AnqpInfoId.h>
 #include <aidl/android/hardware/wifi/supplicant/BnSupplicantStaIface.h>
 #include <aidl/android/hardware/wifi/supplicant/BtCoexistenceMode.h>