自 2025 年 3 月 27 日起,我們建議您使用 android-latest-release
而非 aosp-main
建構及貢獻 AOSP。詳情請參閱「Android 開放原始碼計畫變更」。
總覽
透過集合功能整理內容
你可以依據偏好儲存及分類內容。
Android 提供預設的 Android 架構實作,其中包含各種 Wi-Fi 通訊協定和模式的支援,包括:
- Wi-Fi 基礎架構 (STA)
- 在 Tethered 或僅限本機模式下使用 Wi-Fi 無線基地台 (Soft AP)
- Wi-Fi Direct (p2p)
- Wi-Fi Aware (NAN)
- Wi-Fi RTT (IEEE 802.11mc FTM)
使用 Wi-Fi 服務的應用程式會透過 Binder 直接與各種 Wi-Fi 服務通訊。Wi-Fi 服務會在系統服務中執行,並透過提供的 HIDL 和 AIDL 介面與 HAL 通訊。這張圖表顯示 Android Wi-Fi 堆疊的一般結構。
圖 1. Android Wi-Fi 架構
應用程式架構
應用程式架構層級是應用程式程式碼,會使用各種 android.net.wifi API 與 Wi-Fi 架構和硬體互動。在內部,這個程式碼會透過 Binder IPC 機制呼叫 Wi-Fi 程序。
Wi-Fi 服務
Wi-Fi 服務會在系統服務中執行,並位於 packages/modules/Wifi/service/
中。Wi-Fi 服務會透過 AIDL 與 Wi-Fi HAL 通訊。
有多種 Wi-Fi 服務:
- Wi-Fi 服務:控制 Wi-Fi 基礎架構模式 (包括 STA 和 AP) 的主要機制。
- Wi-Fi P2P 服務:管理 Wi-Fi Direct 模式。
- Wi-Fi Aware 服務:管理 Wi-Fi Aware 模式。
- Wi-Fi RTT 服務:管理 IEEE 802.11mc FTM 功能。
Wi-Fi 架構也包含獨立程序 wificond,位於 system/connectivity/wificond
。wificond 程序會透過標準 nl80211
指令與 Wi-Fi 驅動程式通訊。
Wi-Fi HAL
Wi-Fi 架構有三個 Wi-Fi HAL 途徑,分別由三個不同的介面代表:供應商 HAL、申請者 HAL 和 Hostapd HAL。
如要進一步瞭解各種 HAL 的實作方式,請參閱「Wi-Fi HAL」。
這個頁面中的內容和程式碼範例均受《內容授權》中的授權所規範。Java 與 OpenJDK 是 Oracle 和/或其關係企業的商標或註冊商標。
上次更新時間:2025-07-27 (世界標準時間)。
[null,null,["上次更新時間:2025-07-27 (世界標準時間)。"],[],[],null,["# Overview\n\nAndroid provides a default Android framework implementation that includes\nsupport for various Wi-Fi protocols and modes, including:\n\n- Wi-Fi infrastructure (STA)\n- Wi-Fi hotspot (Soft AP) in either tethered or local-only modes\n- Wi-Fi Direct (p2p)\n- Wi-Fi Aware (NAN)\n- Wi-Fi RTT (IEEE 802.11mc FTM)\n\nAn application using Wi-Fi services directly communicates with the various Wi-Fi\nservices through Binder. The Wi-Fi services run in the System Service and\ncommunicate with the HAL over the provided HIDL and AIDL interfaces.\nThis diagram shows the general structure of the Android Wi-Fi stack.\n\n**Figure 1.** Android Wi-Fi architecture\n\nApplication framework\n---------------------\n\nAt the application framework level is application code, which uses the various\n[android.net.wifi](https://developer.android.com/reference/android/net/wifi/package-summary)\nAPIs to interact with the Wi-Fi framework and hardware. Internally, this code\ncalls the Wi-Fi process through the Binder IPC mechanism.\n\nWi-Fi services\n--------------\n\nThe Wi-Fi services run in the System Service, and are located in\n`packages/modules/Wifi/service/`. The Wi-Fi service communicates with the\nWi-Fi HAL over AIDL.\n\nThere are various Wi-Fi services:\n\n- Wi-Fi Service: Primary mechanism for controlling Wi-Fi infrastructure modes (both STA and AP).\n- Wi-Fi P2P Service: Manages the Wi-Fi Direct mode.\n- Wi-Fi Aware Service: Manages the Wi-Fi Aware mode.\n- Wi-Fi RTT Service: Manages the IEEE 802.11mc FTM functionality.\n\nThe Wi-Fi framework also includes a stand-alone process, **wificond** , located\nat `system/connectivity/wificond`. The **wificond** process communicates with\nthe Wi-Fi driver over standard `nl80211` commands.\n\nWi-Fi HALs\n----------\n\nThe Wi-Fi framework has three Wi-Fi HAL surfaces represented by three different\ninterfaces: Vendor HAL, Supplicant HAL, and Hostapd HAL.\n\nFor details about implementations of the various HALs, see\n[Wi-Fi HAL](/docs/core/connect/wifi-hal)."]]