//based on Android2.3 QCom MSM7227A AR6003-v806 source.

learning by wifi sta enabling

Load driver:

  1. com.android.server.WifiService.setWifiEnabled(true)
  2. android.net.wifi.WifiStateTracker.loadDriver()
  3. 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
  4. 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:

  1. see "Load driver" step 1
  2. see "Load driver" step 2
  3. see "Load driver" step 3
  4. 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:

  1. android.net.wifi.WifiStateTracker.startEventLoop()
  2. android.net.wifi.WifiMonitor.MonitorThread.run()
  3. MonitorThread.connectToSupplicant()
    • hardware/libhardware_legacy/wifi/wifi.c:wifi_connect_to_supplicant():wpa_ctrl_open()
  4. MonitorThread.handleSupplicantStateChange():MonitorThread.handleDriverEvent()
  5. if driver state change to "STARTED", start scan:andorid.net.wifi.WifiStateTracker.scan()

Scan AP:

  1. andorid.net.wifi.WifiStateTracker.scan()
  2. android.net.wifi.WifiStateTracker.android_net_wifi_scanCommand():
    • doCommand("DRIVER SCAN-ACTIVE");
    • doCommand("SCAN")
  3. hardware/libhardware_legacy/wifi/wifi.c:wifi_send_command()
    • wpa_ctrl_request
posted on 2013-09-18 19:41  jan4984  阅读(343)  评论(0编辑  收藏  举报