ugh more fix, wifiManager is craze

pull/35293/head
Shane Smiskol 2 months ago
parent f79bcdf6bf
commit c8bd71edc2
  1. 2
      selfdrive/ui/qt/network/networking.cc
  2. 53
      selfdrive/ui/qt/network/wifi_manager.cc

@ -237,7 +237,7 @@ void AdvancedNetworking::refresh() {
wifiMeteredToggle->setEnabled(false);
wifiMeteredToggle->setValue("Unsupported while tethering");
wifiMeteredToggle->setToggled(false);
} else if (wifi->ipv4_address != "") { // TODO: check wifi
} else if (wifi->ipv4_address != "") { // TODO: ~check type~ fix type
bool metered = wifi->currentNetworkMetered();
wifiMeteredToggle->setEnabled(true);
wifiMeteredToggle->setValue(metered ? "Metered" : "Unmetered");

@ -397,24 +397,45 @@ bool WifiManager::currentNetworkMetered() {
}
bool WifiManager::setCurrentNetworkMetered(bool metered) {
auto primary_conn = call<QDBusObjectPath>(NM_DBUS_PATH, NM_DBUS_INTERFACE_PROPERTIES, "Get", NM_DBUS_INTERFACE, "PrimaryConnection");
QDBusObjectPath settingsConnPath = call<QDBusObjectPath>(primary_conn.path(), NM_DBUS_INTERFACE_PROPERTIES, "Get", NM_DBUS_INTERFACE_ACTIVE_CONNECTION, "Connection");
auto primary_type = call<QString>(primary_conn.path(), NM_DBUS_INTERFACE_PROPERTIES, "Get", NM_DBUS_INTERFACE_ACTIVE_CONNECTION, "Type");
// auto primary_conn = call<QDBusObjectPath>(NM_DBUS_PATH, NM_DBUS_INTERFACE_PROPERTIES, "Get", NM_DBUS_INTERFACE, "PrimaryConnection");
// std::cout << "Primary connection: " << primary_conn.path() << "\n";
// QDBusObjectPath settingsConnPath = call<QDBusObjectPath>(primary_conn.path(), NM_DBUS_INTERFACE_PROPERTIES, "Get", NM_DBUS_INTERFACE_ACTIVE_CONNECTION, "Connection");
// std::cout << "Settings connection path: " << settingsConnPath.path() << "\n";
// auto primary_type = call<QString>(primary_conn.path(), NM_DBUS_INTERFACE_PROPERTIES, "Get", NM_DBUS_INTERFACE_ACTIVE_CONNECTION, "Type");
// std::cout << "Primary type: " << primary_type.toStdString() << "\n";
NetworkType type = currentNetworkType();
std::cout << "Setting metered to " << metered << " for type " << (int)type << "\n";
std::cout << "tethering: " << isTetheringEnabled() << "\n";
if (ipv4_address != "" && !isTetheringEnabled()) { // note: already checks tethering
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;
for (const auto &p : getActiveConnections()) {
QDBusObjectPath settingsConnPath = call<QDBusObjectPath>(p.path(), NM_DBUS_INTERFACE_PROPERTIES, "Get", NM_DBUS_INTERFACE_ACTIVE_CONNECTION, "Connection");
QString type = call<QString>(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;
}
return false;
}
}
return false;
//// NetworkType type = currentNetworkType();
// std::cout << "Setting metered to " << metered << " for type " << (int)type << "\n";
// std::cout << "tethering: " << isTetheringEnabled() << "\n";
// if (ipv4_address != "" && !isTetheringEnabled()) { // note: already checks tethering
// 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;
//
// // TODO: support eth? why not
// if (primary_type == "802-3-ethernet") {

Loading…
Cancel
Save