Add findWithParams and connectWithParams to the P2P
Supplicant AIDL Interface

Also deprecates the previous find and connect methods.

Bug: 296069900
Test: m

Change-Id: I764b3a7e54a6676fab9d1f4728fdbca8ce4b3c6f
diff --git a/wifi/supplicant/aidl/aidl_api/android.hardware.wifi.supplicant/current/android/hardware/wifi/supplicant/ISupplicantP2pIface.aidl b/wifi/supplicant/aidl/aidl_api/android.hardware.wifi.supplicant/current/android/hardware/wifi/supplicant/ISupplicantP2pIface.aidl
index 19e6728..0729646 100644
--- a/wifi/supplicant/aidl/aidl_api/android.hardware.wifi.supplicant/current/android/hardware/wifi/supplicant/ISupplicantP2pIface.aidl
+++ b/wifi/supplicant/aidl/aidl_api/android.hardware.wifi.supplicant/current/android/hardware/wifi/supplicant/ISupplicantP2pIface.aidl
@@ -43,10 +43,16 @@
   void cancelServiceDiscovery(in long identifier);
   void cancelWps(in String groupIfName);
   void configureExtListen(in int periodInMillis, in int intervalInMillis);
+  /**
+   * @deprecated This method is deprecated from AIDL v3, newer HALs should use connectWithParams.
+   */
   String connect(in byte[] peerAddress, in android.hardware.wifi.supplicant.WpsProvisionMethod provisionMethod, in String preSelectedPin, in boolean joinExistingGroup, in boolean persistent, in int goIntent);
   byte[] createNfcHandoverRequestMessage();
   byte[] createNfcHandoverSelectMessage();
   void enableWfd(in boolean enable);
+  /**
+   * @deprecated This method is deprecated from AIDL v3, newer HALs should use findWithParams.
+   */
   void find(in int timeoutInSec);
   void flush();
   void flushServices();
@@ -93,8 +99,16 @@
   String startWpsPinDisplay(in String groupIfName, in byte[] bssid);
   void startWpsPinKeypad(in String groupIfName, in String pin);
   void stopFind();
+  /**
+   * @deprecated This method is deprecated from AIDL v3, newer HALs should use findWithParams.
+   */
   void findOnSocialChannels(in int timeoutInSec);
+  /**
+   * @deprecated This method is deprecated from AIDL v3, newer HALs should use findWithParams.
+   */
   void findOnSpecificFrequency(in int freqInHz, in int timeoutInSec);
   void setVendorElements(in android.hardware.wifi.supplicant.P2pFrameTypeMask frameTypeMask, in byte[] vendorElemBytes);
   void configureEapolIpAddressAllocationParams(in int ipAddressGo, in int ipAddressMask, in int ipAddressStart, in int ipAddressEnd);
+  String connectWithParams(in android.hardware.wifi.supplicant.P2pConnectInfo connectInfo);
+  void findWithParams(in android.hardware.wifi.supplicant.P2pDiscoveryInfo discoveryInfo);
 }
