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)

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

  • 相关阅读:
    Setup VSFTPD Server with Virtual Users On CentOS, RHEL, Scientific Linux 6.5/6.4/6.3
    C++ xmmp IM开发笔记(一)
    getting “fatal: not a git repository: '.'” when using post-update hook to execute 'git pull' on another repo
    Bad owner or permissions on .ssh/config
    CentOS6.3安装VBoxAdditions
    仿春雨医生 安卓app(android)
    centos git gitolite安装笔记
    存储过程编译报错如何解决
    冒泡排序
    ORACLE WITH AS 用法
  • 原文地址:https://www.cnblogs.com/claruarius/p/6379891.html
Copyright © 2011-2022 走看看