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.
Device manufacturers need to provide both framework and HAL/firmware support:
- 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:
device/<oem>/<device>, add the following flag:
WIFI_HIDL_FEATURE_AWARE := true
device/<oem>/<device>, modify the
PRODUCT_COPY_FILESenvironment 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.
WIFI_HIDL_FEATURE_AWARE flag is ignored if the
flag is specified. For more information, see
Wi-Fi multi-interface concurrency.
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.macAddressRandomizationIntervalSecHIDL parameter. This is configured by the framework by default to be 30 minutes.
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).
The Wi-Fi Aware package tests are executed using:
Integration tests (ACTS)
acts/sl4a test suite, described in
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:
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.