diff --git a/wifi/supplicant/aidl/aidl_api/android.hardware.wifi.supplicant/current/android/hardware/wifi/supplicant/P2pConnectInfo.aidl b/wifi/supplicant/aidl/aidl_api/android.hardware.wifi.supplicant/current/android/hardware/wifi/supplicant/P2pConnectInfo.aidl
new file mode 100644
index 0000000..f4662de
--- /dev/null
+++ b/wifi/supplicant/aidl/aidl_api/android.hardware.wifi.supplicant/current/android/hardware/wifi/supplicant/P2pConnectInfo.aidl
@@ -0,0 +1,44 @@
+/*
+ * Copyright (C) 2023 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+///////////////////////////////////////////////////////////////////////////////
+// THIS FILE IS IMMUTABLE. DO NOT EDIT IN ANY CASE.                          //
+///////////////////////////////////////////////////////////////////////////////
+
+// This file is a snapshot of an AIDL file. Do not edit it manually. There are
+// two cases:
+// 1). this is a frozen version file - do not edit this in any case.
+// 2). this is a 'current' file. If you make a backwards compatible change to
+//     the interface (from the latest frozen version), the build system will
+//     prompt you to update this file with `m <name>-update-api`.
+//
+// You must not make a backward incompatible change to any AIDL file built
+// with the aidl_interface module type with versions property set. The module
+// type is used to build AIDL files in a way that they can be used across
+// independently updatable components of the system. If a device is shipped
+// with such a backward incompatible change, it has a high risk of breaking
+// later when a module using the interface is updated, e.g., Mainline modules.
+
+package android.hardware.wifi.supplicant;
+@VintfStability
+parcelable P2pConnectInfo {
+  byte[6] peerAddress;
+  android.hardware.wifi.supplicant.WpsProvisionMethod provisionMethod;
+  String preSelectedPin;
+  boolean joinExistingGroup;
+  boolean persistent;
+  int goIntent;
+  @nullable android.hardware.wifi.common.OuiKeyedData[] vendorData;
+}
diff --git a/wifi/supplicant/aidl/aidl_api/android.hardware.wifi.supplicant/current/android/hardware/wifi/supplicant/P2pDiscoveryInfo.aidl b/wifi/supplicant/aidl/aidl_api/android.hardware.wifi.supplicant/current/android/hardware/wifi/supplicant/P2pDiscoveryInfo.aidl
new file mode 100644
index 0000000..5b7dd3f
--- /dev/null
+++ b/wifi/supplicant/aidl/aidl_api/android.hardware.wifi.supplicant/current/android/hardware/wifi/supplicant/P2pDiscoveryInfo.aidl
@@ -0,0 +1,41 @@
+/*
+ * Copyright (C) 2023 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+///////////////////////////////////////////////////////////////////////////////
+// THIS FILE IS IMMUTABLE. DO NOT EDIT IN ANY CASE.                          //
+///////////////////////////////////////////////////////////////////////////////
+
+// This file is a snapshot of an AIDL file. Do not edit it manually. There are
+// two cases:
+// 1). this is a frozen version file - do not edit this in any case.
+// 2). this is a 'current' file. If you make a backwards compatible change to
+//     the interface (from the latest frozen version), the build system will
+//     prompt you to update this file with `m <name>-update-api`.
+//
+// You must not make a backward incompatible change to any AIDL file built
+// with the aidl_interface module type with versions property set. The module
+// type is used to build AIDL files in a way that they can be used across
+// independently updatable components of the system. If a device is shipped
+// with such a backward incompatible change, it has a high risk of breaking
+// later when a module using the interface is updated, e.g., Mainline modules.
+
+package android.hardware.wifi.supplicant;
+@VintfStability
+parcelable P2pDiscoveryInfo {
+  android.hardware.wifi.supplicant.P2pScanType scanType;
+  int frequencyMhz;
+  int timeoutInSec;
+  @nullable android.hardware.wifi.common.OuiKeyedData[] vendorData;
+}
diff --git a/wifi/supplicant/aidl/aidl_api/android.hardware.wifi.supplicant/current/android/hardware/wifi/supplicant/P2pScanType.aidl b/wifi/supplicant/aidl/aidl_api/android.hardware.wifi.supplicant/current/android/hardware/wifi/supplicant/P2pScanType.aidl
new file mode 100644
index 0000000..ff3efd2
--- /dev/null
+++ b/wifi/supplicant/aidl/aidl_api/android.hardware.wifi.supplicant/current/android/hardware/wifi/supplicant/P2pScanType.aidl
@@ -0,0 +1,40 @@
+/*
+ * Copyright (C) 2023 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+///////////////////////////////////////////////////////////////////////////////
+// THIS FILE IS IMMUTABLE. DO NOT EDIT IN ANY CASE.                          //
+///////////////////////////////////////////////////////////////////////////////
+
+// This file is a snapshot of an AIDL file. Do not edit it manually. There are
+// two cases:
+// 1). this is a frozen version file - do not edit this in any case.
+// 2). this is a 'current' file. If you make a backwards compatible change to
+//     the interface (from the latest frozen version), the build system will
+//     prompt you to update this file with `m <name>-update-api`.
+//
+// You must not make a backward incompatible change to any AIDL file built
+// with the aidl_interface module type with versions property set. The module
+// type is used to build AIDL files in a way that they can be used across
+// independently updatable components of the system. If a device is shipped
+// with such a backward incompatible change, it has a high risk of breaking
+// later when a module using the interface is updated, e.g., Mainline modules.
+
+package android.hardware.wifi.supplicant;
+@Backing(type="int") @VintfStability
+enum P2pScanType {
+  FULL,
+  SOCIAL,
+  SPECIFIC_FREQ,
+}
diff --git a/wifi/supplicant/aidl/android/hardware/wifi/supplicant/ISupplicantP2pIface.aidl b/wifi/supplicant/aidl/android/hardware/wifi/supplicant/ISupplicantP2pIface.aidl
index e58422c..983ed15 100644
--- a/wifi/supplicant/aidl/android/hardware/wifi/supplicant/ISupplicantP2pIface.aidl
+++ b/wifi/supplicant/aidl/android/hardware/wifi/supplicant/ISupplicantP2pIface.aidl
@@ -16,11 +16,14 @@
 
 package android.hardware.wifi.supplicant;
 
+import android.hardware.wifi.common.OuiKeyedData;
 import android.hardware.wifi.supplicant.FreqRange;
 import android.hardware.wifi.supplicant.ISupplicantP2pIfaceCallback;
 import android.hardware.wifi.supplicant.ISupplicantP2pNetwork;
 import android.hardware.wifi.supplicant.IfaceType;
 import android.hardware.wifi.supplicant.MiracastMode;
+import android.hardware.wifi.supplicant.P2pConnectInfo;
+import android.hardware.wifi.supplicant.P2pDiscoveryInfo;
 import android.hardware.wifi.supplicant.P2pFrameTypeMask;
 import android.hardware.wifi.supplicant.P2pGroupCapabilityMask;
 import android.hardware.wifi.supplicant.WpsConfigMethods;
@@ -176,6 +179,9 @@
      * Start P2P group formation with a discovered P2P peer. This includes
      * optional group owner negotiation, group interface setup, provisioning,
      * and establishing data connection.
+     * <p>
+     * @deprecated This method is deprecated from AIDL v3, newer HALs should use
+     * connectWithParams.
      *
      * @param peerAddress MAC address of the device to connect to.
      * @param provisionMethod Provisioning method to use.
@@ -236,6 +242,9 @@
 
     /**
      * Initiate a P2P service discovery with an optional timeout.
+     * <p>
+     * @deprecated This method is deprecated from AIDL v3, newer HALs should use
+     * findWithParams.
      *
      * @param timeoutInSec Max time to be spent is performing discovery.
      *        Set to 0 to indefinitely continue discovery until an explicit
@@ -782,8 +791,9 @@
 
     /**
      * Initiate a P2P device discovery only on social channels.
-     *
-     * Full P2P discovery is performed through |ISupplicantP2pIface.find| method.
+     * <p>
+     * @deprecated This method is deprecated from AIDL v3, newer HALs should use
+     * findWithParams.
      *
      * @param timeoutInSec The maximum amount of time that should be spent in performing device
      *         discovery.
@@ -798,8 +808,9 @@
 
     /**
      * Initiate a P2P device discovery on a specific frequency.
-     *
-     * Full P2P discovery is performed through |ISupplicantP2pIface.find| method.
+     * <p>
+     * @deprecated This method is deprecated from AIDL v3, newer HALs should use
+     * findWithParams.
      *
      * @param freqInHz the frequency to be scanned.
      * @param timeoutInSec Max time to be spent is performing discovery.
@@ -845,4 +856,30 @@
      */
     void configureEapolIpAddressAllocationParams(
             in int ipAddressGo, in int ipAddressMask, in int ipAddressStart, in int ipAddressEnd);
