//based on Android2.3 QCom MSM7227A AR6003-v806 source.
learning by wifi sta enabling
Load driver:
- com.android.server.WifiService.setWifiEnabled(true)
- android.net.wifi.WifiStateTracker.loadDriver()
- hardware/libhardware_legacy/wifi/wifi.c: wifi_load_driver()
- start init service "init.svc.wlan_tool" with parameter "load" to load driver
- check value of property wlan.driver.status to make sure driver is loaded
- check /init.rc. service wlan_tool: /system/bin/wlan_tool :system/wlan/atheros/AR6kSDK.build_3.1_RC.806/host/tools/wlan_tool/wlan_tool. it is a linux shell script
- it is a onshot service
- loaddriver():reload():do_insmod():insmod /system/wifi/ar6000.ko
Start supplicant:
- see "Load driver" step 1
- see "Load driver" step 2
- see "Load driver" step 3
- check /init.rc. service "wpa_supplicant" : /system/bin/wpa_supplicant -Dwext -iwlan0 -c/data/misc/wifi/wpa_supplicant.conf
- wpa_supplicant now running.
Connect to wpa_supplicant and monitor wifi states:
- android.net.wifi.WifiStateTracker.startEventLoop()
- android.net.wifi.WifiMonitor.MonitorThread.run()
- MonitorThread.connectToSupplicant()
- hardware/libhardware_legacy/wifi/wifi.c:wifi_connect_to_supplicant():wpa_ctrl_open()
- MonitorThread.handleSupplicantStateChange():MonitorThread.handleDriverEvent()
- if driver state change to "STARTED", start scan:andorid.net.wifi.WifiStateTracker.scan()
Scan AP:
- andorid.net.wifi.WifiStateTracker.scan()
- android.net.wifi.WifiStateTracker.android_net_wifi_scanCommand():
- doCommand("DRIVER SCAN-ACTIVE");
- doCommand("SCAN")
- hardware/libhardware_legacy/wifi/wifi.c:wifi_send_command()
- wpa_ctrl_request