Skip to content

Commit

Permalink
ui/network: wait before calling activateModemConnection
Browse files Browse the repository at this point in the history
  • Loading branch information
andiradulescu committed Nov 23, 2023
1 parent 8d3bf1f commit 859a90d
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
14 changes: 10 additions & 4 deletions selfdrive/ui/qt/network/wifi_manager.cc
Original file line number Diff line number Diff line change
Expand Up @@ -203,8 +203,8 @@ void WifiManager::deactivateConnectionBySsid(const QString &ssid) {
}
}

void WifiManager::deactivateConnection(const QDBusObjectPath &path) {
asyncCall(NM_DBUS_PATH, NM_DBUS_INTERFACE, "DeactivateConnection", QVariant::fromValue(path));
std::optional<QDBusPendingCall> WifiManager::deactivateConnection(const QDBusObjectPath &path) {
return asyncCall(NM_DBUS_PATH, NM_DBUS_INTERFACE, "DeactivateConnection", QVariant::fromValue(path));
}

QVector<QDBusObjectPath> WifiManager::getActiveConnections() {
Expand Down Expand Up @@ -392,8 +392,14 @@ void WifiManager::updateGsmSettings(bool roaming, QString apn, bool metered) {

if (changes) {
call(lteConnectionPath.path(), NM_DBUS_INTERFACE_SETTINGS_CONNECTION, "UpdateUnsaved", QVariant::fromValue(settings)); // update is temporary
deactivateConnection(lteConnectionPath);
activateModemConnection(lteConnectionPath);
auto pending_call = deactivateConnection(lteConnectionPath);

if (pending_call) {
QDBusPendingCallWatcher *watcher = new QDBusPendingCallWatcher(*pending_call);
QObject::connect(watcher, &QDBusPendingCallWatcher::finished, this, [=]() {
activateModemConnection(lteConnectionPath);
});
}
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion selfdrive/ui/qt/network/wifi_manager.h
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ class WifiManager : public QObject {
uint getAdapterType(const QDBusObjectPath &path);
QString getIp4Address();
void deactivateConnectionBySsid(const QString &ssid);
void deactivateConnection(const QDBusObjectPath &path);
std::optional<QDBusPendingCall> deactivateConnection(const QDBusObjectPath &path);
QVector<QDBusObjectPath> getActiveConnections();
QByteArray get_property(const QString &network_path, const QString &property);
SecurityType getSecurityType(const QVariantMap &properties);
Expand Down

0 comments on commit 859a90d

Please sign in to comment.