From 26a36d4802169042a82b650988cb1d72df17d6e4 Mon Sep 17 00:00:00 2001 From: gongheng Date: Mon, 1 Dec 2025 15:34:45 +0800 Subject: [PATCH] Fix: [custom] The memory size not show on special platform. -- Add to to adjust the special platform to show memory size. Log: fix issue Bug: https://pms.uniontech.com/bug-view-342533.html --- .../src/GenerateDevice/DeviceFactory.cpp | 11 +++++-- deepin-devicemanager/src/Tool/commontools.cpp | 31 +++++++++++++++++++ deepin-devicemanager/src/Tool/commontools.h | 1 + deepin-devicemanager/src/main.cpp | 2 +- 4 files changed, 41 insertions(+), 4 deletions(-) diff --git a/deepin-devicemanager/src/GenerateDevice/DeviceFactory.cpp b/deepin-devicemanager/src/GenerateDevice/DeviceFactory.cpp index 30102c9b..a3b526b0 100644 --- a/deepin-devicemanager/src/GenerateDevice/DeviceFactory.cpp +++ b/deepin-devicemanager/src/GenerateDevice/DeviceFactory.cpp @@ -10,6 +10,7 @@ #include "HWGenerator.h" #include "CustomGenerator.h" #include "commonfunction.h" +#include "commontools.h" // Qt库文件 #include @@ -42,9 +43,13 @@ DeviceGenerator *DeviceFactory::getDeviceGenerator() generator = new HWGenerator(); else if (type == "PGUX") generator = new HWGenerator(); - else if (type == "CustomType") - generator = new CustomGenerator(); - else + else if (type == "CustomType") { + if (CommonTools::hasPciGraphicsCard()) { + generator = new ArmGenerator(); + } else { + generator = new CustomGenerator(); + } + } else generator = new HWGenerator(); } else generator = new ArmGenerator(); diff --git a/deepin-devicemanager/src/Tool/commontools.cpp b/deepin-devicemanager/src/Tool/commontools.cpp index d3d21fba..d5c76fb6 100644 --- a/deepin-devicemanager/src/Tool/commontools.cpp +++ b/deepin-devicemanager/src/Tool/commontools.cpp @@ -14,6 +14,8 @@ #include #include #include +#include +#include #include DWIDGET_USE_NAMESPACE @@ -304,6 +306,35 @@ QString CommonTools::preGenerateGpuInfo() return (gpuBaseInfo + gpuMemInfo); } +bool CommonTools::hasPciGraphicsCard() +{ + static bool result = false; + static bool initialized = false; + static QMutex mutex; + + QMutexLocker locker(&mutex); + + if (!initialized) { + QProcess process; + process.setProgram("lspci"); + process.setArguments(QStringList() << "-v" << "-d" << "::0300"); + process.start(); + if (!process.waitForFinished(5000)) { + qCritical() << "Exec lspci time out!"; + result = false; + } else if (process.exitCode() != 0) { + qCritical() << "Failed to exec lspci, code : " << process.exitCode(); + result = false; + } else { + QString output = process.readAllStandardOutput(); + result = !output.trimmed().isEmpty(); + } + initialized = true; + } + + return result; +} + bool CommonTools::getGpuBaseInfo(QMap &mapInfo) { QProcess process; diff --git a/deepin-devicemanager/src/Tool/commontools.h b/deepin-devicemanager/src/Tool/commontools.h index 915d5f99..8367f1a4 100644 --- a/deepin-devicemanager/src/Tool/commontools.h +++ b/deepin-devicemanager/src/Tool/commontools.h @@ -81,6 +81,7 @@ class CommonTools : public QObject static void parseEDID(const QStringList &allEDIDS, const QString &input, bool isHW = true); static QString getGpuInfoCommandFromDConfig(); static QString preGenerateGpuInfo(); + static bool hasPciGraphicsCard(); private: static bool getGpuBaseInfo(QMap &mapInfo); diff --git a/deepin-devicemanager/src/main.cpp b/deepin-devicemanager/src/main.cpp index 2132afbe..3cafae4c 100644 --- a/deepin-devicemanager/src/main.cpp +++ b/deepin-devicemanager/src/main.cpp @@ -124,7 +124,7 @@ int main(int argc, char *argv[]) } // 特殊机型,提前缓存GPU信息 - if (Common::specialComType == Common::kCustomType) { + if (Common::specialComType == Common::kCustomType && !CommonTools::hasPciGraphicsCard()) { CommonTools::preGenerateGpuInfo(); }