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 Vendor and Supplicant HAL interfaces. Starting with Android 13, the Supplicant interface uses AIDL for the HAL definition. For releases before Android 13, interfaces and vendor partitions use HIDL.
The following Wi-Fi HAL surfaces are required to employ the Wi-Fi Direct feature:
hardware/interfaces/wifi/supplicant/1.2or higher, or
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 or AIDL
interfaces and enable the feature flag for Wi-Fi Direct. 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 implemented in 'wpa_supplicant' and controlled
by two configurations,
To enable this feature, device manufacturers must:
- Implement the Wi-Fi Supplicant
ISupplicantP2pIface::setMacRandomizationAPI. Depending on the interface implemented, this is in:
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.
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.