WPA_SUPPLICANT_VERSION := VER_0_6_ATHEROS
然後在 external 下有三個 wpa_supplicant :
- wpa_supplicant
- wpa_supplicant_6
- wpa_supplicant_ath
從 每個 folder 的 Android.mk 來看,開頭
ifeq ($(WPA_SUPPLICANT_VERSION),VER_0_5_X)
這樣決定- wpa_supplicant : VER_0_5_X
- wpa_supplicant_6 : VER_0_6_X
- wpa_supplicant_ath : VER_0_6_ATHEROS
啟動 wifi
在 Setting - Wireless and networks 把Wi-Fi check 後。
package setting 下的 WifiEnabler.java : onPreferenceChange( ),有
int wifiApState = mWifiManager.getWifiApState();
...
if (mWifiManager.setWifiEnabled(enable)) {
其中的 mWifiManager 是 system service wrapper class:
mWifiManager = (WifiManager) context.getSystemService(Context.WIFI_SERVICE);
WifiManger 的 code: ./frameworks/base/wifi/java/android/net/wifi/WifiManager.java
之後 call 的 WifiManger.setWifiEnabled( ) : 只是一個 seriver 的包裝
public boolean setWifiEnabled(boolean enabled) {
try {
return mService.setWifiEnabled(enabled);
} catch (RemoteException e) {
return false;
}
}
mService 是 IBinder interface :
public WifiManager(IWifiManager service, Handler handler) {
mService = service;
mHandler = handler;
}
IWifiManager 是 (Binder interface): IWifiManager.aidlIWifiManger 的 sponser server 是 WifiService : framework/android/server/WifiService:
public class WifiService extends IWifiManager.Stub {
WifiService 的 setWifiEnabled() :
sendEnableMessage(enable, true, Binder.getCallingUid());
sendEnableMessage()
private void sendEnableMessage(boolean enable, boolean persist, int uid) {
Message msg = Message.obtain(mWifiHandler,
(enable ? MESSAGE_ENABLE_WIFI : MESSAGE_DISABLE_WIFI),
(persist ? 1 : 0), uid);
msg.sendToTarget();
}
這個 message 的 hanelder:
public void handleMessage(Message msg) {
switch (msg.what) {
case MESSAGE_ENABLE_WIFI:
setWifiEnabledBlocking(true, msg.arg1 == 1, msg.arg2);
所以是 setWifiEnabledBlocking : 這個做了 wifi driver loading, connect to wpa.. etc
private boolean setWifiEnabledBlocking(boolean enable, boolean persist, int uid) {
....
if (enable) {
if (!mWifiStateTracker.loadDriver()) {
Slog.e(TAG, "Failed to load Wi-Fi driver.");
setWifiEnabledState(WIFI_STATE_UNKNOWN, uid);
return false;
}
if (!mWifiStateTracker.startSupplicant()) {
mWifiStateTracker.unloadDriver();
Slog.e(TAG, "Failed to start supplicant daemon.");
setWifiEnabledState(WIFI_STATE_UNKNOWN, uid);
return false;
WifiStateTracker 在 framework/base/wifi ...
public synchronized boolean loadDriver() {
return WifiNative.loadDriver();
}
call 到 jni : framework/base/core/jni/android_net_wifi_Wifi.cpp ,這只是 call 到 c code 的 wrapper。實際 implement wifi_load_driver( ) 的在 : hardware/libhardware_legacy/wifi
wifi.c 的 wifi_load_driver 其實很普通,就是用 insmod load driver.
if (insmod(DRIVER_MODULE_PATH, DRIVER_MODULE_ARG) < 0)
driver name, path, argument 都是寫在 Android.mk 裡:
WIFI_DRIVER_MODULE_PATH := "/system/lib/modules/ar6000.ko"
WIFI_DRIVER_MODULE_ARG := ""
WIFI_DRIVER_MODULE_NAME := "ar6000"
沒有留言:
張貼留言