Add limitPowerTransfer API to IUsb

limitPowerTransfer is invoked to limit power transfer
in and out of the Usb port.

Bug: 199357330
Signed-off-by: Badhri Jagan Sridharan <badhri@google.com>
Change-Id: I5f4991d024ad827ae8148fc143a44cc05bafdcb4
diff --git a/usb/aidl/android/hardware/usb/IUsb.aidl b/usb/aidl/android/hardware/usb/IUsb.aidl
index 9a8f000..1596d9a 100644
--- a/usb/aidl/android/hardware/usb/IUsb.aidl
+++ b/usb/aidl/android/hardware/usb/IUsb.aidl
@@ -82,4 +82,17 @@
      * @param transactionId ID to be used when invoking the callback.
      */
     void switchRole(in String portName, in PortRole role, long transactionId);
+
+    /**
+     * This function is used to limit power transfer in and out of the port.
+     * When limited, the port does not charge from the partner port.
+     * Also, the port limits sourcing power to the partner port when the USB
+     * specification allows it to do so.
+     *
+     * @param portName name of the port for which power transfer is being limited.
+     * @param limit true limit power transfer.
+     *              false relax limiting power transfer.
+     * @param transactionId ID to be used when invoking the callback.
+     */
+    void limitPowerTransfer(in String portName, boolean limit, long transactionId);
 }
diff --git a/usb/aidl/android/hardware/usb/IUsbCallback.aidl b/usb/aidl/android/hardware/usb/IUsbCallback.aidl
index 232a15b..b733fed 100644
--- a/usb/aidl/android/hardware/usb/IUsbCallback.aidl
+++ b/usb/aidl/android/hardware/usb/IUsbCallback.aidl
@@ -83,4 +83,16 @@
      * @param transactionId transactionId sent during queryPortStatus request
      */
     void notifyQueryPortStatus(in String portName, in Status retval, long transactionId);
+
+    /**
+     * Used to notify the result of requesting limitPowerTransfer.
+     *
+     * @param portName name of the port for which power transfer is being limited.
+     * @param limit true limit power transfer.
+     *              false relax limiting power transfer.
+     * @param retval SUCCESS if the request to enable/disable limitPowerTransfer succeeds.
+     *               FAILURE otherwise.
+     * @param transactionId ID sent during limitPowerTransfer request.
+     */
+    void notifyLimitPowerTransferStatus(in String portName, boolean limit, in Status retval, long transactionId);
 }
diff --git a/usb/aidl/android/hardware/usb/PortStatus.aidl b/usb/aidl/android/hardware/usb/PortStatus.aidl
index 8afe009..fb979e5 100644
--- a/usb/aidl/android/hardware/usb/PortStatus.aidl
+++ b/usb/aidl/android/hardware/usb/PortStatus.aidl
@@ -104,4 +104,8 @@
      * UsbData status of the port.
      */
     boolean usbDataEnabled;
+    /**
+     * Denoted whether power transfer is limited in the port.
+     */
+    boolean powerTransferLimited;
 }