自 2025 年 3 月 27 日起,我們建議您使用 android-latest-release
而非 aosp-main
建構及貢獻 AOSP。詳情請參閱「Android 開放原始碼計畫變更」。
Wi-Fi 輕鬆連線
透過集合功能整理內容
你可以依據偏好儲存及分類內容。
Android 10 推出了 Wi-Fi Easy Connect 通訊協定 (也稱為裝置佈建通訊協定 (DPP)) 的支援功能。Wi-Fi Easy Connect 是由 Wi-Fi 聯盟 (WFA) 推出的 Wi-Fi 保護設定 (WPS) 替代方案。WPS 已在 Android 9 中淘汰。
Wi-Fi Easy Connect 提供簡單又安全的方法,可用於:
- 將 Wi-Fi 裝置 (包括無頭裝置) 連上網路,不必輸入密碼。
- 不必知道或輸入密碼,即可加入 Wi-Fi 網路。
系統會使用 URI 設定引導程序和驗證機制,這些資訊可透過掃描 QR code (使用相機) 取得,或透過 BLE 或 NFC 等外部管道設定。
Wi-Fi Easy Connect 會使用加密通道在裝置之間傳送 Wi-Fi 憑證,而且由於使用公開動作框架,裝置可以使用現有的存取點。
Android 10 僅在啟動器模式下支援 Wi-Fi Easy Connect (不支援回應者模式)。支援下列運作模式:
- 啟動者設定工具:掃描 QR code,將網路憑證傳送至新裝置。
- 發起者-受試者:掃描網路 QR code 即可加入網路。
Android 10 支援 WPA2 的預先共用金鑰 (PSK) 通訊協定,以及 WPA3 的同時驗證對等 (SAE) 通訊協定。
Wi-Fi Easy Connect 僅支援用於用戶端模式 (不支援 SoftAP 模式)。
實作
如要支援 Wi-Fi Easy Connect,請實作 Android 開放原始碼計畫 (AOSP) 提供的申請者介面。視實作的介面而定,這會位於:
如要支援 DPP,必須符合下列條件:
支援 DPP 的 Linux 核心修補程式:
wpa_supplicant
支援 DPP
支援 DPP 的 Wi-Fi 驅動程式
支援 DPP 的 Wi-Fi 韌體
公開 API 可供 Android 10 中的應用程式使用:
啟用 Wi-Fi 輕鬆連線
如要在 Android 架構中啟用 Wi-Fi 輕鬆連線功能,請在 wpa_supplicant
設定檔 android.config
中加入 CONFIG_DPP
編譯選項:
# Easy Connect (Device Provisioning Protocol - DPP)
CONFIG_DPP=y
驗證
如要測試導入成果,請執行下列測試。
單元測試
執行 DppManagerTest
,驗證 DPP 功能旗標的行為。
atest DppManagerTest
VTS 測試
如果已實作 HIDL 介面,請執行 VtsHalWifiSupplicantV1_2TargetTest
來測試申請者 HAL 1.2 的行為。
如果已實作 AIDL 介面,請執行 VtsHalWifiSupplicantStaIfaceTargetTest
來測試申請者 HAL 的行為。
這個頁面中的內容和程式碼範例均受《內容授權》中的授權所規範。Java 與 OpenJDK 是 Oracle 和/或其關係企業的商標或註冊商標。
上次更新時間:2025-07-27 (世界標準時間)。
[[["容易理解","easyToUnderstand","thumb-up"],["確實解決了我的問題","solvedMyProblem","thumb-up"],["其他","otherUp","thumb-up"]],[["缺少我需要的資訊","missingTheInformationINeed","thumb-down"],["過於複雜/步驟過多","tooComplicatedTooManySteps","thumb-down"],["過時","outOfDate","thumb-down"],["翻譯問題","translationIssue","thumb-down"],["示例/程式碼問題","samplesCodeIssue","thumb-down"],["其他","otherDown","thumb-down"]],["上次更新時間:2025-07-27 (世界標準時間)。"],[],[],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."]]