From 0f2dfc4c0e377d0cf2d6723ac1d5bbd0ec391c13 Mon Sep 17 00:00:00 2001
From: shuaijie <shuaijie@uniontech.com>
Date: Thu, 13 Apr 2023 21:46:26 +0800
Subject: [PATCH] fix: Ethernet Controller X710 disable

Ethernet Controller X710 disable

Log: Ethernet Controller X710 disable

Bug: https://pms.uniontech.com/bug-view-188969.html
Change-Id: I93d8157652e23796d91d9ba293f887c988502b0f
---
 deepin-devicemanager/src/GenerateDevice/CmdTool.cpp      | 5 ++++-
 .../src/GenerateDevice/DeviceGenerator.cpp               | 9 ++++++++-
 2 files changed, 12 insertions(+), 2 deletions(-)

diff --git a/deepin-devicemanager/src/GenerateDevice/CmdTool.cpp b/deepin-devicemanager/src/GenerateDevice/CmdTool.cpp
index 6a018adf..0f0f93b2 100644
--- a/deepin-devicemanager/src/GenerateDevice/CmdTool.cpp
+++ b/deepin-devicemanager/src/GenerateDevice/CmdTool.cpp
@@ -738,7 +738,10 @@ void CmdTool::getMapInfoFromLshw(const QString &info, QMap<QString, QString> &ma
                 mapInfo[attr[0].trimmed()] += attr[1].trimmed();
             }
         } else {
-            mapInfo.insert(words[0].trimmed(), words[1].trimmed());
+            if (info.startsWith("network") && true == words[0].contains("logical name") && true == words[1].contains("dev/fb")) {
+                continue;
+            } else
+                mapInfo.insert(words[0].trimmed(), words[1].trimmed());
         }
     }
 }
diff --git a/deepin-devicemanager/src/GenerateDevice/DeviceGenerator.cpp b/deepin-devicemanager/src/GenerateDevice/DeviceGenerator.cpp
index 219ca518..7f4b2d51 100644
--- a/deepin-devicemanager/src/GenerateDevice/DeviceGenerator.cpp
+++ b/deepin-devicemanager/src/GenerateDevice/DeviceGenerator.cpp
@@ -27,6 +27,7 @@
 
 // Qt库文件
 #include <QDebug>
+#include <QDir>
 
 DeviceGenerator::DeviceGenerator(QObject *parent)
     : QObject(parent)
@@ -173,8 +174,14 @@ void DeviceGenerator::generatorNetworkDevice()
     for (; it != lstInfo.end(); ++it) {
         if ((*it).size() < 2)
             continue;
-        if((*it).find("logical name") == (*it).end() || (*it).find("serial") == (*it).end())
+        if ((*it).find("logical name") == (*it).end() || (*it).find("serial") == (*it).end())
             continue;
+        QString logicalname = (*it).value("logical name");
+        QString sysClassNet_path = "/sys/class/net/" + logicalname + "/device";
+        QDir dir(sysClassNet_path);
+        if (! dir.exists())
+            continue;
+
         DeviceNetwork *device = new DeviceNetwork();
         device->setInfoFromLshw(*it);
         DeviceManager::instance()->addNetworkDevice(device);
-- 
2.20.1

