The Wi-Fi Direct feature, also known as Wi-Fi P2P, allows supporting devices to discover and connect to one another directly using the Wi-Fi Direct protocol without internet or cellular network access. This feature, built upon the Wi-Fi Alliance (WFA) Wi-Fi Direct specification allows sharing of high-throughput data among trusted devices and apps that are otherwise off-network.
Examples and source
To use this feature, device manufacturers must 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.
The following Wi-Fi HAL surfaces are required to employ the Wi-Fi Direct feature:
hardware/interfaces/wifi/1.3 or higher
hardware/interfaces/wifi/supplicant/1.2 or higher
Device manufacturers need to provide both framework and HAL/firmware support:
- AOSP code
- Enable Wi-Fi Direct: Requires a feature flag
- Wi-Fi Direct (P2P) HAL support (which implies firmware support)
To implement this feature, device manufacturers implement the Wi-Fi HIDL and
enable the feature flag for Wi-Fi Direct. In
device.mk located in
device/<oem>/<device>, modify the
PRODUCT_COPY_FILES environment variable
to include support for the Wi-Fi Direct feature:
``` PRODUCT_COPY_FILES += frameworks/native/data/etc/android.hardware.wifi.direct.xml:$(TARGET_COPY_OUT_VENDOR)/etc/permissions/android.hardware.wifi.direct.xml ```
All other requirements for supporting Wi-FI Direct are included in AOSP.
Android requires that the Wi-Fi Direct device address and interface address are randomized. They must be different from the true MAC address of the device and must meet the following requirements:
- The Wi-Fi Direct device address must be randomized on interface creation if there is no persistent group saved; otherwise the device address must keep using the last generated MAC address.
- The Wi-Fi Direct interface address, also known as group address, must be randomized every time a connection is established.
Wi-Fi Direct MAC randomization is implementation in the 'wpa_supplicant' and controlled
by two configurations,
To enable this feature, device manufacturers must:
+ Implement the Wi-Fi Supplicant
config_wifi_p2p_mac_randomization_supportedto 'true' in a device custom overlay.
Android provides a set of unit tests, integration tests (Android Connectivity Test Suite, or ACTS), Compatibility Test Suite (CTS) tests, and CTS Verifier tests to validate the Wi-Fi Direct feature. Wi-Fi Direct can also be tested using the Vendor Test Suite (VTS).
Verify the Wi-Fi Direct package using the following tests.
% ./frameworks/opt/net/wifi/tests/wifitests/runtests.sh -e package com.android.server.wifi.p2p
% ./frameworks/base/wifi/tests/runtests.sh -e package android.net.wifi.p2p
Integration tests (ACTS)
The ACTS Wi-FI Direct test suite, located in
functional tests of Wi-Fi Direct.
Compatibility Test Suite (CTS) tests
Use CTS tests to validate the Wi-Fi Direct feature. CTS detects when the feature is enabled and automatically includes the associated tests.
To trigger the CTS tests, run:
% atest android.net.wifi.p2p.cts
CTS Verifier tests
CTS Verifier tests validate Wi-Fi Direct 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 Direct Tests.