From 0d44c6ea28a22531634aca538254813bfd9abda5 Mon Sep 17 00:00:00 2001 From: Shane Smiskol Date: Tue, 20 May 2025 00:07:51 -0700 Subject: [PATCH] more --- selfdrive/ui/qt/network/wifi_manager.cc | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/selfdrive/ui/qt/network/wifi_manager.cc b/selfdrive/ui/qt/network/wifi_manager.cc index b13b204cae..c34be0f16e 100644 --- a/selfdrive/ui/qt/network/wifi_manager.cc +++ b/selfdrive/ui/qt/network/wifi_manager.cc @@ -405,23 +405,25 @@ bool WifiManager::setCurrentNetworkMetered(bool metered) { // std::cout << "Primary type: " << primary_type.toStdString() << "\n"; for (const auto &p : getActiveConnections()) { - QDBusObjectPath settingsConnPath = call(p.path(), NM_DBUS_INTERFACE_PROPERTIES, "Get", NM_DBUS_INTERFACE_ACTIVE_CONNECTION, "Connection"); QString type = call(p.path(), NM_DBUS_INTERFACE_PROPERTIES, "Get", NM_DBUS_INTERFACE_ACTIVE_CONNECTION, "Type"); if (type == "802-11-wireless") { std::cout << "Setting metered to " << metered << " for type " << type.toStdString() << "\n"; std::cout << "tethering: " << isTetheringEnabled() << "\n"; if (!isTetheringEnabled()) { - Connection settings = getConnectionSettings(settingsConnPath); - int meteredInt = metered ? NM_METERED_YES : NM_METERED_NO; - settings["connection"]["metered"] = meteredInt; - - std::cout << "done setting metered to " << meteredInt << "\n"; - call(settingsConnPath.path(), NM_DBUS_INTERFACE_SETTINGS_CONNECTION, "Update", QVariant::fromValue(settings)); - return true; + QDBusObjectPath settingsConnPath = call(p.path(), NM_DBUS_INTERFACE_PROPERTIES, "Get", NM_DBUS_INTERFACE_ACTIVE_CONNECTION, "Connection"); + if (!settingsConnPath.path().isEmpty()) { + Connection settings = getConnectionSettings(settingsConnPath); + int meteredInt = metered ? NM_METERED_YES : NM_METERED_NO; + settings["connection"]["metered"] = meteredInt; + + std::cout << "done setting metered to " << meteredInt << "\n"; + call(settingsConnPath.path(), NM_DBUS_INTERFACE_SETTINGS_CONNECTION, "Update", QVariant::fromValue(settings)); + return true; + } } - return false; } } + return false; //// NetworkType type = currentNetworkType(); // std::cout << "Setting metered to " << metered << " for type " << (int)type << "\n";