diff options
author | Ricky Niu <rickyniu@google.com> | 2021-12-07 20:27:37 +0800 |
---|---|---|
committer | Ricky Niu <rickyniu@google.com> | 2022-01-24 21:28:45 +0800 |
commit | 45131a73095f00b9598c677d3270fb8fe41d0584 (patch) | |
tree | 7b4f36a95f5658e00962fbb569a7fec2aac4834f /usb | |
parent | f883235915244d50bdbe59fa6317ed71094a3fe9 (diff) | |
download | interfaces-45131a73095f00b9598c677d3270fb8fe41d0584.tar.gz |
Add resetUsbPort in USB HAL interface
Bug: 197300598
Test: Verify the API working manually
Signed-off-by: Ricky Niu <rickyniu@google.com>
Change-Id: I52de859244145cb8699f6138ee73a7fe47fdd67b
Diffstat (limited to 'usb')
6 files changed, 38 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 4ba9ff8dff..f866c1eb5b 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 @@ -41,4 +41,5 @@ interface IUsb { 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); + oneway void resetUsbPort(in String portName,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 57f02c548c..4abfaec53b 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 @@ -41,4 +41,5 @@ interface IUsbCallback { 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); + oneway void notifyResetUsbPortStatus(in String portName, in android.hardware.usb.Status retval, long transactionId); } diff --git a/usb/aidl/android/hardware/usb/IUsb.aidl b/usb/aidl/android/hardware/usb/IUsb.aidl index d296fbb209..90ad115731 100644 --- a/usb/aidl/android/hardware/usb/IUsb.aidl +++ b/usb/aidl/android/hardware/usb/IUsb.aidl @@ -104,4 +104,13 @@ oneway interface IUsb { * @param transactionId ID to be used when invoking the callback. */ void limitPowerTransfer(in String portName, boolean limit, long transactionId); + + /** + * This function is used to reset the port role of a specific port. + * For instance, when data transfer through the port fails. + * + * @param portName name of the port that is being reset + * @param transactionId ID to be used when invoking the callback. + */ + void resetUsbPort(in String portName, long transactionId); } diff --git a/usb/aidl/android/hardware/usb/IUsbCallback.aidl b/usb/aidl/android/hardware/usb/IUsbCallback.aidl index e33672aa2b..2ae10d975f 100644 --- a/usb/aidl/android/hardware/usb/IUsbCallback.aidl +++ b/usb/aidl/android/hardware/usb/IUsbCallback.aidl @@ -105,4 +105,13 @@ oneway interface IUsbCallback { * @param transactionId ID sent during limitPowerTransfer request. */ void notifyLimitPowerTransferStatus(in String portName, boolean limit, in Status retval, long transactionId); + + /** + * Used to notify the result of requesting resetUsbPort. + * + * @param portName name of the port that was being reset. + * @param retval SUCCESS if current request succeeded. FAILURE otherwise. + * @param transactionId current transactionId sent during resetUsbPort request. + */ + void notifyResetUsbPortStatus(in String portName, in Status retval, long transactionId); } diff --git a/usb/aidl/default/Usb.cpp b/usb/aidl/default/Usb.cpp index 92b09a2b44..7e738c477f 100644 --- a/usb/aidl/default/Usb.cpp +++ b/usb/aidl/default/Usb.cpp @@ -90,6 +90,22 @@ ScopedAStatus Usb::enableUsbDataWhileDocked(const string& in_portName, int64_t i return ScopedAStatus::ok(); } +ScopedAStatus Usb::resetUsbPort(const string& in_portName, int64_t in_transactionId) { + + pthread_mutex_lock(&mLock); + if (mCallback != NULL) { + ScopedAStatus ret = mCallback->notifyResetUsbPortStatus( + in_portName, Status::NOT_SUPPORTED, in_transactionId); + if (!ret.isOk()) + ALOGE("notifyResetUsbPortStatus error %s", ret.getDescription().c_str()); + } else { + ALOGE("Not notifying the userspace. Callback is not set"); + } + pthread_mutex_unlock(&mLock); + + return ScopedAStatus::ok(); +} + Status queryMoistureDetectionStatus(std::vector<PortStatus> *currentPortStatus) { string enabled, status, path, DetectedPath; diff --git a/usb/aidl/default/Usb.h b/usb/aidl/default/Usb.h index 7e8422e39b..d507af6f53 100644 --- a/usb/aidl/default/Usb.h +++ b/usb/aidl/default/Usb.h @@ -58,6 +58,8 @@ struct Usb : public BnUsb { int64_t in_transactionId) override; ScopedAStatus limitPowerTransfer(const std::string& in_portName, bool in_limit, int64_t in_transactionId)override; + ScopedAStatus resetUsbPort(const std::string& in_portName, + int64_t in_transactionId)override; shared_ptr<IUsbCallback> mCallback; // Protects mCallback variable |