mirror of
https://github.com/Evolution-X/hardware_interfaces
synced 2026-02-01 11:36:00 +00:00
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
This commit is contained in:
committed by
Ricky Niu
parent
aef9dec7dd
commit
623f13385f
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -48,4 +48,5 @@ parcelable PortStatus {
|
||||
boolean supportsEnableContaminantPresenceDetection;
|
||||
android.hardware.usb.ContaminantDetectionStatus contaminantDetectionStatus = android.hardware.usb.ContaminantDetectionStatus.NOT_SUPPORTED;
|
||||
boolean usbDataEnabled;
|
||||
boolean powerTransferLimited;
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -104,4 +104,8 @@ parcelable PortStatus {
|
||||
* UsbData status of the port.
|
||||
*/
|
||||
boolean usbDataEnabled;
|
||||
/**
|
||||
* Denoted whether power transfer is limited in the port.
|
||||
*/
|
||||
boolean powerTransferLimited;
|
||||
}
|
||||
|
||||
@@ -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";
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user