Merge "Add resetCb"

This commit is contained in:
TreeHugger Robot 2023-02-09 02:02:55 +00:00 committed by Android (Google) Code Review
commit d66731d396
6 changed files with 21 additions and 4 deletions

View file

@ -37,5 +37,5 @@ interface IUsbGadget {
oneway void setCurrentUsbFunctions(in long functions, in android.hardware.usb.gadget.IUsbGadgetCallback callback, in long timeoutMs, long transactionId);
oneway void getCurrentUsbFunctions(in android.hardware.usb.gadget.IUsbGadgetCallback callback, long transactionId);
oneway void getUsbSpeed(in android.hardware.usb.gadget.IUsbGadgetCallback callback, long transactionId);
oneway void reset();
oneway void reset(in android.hardware.usb.gadget.IUsbGadgetCallback callback, long transactionId);
}

View file

@ -37,4 +37,5 @@ interface IUsbGadgetCallback {
oneway void setCurrentUsbFunctionsCb(in long functions, in android.hardware.usb.gadget.Status status, long transactionId);
oneway void getCurrentUsbFunctionsCb(in long functions, in android.hardware.usb.gadget.Status status, long transactionId);
oneway void getUsbSpeedCb(in android.hardware.usb.gadget.UsbSpeed speed, long transactionId);
oneway void resetCb(in android.hardware.usb.gadget.Status status, long transactionId);
}

View file

@ -59,6 +59,10 @@ oneway interface IUsbGadget {
* This function is used to reset USB gadget driver.
* Performs USB data connection reset. The connection will disconnect and
* reconnect.
*
* @param callback IUsbGadgetCallback::resetCb used to propagate
* the result of requesting resetUsbGadget.
* @param transactionId ID to be used when invoking the callback.
*/
void reset();
void reset(in IUsbGadgetCallback callback, long transactionId);
}

View file

@ -59,4 +59,12 @@ oneway interface IUsbGadgetCallback {
* @param transactionId ID to be used when invoking the callback.
*/
void getUsbSpeedCb(in UsbSpeed speed, long transactionId);
/**
* Callback function used to propagate the result of requesting
* resetUsbGadget.
* @param status SUCCESS if current request succeeded. FAILURE otherwise.
* @param transactionId current transactionId sent during reset request.
*/
void resetCb(in Status status, long transactionId);
}

View file

@ -144,7 +144,10 @@ Status UsbGadget::tearDownGadget() {
return Status::SUCCESS;
}
ScopedAStatus UsbGadget::reset() {
ScopedAStatus UsbGadget::reset(const shared_ptr<IUsbGadgetCallback> &callback,
int64_t in_transactionId) {
if (callback)
callback->resetCb(Status::SUCCESS, in_transactionId);
return ScopedAStatus::ok();
}

View file

@ -96,7 +96,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;