Android: Android Wifi System

 

Wifi System:

Java应用层
Java Framework层 
JNI层 
适配器层
wpa_supplicant程序
Kernel层

 

Java应用层
 -- Settings, WifiSwitcher等应用
 --> /system/app
Java Framework层 
    -- frameworks/base/wifi/java/android/net/wifi/*  (android.net.wifi)           
    -- frameworks/base/services/java/com/android/server/WifiService.java
       frameworks/base/services/java/com/android/server/WifiWatchdogService.java
    --> /system/framework/framework.jar
        /system/framework/services.jar
JNI层 
 -- frameworks/base/core/jni/android_net_wifi_Wifi.cpp
 --> /system/lib/libandroid_runtime.so
适配器层
    -- hardware/libhardware_legacy/wifi/wifi.c 
    --> /system/lib/libhardware_legacy.so
wpa_supplicant程序
    -- external/wpa_supplicant
    -- external/wpa_supplicant_6 
    --> /system/bin/wpa_supplicant
        /system/lib/libwpa_client.so
Kernel层
 -- kernel wifi driver 

 

Enable Wifi 的过程:

Settings/WifiEnabler.java
    mWifiManager.setWifiEnabled(enable);
-->
frameworks/base/wifi/java/android/net/wifi/WifiManager.java
    public boolean setWifiEnabled(boolean enabled) {
        mService.setWifiEnabled(enabled);
    }
-->
frameworks/base/services/java/com/android/server/WifiService.java
    public boolean setWifiEnabled(boolean enable) {
        sendEnableMessage(enable, true, Binder.getCallingUid());
    }
    ->
    setWifiEnabledBlocking() {
        if (enable) {
         mWifiStateTracker.loadDriver();
         mWifiStateTracker.startSupplicant();
        } else {
         mWifiStateTracker.stopSupplicant();
         mWifiStateTracker.unloadDriver();
        }
    }
-->
frameworks/base/wifi/java/android/net/wifi/WifiStateTracker.java
    public synchronized boolean loadDriver() {
        return WifiNative.loadDriver();
    }
    public synchronized boolean startSupplicant() {
        return WifiNative.startSupplicant();
    }
-->
frameworks/base/wifi/java/android/net/wifi/WifiNative.java
 public native static boolean loadDriver();
 public native static boolean startSupplicant();
-->
frameworks/base/core/jni/android_net_wifi_Wifi.cpp
 static jboolean android_net_wifi_loadDriver(JNIEnv* env, jobject clazz)
 {
     return (jboolean)(::wifi_load_driver() == 0);
 }
 static jboolean android_net_wifi_startSupplicant(JNIEnv* env, jobject clazz)
 {
     return (jboolean)(::wifi_start_supplicant() == 0);
 } 
-->
hardware/libhardware_legacy/wifi/wifi.c
 int wifi_load_driver(){
  //for build in driver, do nothing
  //for .ko driver, insmod/load firmware...
 }
 int wifi_start_supplicant(){
  property_set("ctl.start", "wpa_supplicant");
 } 
-->
/init.rc
 service wpa_supplicant /system/bin/wpa_supplicant ...

你可能感兴趣的:(java,android,jni,System,Build)