自 2025 年 3 月 27 日起,我们建议您使用 android-latest-release
而非 aosp-main
构建 AOSP 并为其做出贡献。如需了解详情,请参阅 AOSP 的变更。
USB 耳机:设备规范
使用集合让一切井井有条
根据您的偏好保存内容并对其进行分类。
为了让 USB 耳机能够在 Android 生态系统中无缝工作,Android 设备必须为其提供一致的支持。本文档详细说明了在整个 Android 生态系统中支持 USB 耳机和适配器的 USB 行为。
软件映射
兼容的 USB 耳机需要支持兼容的 HID 映射。以下键码映射需要设备支持。
函数 |
映射 |
情境 |
行为 |
A |
HID 用法页:0x0C
HID 用法:0x0CD
内核键:KEY_PLAYPAUSE
Android 键:KEYCODE_MEDIA_PLAY_PAUSE |
媒体播放 |
输入:短按
输出:播放或暂停 |
输入:长按
输出:启动语音指令
如果设备锁定或其屏幕关闭,发送:android.speech.action.VOICE_SEARCH_HANDS_FREE ,否则发送 android.speech.RecognizerIntent.ACTION_WEB_SEARCH |
来电 |
输入:短按
输出:接听来电 |
输入:长按
输出:拒接来电 |
正在通话 |
输入:短按
输出:结束通话 |
输入:长按
输出:将麦克风静音或取消静音 |
B |
HID 用途页:0x0C
HID 用途:0x0E9
内核按键:KEY_VOLUMEUP
Android 按键:VOLUME_UP |
媒体播放、当前通话 |
输入:短按或长按
输出:调高系统或耳机的音量 |
C |
HID 用途页:0x0C
HID 用途:0x0EA
内核按键:KEY_VOLUMEDOWN
Android 按键:VOLUME_DOWN |
媒体播放、当前通话 |
输入:短按或长按
输出:调低系统或耳机的音量 |
D |
HID 用途页:0x0C
HID 用途:0x0CF
内核按键:KEY_VOICECOMMAND
Android 按键:KEYCODE_VOICE_ASSIST |
所有。可在任何情况下触发。 |
输入:短按或长按
输出:启动语音指令 |
硬件
设备制造商还应参阅 USB 数字音频,进一步了解 Android 设备上的 USB 实现。此外,设备制造商还必须遵循 Android CDD 中 USB 部分的要求。
本页面上的内容和代码示例受内容许可部分所述许可的限制。Java 和 OpenJDK 是 Oracle 和/或其关联公司的注册商标。
最后更新时间 (UTC):2025-07-27。
[[["易于理解","easyToUnderstand","thumb-up"],["解决了我的问题","solvedMyProblem","thumb-up"],["其他","otherUp","thumb-up"]],[["没有我需要的信息","missingTheInformationINeed","thumb-down"],["太复杂/步骤太多","tooComplicatedTooManySteps","thumb-down"],["内容需要更新","outOfDate","thumb-down"],["翻译问题","translationIssue","thumb-down"],["示例/代码问题","samplesCodeIssue","thumb-down"],["其他","otherDown","thumb-down"]],["最后更新时间 (UTC):2025-07-27。"],[],[],null,["# USB headset: Device specification\n\nFor USB headsets to work seamlessly across the Android ecosystem, Android\ndevices must support them uniformly. This documentation specifies USB\nbehavior to support USB headsets and adapters across the Android ecosystem.\n\nSoftware mapping\n----------------\n\n\nCompatible USB headsets are required to support compatible HID mappings.\nDevice support is required for the following keycode mappings.\n\n| Function | Mappings | Context | Behavior |\n|----------|-------------------------------------------------------------------------------------------------------------------------------|----------------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| A | **HID usage page** : 0x0C **HID usage** : 0x0CD **Kernel key** : `KEY_PLAYPAUSE` **Android key** : `KEYCODE_MEDIA_PLAY_PAUSE` | Media playback | **Input** : Short press **Output**: Play or pause |\n| A | **HID usage page** : 0x0C **HID usage** : 0x0CD **Kernel key** : `KEY_PLAYPAUSE` **Android key** : `KEYCODE_MEDIA_PLAY_PAUSE` | Media playback | **Input** : Long press **Output** : Launch voice command **Sends** : `android.speech.action.VOICE_SEARCH_HANDS_FREE` if the device is locked or its screen is off. Sends `android.speech.RecognizerIntent.ACTION_WEB_SEARCH` otherwise |\n| A | **HID usage page** : 0x0C **HID usage** : 0x0CD **Kernel key** : `KEY_PLAYPAUSE` **Android key** : `KEYCODE_MEDIA_PLAY_PAUSE` | Incoming call | **Input** : Short press **Output**: Accept call |\n| A | **HID usage page** : 0x0C **HID usage** : 0x0CD **Kernel key** : `KEY_PLAYPAUSE` **Android key** : `KEYCODE_MEDIA_PLAY_PAUSE` | Incoming call | **Input** : Long press **Output**: Reject call |\n| A | **HID usage page** : 0x0C **HID usage** : 0x0CD **Kernel key** : `KEY_PLAYPAUSE` **Android key** : `KEYCODE_MEDIA_PLAY_PAUSE` | Ongoing call | **Input** : Short press **Output**: End call |\n| A | **HID usage page** : 0x0C **HID usage** : 0x0CD **Kernel key** : `KEY_PLAYPAUSE` **Android key** : `KEYCODE_MEDIA_PLAY_PAUSE` | Ongoing call | **Input** : Long press **Output**: Mute or unmute microphone |\n| B | **HID usage page** : 0x0C **HID usage** : 0x0E9 **Kernel key** : `KEY_VOLUMEUP` **Android key** : `VOLUME_UP` | Media playback, Ongoing call | **Input** : Short or long press **Output**: Increases the system or headset volume |\n| C | **HID usage page** : 0x0C **HID usage** : 0x0EA **Kernel key** : `KEY_VOLUMEDOWN` **Android key** : `VOLUME_DOWN` | Media playback, Ongoing call | **Input** : Short or long press **Output**: Decreases the system or headset volume |\n| D | **HID usage page** : 0x0C **HID usage** : 0x0CF **Kernel key** : `KEY_VOICECOMMAND` **Android key** : `KEYCODE_VOICE_ASSIST` | All. Can be triggered in any instance. | **Input** : Short or long press **Output**: Launch voice command |\n\nHardware\n--------\n\n\nDevice manufacturers should also see\n[USB digital audio](/docs/core/audio/usb) for more\ninformation about USB implementation on Android. Device manufacturers must also\nfollow the requirements in the\n[USB section](/docs/compatibility/13/android-13-cdd#77_usb) of the Android CDD."]]