wifi相关的文件位置:
WIFI Settings应用程序位于
packages/apps/Settings/src/com/android/settings/wifi/
JAVA部分:
frameworks/base/services/java/com/android/server/
frameworks/base/wifi/java/android/net/wifi/
JNI部分:
frameworks/base/core/jni/android_net_wifi_Wifi.cpp
wifi管理库。
hardware/libhardware_legary/wifi/
wifi用户空间的程序和库:
external/wpa_supplicant/
生成库libwpaclient.so和守护进程wpa_supplicant。
调用流程:
wifi模块的初始化:
(frameworks/base/services/java/com/android/server/SystemServer.Java)
在 SystemServer 启动的时候,会生成一个ConnectivityService 的实例,
classServerThread extends Thread {
。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。
try {
Slog.i(TAG,"Connectivity Service");
connectivity= ConnectivityService.getInstance(context);
ServiceManager.addService(Context.CONNECTIVITY_SERVICE,connectivity);
} catch(Throwable e) {
Slog.e(TAG,"Failure starting Connectivity Service", e);
}
。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。
}
其中 ,ConnectivityService.getInstance(context); 对应于(frameworks/base/services/java/com/android/server/ ConnectivityService.Java)ConnectivityService.Java。
下面看下ConnectivityService.Java中的
public static ConnectivityServicegetInstance(Context context) {
returnConnectivityThread.getServiceInstance(context);
}函数, 继续往下看:
public static ConnectivityService getServiceInstance(Context context) {
ConnectivityThread thread = newConnectivityThread(context);
thread.start();
synchronized (thread) {
while (sServiceInstance == null) {
try {
// Wait until sServiceInstance has beeninitialized.
thread.wait();
} catch (InterruptedExceptionignore) {
Slog.e(TAG,
"UnexpectedInterruptedException while waiting"+
" forConnectivityService thread");
}
}
}
return sServiceInstance;
}
}
继续往下跟:
private static class ConnectivityThreadextends Thread {
private Context mContext;
private ConnectivityThread(Context context) {
super("ConnectivityThread");
mContext = context;
}
@Override
public voi