+
+    /**
+     * Start P2P group formation with a discovered P2P peer. This includes
+     * optional group owner negotiation, group interface setup, provisioning,
+     * and establishing data connection.
+     *
+     * @param connectInfo Parameters associated with this connection request.
+     * @return Pin generated, if |provisionMethod| uses one of the
+     *         generated |PIN*| methods.
+     * @throws ServiceSpecificException with one of the following values:
+     *         |SupplicantStatusCode.FAILURE_ARGS_INVALID|,
+     *         |SupplicantStatusCode.FAILURE_UNKNOWN|,
+     *         |SupplicantStatusCode.FAILURE_IFACE_INVALID|
+     */
+    String connectWithParams(in P2pConnectInfo connectInfo);
+
+    /**
+     * Initiate a P2P service discovery with an optional timeout.
+     *
+     * @param discoveryInfo Parameters associated with this discovery request.
+     * @throws ServiceSpecificException with one of the following values:
+     *         |SupplicantStatusCode.FAILURE_UNKNOWN|,
+     *         |SupplicantStatusCode.FAILURE_IFACE_INVALID|
+     *         |SupplicantStatusCode.FAILURE_IFACE_DISABLED|
+     */
+    void findWithParams(in P2pDiscoveryInfo discoveryInfo);
 }
