zoukankan      html  css  js  c++  java
  • 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)

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

  • 相关阅读:
    【转载】ASP.NET MVC中Controller与View之间的数据传递总结
    [转载]ASP.NET MVC 2配置使用CKEditor编辑器
    一步一步学NUnit(1)
    js关闭窗口弹出对话框
    [转载]将ASP.NET MVC 2.0 部署在IIS6和IIS7上的教程
    [转载] HTTP MIME
    【转载】用ckeditor分页符结合正则表达式给文章分页
    ASP.NET MVC2中返回Json异常的解决办法
    CKEditor
    [转载].net下的生成静态页面并分页 .
  • 原文地址:https://www.cnblogs.com/claruarius/p/6379891.html
Copyright © 2011-2022 走看看