| <html devsite><head> |
| <title>蓝牙服务</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> |
| 通过蓝牙,设备可以传输数据并供各种交互式服务(例如音频、短信和电话)使用。您可以在以下位置找到用于不同服务的蓝牙配置文件:<code><a href="https://android.googlesource.com/platform/system/bt/+/master/include/hardware/bluetooth.h"> |
| include/hardware/bluetooth.h</a></code>。 |
| </p> |
| |
| <h2 id="audio">音频</h2> |
| |
| <aside class="note"><strong>注意</strong>:目前只有传统版(非低功耗)蓝牙支持所有类型的音频流式传输。 |
| </aside> |
| |
| <p> |
| 利用蓝牙连接,用户可在启用了蓝牙的设备上流式传输音频。对于大多数音频用例,Android 设备是音频源,呈现设备(例如音响设备或耳机)是接收器。 |
| </p> |
| |
| <h3 id="absolute-volume-control">绝对音量控制</h3> |
| |
| <p> |
| 在 Android 6.0 及更高版本中,Android 蓝牙堆栈允许音频源设置绝对音量,以便用户准确控制音频音量。音频源设备会将音量信息和未衰减的音频发送到接收器。然后,接收器会根据音量信息放大音频,以便用户听到准确的播放音量。 |
| </p> |
| |
| <p> |
| 音频源设备还可以注册接收音量通知。进行此项注册后,当用户使用接收器上的控件更改音量时,接收器便会向音频源发送通知。这样一来,音频源便能够准确地在界面上显示音量信息。 |
| </p> |
| |
| <p> |
| 绝对音量控制默认处于开启状态。要停用绝对音量控制,用户可以依次转到<strong>设置</strong> > <strong>系统</strong> > <strong>开发者选项</strong>,然后选择<strong>停用绝对音量功能</strong>开关。 |
| </p> |
| |
| <h3 id="advanced-audio-codecs">高级音频编解码器</h3> |
| |
| <p> |
| 在 Android 8.0 中,使用高级音频分发配置文件 (A2DP) 的设备可以支持额外的音频编解码器。当设备连接到远程音频接收器时,蓝牙堆栈支持音频编解码器协商。该协商旨在选择发送器和接收器都支持的最佳编解码器,以提供高质量的音频。之后,所有音频都会先路由选定的编码器,然后再发送到接收器。 |
| </p> |
| |
| <h4 id="implementation">实现</h4> |
| |
| <p> |
| 运行 Android 8.0 且支持 A2DP 的设备会自动获得额外编解码器支持。设备制造商可能需要针对某些专有音频编解码器获得单独的许可和二进制 Blob。除了 SBC,Android 8.0 还支持以下编解码器: |
| |
| </p> |
| |
| <ul> |
| <li>AAC</li> |
| <li>aptX</li> |
| <li>aptX HD</li> |
| <li>LDAC</li> |
| </ul> |
| |
| <p> |
| 设备制造商可以选择他们的设备首先尝试使用哪些编解码器。可以通过在 <code><a href="https://android.googlesource.com/platform/packages/apps/Bluetooth/+/master/res/values/config.xml"> |
| res/values/config.xml</a></code> 中更改以下值来设置编解码器的优先级: |
| </p> |
| |
| <pre class="prettyprint"> |
| <!-- Configuring priorities of A2DP source codecs. Larger value means |
| higher priority. Value -1 means the codec is disabled. |
| Value 0 is reserved and should not be used here. Enabled codecs |
| should have priorities in the interval [1, 999999], and each |
| priority value should be unique. --> |
| <integer name="a2dp_source_codec_priority_sbc">1001</integer> |
| <integer name="a2dp_source_codec_priority_aac">2001</integer> |
| <integer name="a2dp_source_codec_priority_aptx">3001</integer> |
| <integer name="a2dp_source_codec_priority_aptx_hd">4001</integer> |
| <integer name="a2dp_source_codec_priority_ldac">5001</integer> |
| </pre> |
| |
| <h4 id="ldac-certification">LDAC 认证</h4> |
| |
| <p> |
| Android 开源项目纳入了索尼的 LDAC 编解码器,因此对于该编解码器,不需要单独的许可或 Blob。要将 LDAC 编解码器集成到您的设备中,请向索尼提交申请,并按照 <a href="https://www.sony.net/Products/LDAC/aosp/">LDAC 认证流程</a>进行操作。 |
| </p> |
| |
| <p> |
| LDAC 认证网站上提供了关于 LDAC 的文档(例如规范和操作手册),而且还提供了针对移动设备和平板电脑设备的验证和互操作性测试。需要将表明通过测试的结果发送给索尼,才能完成 LDAC 认证。 |
| </p> |
| |
| <h4 id="ui-features">界面功能</h4> |
| |
| <p> |
| 除了额外编解码器支持,Android 8.0 还提供了一项面向用户的设置,用于停用高清 (HD) 蓝牙音频编解码器。 |
| </p> |
| |
| <ol> |
| <li>依次转到<strong>设置</strong> > <strong>已连接的设备</strong> > <strong>蓝牙</strong>。</li> |
| <li>点按您要停用编解码器的接收器旁边的齿轮图标。</li> |
| <li>取消选中 <strong>HD 音频</strong>复选框。</li> |
| </ol> |
| |
| <p> |
| 对“设置”进行自定义的设备制造商应为用户实现一种停用高清编解码器的方式。 |
| </p> |
| |
| <h2 id="messaging">短信</h2> |
| |
| <p> |
| 借助通过蓝牙发送短信的功能,用户可以从远程设备阅读、浏览和撰写短信。该功能通常是在将手机连接到车载信息娱乐系统时使用。 |
| </p> |
| |
| <aside class="note"><strong>注意</strong>:蓝牙短信服务目前仅支持短信,不支持电子邮件和即时通讯。 |
| </aside> |
| |
| <h2 id="telephony">电话</h2> |
| |
| <p> |
| 通过蓝牙电话服务,用户可以将通话从手机流式传输到另一台蓝牙设备,并可以将手机中的联系人信息同步到另一台蓝牙设备。这些功能经常是在用户开车时用于进行免提通话。 |
| </p> |
| |
| <p> |
| 在 Android 8.0 中,蓝牙支持手机默认铃声。当通过蓝牙连接的手机收到来电时,接收器上将会播放铃声。要启用手机默认铃声,请依次转到<strong>设置</strong> > <strong>系统</strong> > <strong>开发者选项</strong>,然后选择<strong>启用手机默认铃声</strong>开关。 |
| </p> |
| |
| <h2>蓝牙功能</h2> |
| <p>为了实现蓝牙服务,蓝牙堆栈支持多种配置文件和功能。 |
| </p> |
| |
| <h3 id="bluetooth-profiles">蓝牙配置文件</h3> |
| |
| <p> |
| 可用的蓝牙配置文件如下: |
| </p> |
| |
| <table> |
| <tbody><tr> |
| <th colspan="2">功能</th> |
| <th colspan="5">Android 版本</th> |
| </tr> |
| <tr> |
| <th>名称</th> |
| <th>说明</th> |
| <th>6.0</th> |
| <th>7.0</th> |
| <th>7.1</th> |
| <th>7.1.2</th> |
| <th>8 </th> |
| </tr> |
| <tr> |
| <td><strong>SAP</strong></td> |
| <td>SIM 卡访问配置文件</td> |
| <td>1.1</td> |
| <td>1.1</td> |
| <td>1.1</td> |
| <td>1.1</td> |
| <td>1.1</td> |
| </tr> |
| <tr> |
| <td><strong>MAP</strong></td> |
| <td>用于短信的消息访问配置文件</td> |
| <td>1.2</td> |
| <td>1.2</td> |
| <td>1.2</td> |
| <td>1.2</td> |
| <td>1.2</td> |
| </tr> |
| <tr> |
| <td><strong>OPP</strong></td> |
| <td>对象推送配置文件</td> |
| <td>1.1</td> |
| <td>1.1</td> |
| <td>1.1</td> |
| <td>1.1</td> |
| <td>1.2</td> |
| </tr> |
| <tr> |
| <td><strong>OBEX over L2CAP</strong></td> |
| <td>通过逻辑链路控制和适配协议进行对象交换</td> |
| <td>是</td> |
| <td>是</td> |
| <td>是</td> |
| <td>是</td> |
| <td>是</td> |
| </tr> |
| <tr> |
| <td><strong>HFP 音频网关</strong></td> |
| <td>免提模式配置文件</td> |
| <td>1.6</td> |
| <td>1.6</td> |
| <td>1.7</td> |
| <td>1.7</td> |
| <td>1.7</td> |
| </tr> |
| <tr> |
| <td><strong>HSP</strong></td> |
| <td>耳机配置文件</td> |
| <td>1.2</td> |
| <td>1.2</td> |
| <td>1.2</td> |
| <td>1.2</td> |
| <td>1.2</td> |
| </tr> |
| <tr> |
| <td><strong>A2DP</strong></td> |
| <td>高级音频分发配置文件</td> |
| <td>1.2</td> |
| <td>1.2</td> |
| <td>1.2</td> |
| <td>1.2</td> |
| <td>1.2</td> |
| </tr> |
| <tr> |
| <td><strong>AVRCP</strong></td> |
| <td>音频/视频远程控制配置文件</td> |
| <td>1.3</td> |
| <td>1.3</td> |
| <td>1.3</td> |
| <td>1.3</td> |
| <td>1.4</td> |
| </tr> |
| <tr> |
| <td><strong>HID</strong></td> |
| <td>人机接口设备配置文件</td> |
| <td>1.0</td> |
| <td>1.0</td> |
| <td>1.0</td> |
| <td>1.0</td> |
| <td>1.0</td> |
| </tr> |
| <tr> |
| <td><strong>PBAP</strong></td> |
| <td>电话簿访问配置文件</td> |
| <td>1.1.1</td> |
| <td>1.1.1</td> |
| <td>1.1.1</td> |
| <td>1.1.1</td> |
| <td>1.2</td> |
| </tr> |
| <tr> |
| <td><strong>HDP</strong></td> |
| <td>健康设备配置文件</td> |
| <td>1.0</td> |
| <td>1.0</td> |
| <td>1.1</td> |
| <td>1.1</td> |
| <td>1.1</td> |
| </tr> |
| <tr> |
| <td><strong>SPP</strong></td> |
| <td>串行端口配置文件</td> |
| <td>1.2</td> |
| <td>1.2</td> |
| <td>1.2</td> |
| <td>1.2</td> |
| <td>1.2</td> |
| </tr> |
| <tr> |
| <td><strong>PAN/BNEP</strong></td> |
| <td>个人区域网络配置文件/蓝牙网络封装协议</td> |
| <td>1.0</td> |
| <td>1.0</td> |
| <td>1.0</td> |
| <td>1.0</td> |
| <td>1.0</td> |
| </tr> |
| <tr> |
| <td><strong>DIP</strong></td> |
| <td>设备 ID 配置文件</td> |
| <td>1.3</td> |
| <td>1.3</td> |
| <td>1.3</td> |
| <td>1.3</td> |
| <td>1.3</td> |
| </tr> |
| <tr> |
| <td><strong>HOGP 1.0</strong></td> |
| <td>HID over GATT</td> |
| <td>是</td> |
| <td>是</td> |
| <td>是</td> |
| <td>是</td> |
| <td>是</td> |
| </tr> |
| <tr> |
| <td><strong>高清音频</strong><sup id="fnref1"><a href="#fn1" rel="footnote">1</a></sup></td> |
| <td>请参阅上面的“高级音频编解码器”</td> |
| <td>否</td> |
| <td>否</td> |
| <td>否</td> |
| <td>否</td> |
| <td>是</td> |
| </tr> |
| </tbody></table> |
| |
| <p> |
| <sup id="fn1">1</sup>实现高清音频同时取决于音频源和接收器上的设备功能。 |
| </p> |
| |
| <h3 id="bluetooth-low-energy-features">蓝牙低功耗功能</h3> |
| |
| <p> |
| 可用的 BLE 功能如下: |
| </p> |
| |
| <table> |
| <tbody><tr> |
| <th>功能</th> |
| <th colspan="5">Android 版本</th> |
| </tr> |
| <tr> |
| <th>名称</th> |
| <th>6.0</th> |
| <th>7.0</th> |
| <th>7.1</th> |
| <th>7.1.2</th> |
| <th>8 </th> |
| </tr> |
| <tr> |
| <td><strong>BR/EDR 安全连接</strong></td> |
| <td>4.1 </td> |
| <td>4.1 </td> |
| <td>4.1 </td> |
| <td>4.1 </td> |
| <td>5.0</td> |
| </tr> |
| <tr> |
| <td><strong>LE 隐私</strong></td> |
| <td>4.2 </td> |
| <td>4.2 </td> |
| <td>4.2 </td> |
| <td>4.2 </td> |
| <td>5.0</td> |
| </tr> |
| <tr> |
| <td><strong>LE 安全连接</strong></td> |
| <td>4.2 </td> |
| <td>4.2 </td> |
| <td>4.2 </td> |
| <td>4.2 </td> |
| <td>5.0</td> |
| </tr> |
| <tr> |
| <td><strong>数据包扩展</strong></td> |
| <td>4.2 </td> |
| <td>4.2 </td> |
| <td>4.2 </td> |
| <td>4.2 </td> |
| <td>5.0</td> |
| </tr> |
| <tr> |
| <td><strong>32 位 UUID</strong></td> |
| <td>是</td> |
| <td>是</td> |
| <td>是</td> |
| <td>是</td> |
| <td>是</td> |
| </tr> |
| <tr> |
| <td><strong>双模式 LE(中央/外设)</strong></td> |
| <td>是</td> |
| <td>是</td> |
| <td>是</td> |
| <td>是</td> |
| <td>是</td> |
| </tr> |
| <tr> |
| <td><strong>LE 外设模式</strong></td> |
| <td>是</td> |
| <td>是</td> |
| <td>是</td> |
| <td>是</td> |
| <td>是</td> |
| </tr> |
| <tr> |
| <td><strong>Google HCI 要求</strong></td> |
| <td>是</td> |
| <td>是</td> |
| <td>是</td> |
| <td>是</td> |
| <td>是</td> |
| </tr> |
| <tr> |
| <td><strong>LE 连接导向型频道</strong></td> |
| <td>否</td> |
| <td>否</td> |
| <td>否</td> |
| <td>否</td> |
| <td>是<sup id="fnref2"><a href="#fn2" rel="footnote">2</a></sup> |
| </td> |
| </tr> |
| </tbody></table> |
| |
| <p> |
| <sup id="fn2">2</sup>实现 LE 连接导向型频道同时取决于音频源和接收器上的设备功能。 |
| </p> |
| |
| </body></html> |