Technical Overview of Android Wi-Fi System
Android’s Wi-Fi subsystem is a comprehensive implementation that includes low-level drivers, user-space daemons, and APIs for developers to leverage connectivity features. This article delves into Android’s Wi-Fi architecture, capabilities, and the processes underpinning its operation, as well as the APIs available for development.
Wi-Fi Architecture in Android
The Android Wi-Fi stack consists of several key components:
Kernel-Level Drivers:
- The low-level drivers communicate directly with Wi-Fi hardware.
- Android typically uses the mac80211 framework and cfg80211 for wireless networking, interfacing with hardware-specific drivers like ath10k or brcmfmac.
HAL and WPA Supplicant:
- The Hardware Abstraction Layer (HAL) provides a bridge between the Android framework and kernel drivers.
- WPA Supplicant, a user-space daemon, manages Wi-Fi security and connectivity (e.g., WPA2/3 authentication). Recent Android versions use the Wi-Fi HAL as an abstraction layer for the supplicant.
Framework Services:
- Android frameworks handle Wi-Fi management and connectivity services (e.g., scanning, connecting, hotspot setup). These services interact with HAL and user-space components.
Passpoint/Hotspot 2.0 Support:
- Android supports Passpoint (802.11u) for seamless access to Wi-Fi networks. It uses features like Generic Advertisement Service (GAS) and Access Network Query Protocol (ANQP) to enable automatic network selection and authentication.
Wi-Fi Features Available to Users
Android’s Wi-Fi functionality includes:
Standard Connectivity:
- Join networks with various security protocols (e.g., WPA, WPA2, WPA3).
- Save and manage network credentials.
Hotspot & Tethering:
- Turn devices into Wi-Fi hotspots.
- Share data connections with other devices.
Advanced Features:
- Wi-Fi Direct for peer-to-peer connectivity.
- Support for Wi-Fi Aware (neighbor-aware networking).
- Improved performance with WPA3 and Hotspot 2.0.
Wi-Fi Startup Process
- Driver Initialization:
- On boot, kernel modules for Wi-Fi hardware are loaded.
- HAL and WPA Supplicant:
- The HAL interacts with the supplicant to initialize configuration and manage hardware communication.
- Framework Initialization:
- Android’s
WifiManager
andWifiService
start and handle user-level interactions and APIs.
- Android’s
Low-Level Wi-Fi Driver Techniques
- Android leverages Linux kernel features like Netlink sockets for communication between the user-space and kernel-space.
- Wireless drivers use the cfg80211 subsystem for configuration, and the mac80211 stack handles packet processing.
Developer APIs
Developers can use the following key APIs in Android to manage Wi-Fi functionality:
WifiManager
:- Provides methods to scan for networks, connect, disconnect, and retrieve network information.
- Example:
startScan()
,getConnectionInfo()
.
WifiP2pManager
:- Enables peer-to-peer connectivity using Wi-Fi Direct.
WifiAwareManager
:- Manages Wi-Fi Aware operations, enabling devices to discover and communicate directly without an access point.
Network Connectivity APIs:
ConnectivityManager
provides methods to monitor and manage active network connections.
WPA Supplicant and Protocols
- WPA Supplicant plays a vital role in network authentication and supports protocols like EAP (Extensible Authentication Protocol) for secure access.
- Android HAL uses HIDL or AIDL interfaces to interact with the supplicant based on Android versions.
Sample Code for Scanning Wi-Fi Networks
1 | WifiManager wifiManager = (WifiManager) getSystemService(Context.WIFI_SERVICE); |
Conclusion
The Android Wi-Fi subsystem is a robust platform for connectivity, offering a rich set of APIs and underlying mechanisms to ensure secure and seamless network management. By understanding its architecture and using the provided APIs, developers can build applications leveraging cutting-edge Wi-Fi capabilities.