diff --git a/usb/gadget/UsbGadget.cpp b/usb/gadget/UsbGadget.cpp index 3a5309ab..04dcd932 100644 --- a/usb/gadget/UsbGadget.cpp +++ b/usb/gadget/UsbGadget.cpp @@ -309,11 +309,14 @@ static Status validateAndSetVidPid(uint64_t functions) { return ret; } -ScopedAStatus UsbGadget::reset() { +ScopedAStatus UsbGadget::reset(const shared_ptr &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"); } @@ -322,9 +325,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 4483710f..4079b017 100644 --- a/usb/gadget/UsbGadget.h +++ b/usb/gadget/UsbGadget.h @@ -107,7 +107,8 @@ struct UsbGadget : public BnUsbGadget { ScopedAStatus getCurrentUsbFunctions(const shared_ptr &callback, int64_t in_transactionId) override; - ScopedAStatus reset() override; + ScopedAStatus reset(const shared_ptr &callback, + int64_t in_transactionId) override; ScopedAStatus getUsbSpeed(const shared_ptr &callback, int64_t in_transactionId) override;