blob: b3cc73fe19af836854e076b818fa75611b8f5c43 [file] [log] [blame]
<html devsite><head>
<title>USB 耳机:设备规范</title>
<meta name="project_path" value="/_project.yaml"/>
<meta name="book_path" value="/_book.yaml"/>
</head>
<body>
<!--
Copyright 2017 The Android Open Source Project
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<p>为了让 USB 耳机能够在 Android 生态系统中无缝工作,Android 设备必须为其提供一致的支持。本文档详细说明了在整个 Android 生态系统中支持 USB 耳机和适配器的 USB 行为。
</p>
<h2 id="software-mapping">软件映射</h2>
<p>
兼容的 USB 耳机需要支持兼容的 HID 映射。以下键码映射需要设备支持。
</p>
<table>
<tbody><tr>
<th>函数</th>
<th>映射</th>
<th>环境</th>
<th>行为</th>
</tr>
<tr>
<td rowspan="6">A</td>
<td rowspan="6"><strong>HID 用途页</strong>:0x0C<br />
<strong>HID 用途</strong>:0x0CD<br />
<strong>内核按键</strong><code>KEY_PLAYPAUSE</code><br />
<strong>Android 按键</strong><code>KEYCODE_MEDIA_PLAY_PAUSE</code></td>
<td rowspan="2">媒体播放</td>
<td><strong>输入</strong>:短按<br />
<strong>输出</strong>:播放或暂停</td>
</tr>
<tr>
<td><strong>输入</strong>:长按<br />
<strong>输出</strong>:启动语音指令<br />
<strong>发送</strong><code>android.speech.action.VOICE_SEARCH_HANDS_FREE</code>(如果设备被锁定或其屏幕已关闭)。否则发送 <code>android.speech.RecognizerIntent.ACTION_WEB_SEARCH</code></td>
</tr>
<tr>
<td rowspan="2">来电</td>
<td><strong>输入</strong>:短按<br />
<strong>输出</strong>:接听来电</td>
</tr>
<tr>
<td><strong>输入</strong>:长按<br />
<strong>输出</strong>:拒绝来电</td>
</tr>
<tr>
<td rowspan="2">当前通话</td>
<td><strong>输入</strong>:短按<br />
<strong>输出</strong>:结束通话</td>
</tr>
<tr>
<td><strong>输入</strong>:长按<br />
<strong>输出</strong>:将麦克风设为静音或取消静音</td>
</tr>
<tr>
<td>B</td>
<td><strong>HID 用途页</strong>:0x0C<br />
<strong>HID 用途</strong>:0x0E9<br />
<strong>内核按键</strong><code>KEY_VOLUMEUP</code><br />
<strong>Android 按键</strong><code>VOLUME_UP</code></td>
<td>媒体播放、当前通话</td>
<td><strong>输入</strong>:短按或长按<br />
<strong>输出</strong>:调高系统或耳机的音量</td>
</tr>
<tr>
<td>C</td>
<td><strong>HID 用途页</strong>:0x0C<br />
<strong>HID 用途</strong>:0x0EA<br />
<strong>内核按键</strong><code>KEY_VOLUMEDOWN</code><br />
<strong>Android 按键</strong><code>VOLUME_DOWN</code></td>
<td>媒体播放、当前通话</td>
<td><strong>输入</strong>:短按或长按<br />
<strong>输出</strong>:调低系统或耳机的音量</td>
</tr>
<tr>
<td>D</td>
<td><strong>HID 用途页</strong>:0x0C<br />
<strong>HID 用途</strong>:0x0CF<br />
<strong>内核按键</strong><code>KEY_VOICECOMMAND</code><br />
<strong>Android 按键</strong><code>KEYCODE_VOICE_ASSIST</code></td>
<td>所有。可在任何情况下触发。</td>
<td><strong>输入</strong>:短按或长按<br />
<strong>输出</strong>:启动语音指令</td>
</tr>
</tbody></table>
<h2 id="mechanical">机械工程</h2>
<p>
设备制造商还应参考 <a href="/devices/audio/usb.html">USB 数字音频</a>页面,以了解有关在 Android 设备上实现 USB 的更多信息。设备制造商还必须遵循 Android CDD 的 <a href="/compatibility/android-cdd.html#7_7_usb">USB 部分</a>中的要求。</p>
</body></html>