From 79df9d0d49c8204dbe0855992253c86c9076f73a Mon Sep 17 00:00:00 2001 From: deanlee Date: Sun, 9 Jan 2022 07:30:26 +0800 Subject: [PATCH] emit refreshSignal in refreshNetworkds --- selfdrive/ui/qt/offroad/networking.cc | 5 +---- selfdrive/ui/qt/offroad/wifiManager.cc | 21 ++++----------------- selfdrive/ui/qt/offroad/wifiManager.h | 3 --- 3 files changed, 5 insertions(+), 24 deletions(-) diff --git a/selfdrive/ui/qt/offroad/networking.cc b/selfdrive/ui/qt/offroad/networking.cc index 51e6f87f023ad1..052eae29baffc2 100644 --- a/selfdrive/ui/qt/offroad/networking.cc +++ b/selfdrive/ui/qt/offroad/networking.cc @@ -101,10 +101,7 @@ void Networking::wrongPassword(const QString &ssid) { void Networking::showEvent(QShowEvent* event) { // Wait to refresh to avoid delay when showing Networking widget - QTimer::singleShot(300, this, [=]() { - wifi->start(); - refresh(); - }); + QTimer::singleShot(300, this, [this]() { wifi->start(); }); } void Networking::hideEvent(QHideEvent* event) { diff --git a/selfdrive/ui/qt/offroad/wifiManager.cc b/selfdrive/ui/qt/offroad/wifiManager.cc index 8b9259102da1f1..cb5b233f52da21 100644 --- a/selfdrive/ui/qt/offroad/wifiManager.cc +++ b/selfdrive/ui/qt/offroad/wifiManager.cc @@ -39,8 +39,8 @@ void WifiManager::setup() { bus.connect(NM_DBUS_SERVICE, NM_DBUS_PATH_SETTINGS, NM_DBUS_INTERFACE_SETTINGS, "NewConnection", this, SLOT(newConnection(QDBusObjectPath))); raw_adapter_state = call(adapter, NM_DBUS_INTERFACE_PROPERTIES, "Get", NM_DBUS_INTERFACE_DEVICE, "State"); - - initActiveAp(); + activeAp = call(adapter, NM_DBUS_INTERFACE_PROPERTIES, "Get", NM_DBUS_INTERFACE_DEVICE_WIRELESS, "ActiveAccessPoint").path(); + initConnections(); requestScan(); } @@ -71,6 +71,7 @@ void WifiManager::refreshNetworks() { } seenNetworks[ssid] = {ssid, strength, ctype, security}; } + emit refreshSignal(); } QString WifiManager::get_ipv4_address() { @@ -179,18 +180,10 @@ uint WifiManager::getAdapterType(const QDBusObjectPath &path) { return call(path.path(), NM_DBUS_INTERFACE_PROPERTIES, "Get", NM_DBUS_INTERFACE_DEVICE, "DeviceType"); } -bool WifiManager::isWirelessAdapter(const QDBusObjectPath &path) { - return getAdapterType(path) == NM_DEVICE_TYPE_WIFI; -} - void WifiManager::requestScan() { call(adapter, NM_DBUS_INTERFACE_DEVICE_WIRELESS, "RequestScan", QVariantMap()); } -uint WifiManager::get_wifi_device_state() { - return call(adapter, NM_DBUS_INTERFACE_PROPERTIES, "Get", NM_DBUS_INTERFACE_DEVICE, "State"); -} - QByteArray WifiManager::get_property(const QString &network_path , const QString &property) { return call(network_path, NM_DBUS_INTERFACE_PROPERTIES, "Get", NM_DBUS_INTERFACE_ACCESS_POINT, property); } @@ -218,7 +211,6 @@ void WifiManager::stateChange(unsigned int new_state, unsigned int previous_stat connecting_to_network = ""; if (!stop_) { refreshNetworks(); - emit refreshSignal(); } } } @@ -228,7 +220,6 @@ void WifiManager::propertyChange(const QString &interface, const QVariantMap &pr if (interface == NM_DBUS_INTERFACE_DEVICE_WIRELESS && props.contains("LastScan")) { if (!stop_ || firstScan) { refreshNetworks(); - emit refreshSignal(); firstScan = false; } } else if (interface == NM_DBUS_INTERFACE_DEVICE_WIRELESS && props.contains("ActiveAccessPoint")) { @@ -237,7 +228,7 @@ void WifiManager::propertyChange(const QString &interface, const QVariantMap &pr } void WifiManager::deviceAdded(const QDBusObjectPath &path) { - if (isWirelessAdapter(path) && (adapter.isEmpty() || adapter == "/")) { + if (getAdapterType(path) == NM_DEVICE_TYPE_WIFI && (adapter.isEmpty() || adapter == "/")) { adapter = path.path(); setup(); } @@ -391,10 +382,6 @@ void WifiManager::setTetheringEnabled(bool enabled) { } } -void WifiManager::initActiveAp() { - activeAp = call(adapter, NM_DBUS_INTERFACE_PROPERTIES, "Get", NM_DBUS_INTERFACE_DEVICE_WIRELESS, "ActiveAccessPoint").path(); -} - bool WifiManager::isTetheringEnabled() { if (activeAp != "" && activeAp != "/") { return get_property(activeAp, "Ssid") == tethering_ssid; diff --git a/selfdrive/ui/qt/offroad/wifiManager.h b/selfdrive/ui/qt/offroad/wifiManager.h index 3e73f6fcaa1df2..6862074e0db47f 100644 --- a/selfdrive/ui/qt/offroad/wifiManager.h +++ b/selfdrive/ui/qt/offroad/wifiManager.h @@ -77,14 +77,11 @@ class WifiManager : public QObject { bool firstScan = true; QString getAdapter(const uint = NM_DEVICE_TYPE_WIFI); uint getAdapterType(const QDBusObjectPath &path); - bool isWirelessAdapter(const QDBusObjectPath &path); QString get_ipv4_address(); QString activeAp; - void initActiveAp(); void deactivateConnectionBySsid(const QString &ssid); void deactivateConnection(const QDBusObjectPath &path); QVector get_active_connections(); - uint get_wifi_device_state(); QByteArray get_property(const QString &network_path, const QString &property); unsigned int get_ap_strength(const QString &network_path); SecurityType getSecurityType(const QString &path);