自 2025 年 3 月 27 日起,我们建议您使用 android-latest-release
而非 aosp-main
构建 AOSP 并为其做出贡献。如需了解详情,请参阅 AOSP 的变更。
WLAN Easy Connect
使用集合让一切井井有条
根据您的偏好保存内容并对其进行分类。
Android 10 引入了对 Wi-Fi Easy Connect 协议(也称为设备配置协议 [DPP])的支持。Wi-Fi Easy Connect 由 Wi-Fi 联盟 (WFA) 引入,用于替代 Wi-Fi 保护设置 (WPS)。WPS 在 Android 9 中已弃用。
WLAN Easy Connect 可提供实现以下目的的简单且安全的方法:
- 在不输入密码的情况下将 WLAN 设备(包括无头设备)连接到网络。
- 在不知道或不输入密码的情况下接入 Wi-Fi 网络。
引导和身份验证使用 URI 进行配置;URI 通过扫描二维码(使用摄像头)获得或在带外进行配置(例如使用 BLE 或 NFC)。
WLAN Easy Connect 使用加密渠道在设备之间发送 WLAN 凭据,而且由于使用了公开操作帧,设备可以使用现有接入点。
Android 10 仅在发起程序模式下支持 WLAN Easy Connect(不支持响应程序模式)。支持以下操作模式:
- Initiator-Configurator:通过扫描网络凭据的二维码将其发送到新设备。
- Initiator-Enrollee:通过扫描网络二维码接入网络。
Android 10 支持适用于 WPA2 的预共享密钥 (PSK) 协议和适用于 WPA3 的对等实体同时验证 (SAE) 协议。
WLAN Easy Connect 仅在客户端模式下受支持(不支持 SoftAP 模式)。
实现
如需支持 Wi-Fi Easy Connect,请实现 Android 开源项目 (AOSP) 中提供的客户端接口。根据已实现的接口,相应位置如下:
如需支持 DPP,必须具备以下几项:
用以支持 DPP 的 Linux 内核补丁程序:
支持 DPP 的 wpa_supplicant
支持 DPP 的 Wi-Fi 驱动程序
支持 DPP 的 WLAN 固件
Android 10 中提供可供应用使用的公共 API:
启用 Wi-Fi Easy Connect
如需在 Android 框架中启用 Wi-Fi Easy Connect,请在 wpa_supplicant
配置文件 android.config
中添加 CONFIG_DPP
编译选项:
# Easy Connect (Device Provisioning Protocol - DPP)
CONFIG_DPP=y
验证
要测试实现情况,请运行以下测试。
单元测试
运行 DppManagerTest
以验证 DPP 功能标志的行为。
atest DppManagerTest
VTS 测试
如果实现了 HIDL 接口,请运行 VtsHalWifiSupplicantV1_2TargetTest
来测试客户端 HAL v1.2 的行为。
如果实现了 AIDL 接口,请运行 VtsHalWifiSupplicantStaIfaceTargetTest
来测试客户端 HAL 的行为。
本页面上的内容和代码示例受内容许可部分所述许可的限制。Java 和 OpenJDK 是 Oracle 和/或其关联公司的注册商标。
最后更新时间 (UTC):2025-03-26。
[null,null,["最后更新时间 (UTC):2025-03-26。"],[],[],null,["# Wi-Fi Easy Connect\n\nAndroid 10 introduces support for the Wi-Fi Easy\nConnect protocol, also known as the device provisioning protocol (DPP).\n[Wi-Fi Easy Connect](https://www.wi-fi.org/discover-wi-fi/wi-fi-easy-connect)\nwas introduced by the Wi-Fi Alliance (WFA) as an alternative to\nWi-Fi Protected Setup (WPS). WPS was deprecated in Android 9.\n\nWi-Fi Easy Connect provides a simple and secure method to:\n\n- Onboard Wi-Fi devices (including headless devices) to a network without entering a password.\n- Join Wi-Fi networks without knowing or entering a password.\n\nBootstrapping and authentication is configured using a URI, which is acquired\nby scanning a QR code (using a camera), or is configured out-of-band,\nfor example, using BLE or NFC.\n\nWi-Fi Easy Connect uses an encrypted channel to send Wi-Fi credentials between\ndevices, and because public action frames are used, devices can use existing\naccess points.\n\nAndroid 10 supports Wi-Fi Easy Connect only in\ninitiator mode (responder mode is\nnot supported). These modes of operation are supported:\n\n- **Initiator-Configurator:** Send network credentials to a new device by scanning its QR code.\n- **Initiator-Enrollee:** Join a network by scanning the network QR code.\n\nAndroid 10 supports the pre-shared key (PSK) protocol\nfor WPA2 and the simultaneous authentication of equals (SAE) protocol for WPA3.\n\nWi-Fi Easy Connect is only supported in client mode (SoftAP mode is not\nsupported).\n\nImplementation\n--------------\n\nTo support Wi-Fi Easy Connect, implement the supplicant interface\nprovided in the Android Open Source Project (AOSP).\nDepending on the interface that was implemented, this is at:\n\n- [`hardware/interfaces/wifi/supplicant/1.2/`](https://android.googlesource.com/platform/hardware/interfaces/+/refs/heads/android16-release/wifi/supplicant/1.2/) or a later version for HIDL\n- [`hardware/interfaces/wifi/supplicant/aidl/`](https://android.googlesource.com/platform/hardware/interfaces/+/refs/heads/android16-release/wifi/supplicant/aidl/android/hardware/wifi/supplicant) for AIDL\n\nThe following are required to support DPP:\n\n- Linux kernel patches to support DPP:\n\n - cfg80211\n - nl80211\n- [`wpa_supplicant`](https://android.googlesource.com/platform/external/wpa_supplicant_8/+/refs/heads/main)\n with support for DPP\n\n- Wi-Fi driver with support for DPP\n\n- Wi-Fi firmware with support for DPP\n\nPublic APIs are available in Android 10 for use by\napps:\n\n- [`WifiManager#isEasyConnectSupported`](https://developer.android.com/reference/android/net/wifi/WifiManager#isEasyConnectSupported()): Queries the framework to determine whether the device supports Wi-Fi Easy Connect.\n- [`Activity#startActivityForResult(ACTION_PROCESS_WIFI_EASY_CONNECT_URI)`](https://developer.android.com/reference/android/provider/Settings.html#ACTION_PROCESS_WIFI_EASY_CONNECT_URI): Allows apps to integrate Wi-Fi Easy Connect into their onboarding/setup flow.\n\n### Enable Wi-Fi Easy Connect\n\nTo enable Wi-Fi Easy Connect in the Android framework, include the\n`CONFIG_DPP` compilation\noption in the `wpa_supplicant` configuration file,\n[`android.config`](https://android.googlesource.com/platform/external/wpa_supplicant_8/+/refs/heads/android16-release/wpa_supplicant/android.config): \n\n```\n# Easy Connect (Device Provisioning Protocol - DPP)\nCONFIG_DPP=y\n```\n\nValidation\n----------\n\nTo test your implementation, run the following tests.\n\n### Unit tests\n\nRun\n[`DppManagerTest`](https://cs.android.com/android/platform/superproject/+/android-latest-release:packages/modules/Wifi/service/tests/wifitests/src/com/android/server/wifi/DppManagerTest.java)\nto verify the behavior of the capability flags for DPP. \n\n```\natest DppManagerTest\n```\n\n### VTS tests\n\nIf the HIDL interface is implemented, run\n[`VtsHalWifiSupplicantV1_2TargetTest`](https://cs.android.com/android/platform/superproject/+/android-latest-release:hardware/interfaces/wifi/supplicant/1.2/vts/functional/supplicant_sta_iface_hidl_test.cpp)\nto test the behavior of the supplicant HAL v1.2.\n\nIf the AIDL interface is implemented, run\n[`VtsHalWifiSupplicantStaIfaceTargetTest`](https://cs.android.com/android/platform/superproject/+/android-latest-release:hardware/interfaces/wifi/supplicant/aidl/vts/functional/supplicant_sta_iface_aidl_test.cpp)\nto test the behavior of the supplicant HAL."]]