Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions deepin-devicemanager/src/GenerateDevice/DeviceFactory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,11 @@
#include "ArmGenerator.h"
#include "HWGenerator.h"
#include "CustomGenerator.h"
#include "commonfunction.h"

Check warning on line 12 in deepin-devicemanager/src/GenerateDevice/DeviceFactory.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: "commonfunction.h" not found.
#include "commontools.h"

Check warning on line 13 in deepin-devicemanager/src/GenerateDevice/DeviceFactory.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: "commontools.h" not found.

// Qt库文件
#include <QProcess>

Check warning on line 16 in deepin-devicemanager/src/GenerateDevice/DeviceFactory.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: <QProcess> not found. Please note: Cppcheck does not need standard library headers to get proper results.
#include <QFile>

DeviceFactory::DeviceFactory()
Expand Down Expand Up @@ -42,9 +43,13 @@
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();
Expand Down
31 changes: 31 additions & 0 deletions deepin-devicemanager/src/Tool/commontools.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,12 @@
#include <QDateTime>
#include <QDBusInterface>
#include <QDBusReply>
#include <QFile>

Check warning on line 14 in deepin-devicemanager/src/Tool/commontools.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: <QFile> not found. Please note: Cppcheck does not need standard library headers to get proper results.
#include <QDir>

Check warning on line 15 in deepin-devicemanager/src/Tool/commontools.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: <QDir> not found. Please note: Cppcheck does not need standard library headers to get proper results.
#include <QProcess>

Check warning on line 16 in deepin-devicemanager/src/Tool/commontools.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: <QProcess> not found. Please note: Cppcheck does not need standard library headers to get proper results.
#include <QMutex>

Check warning on line 17 in deepin-devicemanager/src/Tool/commontools.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: <QMutex> not found. Please note: Cppcheck does not need standard library headers to get proper results.
#include <QMutexLocker>

Check warning on line 18 in deepin-devicemanager/src/Tool/commontools.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: <QMutexLocker> not found. Please note: Cppcheck does not need standard library headers to get proper results.
#include <DConfig>

Check warning on line 19 in deepin-devicemanager/src/Tool/commontools.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: <DConfig> not found. Please note: Cppcheck does not need standard library headers to get proper results.

DWIDGET_USE_NAMESPACE
using namespace DDLog;
Expand Down Expand Up @@ -304,6 +306,35 @@
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<QString, QString> &mapInfo)
{
QProcess process;
Expand Down
1 change: 1 addition & 0 deletions deepin-devicemanager/src/Tool/commontools.h
Original file line number Diff line number Diff line change
Expand Up @@ -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<QString, QString> &mapInfo);
Expand Down
2 changes: 1 addition & 1 deletion deepin-devicemanager/src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}

Expand Down