Starting March 27, 2025, we recommend using android-latest-release
instead of aosp-main
to build and contribute to AOSP. For more information, see Changes to AOSP.
USB Port Reset API
Stay organized with collections
Save and categorize content based on your preferences.
To support the USB Hardware Abstraction Layer (HAL) API, device manufacturers
must implement the corresponding USB HAL version. To use the USB HAL API, a
system-privileged app is required.
The USB HAL supports the USB Port Reset API, which requires USB HAL v2.0 and is
available for devices running Android 13 and higher. Use this API to reset the
USB connection with the connected host.
Find the USB HAL and its APIs
Device manufacturers must implement the USB HAL to support the APIs.
To find the default implementation of USB HAL, use the following paths:
Version AIDL (latest):
<aosp>/hardware/interfaces/usb/gadget/1.2/default/
To find the hardware interface header file, use the following path:
Version AIDL (latest):
<aosp>/hardware/interfaces/usb/gadget/1.2/IUsbGadget.hal
To find the APIs, use the following path to locate the APIs under the
AIDL header file. This path is also the Android Framework entry point for the API:
android.hardware.usb
:
<aosp>/core/java/android/hardware/usb
Implement the USB HAL
To work with the USB HAL API, implement the:
Correct USB HAL version. No system UI implementation is required.
USB AIDL HAL for the USB Port Reset API by resetting the USB connection between the target device and the host.
Understand the USB HAL API architecture
The USB HAL API is built into the android.hardware.usb
package and leverages the USB HAL to interact with the device. Details about the architecture for the API is provided in the figure below.
USB Port Reset API
The following figure illustrates the code flow of the USB Port Reset API in a framework, including the implementation of the USB HAL.
Figure 1.1 Sample USB Port Reseat API code flow.
Validate your implementation
Each USB HAL version and its corresponding API is associated with a test case in
the Vendor Test Suite (VTS).
USB Port Reset API
To find the VTS test case for the USB Port Reset API, go to:
<aosp>/test/vts-testcase/hal/usb/gadget/V1_2/
The VTS test case for USB HAL v1.2 is a host-side test case you can use to
perform these actions.
To invoke the USB Port Reset API, use the adb shell
command (#svc usb resetUsbPort
).
Confirm that the device under test (DUT) can disconnect and reconnect.
Content and code samples on this page are subject to the licenses described in the Content License. Java and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.
Last updated 2025-06-18 UTC.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-06-18 UTC."],[],[],null,["# USB Port Reset API\n\nTo support the USB Hardware Abstraction Layer (HAL) API, device manufacturers\nmust implement the corresponding USB HAL version. To use the USB HAL API, a\nsystem-privileged app is required.\n\nThe USB HAL supports the USB Port Reset API, which requires USB HAL v2.0 and is\navailable for devices running Android 13 and higher. Use this API to reset the\nUSB connection with the connected host.\n\nFind the USB HAL and its APIs\n-----------------------------\n\nDevice manufacturers must implement the USB HAL to support the APIs.\n\n1. To find the default implementation of USB HAL, use the following paths:\n\n **Version AIDL (latest):**\n [`\u003caosp\u003e/hardware/interfaces/usb/gadget/1.2/default/`](https://android.googlesource.com/platform/hardware/interfaces/+/refs/heads/android16-release/usb/gadget/1.2/default/)\n2. To find the hardware interface header file, use the following path:\n\n **Version AIDL (latest):**\n [`\u003caosp\u003e/hardware/interfaces/usb/gadget/1.2/IUsbGadget.hal`](https://android.googlesource.com/platform/hardware/interfaces/+/refs/heads/android16-release/usb/gadget/1.2/IUsbGadget.hal)\n3. To find the APIs, use the following path to locate the APIs under the\n AIDL header file. This path is also the Android Framework entry point for the API:\n\n `android.hardware.usb`:\n [`\u003caosp\u003e/core/java/android/hardware/usb`](https://android.googlesource.com/platform/frameworks/base/+/refs/heads/android16-release/core/java/android/hardware/usb/IUsbManager.aidl)\n\nImplement the USB HAL\n---------------------\n\nTo work with the USB HAL API, implement the:\n\n1. Correct USB HAL version. No system UI implementation is required.\n\n2. USB AIDL HAL for the USB Port Reset API by resetting the USB connection between the target device and the host.\n\nUnderstand the USB HAL API architecture\n---------------------------------------\n\nThe USB HAL API is built into the `android.hardware.usb` package and leverages the USB HAL to interact with the device. Details about the architecture for the API is provided in the figure below.\n\n### USB Port Reset API\n\nThe following figure illustrates the code flow of the USB Port Reset API in a framework, including the implementation of the USB HAL.\n\n**Figure 1.1** Sample USB Port Reseat API code flow.\n\nValidate your implementation\n----------------------------\n\nEach USB HAL version and its corresponding API is associated with a test case in\nthe Vendor Test Suite (VTS).\n\n### USB Port Reset API\n\nTo find the VTS test case for the USB Port Reset API, go to:\n\n[`\u003caosp\u003e/test/vts-testcase/hal/usb/gadget/V1_2/`](https://android.googlesource.com/platform/test/vts-testcase/hal/+/refs/heads/android16-release/usb/gadget/V1_2)\n\nThe VTS test case for USB HAL v1.2 is a host-side test case you can use to\nperform these actions.\n\n- To invoke the USB Port Reset API, use the `adb shell`\n command (`#svc usb resetUsbPort`).\n\n- Confirm that the device under test (DUT) can disconnect and reconnect."]]