From 850fd4a2897a526fc977b3949ced44c59a80c177 Mon Sep 17 00:00:00 2001 From: Devendra Tewari Date: Mon, 23 Aug 2021 16:13:28 -0300 Subject: [PATCH] Create WPA DBUS proxy synchronously (#8834) --- .../Linux/ConnectivityManagerImpl.cpp | 28 ++++++++----------- 1 file changed, 12 insertions(+), 16 deletions(-) diff --git a/src/platform/Linux/ConnectivityManagerImpl.cpp b/src/platform/Linux/ConnectivityManagerImpl.cpp index a79fda4f5c0012..1f5a40b7fb5313 100644 --- a/src/platform/Linux/ConnectivityManagerImpl.cpp +++ b/src/platform/Linux/ConnectivityManagerImpl.cpp @@ -591,11 +591,21 @@ void ConnectivityManagerImpl::_OnWpaInterfaceRemoved(WpaFiW1Wpa_supplicant1 * pr } } -void ConnectivityManagerImpl::_OnWpaProxyReady(GObject * source_object, GAsyncResult * res, gpointer user_data) +void ConnectivityManagerImpl::StartWiFiManagement(bool startAsync) { GError * err = nullptr; - mWpaSupplicant.proxy = wpa_fi_w1_wpa_supplicant1_proxy_new_for_bus_finish(res, &err); + mConnectivityFlag.ClearAll(); + mWpaSupplicant.state = GDBusWpaSupplicant::INIT; + mWpaSupplicant.scanState = GDBusWpaSupplicant::WIFI_SCANNING_IDLE; + mWpaSupplicant.proxy = nullptr; + mWpaSupplicant.iface = nullptr; + mWpaSupplicant.interfacePath = nullptr; + mWpaSupplicant.networkPath = nullptr; + + mWpaSupplicant.proxy = wpa_fi_w1_wpa_supplicant1_proxy_new_for_bus_sync(G_BUS_TYPE_SYSTEM, G_DBUS_PROXY_FLAGS_NONE, + kWpaSupplicantServiceName, + kWpaSupplicantObjectPath, nullptr, &err); if (mWpaSupplicant.proxy != nullptr && err == nullptr) { mWpaSupplicant.state = GDBusWpaSupplicant::WPA_CONNECTED; @@ -619,20 +629,6 @@ void ConnectivityManagerImpl::_OnWpaProxyReady(GObject * source_object, GAsyncRe g_error_free(err); } -void ConnectivityManagerImpl::StartWiFiManagement() -{ - mConnectivityFlag.ClearAll(); - mWpaSupplicant.state = GDBusWpaSupplicant::INIT; - mWpaSupplicant.scanState = GDBusWpaSupplicant::WIFI_SCANNING_IDLE; - mWpaSupplicant.proxy = nullptr; - mWpaSupplicant.iface = nullptr; - mWpaSupplicant.interfacePath = nullptr; - mWpaSupplicant.networkPath = nullptr; - - wpa_fi_w1_wpa_supplicant1_proxy_new_for_bus(G_BUS_TYPE_SYSTEM, G_DBUS_PROXY_FLAGS_NONE, kWpaSupplicantServiceName, - kWpaSupplicantObjectPath, nullptr, _OnWpaProxyReady, nullptr); -} - void ConnectivityManagerImpl::DriveAPState() { CHIP_ERROR err = CHIP_NO_ERROR;