• WifiMonitor的事件发放


    Wifi框架中WifiMonitor负责上报wpa_supplicant的消息给WifiStateMachine,WifiNative负责将WifiStateMachine的消息下发给wpa_supplicant执行.

    本文先来简单介绍WifiMonitor如何处理事件以及怎么分发事件。(未完待续)

    (1)

    WifiStateMachineInitialState状态收到CMD_START_SUPPLICANT消息时候

    if (mWifiNative.startSupplicant(mP2pSupported)) {
        setWifiState(WIFI_STATE_ENABLING);
        if (DBG) log("Supplicant start successful");
        mWifiMonitor.startMonitoring(mInterfaceName);
    transitionTo(mSupplicantStartingState);
    } else {……}

    (2)

    startMonitoring这是一个同步函数

    (3)

    关注ensureConnectedLocked函数

    (4)

    一个跟踪的线程类MonitorThread

    private class MonitorThread extends Thread {
            private final LocalLog mLocalLog = mWifiNative.getLocalLog();
    
            public MonitorThread() {
                super("WifiMonitor");
            }
    
            public void run() {
                if (DBG) {
                    Log.d(TAG, "MonitorThread start with mConnected=" + mConnected);
                }
                //noinspection InfiniteLoopStatement
                for (;;) {
                    if (!mConnected) {
                        if (DBG) Log.d(TAG, "MonitorThread exit because mConnected is false");
                        break;
                    }
                    String eventStr = mWifiNative.waitForEvent();
    
                    // Skip logging the common but mostly uninteresting events
                    if (!eventStr.contains(BSS_ADDED_STR) && !eventStr.contains(BSS_REMOVED_STR)) {
                        if (DBG) Log.d(TAG, "Event [" + eventStr + "]");
                        mLocalLog.log("Event [" + eventStr + "]");
                    }
    
                    if (dispatchEvent(eventStr)) {
                        if (DBG) Log.d(TAG, "Disconnecting from the supplicant, no more events");
                        break;
                    }
                }
            }
    }

    (5)

    然后事件被dispatchEvent函数分发。

    ispatchEvent函数有两个,一个是一个参数,一个是两个参数的。

    1 private boolean dispatchEvent(String eventStr, String iface)
    2 private synchronized boolean dispatchEvent(String eventStr)

    (版权所有,转载请告知)

  • 相关阅读:
    .Net框架集WebClient类向WinCE平台上传文件(FTP方式)延迟15秒释疑
    WinCE系统下BootLoader的开发
    cf1154G 埃氏筛应用
    关于调用C kernel functions
    Download internal table data into Excel(比使用OLE自己填写速度要快)
    Internet+大会和Google请来的大师
    回到Mountain View
    关于F4 Help帮助窗口的参数F4METHOD的设置
    计划策略 MTS部分
    人在Google
  • 原文地址:https://www.cnblogs.com/claruarius/p/6379891.html
Copyright © 2020-2023  润新知