Android-WiFi system architecture

Source: Internet
Author: User
1. System Architecture

The android WiFi system introduces wpa_supplicant. The entire WiFi system uses wpa_supplicant as the core to define upper-layer user interfaces and lower-layer driver interfaces. Shows the entire Wi-Fi system architecture:

Everything is in progress. Next we will analyze each part in detail.

1.1 wifiservice

The connecttivityservice created when systemserver is started is responsible for starting and disabling wpa_supplicant, starting and closing the wifimonitor thread, issuing the command to wpa_supplicant, and updating the WiFi status.

Handle remote Wi-Fi Operations sent by other modules through the iwifimanager interface.

1.2 wifimonitor

Receives Event Notifications from wpa_supplicant.

1.3 wpa_supplicant

1) read the configuration file
2) initialize configuration parameters and Drive Functions
3) Let the driver scan all current bssid
4) check whether the scan parameters are consistent with those set by the user.
5) if they match, the notification driver will perform permission and authentication operations.
6) connect to the AP

1.4 WiFi Driver Module

Source provided by the vendor, mainly for load firware and kernel Wireless Communication

1.5 WiFi Power Management Module

It mainly controls the hardware gpio and power-on and power-off, so that the CPU and WiFi modules can communicate with each other through the sdio interface or USB interface.

1.6 WiFi procedure

1) WiFi startup
2) Start scanning
3) display the scanned AP
4) configure the AP
5) connect to the AP
6) obtain the IP address
7) surfing the internet

1.7 WiFi module code

1) WiFi settings Application
Packages/apps/settings/src/COM/Android/settings/WiFi

2) WiFi framework
Frameworks/base/WiFi/Java/Android/NET/WiFi (the UI uses android.net. WiFi package
Send command to wifi. c)

Frameworks/base/CORE/Java/Android/net (higher-level network management)
Frameworks/base/services/Java/COM/Android/Server

3) WiFi JNI
Frameworks/base/CORE/JNI/android_net_wifi_wifi.cpp
4) WiFi hardware (WiFi Management Library)
Hardware/libhardware_legacy/WiFi/wifi. c

5) wpa_supplicant (WiFi tool)

External/wpa_supplicant8
(1) wpa_client (generate library libwpaclient. So)

External/wpa_supplicant_8/wpa_supplicant/src/common/wpa_ctrl.c

(2) wpa_server (generate the daemon wpa_supplicant)

External/wpa_supplicant_8/wpa_supplicant/Main. c
 6) WiFi Kernel
Net/wireless Drivers/wlan_xxx ARCH/ARM/Mach-xxx/wlan_pm.c


2. wifiservice and wpa_supplicant Startup Process

Shows the wifiservice and wpa_supplicant startup processes:

2.1 status changes

• The status change process for loading the WiFi driver is as follows:

Initial State: minitialstate

|
Mdriverunloadedstate

|
Mwaitforp2pdisablestate

|
Mdriverloadingstate (its enter calls wifinative. loaddriver)

 

• The status of wpa_supplicant startup changes as follows:
Call wifinative. startsupplicant in processmessage of driverloadedstate.

3. automatically enable WiFi during production

In production, WiFi is disabled by default. To enable it by default, you can modify the following code in wifiservice. Java:

 

[CPP]View
Plaincopy

  1. /**
  2. * Check if Wi-Fi needs to be enabled and start
  3. * If needed
  4. *
  5. * This function is used only at boot time
  6. */
  7. Public void checkandstartwifi (){
  8. Mairplanemodeon. Set (isairplanemodeon ());
  9. Mpersistwifistate. Set (getpersistedwifistate ());
  10. /* Start If wi-fi shoshould be enabled or the saved State indicates Wi-Fi was on */
  11. Boolean wifienabled = shouldwifibeenabled () | testandclearwifisavedstate ();
  12. Slog. I (TAG, "wifiservice starting up with Wi-Fi" +
  13. (Wifienabled? "Enabled": "disabled "));
  14. Setwifienabled (wifienabled); // set it to true.
  15. Mwifiwatchdogstatemachine = wifiwatchdogstatemachine.
  16. Makewifiwatchdogstatemachine (mcontext );
  17. }

 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.