summaryrefslogtreecommitdiff
path: root/usb
diff options
context:
space:
mode:
authorBadhri Jagan Sridharan <badhri@google.com>2021-11-25 09:35:21 -0800
committerRicky Niu <rickyniu@google.com>2022-01-21 18:49:39 +0800
commit623f13385f0e839c2c1d41e61f149a61f2e10e31 (patch)
treeb1c10844f6bc91bd8cfe56397a0efdaf3944b9fe /usb
parentaef9dec7dd394016caf42cd0287430f94b5d31ed (diff)
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
Diffstat (limited to 'usb')
-rw-r--r--usb/aidl/aidl_api/android.hardware.usb/current/android/hardware/usb/IUsb.aidl1
-rw-r--r--usb/aidl/aidl_api/android.hardware.usb/current/android/hardware/usb/IUsbCallback.aidl1
-rw-r--r--usb/aidl/aidl_api/android.hardware.usb/current/android/hardware/usb/PortStatus.aidl1
-rw-r--r--usb/aidl/android/hardware/usb/IUsb.aidl13
-rw-r--r--usb/aidl/android/hardware/usb/IUsbCallback.aidl12
-rw-r--r--usb/aidl/android/hardware/usb/PortStatus.aidl4
-rw-r--r--usb/aidl/default/Usb.cpp18
-rw-r--r--usb/aidl/default/Usb.h2
8 files changed, 52 insertions, 0 deletions
diff --git a/usb/aidl/aidl_api/android.hardware.usb/current/android/hardware/usb/IUsb.aidl b/usb/aidl/aidl_api/android.hardware.usb/current/android/hardware/usb/IUsb.aidl
index 7513461afb..73c7b825e2 100644
--- a/usb/aidl/aidl_api/android.hardware.usb/current/android/hardware/usb/IUsb.aidl
+++ b/usb/aidl/aidl_api/android.hardware.usb/current/android/hardware/usb/IUsb.aidl
@@ -39,4 +39,5 @@ interface IUsb {
oneway void queryPortStatus(long transactionId);
oneway void setCallback(in android.hardware.usb.IUsbCallback callback);
oneway void switchRole(in String portName, in android.hardware.usb.PortRole role, long transactionId);
+ oneway void limitPowerTransfer(in String portName, boolean limit, long transactionId);
}
diff --git a/usb/aidl/aidl_api/android.hardware.usb/current/android/hardware/usb/IUsbCallback.aidl b/usb/aidl/aidl_api/android.hardware.usb/current/android/hardware/usb/IUsbCallback.aidl
index 57be590563..85861e9d41 100644
--- a/usb/aidl/aidl_api/android.hardware.usb/current/android/hardware/usb/IUsbCallback.aidl
+++ b/usb/aidl/aidl_api/android.hardware.usb/current/android/hardware/usb/IUsbCallback.aidl
@@ -39,4 +39,5 @@ interface IUsbCallback {
oneway void notifyEnableUsbDataStatus(in String portName, boolean enable, in android.hardware.usb.Status retval, long transactionId);
oneway void notifyContaminantEnabledStatus(in String portName, boolean enable, in android.hardware.usb.Status retval, long transactionId);
oneway void notifyQueryPortStatus(in String portName, in android.hardware.usb.Status retval, long transactionId);
+ oneway void notifyLimitPowerTransferStatus(in String portName, boolean limit, in android.hardware.usb.Status retval, long transactionId);
}
diff --git a/usb/aidl/aidl_api/android.hardware.usb/current/android/hardware/usb/PortStatus.aidl b/usb/aidl/aidl_api/android.hardware.usb/current/android/hardware/usb/PortStatus.aidl
index 78dcfacef9..14bb90fd15 100644
--- a/usb/aidl/aidl_api/android.hardware.usb/current/android/hardware/usb/PortStatus.aidl
+++ b/usb/aidl/aidl_api/android.hardware.usb/current/android/hardware/usb/PortStatus.aidl
@@ -48,4 +48,5 @@ parcelable PortStatus {
boolean supportsEnableContaminantPresenceDetection;
android.hardware.usb.ContaminantDetectionStatus contaminantDetectionStatus = android.hardware.usb.ContaminantDetectionStatus.NOT_SUPPORTED;
boolean usbDataEnabled;
+ boolean powerTransferLimited;
}
diff --git a/usb/aidl/android/hardware/usb/IUsb.aidl b/usb/aidl/android/hardware/usb/IUsb.aidl
index 9a8f0006ee..1596d9ada5 100644
--- a/usb/aidl/android/hardware/usb/IUsb.aidl
+++ b/usb/aidl/android/hardware/usb/IUsb.aidl
@@ -82,4 +82,17 @@ oneway interface IUsb {
* @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 232a15babe..b733fede3b 100644
--- a/usb/aidl/android/hardware/usb/IUsbCallback.aidl
+++ b/usb/aidl/android/hardware/usb/IUsbCallback.aidl
@@ -83,4 +83,16 @@ oneway interface IUsbCallback {
* @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 8afe00916c..fb979e5f62 100644
--- a/usb/aidl/android/hardware/usb/PortStatus.aidl
+++ b/usb/aidl/android/hardware/usb/PortStatus.aidl
@@ -104,4 +104,8 @@ parcelable PortStatus {
* UsbData status of the port.
*/
boolean usbDataEnabled;
+ /**
+ * Denoted whether power transfer is limited in the port.
+ */
+ boolean powerTransferLimited;
}
diff --git a/usb/aidl/default/Usb.cpp b/usb/aidl/default/Usb.cpp
index 1105376ad9..0624963883 100644
--- a/usb/aidl/default/Usb.cpp
+++ b/usb/aidl/default/Usb.cpp
@@ -289,6 +289,24 @@ ScopedAStatus Usb::switchRole(const string& in_portName,
return ScopedAStatus::ok();
}
+ScopedAStatus Usb::limitPowerTransfer(const string& in_portName, bool /*in_limit*/,
+ int64_t in_transactionId) {
+ std::vector<PortStatus> currentPortStatus;
+
+ pthread_mutex_lock(&mLock);
+ if (mCallback != NULL && in_transactionId >= 0) {
+ ScopedAStatus ret = mCallback->notifyLimitPowerTransferStatus(
+ in_portName, false, Status::NOT_SUPPORTED, in_transactionId);
+ if (!ret.isOk())
+ ALOGE("limitPowerTransfer error %s", ret.getDescription().c_str());
+ } else {
+ ALOGE("Not notifying the userspace. Callback is not set");
+ }
+ pthread_mutex_unlock(&mLock);
+
+ return ScopedAStatus::ok();
+}
+
Status getAccessoryConnected(const string &portName, string *accessory) {
string filename = kTypecPath + portName + "-partner/accessory_mode";
diff --git a/usb/aidl/default/Usb.h b/usb/aidl/default/Usb.h
index bca86ae06c..71ec938a56 100644
--- a/usb/aidl/default/Usb.h
+++ b/usb/aidl/default/Usb.h
@@ -54,6 +54,8 @@ struct Usb : public BnUsb {
int64_t in_transactionId) override;
ScopedAStatus enableUsbData(const string& in_portName, bool in_enable,
int64_t in_transactionId) override;
+ ScopedAStatus limitPowerTransfer(const std::string& in_portName, bool in_limit,
+ int64_t in_transactionId)override;
shared_ptr<IUsbCallback> mCallback;
// Protects mCallback variable