| <html devsite><head> |
| <title>WLAN 感知</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> |
| Android 8.1 (O MR1) 版本中的 <a href="https://developer.android.com/guide/topics/connectivity/wifi-aware.html">WLAN 感知</a>功能支持多个设备直接通过 WLAN 进行互连(无需连接到互联网或移动网络)。此功能是基于 <a href="https://www.wi-fi.org/">WLAN 联盟</a> <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 硬件接口设计语言 (HIDL)。在 Android 8.0 (O) 版本中,HIDL 取代了之前使用的硬件抽象层 (HAL) 结构,以便通过指定收集到接口和软件包的类型和方法调用来简化实现流程。 |
| </p> |
| |
| <p> |
| 借助 WLAN HIDL 使用 WLAN 感知功能:hardware/interfaces/wifi/1.0。WLAN 感知 HAL 表面非常大;<a href="https://android.googlesource.com/platform/hardware/interfaces/+/master/wifi/1.0/README-NAN.md">hardware/interfaces/wifi/1.0/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> |
| |
| <p> |
| 在 <code>BoardConfig.mk</code> 中,添加此标记可指示 WLAN HIDL 包含 WLAN 感知功能:<code>WIFI_HIDL_FEATURE_AWARE := true</code> |
| </p> |
| |
| <p> |
| 在 <code>device.mk</code> 中,修改 <code>PRODUCT_COPY_FILES</code> 环境变量以提供对 WLAN 感知功能的支持: |
| <code>PRODUCT_COPY_FILES += |
| frameworks/native/data/etc/android.hardware.wifi.aware.xml:system/etc/permissions/android.hardware.wifi.aware.xml</code> |
| </p> |
| |
| <p> |
| 否则,实现此功能所需的所有内容都会包含在 AOSP 中。</p> |
| |
| <h2 id="validation">验证</h2> |
| |
| <p> |
| 这项功能有适用的 Android 兼容性测试套件 (CTS) 测试。CTS 会检测何时启用了这项功能,并会自动包含相关测试。 |
| </p> |
| |
| <p> |
| 您也可以使用<a href="/devices/tech/test_infra/tradefed/fundamentals/vts">供应商测试套件 (VTS) </a>和 <a href="https://android.googlesource.com/platform/tools/test/connectivity/+/master/acts/tests/google/wifi/">acts/sl4a</a>(用于执行扩展程序集成测试的测试套件)来测试此功能。 |
| </p> |
| |
| <p> |
| acts/sl4a 测试套件(在 <a href="https://android.googlesource.com/platform/tools/test/connectivity/+/master/acts/tests/google/wifi/aware/README.md">tools/test/connectivity/acts/tests/google/wifi/aware/README.md</a> 中有相应说明)提供了功能测试、性能测试和压力测试。 |
| </p> |
| |
| </body></html> |