Add default implementations in supplicant service
for findWithParams and connectWithParams.

Bug: 296069900
Test: atest VtsHalWifiSupplicantP2pIfaceTargetTest
Change-Id: Ia6c05d88e711f2a636e4365efcc246bac31b0401
diff --git a/wpa_supplicant/aidl/p2p_iface.cpp b/wpa_supplicant/aidl/p2p_iface.cpp
index 33db802..ec52b44 100644
--- a/wpa_supplicant/aidl/p2p_iface.cpp
+++ b/wpa_supplicant/aidl/p2p_iface.cpp
@@ -815,6 +815,21 @@
 		in_ipAddressGo, in_ipAddressMask, in_ipAddressStart, in_ipAddressEnd);
 }
 
+::ndk::ScopedAStatus P2pIface::connectWithParams(
+		const P2pConnectInfo& in_connectInfo, std::string* _aidl_return)
+{
+	return validateAndCall(
+		this, SupplicantStatusCode::FAILURE_IFACE_INVALID,
+		&P2pIface::connectWithParamsInternal, _aidl_return, in_connectInfo);
+}
+
+::ndk::ScopedAStatus P2pIface::findWithParams(const P2pDiscoveryInfo& in_discoveryInfo)
+{
+	return validateAndCall(
+		this, SupplicantStatusCode::FAILURE_IFACE_INVALID,
+		&P2pIface::findWithParamsInternal, in_discoveryInfo);
+}
+
 std::pair<std::string, ndk::ScopedAStatus> P2pIface::getNameInternal()
 {
 	return {ifname_, ndk::ScopedAStatus::ok()};
@@ -1852,6 +1867,33 @@
 	return ndk::ScopedAStatus::ok();
 }
 
+std::pair<std::string, ndk::ScopedAStatus> P2pIface::connectWithParamsInternal(
+		const P2pConnectInfo& connectInfo)
+{
+	std::vector<uint8_t> peerAddressVec {
+		connectInfo.peerAddress.begin(), connectInfo.peerAddress.end()};
+	return connectInternal(peerAddressVec, connectInfo.provisionMethod,
+		connectInfo.preSelectedPin, connectInfo.joinExistingGroup,
+		connectInfo.persistent, connectInfo.goIntent);
+}
+
+ndk::ScopedAStatus P2pIface::findWithParamsInternal(const P2pDiscoveryInfo& discoveryInfo)
+{
+	switch (discoveryInfo.scanType) {
+		case P2pScanType::FULL:
+			return findInternal(discoveryInfo.timeoutInSec);
+		case P2pScanType::SOCIAL:
+			return findOnSocialChannelsInternal(discoveryInfo.timeoutInSec);
+		case P2pScanType::SPECIFIC_FREQ:
+			return findOnSpecificFrequencyInternal(
+				discoveryInfo.frequencyMhz, discoveryInfo.timeoutInSec);
+		default:
+			wpa_printf(MSG_DEBUG,
+				"findWithParams received invalid scan type %d", discoveryInfo.scanType);
+			return createStatus(SupplicantStatusCode::FAILURE_ARGS_INVALID);
+	}
+}
+
 /**
  * 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 61972f2..c4f036c 100644
--- a/wpa_supplicant/aidl/p2p_iface.h
+++ b/wpa_supplicant/aidl/p2p_iface.h
@@ -175,6 +175,9 @@
 	::ndk::ScopedAStatus configureEapolIpAddressAllocationParams(
 		int32_t in_ipAddressGo, int32_t in_ipAddressMask,
 		int32_t in_ipAddressStart, int32_t in_ipAddressEnd) override;
+	::ndk::ScopedAStatus connectWithParams(
+		const P2pConnectInfo& in_connectInfo, std::string* _aidl_return) override;
+	::ndk::ScopedAStatus findWithParams(const P2pDiscoveryInfo& in_discoveryInfo) override;
 
 private:
 	// Corresponding worker functions for the AIDL methods.
@@ -298,6 +301,9 @@
 	::ndk::ScopedAStatus configureEapolIpAddressAllocationParamsInternal(
 		uint32_t ipAddressGo, uint32_t ipAddressMask,
 		uint32_t ipAddressStart, uint32_t ipAddressEnd);
+	std::pair<std::string, ndk::ScopedAStatus> connectWithParamsInternal(
+		const P2pConnectInfo& connectInfo);
+	ndk::ScopedAStatus findWithParamsInternal(const P2pDiscoveryInfo& discoveryInfo);
 
 	struct wpa_supplicant* retrieveIfacePtr();
 	struct wpa_supplicant* retrieveGroupIfacePtr(