From 28b95d9bca7653d28e3ad31b9a88abfd426e94f6 Mon Sep 17 00:00:00 2001 From: shuaijie Date: Wed, 29 Nov 2023 15:47:17 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E9=83=A8=E5=88=86?= =?UTF-8?q?=E7=BD=91=E5=9D=80=E8=AE=BE=E5=A4=87=E8=AF=86=E5=88=AB=E9=97=AE?= =?UTF-8?q?=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit en01与en02网口MAC相同导致信息识别不全 Log: 网口的信息识别全 Bug: https://pms.uniontech.com/bug-view-230087.html --- deepin-devicemanager/src/DeviceManager/DeviceInfo.cpp | 10 ++++++---- .../src/DeviceManager/DeviceNetwork.cpp | 2 +- .../src/GenerateDevice/DeviceGenerator.cpp | 5 +++-- 3 files changed, 10 insertions(+), 7 deletions(-) diff --git a/deepin-devicemanager/src/DeviceManager/DeviceInfo.cpp b/deepin-devicemanager/src/DeviceManager/DeviceInfo.cpp index a739aaab..522c9769 100644 --- a/deepin-devicemanager/src/DeviceManager/DeviceInfo.cpp +++ b/deepin-devicemanager/src/DeviceManager/DeviceInfo.cpp @@ -726,9 +726,9 @@ void DeviceBaseInfo::mapInfoToList() void DeviceBaseInfo::setHwinfoLshwKey(const QMap &mapInfo) { - // 网卡使用物理地址作为匹配值 + // 网卡使用物理地址+逻辑设备名作为匹配值 if (mapInfo.find("HW Address") != mapInfo.end()) { - m_HwinfoToLshw = mapInfo["HW Address"]; + m_HwinfoToLshw = (mapInfo.find("Device File") != mapInfo.end()) ? mapInfo["HW Address"] + mapInfo["Device File"] : mapInfo["HW Address"]; return; } @@ -773,9 +773,11 @@ void DeviceBaseInfo::setHwinfoLshwKey(const QMap &mapInfo) bool DeviceBaseInfo::matchToLshw(const QMap &mapInfo) { - // 网卡设备与序列号匹配上 + // 网卡设备与序列号匹配上 或者加上逻辑设备名 if (mapInfo.find("logical name") != mapInfo.end() && mapInfo.find("serial") != mapInfo.end()) { - if (m_HwinfoToLshw == mapInfo["serial"]) { + if (m_HwinfoToLshw == mapInfo["serial"] + mapInfo["logical name"]) { + return true; + } else if (m_HwinfoToLshw == mapInfo["serial"]) { return true; } } diff --git a/deepin-devicemanager/src/DeviceManager/DeviceNetwork.cpp b/deepin-devicemanager/src/DeviceManager/DeviceNetwork.cpp index bb1559a3..bdaf1e59 100644 --- a/deepin-devicemanager/src/DeviceManager/DeviceNetwork.cpp +++ b/deepin-devicemanager/src/DeviceManager/DeviceNetwork.cpp @@ -151,7 +151,7 @@ bool DeviceNetwork::setInfoFromHwinfo(const QMap &mapInfo) m_CanUninstall = !driverIsKernelIn(m_Driver); return true; } - + setAttribute(mapInfo, "Device File", m_LogicalName); setAttribute(mapInfo, "HW Address", m_MACAddress); setAttribute(mapInfo, "Permanent HW Address", m_UniqueID); setAttribute(mapInfo, "SysFS Device Link", m_SysPath); diff --git a/deepin-devicemanager/src/GenerateDevice/DeviceGenerator.cpp b/deepin-devicemanager/src/GenerateDevice/DeviceGenerator.cpp index f2370953..3f698b1b 100644 --- a/deepin-devicemanager/src/GenerateDevice/DeviceGenerator.cpp +++ b/deepin-devicemanager/src/GenerateDevice/DeviceGenerator.cpp @@ -273,9 +273,10 @@ void DeviceGenerator::generatorNetworkDevice() for (QList >::const_iterator it = lstLshw.begin(); it != lstLshw.end(); ++it) { if ((*it).find("serial") == (*it).end()) continue; - const QString &serialNumber = (*it)["serial"]; + const QString &serialNumber = ((*it).find("logical name") != (*it).end()) ? (*it)["serial"] + (*it)["logical name"] : (*it)["serial"]; for (QList::iterator itDevice = lstDevice.begin(); itDevice != lstDevice.end(); ++itDevice) { - if (!serialNumber.isEmpty() && ((*itDevice)->uniqueID() == serialNumber || (*itDevice)->hwAddress() == serialNumber)) { + const QString &ser2Number = (*itDevice)->logicalName().isEmpty() ? (*itDevice)->hwAddress() : (*itDevice)->hwAddress() + (*itDevice)->logicalName(); + if (!serialNumber.isEmpty() && ((*itDevice)->uniqueID() == serialNumber || ser2Number == serialNumber)) { (*itDevice)->setInfoFromLshw(*it); break; }