Add resetCb

Add the resetCb to complete asynchronous

Bug: 267252826
Test: Boot to home and function work
Change-Id: I9d6624cbe15c86c63e28f8f176d7c560aed8446f
This commit is contained in:
Ricky Niu 2023-01-31 18:01:06 +08:00 committed by TreeHugger Robot
parent b77191c0fa
commit 744f214f40
2 changed files with 10 additions and 2 deletions

View file

@ -336,11 +336,14 @@ static Status validateAndSetVidPid(int64_t functions) {
return ret; return ret;
} }
ScopedAStatus UsbGadget::reset() { ScopedAStatus UsbGadget::reset(const shared_ptr<IUsbGadgetCallback> &callback,
int64_t in_transactionId) {
ALOGI("USB Gadget reset"); ALOGI("USB Gadget reset");
if (!WriteStringToFile("none", PULLUP_PATH)) { if (!WriteStringToFile("none", PULLUP_PATH)) {
ALOGI("Gadget cannot be pulled down"); ALOGI("Gadget cannot be pulled down");
if (callback)
callback->resetCb(Status::ERROR, in_transactionId);
return ScopedAStatus::fromServiceSpecificErrorWithMessage( return ScopedAStatus::fromServiceSpecificErrorWithMessage(
-1, "Gadget cannot be pulled down"); -1, "Gadget cannot be pulled down");
} }
@ -349,9 +352,13 @@ ScopedAStatus UsbGadget::reset() {
if (!WriteStringToFile(kGadgetName, PULLUP_PATH)) { if (!WriteStringToFile(kGadgetName, PULLUP_PATH)) {
ALOGI("Gadget cannot be pulled up"); ALOGI("Gadget cannot be pulled up");
if (callback)
callback->resetCb(Status::ERROR, in_transactionId);
return ScopedAStatus::fromServiceSpecificErrorWithMessage( return ScopedAStatus::fromServiceSpecificErrorWithMessage(
-1, "Gadget cannot be pulled up"); -1, "Gadget cannot be pulled up");
} }
if (callback)
callback->resetCb(Status::SUCCESS, in_transactionId);
return ScopedAStatus::ok(); return ScopedAStatus::ok();
} }

View file

@ -107,7 +107,8 @@ struct UsbGadget : public BnUsbGadget {
ScopedAStatus getCurrentUsbFunctions(const shared_ptr<IUsbGadgetCallback> &callback, ScopedAStatus getCurrentUsbFunctions(const shared_ptr<IUsbGadgetCallback> &callback,
int64_t in_transactionId) override; 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, ScopedAStatus getUsbSpeed(const shared_ptr<IUsbGadgetCallback> &callback,
int64_t in_transactionId) override; int64_t in_transactionId) override;