Implement resetUsbPort in USB HAL
Bug: 197300598 Test: Check it works Signed-off-by: Ricky Niu <rickyniu@google.com> Change-Id: Ibd6fd14faf47e1ad5d7817b006f9ba64e2ab5fb9
This commit is contained in:
parent
6d45ee7df3
commit
df693e00a8
2 changed files with 26 additions and 0 deletions
|
@ -172,6 +172,31 @@ ScopedAStatus Usb::enableUsbDataWhileDocked(const string& in_portName,
|
||||||
return ScopedAStatus::ok();
|
return ScopedAStatus::ok();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ScopedAStatus Usb::resetUsbPort(const std::string& in_portName, int64_t in_transactionId) {
|
||||||
|
bool result = true;
|
||||||
|
std::vector<PortStatus> currentPortStatus;
|
||||||
|
|
||||||
|
ALOGI("Userspace reset USB Port. opID:%ld", in_transactionId);
|
||||||
|
|
||||||
|
if (!WriteStringToFile("none", PULLUP_PATH)) {
|
||||||
|
ALOGI("Gadget cannot be pulled down");
|
||||||
|
result = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
pthread_mutex_lock(&mLock);
|
||||||
|
if (mCallback != NULL) {
|
||||||
|
::ndk::ScopedAStatus ret = mCallback->notifyResetUsbPortStatus(
|
||||||
|
in_portName, result ? Status::SUCCESS : Status::ERROR, in_transactionId);
|
||||||
|
if (!ret.isOk())
|
||||||
|
ALOGE("notifyTransactionStatus error %s", ret.getDescription().c_str());
|
||||||
|
} else {
|
||||||
|
ALOGE("Not notifying the userspace. Callback is not set");
|
||||||
|
}
|
||||||
|
pthread_mutex_unlock(&mLock);
|
||||||
|
|
||||||
|
return ::ndk::ScopedAStatus::ok();
|
||||||
|
}
|
||||||
|
|
||||||
Status getI2cBusHelper(string *name) {
|
Status getI2cBusHelper(string *name) {
|
||||||
DIR *dp;
|
DIR *dp;
|
||||||
|
|
||||||
|
|
|
@ -69,6 +69,7 @@ struct Usb : public BnUsb {
|
||||||
int64_t in_transactionId) override;
|
int64_t in_transactionId) override;
|
||||||
ScopedAStatus limitPowerTransfer(const string& in_portName, bool in_limit,
|
ScopedAStatus limitPowerTransfer(const string& in_portName, bool in_limit,
|
||||||
int64_t in_transactionId) override;
|
int64_t in_transactionId) override;
|
||||||
|
ScopedAStatus resetUsbPort(const string& in_portName, int64_t in_transactionId) override;
|
||||||
|
|
||||||
std::shared_ptr<::aidl::android::hardware::usb::IUsbCallback> mCallback;
|
std::shared_ptr<::aidl::android::hardware::usb::IUsbCallback> mCallback;
|
||||||
// Protects mCallback variable
|
// Protects mCallback variable
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue