Android 9 引入了可让设备同时在 STA 和 AP 模式下运行的功能。对于支持双频并发 (DBS) 的设备,此功能让一些新功能得以实现,例如在用户想要启用热点 (softAP) 时不会中断 STA WLAN。
示例和来源
默认的 AOSP Android 框架代码支持 Wi-Fi STA/AP 并发。WLAN HAL 中介绍的参考 HAL 实现也支持 WLAN STA/AP 并发。实现部分中介绍的 WIFI_HIDL_FEATURE_DUAL_INTERFACE 构建时标志会启用接口并发规范,表明支持 STA 和 AP 并发。
实现
要在设备上实现 WLAN STA/AP 并发,请执行以下操作:
开启一个构建时标志,以便在 HAL 中启用对两个接口的支持。该标志位于 device/<oem>/<device>/BoardConfig-common.mk 中。
[null,null,["最后更新时间 (UTC):2025-04-04。"],[],[],null,["# Wi-Fi STA/AP concurrency\n\nAndroid 9 introduces the ability for devices to\noperate in STA and AP mode concurrently. For devices supporting Dual Band\nSimultaneous (DBS), this feature opens up new capabilities such as not\ndisrupting STA Wi-Fi when a user wants to enable hotspot (softAP).\n\nExamples and source\n-------------------\n\nWi-Fi STA/AP concurrency is supported in the default AOSP Android framework\ncode. It is also supported by the reference HAL implementation described in\n[Wi-Fi HAL](/docs/core/connect/wifi-hal). The\n`WIFI_HIDL_FEATURE_DUAL_INTERFACE` build-time flag described in\n[Implementation](#implementation) enables an interface concurrency specification\nindicating concurrent support for STA and AP.\n\nImplementation\n--------------\n\nTo implement Wi-Fi STA/AP concurrency on your device:\n\n1. Turn on a build-time flag to enable support for two interfaces in the HAL.\n The flag is located in `device/\u003coem\u003e/\u003cdevice\u003e/BoardConfig-common.mk`.\n\n - **WIFI_HIDL_FEATURE_DUAL_INTERFACE := true**\n2. Expose two network interfaces:\n\n - **wlan0** and **wlan1**\n\n| **Note:** To avoid performance issues, only use this feature on devices with a Wi-Fi chip that supports multiple independent hardware MACs (radio chains).\n\nThe `WIFI_HIDL_FEATURE_DUAL_INTERFACE` flag is ignored if the\n`WIFI_HAL_INTERFACE_COMBINATIONS`\nflag is specified. For more information, see\n[Wi-Fi multi-interface\nconcurrency](/docs/core/connect/wifi-hal#wi-fi_multi-interface_concurrency).\n\nValidation\n----------\n\nTo validate that the feature is working as intended, run a manual test.\n\nTo manually validate this feature, turn the STA and AP interfaces on and off\nindependently from UI.\n\nIf both AP and STA are on the same subnet, routing issues on the\ndevice-under-test (DUT) may occur. To avoid collisions, try moving the AP to a\ndifferent subnet.\n\nSome Wi-Fi chip vendors place the radio in time-sharing mode if STA and AP are\non the same band but on different channels. This leads to a severe drop in\nperformance. To address this issue, the chip can use Channel Switch Avoidance\n(CSA) to either:\n\n- Move the AP to the same channel as the STA\n- Move the AP to a different band from the STA"]]