ubuntu 在 R40e 上 還有 Debian 在 Sempron 2600 上

2012年12月4日 星期二

wifi 控制的底層好像是 hardware/libhardware_legacy/wifi ..
跟著 driver loading 的 code..

wifi.c : wifi_load_driver()

framework/base/core/jni/android_net_wifi_Wifi.cpp : static jboolean android_net_wifi_loadDriver(JNIEnv* env, jobject clazz) { return (jboolean)(::wifi_load_driver() == 0); } ... { "loadDriver", "()Z", (void *)android_net_wifi_loadDriver }, ... 這段 在 java 的 介面是: ./wifi/java/android/net/wifi/WifiNative.java:45: public native static boolean loadDriver();
在 ./wifi/java/android/net/wifi/WifiStateTracker.java 中再包裝一次。

然後就是 ./services/java/com/android/server/WifiService.java 呼叫 WifiStateTracker:
private boolean setWifiEnabledBlocking(boolean enable, boolean persist, int uid) {

這 funciton 是在 WifiService 的 handleMessge 處理的 public void handleMessage(Message msg) { switch (msg.what) { case MESSAGE_ENABLE_WIFI: setWifiEnabledBlocking(true, msg.arg1 == 1, msg.arg2); if (mWifiWatchdogService == null) { mWifiWatchdogService = new WifiWatchdogService(mContext, mWifiStateTracker); } sWakeLock.release(); break; case MESSAGE_START_WIFI: reportStartWorkSource(); mWifiStateTracker.setScanOnlyMode(msg.arg1 == WifiManager.WIFI_MODE_SCAN_ONLY); mWifiStateTracker.restart(); mWifiStateTracker.setHighPerfMode(msg.arg1 == WifiManager.WIFI_MODE_FULL_HIGH_PERF); sWakeLock.release(); break;

對應的function : 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(); } private void sendStartMessage(int lockMode) { Message.obtain(mWifiHandler, MESSAGE_START_WIFI, lockMode, 0).sendToTarget(); }

沒有留言:

標籤

網誌存檔