diff --git a/wifi/supplicant/aidl/android/hardware/wifi/supplicant/P2pConnectInfo.aidl b/wifi/supplicant/aidl/android/hardware/wifi/supplicant/P2pConnectInfo.aidl
new file mode 100644
index 0000000..f09b476
--- /dev/null
+++ b/wifi/supplicant/aidl/android/hardware/wifi/supplicant/P2pConnectInfo.aidl
@@ -0,0 +1,68 @@
+/*
+ * Copyright (C) 2023 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.hardware.wifi.supplicant;
+
+import android.hardware.wifi.common.OuiKeyedData;
+import android.hardware.wifi.supplicant.WpsProvisionMethod;
+
+/**
+ * Request parameters used for |ISupplicantP2pIface.connectWithParams|
+ */
+@VintfStability
+parcelable P2pConnectInfo {
+    /**
+     * MAC address of the device to connect to.
+     */
+    byte[6] peerAddress;
+
+    /**
+     * Provisioning method to use.
+     */
+    WpsProvisionMethod provisionMethod;
+
+    /**
+     * Pin to be used, if |provisionMethod| uses one of the
+     * preselected |PIN*| methods.
+     */
+    String preSelectedPin;
+
+    /**
+     * Indicates that this is a command to join an existing group as a client.
+     * This means that the group owner negotiation step can be skipped.
+     * This must send a Provision Discovery Request message to the
+     * target group owner before associating for WPS provisioning.
+     */
+    boolean joinExistingGroup;
+
+    /**
+     * Used to request a persistent group to be formed.
+     */
+    boolean persistent;
+
+    /**
+     * Used to override the default Intent for this group owner
+     * negotiation (Values from 1-15). Refer to section 4.1.6 in
+     * Wi-Fi Peer-to-Peer (P2P) Technical Specification Version 1.7.
+     */
+    int goIntent;
+
+    /**
+     * Optional vendor-specific parameters. Null value indicates
+     * that no vendor data is provided.
+     */
+    @nullable OuiKeyedData[] vendorData;
+}
diff --git a/wifi/supplicant/aidl/android/hardware/wifi/supplicant/P2pDiscoveryInfo.aidl b/wifi/supplicant/aidl/android/hardware/wifi/supplicant/P2pDiscoveryInfo.aidl
new file mode 100644
index 0000000..ddb8a3d
--- /dev/null
+++ b/wifi/supplicant/aidl/android/hardware/wifi/supplicant/P2pDiscoveryInfo.aidl
@@ -0,0 +1,49 @@
+/*
+ * Copyright (C) 2023 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.hardware.wifi.supplicant;
+
+import android.hardware.wifi.common.OuiKeyedData;
+import android.hardware.wifi.supplicant.P2pScanType;
+
+/**
+ * Request parameters used for |ISupplicantP2pIface.findWithParams|
+ */
+@VintfStability
+parcelable P2pDiscoveryInfo {
+    /**
+     * P2P scan type.
+     */
+    P2pScanType scanType;
+
+    /**
+     * Frequency to scan in MHz. Only valid the scan type is |P2pScanType.SPECIFIC_FREQ|
+     */
+    int frequencyMhz;
+
+    /**
+     * Max time, in seconds, to be spent in performing discovery.
+     * Set to 0 to indefinitely continue discovery until an explicit
+     * |stopFind| is sent.
+     */
+    int timeoutInSec;
+
+    /**
+     * Optional vendor-specific parameters. Null value indicates
+     * that no vendor data is provided.
+     */
+    @nullable OuiKeyedData[] vendorData;
+}
diff --git a/wifi/supplicant/aidl/android/hardware/wifi/supplicant/P2pScanType.aidl b/wifi/supplicant/aidl/android/hardware/wifi/supplicant/P2pScanType.aidl
new file mode 100644
index 0000000..1ab14c4
--- /dev/null
+++ b/wifi/supplicant/aidl/android/hardware/wifi/supplicant/P2pScanType.aidl
@@ -0,0 +1,37 @@
+/*
+ * Copyright (C) 2023 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.hardware.wifi.supplicant;
+
+/**
+ * Scan types used in P2P.
+ */
+@VintfStability
+@Backing(type="int")
+enum P2pScanType {
+    /**
+     * All channels.
+     */
+    FULL,
+    /**
+     * Social channels.
+     */
+    SOCIAL,
+    /**
+     * Specific channel.
+     */
+    SPECIFIC_FREQ,
+}