From 6d43fd00dd617afcb4e6fd40386b5464787987c9 Mon Sep 17 00:00:00 2001 From: jzxc95 <907297917@qq.com> Date: Mon, 4 Sep 2023 14:06:56 +0800 Subject: [PATCH] fix(hotspot):fix error when a wirless device do not support Adhoc(#190431) --- plugins/mobilehotspot/mobilehotspotwidget.cpp | 2 +- .../dbus-interface/kylinnetworkdeviceresource.cpp | 9 +++++---- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/plugins/mobilehotspot/mobilehotspotwidget.cpp b/plugins/mobilehotspot/mobilehotspotwidget.cpp index 40d6623b..0a3c12b5 100644 --- a/plugins/mobilehotspot/mobilehotspotwidget.cpp +++ b/plugins/mobilehotspot/mobilehotspotwidget.cpp @@ -416,7 +416,7 @@ void MobileHotspotWidget::initInterfaceInfo() QMap::Iterator iter = devMap.begin(); while (iter != devMap.end()) { QString interfaceName = iter.key(); - if (devCapMap[interfaceName] & 0x01) { + if (!(devCapMap[interfaceName] & 0x01)) { m_interfaceComboBox->addItem(interfaceName); } iter++; diff --git a/src/backend/dbus-interface/kylinnetworkdeviceresource.cpp b/src/backend/dbus-interface/kylinnetworkdeviceresource.cpp index ecc9c378..2441289a 100644 --- a/src/backend/dbus-interface/kylinnetworkdeviceresource.cpp +++ b/src/backend/dbus-interface/kylinnetworkdeviceresource.cpp @@ -452,11 +452,12 @@ int KyNetworkDeviceResourse::getWirelessDeviceCapability(const QString deviceNam NetworkManager::WirelessDevice *wirelessDevicePtr = qobject_cast(connectDevice.data()); - int cap = 0x01; - if (!wirelessDevicePtr->wirelessCapabilities() & NetworkManager::WirelessDevice::AdhocCap) { - return cap; + int cap = 0x00; + if (wirelessDevicePtr->wirelessCapabilities() & NetworkManager::WirelessDevice::AdhocCap) { + cap = cap | 0x02; + } else { + return 0x01; } - cap = cap | 0x02; QDBusInterface dbusInterface("org.freedesktop.NetworkManager", connectDevice->uni(), "org.freedesktop.NetworkManager.Device.Wireless",