Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 715c03a1 authored by San Mehat's avatar San Mehat Committed by The Android Open Source Project
Browse files

am d6c67966: nexus: Rename onInterfaceStarted -> onInterfaceConnected and add...

am d6c67966: nexus: Rename onInterfaceStarted -> onInterfaceConnected and add Dhcp start/stop control

Merge commit 'd6c67966'

* commit 'd6c67966':
  nexus: Rename onInterfaceStarted -> onInterfaceConnected and add Dhcp start/stop control
parents e61e50f4 d6c67966
Loading
Loading
Loading
Loading
+2 −2
Original line number Original line Diff line number Diff line
@@ -22,8 +22,8 @@ class InterfaceConfig;


class IControllerHandler {
class IControllerHandler {
public:
public:
    virtual void onInterfaceStarted(Controller *c, const InterfaceConfig *cfg) = 0;
    virtual void onInterfaceConnected(Controller *c, const InterfaceConfig *cfg) = 0;
    virtual void onInterfaceStopping(Controller *c, const char *name) = 0;
    virtual void onInterfaceDisconnected(Controller *c, const char *name) = 0;
};
};


#endif
#endif
+14 −7
Original line number Original line Diff line number Diff line
@@ -23,6 +23,7 @@


#include "NetworkManager.h"
#include "NetworkManager.h"
#include "InterfaceConfig.h"
#include "InterfaceConfig.h"
#include "DhcpClient.h"


NetworkManager *NetworkManager::sInstance = NULL;
NetworkManager *NetworkManager::sInstance = NULL;


@@ -36,6 +37,7 @@ NetworkManager::NetworkManager(PropertyManager *propMngr) {
    mBroadcaster = NULL;
    mBroadcaster = NULL;
    mControllers = new ControllerCollection();
    mControllers = new ControllerCollection();
    mPropMngr = propMngr;
    mPropMngr = propMngr;
    mDhcp = new DhcpClient(this);
}
}


NetworkManager::~NetworkManager() {
NetworkManager::~NetworkManager() {
@@ -89,8 +91,8 @@ Controller *NetworkManager::findController(const char *name) {
    return NULL;
    return NULL;
}
}


void NetworkManager::onInterfaceStarted(Controller *c, const InterfaceConfig *cfg) {
void NetworkManager::onInterfaceConnected(Controller *c, const InterfaceConfig *cfg) {
    LOGD("Interface %s started by controller %s", c->getBoundInterface(), c->getName());
    LOGD("Controller %s interface %s connected", c->getName(), c->getBoundInterface());


    // Look up the interface
    // Look up the interface


@@ -98,9 +100,9 @@ void NetworkManager::onInterfaceStarted(Controller *c, const InterfaceConfig *cf
    }
    }


    if (cfg) {
    if (cfg) {
        if (cfg->getUseDhcp()) {
        if (cfg->getUseDhcp() && mDhcp->start(c->getBoundInterface())) {
            // Launch DHCP thread
            LOGE("DHCP start failed");
        } else {
        } else if (!cfg->getUseDhcp()) {
            // Static configuration
            // Static configuration
        }
        }
    } else {
    } else {
@@ -109,6 +111,11 @@ void NetworkManager::onInterfaceStarted(Controller *c, const InterfaceConfig *cf
    }
    }
}
}


void NetworkManager::onInterfaceStopping(Controller *c, const char *name) {
void NetworkManager::onInterfaceDisconnected(Controller *c, const char *name) {
    LOGD("Interface %s stopped by controller %s", name, c->getName());
    LOGD("Controller %s interface %s disconnected", c->getName(), name);

    // If we have a DHCP request out on this interface then stop it
    if (1) {
        mDhcp->stop();
    }
}
}
+6 −3
Original line number Original line Diff line number Diff line
@@ -22,10 +22,12 @@
#include "Controller.h"
#include "Controller.h"
#include "PropertyManager.h"
#include "PropertyManager.h"
#include "IControllerHandler.h"
#include "IControllerHandler.h"
#include "IDhcpEventHandlers.h"


class InterfaceConfig;
class InterfaceConfig;
class DhcpClient;


class NetworkManager : public IControllerHandler {
class NetworkManager : public IControllerHandler, public IDhcpEventHandlers {
private:
private:
    static NetworkManager *sInstance;
    static NetworkManager *sInstance;


@@ -33,6 +35,7 @@ private:
    ControllerCollection *mControllers;
    ControllerCollection *mControllers;
    SocketListener       *mBroadcaster;
    SocketListener       *mBroadcaster;
    PropertyManager      *mPropMngr;
    PropertyManager      *mPropMngr;
    DhcpClient           *mDhcp;


public:
public:
    virtual ~NetworkManager();
    virtual ~NetworkManager();
@@ -55,7 +58,7 @@ private:


    NetworkManager(PropertyManager *propMngr);
    NetworkManager(PropertyManager *propMngr);


    void onInterfaceStarted(Controller *c, const InterfaceConfig *cfg);
    void onInterfaceConnected(Controller *c, const InterfaceConfig *cfg);
    void onInterfaceStopping(Controller *c, const char *name);
    void onInterfaceDisconnected(Controller *c, const char *name);
};
};
#endif
#endif
+22 −24
Original line number Original line Diff line number Diff line
@@ -279,7 +279,6 @@ void WifiController::onAssociatedEvent(SupplicantAssociatedEvent *evt) {


void WifiController::onConnectedEvent(SupplicantConnectedEvent *evt) {
void WifiController::onConnectedEvent(SupplicantConnectedEvent *evt) {
    LOGD("onConnectedEvent(%s, %d)", evt->getBssid(), evt->getReassociated());
    LOGD("onConnectedEvent(%s, %d)", evt->getBssid(), evt->getReassociated());
    if (!evt->getReassociated()) {
    SupplicantStatus *ss = mSupplicant->getStatus();
    SupplicantStatus *ss = mSupplicant->getStatus();
    WifiNetwork *wn;
    WifiNetwork *wn;


@@ -304,8 +303,7 @@ void WifiController::onConnectedEvent(SupplicantConnectedEvent *evt) {
    }
    }
  
  
    delete ss;
    delete ss;
        mHandlers->onInterfaceStarted(this, wn->getIfaceCfg());
    mHandlers->onInterfaceConnected(this, wn->getIfaceCfg());
    }
}
}


void WifiController::onScanResultsEvent(SupplicantScanResultsEvent *evt) {
void WifiController::onScanResultsEvent(SupplicantScanResultsEvent *evt) {
@@ -373,7 +371,7 @@ void WifiController::onConnectionTimeoutEvent(SupplicantConnectionTimeoutEvent *
}
}


void WifiController::onDisconnectedEvent(SupplicantDisconnectedEvent *evt) {
void WifiController::onDisconnectedEvent(SupplicantDisconnectedEvent *evt) {
    LOGD("onDisconnectedEvent()");
    mHandlers->onInterfaceDisconnected(this, getBoundInterface());
}
}


#if 0
#if 0