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->setEnabled(false);
wifiMeteredToggle->setValue("Unsupported while tethering"); wifiMeteredToggle->setValue("Unsupported while tethering");
wifiMeteredToggle->setToggled(false); 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(); bool metered = wifi->currentNetworkMetered();
wifiMeteredToggle->setEnabled(true); wifiMeteredToggle->setEnabled(true);
wifiMeteredToggle->setValue(metered ? "Metered" : "Unmetered"); wifiMeteredToggle->setValue(metered ? "Metered" : "Unmetered");

@ -397,24 +397,45 @@ bool WifiManager::currentNetworkMetered() {
} }
bool WifiManager::setCurrentNetworkMetered(bool metered) { bool WifiManager::setCurrentNetworkMetered(bool metered) {
auto primary_conn = call<QDBusObjectPath>(NM_DBUS_PATH, NM_DBUS_INTERFACE_PROPERTIES, "Get", NM_DBUS_INTERFACE, "PrimaryConnection"); // 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"); // std::cout << "Primary connection: " << primary_conn.path() << "\n";
auto primary_type = call<QString>(primary_conn.path(), NM_DBUS_INTERFACE_PROPERTIES, "Get", NM_DBUS_INTERFACE_ACTIVE_CONNECTION, "Type"); // 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(); for (const auto &p : getActiveConnections()) {
std::cout << "Setting metered to " << metered << " for type " << (int)type << "\n"; QDBusObjectPath settingsConnPath = call<QDBusObjectPath>(p.path(), NM_DBUS_INTERFACE_PROPERTIES, "Get", NM_DBUS_INTERFACE_ACTIVE_CONNECTION, "Connection");
std::cout << "tethering: " << isTetheringEnabled() << "\n"; QString type = call<QString>(p.path(), NM_DBUS_INTERFACE_PROPERTIES, "Get", NM_DBUS_INTERFACE_ACTIVE_CONNECTION, "Type");
if (ipv4_address != "" && !isTetheringEnabled()) { // note: already checks tethering if (type == "802-11-wireless") {
Connection settings = getConnectionSettings(settingsConnPath); std::cout << "Setting metered to " << metered << " for type " << type.toStdString() << "\n";
int meteredInt = metered ? NM_METERED_YES : NM_METERED_NO; std::cout << "tethering: " << isTetheringEnabled() << "\n";
settings["connection"]["metered"] = meteredInt; if (!isTetheringEnabled()) {
Connection settings = getConnectionSettings(settingsConnPath);
std::cout << "done setting metered to " << meteredInt << "\n"; int meteredInt = metered ? NM_METERED_YES : NM_METERED_NO;
call(settingsConnPath.path(), NM_DBUS_INTERFACE_SETTINGS_CONNECTION, "Update", QVariant::fromValue(settings)); settings["connection"]["metered"] = meteredInt;
return true;
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 // // TODO: support eth? why not
// if (primary_type == "802-3-ethernet") { // if (primary_type == "802-3-ethernet") {

Loading…
Cancel
Save