在Android上實現WLAN的一點理解 – Android移動開發技術文章_手機開發 Android移動開發教學課程

眾所周知,Android 是基於Linux內核的,所以直接支持Linux的WLAN接口。WLAN的內核驅動是根據用戶在UI上的設定動態加載的,通過ctrl_interface和openssl來實現WLAN的控制和安全性,TCPIP則基於WLAN的標準實現。


WLAN  在Android上的體系構架如下:


Application Framework : base/wifi/java/android/net/wifi


                                WifiManager/WifiMonitor/WifiConfiguration …


Service Framework: base/services/java/com/android/server/


                                WifiService / WifiWatchdogService


JNI (Java Native Interface)


                                jni/android_net_wifi_Wifi.cpp


HAL (Hardware Abstract Layer)


                                hardware/libhardware/wifi/wifi.c


                                wpa_supplicant / ctrl_interface


Kernel driver


在Android手機上打開WIFI的流程如下:


1)Application Framework: WifiManager


                                setWifiEnabled()


2)Service: WifiService


                                setWifiEnabled()


                                handleMessage() : MESSAGE_ENABLE_WIFI


3)JNI: android_net_wifi_Wifi.cpp :


                                JNINativeMethod:  loadDriver


                                android_net_wifi_loadDriver()


4)HAL : hardware/libhardware/wifi/wifi.c


                                wifi_load_driver()


5)Kernel : 加載內核驅動


 


WLAN的搜索流程如下:


1)Application Framework: WifiManager


                                startScan()


2)Service:


                WifiService::startScan()


                WifiNative::scanCommand();


3)JNI: android_net_wifi_Wifi.cpp :


                                JNINativeMethod:  scanCommand / scanResultsCommand


                                android_net_wifi_scanCommand / android_net_wifi_scanResultsCommand


4)HAL : hardware/libhardware/wifi/wifi.c


                                wifi_send_command : SCAN / SCAN_RESULTS


                        wpa_supplicant/driver_wext.c


                                wpa_driver_wext_scan() : SIOCSIWSCAN


5)Kernel : WLAN 驅動處理相關接口的命令


WAPI是我國WLAN的國傢標準—– GB 15629.11,並予以802.11i兼容,在Android上的實現隻需增加相應的鑒權即可

發佈留言

發佈留言必須填寫的電子郵件地址不會公開。 必填欄位標示為 *