summaryrefslogtreecommitdiff
path: root/usb
diff options
context:
space:
mode:
authorRicky Niu <rickyniu@google.com>2023-01-31 18:01:06 +0800
committerTreeHugger Robot <treehugger-gerrit@google.com>2023-02-09 02:02:50 +0000
commitf14cbd637085145feff255b192a8031375fcdaa4 (patch)
tree9959c372f31466da3774bc5f20ce2d89aee43ab4 /usb
parentc7e2a540af99476c3c71083f82f744dc8b296ec6 (diff)
downloadgs201-f14cbd637085145feff255b192a8031375fcdaa4.tar.gz
Add resetCb
Add the resetCb to complete asynchronous Bug: 267252826 Test: Boot to home and function work Change-Id: I9d6624cbe15c86c63e28f8f176d7c560aed8446f
Diffstat (limited to 'usb')
-rw-r--r--usb/gadget/UsbGadget.cpp9
-rw-r--r--usb/gadget/UsbGadget.h3
2 files changed, 10 insertions, 2 deletions
diff --git a/usb/gadget/UsbGadget.cpp b/usb/gadget/UsbGadget.cpp
index 040e453..5da4dd9 100644
--- a/usb/gadget/UsbGadget.cpp
+++ b/usb/gadget/UsbGadget.cpp
@@ -336,11 +336,14 @@ static Status validateAndSetVidPid(uint64_t functions) {
return ret;
}
-ScopedAStatus UsbGadget::reset() {
+ScopedAStatus UsbGadget::reset(const shared_ptr<IUsbGadgetCallback> &callback,
+ int64_t in_transactionId) {
ALOGI("USB Gadget reset");
if (!WriteStringToFile("none", PULLUP_PATH)) {
ALOGI("Gadget cannot be pulled down");
+ if (callback)
+ callback->resetCb(Status::ERROR, in_transactionId);
return ScopedAStatus::fromServiceSpecificErrorWithMessage(
-1, "Gadget cannot be pulled down");
}
@@ -349,9 +352,13 @@ ScopedAStatus UsbGadget::reset() {
if (!WriteStringToFile(kGadgetName, PULLUP_PATH)) {
ALOGI("Gadget cannot be pulled up");
+ if (callback)
+ callback->resetCb(Status::ERROR, in_transactionId);
return ScopedAStatus::fromServiceSpecificErrorWithMessage(
-1, "Gadget cannot be pulled up");
}
+ if (callback)
+ callback->resetCb(Status::SUCCESS, in_transactionId);
return ScopedAStatus::ok();
}
diff --git a/usb/gadget/UsbGadget.h b/usb/gadget/UsbGadget.h
index 1254c8f..403f2cc 100644
--- a/usb/gadget/UsbGadget.h
+++ b/usb/gadget/UsbGadget.h
@@ -107,7 +107,8 @@ struct UsbGadget : public BnUsbGadget {
ScopedAStatus getCurrentUsbFunctions(const shared_ptr<IUsbGadgetCallback> &callback,
int64_t in_transactionId) override;
- ScopedAStatus reset() override;
+ ScopedAStatus reset(const shared_ptr<IUsbGadgetCallback> &callback,
+ int64_t in_transactionId) override;
ScopedAStatus getUsbSpeed(const shared_ptr<IUsbGadgetCallback> &callback,
int64_t in_transactionId) override;