| <html devsite><head> |
| |
| <meta name="book_path" value="/_book.yaml"/> |
| |
| <meta name="project_path" value="/_project.yaml"/> |
| </head> |
| <body> |
| |
| <!-- |
| Copyright 2018 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. |
| --> |
| |
| <h1 id="wi_fi_aware" class="page-title">WLAN 感知</h1> |
| |
| <p>通过 Android 8.0 中新增的 <a href="https://developer.android.com/guide/topics/connectivity/wifi-aware.html">WLAN 感知</a>功能,支持设备可以直接使用 WLAN 感知协议发现其他设备、与其他设备进行互连,以及将覆盖范围扩展到其他设备(Android 9 中新增的功能),而无需连接到互联网或移动网络。此功能是基于 <a href="https://www.wi-fi.org/">WLAN 联盟</a> (WFA) <a href="https://www.wi-fi.org/discover-wi-fi/wi-fi-aware">WLAN 感知规范</a>(2.0 版)构建的,它支持在断开网络的情况下,在可信设备与应用之间轻松共享高吞吐量数据。</p> |
| |
| <h2 id="examples_and_source">示例和来源</h2> |
| |
| <p>要使用此功能,设备制造商应采用在 Android 开源项目 (AOSP) 中提供的 WLAN <a href="/devices/architecture/hidl">硬件接口设计语言 (HIDL)</a>。HIDL 取代了之前使用的<a href="/devices/architecture/hal">硬件抽象层 (HAL)</a> 结构,以便通过指定收集到接口和软件包的类型和方法调用来简化实现流程。</p> |
| |
| <p>借助 WLAN HIDL 使用 WLAN 感知功能:hardware/interfaces/wifi/1.2。WLAN 感知 HAL 表面非常大;<a href="https://android.googlesource.com/platform/hardware/interfaces/+/master/wifi/">hardware/interfaces/wifi/1.2/README-NAN.md</a> 文件描述了框架当前使用的子集。</p> |
| |
| <p>您可以参考旧版 WLAN HAL 来了解它与新 HIDL 接口之间的关系:<a href="https://android.googlesource.com/platform/hardware/libhardware_legacy/+/master/include/hardware_legacy/wifi_nan.h">hardware/libhardware_legacy/+/master/include/hardware_legacy/wifi_nan.h</a>。</p> |
| |
| <h2 id="implementation">实现</h2> |
| |
| <p>设备制造商需要提供框架和 HAL/固件支持:</p> |
| |
| <ul> |
| <li>框架: |
| <ul> |
| <li>AOSP 代码</li> |
| <li>启用感知功能:需要功能标记和 HIDL 编译标记</li> |
| </ul></li> |
| <li>WLAN 感知 (NAN) HAL 支持(意味着固件支持)</li> |
| </ul> |
| |
| <p>为实现此功能,设备制造商需采用 WLAN HIDL,另外还要启用两个功能标记:</p> |
| |
| <ul> |
| <li><p>在位于 <code>device/<oem>/<device></code> 的 <code>BoardConfig.mk</code> 或 BoardConfig-common.mk 中,添加以下标记:</p> |
| <pre class="prettyprint"><code>WIFI_HIDL_FEATURE_AWARE := true |
| </code></pre></li> |
| <li><p>在位于 <code>device/<oem>/<device></code> 的 <code>device.mk</code> 中,修改 <code>PRODUCT_COPY_FILES</code> 环境变量,以便纳入对 WLAN 感知功能的支持:</p> |
| <pre class="prettyprint"><code>PRODUCT_COPY_FILES += |
| frameworks/native/data/etc/android.hardware.wifi.aware.xml:$(TARGET_COPY_OUT_VENDOR)/etc/permissions/android.hardware.wifi.aware.xml |
| </code></pre></li> |
| </ul> |
| |
| <p>WLAN 感知功能包括使用 IEEE 802.11mc 协议(又称为往返时间 (RTT))将覆盖范围扩展到对等设备。WLAN 感知的这一子功能取决于支持 WLAN RTT 功能的设备,即它要求设备支持 WLAN 感知和 WLAN RTT。有关详情,请参阅 <a href="/devices/tech/connect/wifi/rtt">WLAN RTT</a>。</p> |
| |
| <p>除此以外,实现此功能所需的所有内容都会包含在 AOSP 中。</p> |
| |
| <h2 id="mac_randomization">随机分配 MAC 地址</h2> |
| |
| <p>Android 要求随机分配 WLAN 感知发现 (NMI) 和数据接口 (NDP) 的 MAC 地址,而且随机分配的 MAC 地址不应与设备的真实 MAC 地址相同。MAC 地址必须满足以下条件:</p> |
| |
| <ul> |
| <li>每当启用或重新启用 WLAN 感知时进行随机分配。</li> |
| <li><p>WLAN 感知功能启用后,必须按照由 <code>NanConfigRequest.macAddressRandomizationIntervalSec</code> HIDL 参数配置的有规律的间隔随机分配 MAC 地址。框架将时间间隔默认配置为 30 分钟。</p> |
| <aside class="note"><strong>注意</strong>:<span>根据 WLAN 感知规范,配置 NDP 后,随机分配可能会被暂停。</span></aside></li> |
| </ul> |
| |
| <h2 id="validation">验证</h2> |
| |
| <p>Android 提供了一组单元测试、集成测试 (ACTS)、<a href="/compatibility/cts">兼容性测试套件 (CTS)</a> 测试和 <a href="/compatibility/cts/verifier">CTS 验证程序</a>测试,以验证 WLAN 感知功能。您也可以使用<a href="/devices/tech/test_infra/tradefed/fundamentals/vts">供应商测试套件 (VTS)</a> 来测试 WLAN 感知功能。</p> |
| |
| <h3 id="unit_tests">单元测试</h3> |
| |
| <p>WLAN 感知软件包测试:</p> |
| |
| <p>服务测试:</p> |
| <pre class="prettyprint"><code>% ./frameworks/opt/net/wifi/tests/wifitests/runtests.sh -e package |
| com.android.server.wifi.aware |
| </code></pre> |
| <p>Manager 测试:</p> |
| <pre class="prettyprint"><code>% ./frameworks/base/wifi/tests/runtests.sh -e package android.net.wifi.aware |
| </code></pre> |
| <h3 id="integration_tests_acts">集成测试 (ACTS)</h3> |
| |
| <p><code>acts/sl4a</code> 测试套件(在 <code>tools/test/connectivity/acts/tests/google/wifi/aware/README.md</code> 中有相应说明)提供了功能测试、性能测试和压力测试。</p> |
| |
| <h3 id="compatibility_test_suite_cts">兼容性测试套件 (CTS)</h3> |
| |
| <p>使用 CTS 测试来验证 WLAN 感知功能。CTS 会检测何时启用了这项功能,并会自动包含相关测试。</p> |
| |
| <p>可以使用以下方法触发 CTS 测试:</p> |
| <pre class="prettyprint"><code>% atest SingleDeviceTest |
| </code></pre> |
| <h3 id="cts_verifier_tests">CTS 验证程序测试</h3> |
| |
| <p>CTS 验证程序测试使用以下两种设备验证 WLAN 感知行为:测试设备和已知良好的设备。<em></em>要运行测试,请打开 CTS 验证程序并转到“WLAN 感知测试”部分。</p> |
| |
| </body></html> |