From 25c1ca9692df538e4f999cc0b2dcbf5b8857c668 Mon Sep 17 00:00:00 2001 From: jzxc95 <907297917@qq.com> Date: Mon, 18 Sep 2023 11:30:46 +0800 Subject: [PATCH] =?UTF-8?q?fix(device=20switch):=E5=8D=95=E7=BD=91?= =?UTF-8?q?=E5=8D=A1=E5=BC=80=E5=85=B3=E6=94=B9=E4=B8=BA=E5=90=8E=E7=AB=AF?= =?UTF-8?q?=E6=96=B0=E6=8F=90=E4=BE=9B=E7=9A=84SetStatusDevice=E6=8E=A5?= =?UTF-8?q?=E5=8F=A3(#186655)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../kylinnetworkdeviceresource.cpp | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/src/backend/dbus-interface/kylinnetworkdeviceresource.cpp b/src/backend/dbus-interface/kylinnetworkdeviceresource.cpp index 2441289a..eb8cc2c4 100644 --- a/src/backend/dbus-interface/kylinnetworkdeviceresource.cpp +++ b/src/backend/dbus-interface/kylinnetworkdeviceresource.cpp @@ -546,7 +546,24 @@ void KyNetworkDeviceResourse::setDeviceManaged(QString devName, bool managed) qWarning()<<"[KyNetworkDeviceResourse] can not find device " << devName; return; } - setDeviceManagedByGDbus(dbusPath, managed); + + QDBusInterface dbusInterface("org.freedesktop.NetworkManager", + dbusPath, + "org.freedesktop.NetworkManager.Device", + QDBusConnection::systemBus()); + + if (!dbusInterface.isValid()) { + qWarning() << dbusPath << "invalid"; + setDeviceManagedByGDbus(dbusPath, managed); + return; + } + + QDBusReply reply = dbusInterface.call("SetStateDevice", "", managed); + if (!reply.isValid()) { + qWarning() << "SetStateDevice error" << reply.error().message(); + setDeviceManagedByGDbus(dbusPath, managed); + return; + } } bool KyNetworkDeviceResourse::getDeviceManaged(QString deviceName)