From 0cc4988229c6c412bfa4e7bcb04e573dea9b4aa6 Mon Sep 17 00:00:00 2001 From: Gururaaja E S R Date: Tue, 16 Jul 2024 21:00:19 +0000 Subject: [PATCH] To test --- NetworkManager/service/NetworkManager.h | 4 ++ .../service/NetworkManagerRDKProxy.cpp | 49 +++++++++++++------ 2 files changed, 38 insertions(+), 15 deletions(-) diff --git a/NetworkManager/service/NetworkManager.h b/NetworkManager/service/NetworkManager.h index d9d1171005..52e3ba9054 100644 --- a/NetworkManager/service/NetworkManager.h +++ b/NetworkManager/service/NetworkManager.h @@ -190,10 +190,14 @@ namespace WPEFramework oldInterface = "WIFI"; else if(prevActiveInterface == "eth0") oldInterface = "ETHERNET"; + else + oldInterface = prevActiveInterface; if(currentActiveinterface == "wlan0") newInterface = "WIFI"; else if(currentActiveinterface == "eth0") newInterface = "ETHERNET"; + else + newInterface = currentActiveinterface; legacyParams["oldInterfaceName"] = oldInterface; legacyParams["newInterfaceName"] = newInterface; _parent.Notify("onDefaultInterfaceChanged", legacyParams); diff --git a/NetworkManager/service/NetworkManagerRDKProxy.cpp b/NetworkManager/service/NetworkManagerRDKProxy.cpp index 23780bfb26..2379a1dd30 100644 --- a/NetworkManager/service/NetworkManagerRDKProxy.cpp +++ b/NetworkManager/service/NetworkManagerRDKProxy.cpp @@ -385,6 +385,7 @@ namespace WPEFramework void NetworkManagerInternalEventHandler(const char *owner, IARM_EventId_t eventId, void *data, size_t len) { + string interface; LOG_ENTRY_FUNCTION(); if (_instance) { @@ -405,37 +406,55 @@ namespace WPEFramework case IARM_BUS_NETWORK_MANAGER_EVENT_INTERFACE_ENABLED_STATUS: { IARM_BUS_NetSrvMgr_Iface_EventInterfaceEnabledStatus_t *e = (IARM_BUS_NetSrvMgr_Iface_EventInterfaceEnabledStatus_t*) data; - NMLOG_INFO ("IARM_BUS_NETWORK_MANAGER_EVENT_INTERFACE_ENABLED_STATUS :: %s", e->interface); - if (e->status) - ::_instance->ReportInterfaceStateChangedEvent(Exchange::INetworkManager::INTERFACE_ADDED, string(e->interface)); - else - ::_instance->ReportInterfaceStateChangedEvent(Exchange::INetworkManager::INTERFACE_REMOVED, string(e->interface)); + interface = e->interface; + NMLOG_INFO ("IARM_BUS_NETWORK_MANAGER_EVENT_INTERFACE_ENABLED_STATUS :: %s", interface.c_str()); + if(interface == "eth0" || interface == "wlan0") + { + if (e->status) + ::_instance->ReportInterfaceStateChangedEvent(Exchange::INetworkManager::INTERFACE_ADDED, interface); + else + ::_instance->ReportInterfaceStateChangedEvent(Exchange::INetworkManager::INTERFACE_REMOVED, interface); + } break; } case IARM_BUS_NETWORK_MANAGER_EVENT_INTERFACE_CONNECTION_STATUS: { IARM_BUS_NetSrvMgr_Iface_EventInterfaceConnectionStatus_t *e = (IARM_BUS_NetSrvMgr_Iface_EventInterfaceConnectionStatus_t*) data; - NMLOG_INFO ("IARM_BUS_NETWORK_MANAGER_EVENT_INTERFACE_CONNECTION_STATUS :: %s", e->interface); - if (e->status) - ::_instance->ReportInterfaceStateChangedEvent(Exchange::INetworkManager::INTERFACE_LINK_UP, string(e->interface)); - else - ::_instance->ReportInterfaceStateChangedEvent(Exchange::INetworkManager::INTERFACE_LINK_DOWN, string(e->interface)); + interface = e->interface; + NMLOG_INFO ("IARM_BUS_NETWORK_MANAGER_EVENT_INTERFACE_CONNECTION_STATUS :: %s", interface.c_str()); + if(interface == "eth0" || interface == "wlan0") { + if (e->status) + ::_instance->ReportInterfaceStateChangedEvent(Exchange::INetworkManager::INTERFACE_LINK_UP, interface); + else + ::_instance->ReportInterfaceStateChangedEvent(Exchange::INetworkManager::INTERFACE_LINK_DOWN, interface); + } break; } case IARM_BUS_NETWORK_MANAGER_EVENT_INTERFACE_IPADDRESS: { IARM_BUS_NetSrvMgr_Iface_EventInterfaceIPAddress_t *e = (IARM_BUS_NetSrvMgr_Iface_EventInterfaceIPAddress_t*) data; - NMLOG_INFO ("IARM_BUS_NETWORK_MANAGER_EVENT_INTERFACE_IPADDRESS :: %s -- %s", e->interface, e->ip_address); + interface = e->interface; + NMLOG_INFO ("IARM_BUS_NETWORK_MANAGER_EVENT_INTERFACE_IPADDRESS :: %s -- %s", interface.c_str(), e->ip_address); - ::_instance->ReportIPAddressChangedEvent(string(e->interface), e->acquired, e->is_ipv6, string(e->ip_address)); + if(interface == "eth0" || interface == "wlan0") { + ::_instance->ReportIPAddressChangedEvent(interface, e->acquired, e->is_ipv6, string(e->ip_address)); + } break; } case IARM_BUS_NETWORK_MANAGER_EVENT_DEFAULT_INTERFACE: { + string oldInterface; + string newInterface; IARM_BUS_NetSrvMgr_Iface_EventDefaultInterface_t *e = (IARM_BUS_NetSrvMgr_Iface_EventDefaultInterface_t*) data; - NMLOG_INFO ("IARM_BUS_NETWORK_MANAGER_EVENT_DEFAULT_INTERFACE %s :: %s..", e->oldInterface, e->newInterface); - - ::_instance->ReportActiveInterfaceChangedEvent(e->oldInterface, e->newInterface); + oldInterface = e->oldInterface; + newInterface = e->newInterface; + NMLOG_INFO ("IARM_BUS_NETWORK_MANAGER_EVENT_DEFAULT_INTERFACE %s :: %s..", oldInterface.c_str(), newInterface.c_str()); + if(oldInterface != "eth0" || oldInterface != "wlan0") + oldInterface == ""; /* assigning "null" if the interface is not eth0 or wlan0 */ + if(newInterface != "eth0" || newInterface != "wlan0") + newInterface == ""; /* assigning "null" if the interface is not eth0 or wlan0 */ + + ::_instance->ReportActiveInterfaceChangedEvent(oldInterface, newInterface); break; } case IARM_BUS_WIFI_MGR_EVENT_onAvailableSSIDs: