Skip to content

Commit

Permalink
fix: 修复部分网址设备识别问题
Browse files Browse the repository at this point in the history
en01与en02网口MAC相同导致信息识别不全

Log: 网口的信息识别全

Bug: https://pms.uniontech.com/bug-view-230087.html
  • Loading branch information
jeffshuai committed Nov 29, 2023
1 parent 961362c commit 28b95d9
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 7 deletions.
10 changes: 6 additions & 4 deletions deepin-devicemanager/src/DeviceManager/DeviceInfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -726,9 +726,9 @@ void DeviceBaseInfo::mapInfoToList()

void DeviceBaseInfo::setHwinfoLshwKey(const QMap<QString, QString> &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;
}

Expand Down Expand Up @@ -773,9 +773,11 @@ void DeviceBaseInfo::setHwinfoLshwKey(const QMap<QString, QString> &mapInfo)

bool DeviceBaseInfo::matchToLshw(const QMap<QString, QString> &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;
}
}
Expand Down
2 changes: 1 addition & 1 deletion deepin-devicemanager/src/DeviceManager/DeviceNetwork.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ bool DeviceNetwork::setInfoFromHwinfo(const QMap<QString, QString> &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);
Expand Down
5 changes: 3 additions & 2 deletions deepin-devicemanager/src/GenerateDevice/DeviceGenerator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -273,9 +273,10 @@ void DeviceGenerator::generatorNetworkDevice()
for (QList<QMap<QString, QString> >::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<DeviceNetwork *>::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;
}
Expand Down

0 comments on commit 28b95d9

Please sign in to comment.