The USB Port Reset API is a system API available in the Android Open Source Project (AOSP) for devices running Android 11 or higher. Use it to reset the USB gadget connection with the connected host. To support the USB Port Reset API, device manufacturers must implement USB Gadget HAL V1.1. To use the USB Port Reset API, a system privileged app is required.
Finding USB Gadget HAL v1.1 and USB Port Reset API
Device manufacturers must implement USB Gadget HAL v1.1 to support the USB Port Reset API.
- To find the default implementation of USB Gadget HAL v.1.1, use the
- To find the hardware interface header file, use the following path:
- To find the USB Port Reset API, use this path to locate the API under the
AIDL header file. This path is also the Android Framework entry point for
the USB Port Reset API:
Implementing Gadget HAL v1.1
To support the USB Port Reset API, you must implement the USB Gadget HAL v1.1. No system UI implementation is required. To implement USB Gadget HAL v1.1 for USB Port Reset API, reset the USB connection between the target device and the host.
USB Port Reset API code flow
The figure below illustrates the code flow of the USB Port Reset API in a framework, including the implementation of the USB Gadget HAL.
Figure 1. Example USB Port Reset API code flow
Follow this path to find the VTS test case implemented for the USB Port Reset API:
The VTS test case for USB Port Reset API is a host-side test case that lets you perform the following actions:
- Invoke the USB Port Reset API using adb shell command
#svc usb resetUsbGadget).
- Check if the device under test (DUT) can disconnect and reconnect.