The Wi-Fi Aware feature added in Android 8.0 enables supporting devices to discover, connect, and range (added in Android 9) to one another directly using the Wi-Fi Aware protocol without internet or cellular network access. This feature, built upon the Wi-Fi Alliance (WFA) Wi-Fi Aware specification (versions 2.0, 3.0 and 3.1), allows easy sharing of high-throughput data among trusted devices and apps that are otherwise off-network.
Examples and source
To use this feature, device manufacturers should implement the Wi-Fi Hardware Interface Design Language (HIDL) provided in the Android Open Source Project (AOSP). HIDL replaces the previous Hardware Abstraction Layer (HAL) structure used to streamline implementations by specifying types and method calls collected into interfaces and packages.
Follow the Wi-Fi HIDL to employ the Wi-Fi Aware feature: hardware/interfaces/wifi/1.2 or higher. The Wi-Fi Aware HAL surface is very large; the hardware/interfaces/wifi/1.2/README-NAN.md file describes the subset that is currently in use by the framework.
You can reference the legacy Wi-Fi HAL to see how it correlates with the new HIDL interface: hardware/libhardware_legacy/+/master/include/hardware_legacy/wifi_nan.h.
Implementation
Device manufacturers need to provide both framework and HAL/firmware support:
- Framework:
- AOSP code
- Enable Aware: Requires both a feature flag and an HIDL build flag
- Wi-Fi Aware (NAN) HAL support (which implies firmware support)
To implement this feature, device manufacturers implement the Wi-Fi HIDL and enable two feature flags:
In
BoardConfig.mk
orBoardConfig-common.mk
located indevice/<oem>/<device>
, add the following flag:WIFI_HIDL_FEATURE_AWARE := true
In
device.mk
located indevice/<oem>/<device>
, modify thePRODUCT_COPY_FILES
environment variable to include support for the Wi-Fi Aware feature:PRODUCT_COPY_FILES += frameworks/native/data/etc/android.hardware.wifi.aware.xml:$(TARGET_COPY_OUT_VENDOR)/etc/permissions/android.hardware.wifi.aware.xml
Wi-Fi Aware includes ranging to peer devices using the IEEE 802.11mc protocol, also known as Round Trip Time (RTT). This sub-feature of Wi-Fi Aware is conditional on the device supporting the Wi-Fi RTT feature, that is, it requires the device to support both Wi-Fi Aware and Wi-Fi RTT. For more details, see Wi-Fi RTT.
Otherwise, everything required for this feature is included in AOSP.
The WIFI_HIDL_FEATURE_AWARE
flag is ignored if the
WIFI_HAL_INTERFACE_COMBINATIONS
flag is specified. For more information, see
Wi-Fi multi-interface concurrency.
MAC randomization
Android requires the MAC address of the Wi-Fi Aware discovery (NMI) and data interfaces (NDPs) to be randomized and not be identical to the true MAC address of the device. The MAC addresses must be:
- Randomized whenever Wi-Fi Aware is enabled or re-enabled.
When Wi-Fi Aware is enabled, the MAC address must be randomized at a regular interval configured by the
NanConfigRequest.macAddressRandomizationIntervalSec
HIDL parameter. This is configured by the framework by default to be 30 minutes.
Validation
Android provides a set of unit tests, integration tests (ACTS), Compatibility Test Suite (CTS) tests, and CTS Verifier tests to validate the Wi-Fi Aware feature. Wi-Fi Aware can also be tested using the Vendor Test Suite (VTS).
Unit tests
The Wi-Fi Aware package tests are executed using:
Service tests:
atest com.android.server.wifi.aware
Manager tests:
atest android.net.wifi.aware
Integration tests (ACTS)
The acts/sl4a
test suite, described in
tools/test/connectivity/acts_tests/tests/google/wifi/aware/README.md
, provides
functional, performance, and stress tests.
Compatibility Test Suite (CTS) tests
Use CTS tests to validate the Wi-Fi Aware feature. CTS detects when the feature is enabled and automatically includes the associated tests.
The CTS tests can be triggered using:
atest SingleDeviceTest
CTS Verifier tests
CTS Verifier tests validate Wi-Fi Aware behavior using two devices: a test device and a known good device. To run the tests, open CTS Verifier and navigate to the section titled Wi-Fi Aware Tests.