Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
69 commits
Select commit Hold shift + click to select a range
b354698
chore: uniform some arm model code
Nov 25, 2024
c08fc94
chore: extend toml
Nov 28, 2024
1c81683
fix: [network] add network full support
Nov 30, 2024
e3c87c6
chore: [translate] support lupdate auto
Dec 3, 2024
400b158
chore: extend flmx mode of device
add-uos Dec 3, 2024
4d4e3f7
fix: the flmx device of monitor display
add-uos Dec 7, 2024
958f62c
fix: the pgux device of monitor display
add-uos Dec 7, 2024
ed96373
fix: get the network of usb vender info
add-uos Dec 9, 2024
da8e009
fix: [network] add communication network support
Dec 10, 2024
093ad2a
fix: [network] add communication network support
Dec 12, 2024
d6a9c9f
fix: the w515 device of monitor display
add-uos Dec 17, 2024
02ee8d0
fix: the w525 device of monitor display
add-uos Dec 17, 2024
db15a61
fix: fix the UFS display
add-uos Dec 18, 2024
7602f7e
fix: remove invalid url
wyu71 Dec 20, 2024
4820581
fix: the camera info show incorrect
add-uos Dec 20, 2024
366a729
fix: the bluetooth of false identification
add-uos Dec 23, 2024
02f7a69
fix: the device of monitor display
add-uos Dec 30, 2024
49ecd82
fix: the monitor fresh rate
add-uos Jan 6, 2025
3225848
fix: the monitor paramer
add-uos Jan 6, 2025
4cce766
fix: the storage siez display
add-uos Jan 7, 2025
8702ea6
fix: the monitor get info from xrander
add-uos Jan 9, 2025
a9acd86
fix: adjust the select usb timeout
add-uos Jan 13, 2025
a7454bd
fix: fit the UFS for klv
add-uos Jan 14, 2025
3c7ae8d
Revert "fix: adjust the select usb timeout"
GongHeng2017 Jan 20, 2025
7933df4
fix: adjust the select usb timeout
GongHeng2017 Jan 20, 2025
05b1de7
feat: add the storage overview info
add-uos Feb 17, 2025
c6948df
feat: modify the storage size
add-uos Feb 22, 2025
4b2ff1c
fix: the get info from edit in order
add-uos Feb 26, 2025
ed89899
fix: the monitor info in single screen mode (#436)
add-uos Mar 11, 2025
899d8b4
fix: get the storage size info from smartctl (#450)
add-uos Apr 14, 2025
9a46594
fix: the monitor display info in special machine (#453)
add-uos Apr 28, 2025
2e1f8ea
fix: the audio device registe two pci device can't be disable
add-uos Apr 29, 2025
12eaa7c
fix: the audio device may cause crush
add-uos Apr 29, 2025
8e794c9
fix: fit multiple audio device enable function
add-uos May 8, 2025
cf8924c
fix: modify the mouse device name
add-uos May 15, 2025
480a9ef
fix the USB audio device can't be disable
add-uos May 19, 2025
da94bed
fix: filter the invalid power device (#461)
add-uos May 20, 2025
1977ed4
fix: the invalded device show incorrect (#462)
add-uos May 21, 2025
0d1d1c7
Fix: the monitor device incorrect order (#463)
GongHeng2017 May 27, 2025
07bb6c9
fix: modify the temperature of battery.
add-uos May 29, 2025
73f65c2
fix: the cpu model in special machine.
add-uos May 29, 2025
e675774
fix: remove useless info.
add-uos May 29, 2025
af46605
fix: adjust the storage display order.
add-uos May 30, 2025
8777b22
fix: update device description to Universal Flash Storage
add-uos May 30, 2025
d6eac66
fix: add the detail mode of screen size
add-uos Jun 3, 2025
e85b470
fix: [network] The wireless maybe connect.
GongHeng2017 May 30, 2025
1ba0d2a
fix: fix wakeup ps/2 mouse
add-uos Apr 16, 2025
7f7dc01
fix: format the overview of memory display
add-uos Jun 19, 2025
c788e3c
fix: [GPU] The max resolution and min resolution show error.
GongHeng2017 Jul 9, 2025
a9de646
feat: Update display size for specific device models
add-uos Jul 10, 2025
2941cca
fix: [Stroage-interface] The interface show error. (#487)
GongHeng2017 Jul 15, 2025
2608aae
fix: Format graphics card resolution display
add-uos Jul 16, 2025
350c0a6
feat: [GPU] Add logic to show GPU info.
GongHeng2017 Jul 22, 2025
19f6a31
feat: [GPU] Add extra information display logic.
GongHeng2017 Jul 23, 2025
496262e
fix: Improve supported resolution detection for display devices
add-uos Jul 23, 2025
b71dbea
fix: maintain the monitor info in special machine.
add-uos Jul 24, 2025
d705a5e
feat: [GPU] Add logic to show GPU info.
GongHeng2017 Jul 24, 2025
b95f55c
feat: [GPU] Add feature for GPU.
GongHeng2017 Jul 24, 2025
553f3a9
feat: [GPU] Add logic to show GPU info.
GongHeng2017 Jul 24, 2025
10e0f89
Chore: [cppcheck] Resolve issue identified by cppcheck
GongHeng2017 Jul 29, 2025
52f6971
Perf: [cppcheck] parameter should be passed by const reference.
GongHeng2017 Jul 29, 2025
6e5ecd7
fix: Update input device Bus interface display
add-uos Jul 29, 2025
662a912
Feat: [Monitor] The monitor name show error.
GongHeng2017 Jul 29, 2025
dabc018
fix: [cppcheck] Remove the useless code.
GongHeng2017 Jul 30, 2025
04d5c66
Perf: [cppcheck] Improve program execution efficiency.
GongHeng2017 Jul 30, 2025
6961768
fix: [Net-Wakeup] The net card can not wakeup.
GongHeng2017 Aug 1, 2025
bcee01b
Perf: Improve program performance
GongHeng2017 Aug 5, 2025
5e5dff5
Perf: Improve program performance
GongHeng2017 Aug 5, 2025
f965949
Chore: Fix the cppcheck warning.
GongHeng2017 Aug 5, 2025
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
1 change: 1 addition & 0 deletions deepin-devicemanager-server/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ project(deepin-devicemanager-server C CXX)

add_subdirectory(deepin-deviceinfo)
add_subdirectory(deepin-devicecontrol)
add_subdirectory(customgpuinfo)

#TEST--------------------------------------------------
if (CMAKE_COVERAGE_ARG STREQUAL "CMAKE_COVERAGE_ARG_ON")
Expand Down
24 changes: 24 additions & 0 deletions deepin-devicemanager-server/customgpuinfo/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
cmake_minimum_required(VERSION 3.7)

set(BIN_NAME "customgpuinfo")

find_package(Qt5 COMPONENTS Core REQUIRED)

file(GLOB_RECURSE SRC
"${CMAKE_CURRENT_SOURCE_DIR}/*.h"
"${CMAKE_CURRENT_SOURCE_DIR}/*.cpp"
)

add_executable(${BIN_NAME}
${SRC}
)

target_include_directories(${BIN_NAME} PUBLIC
Qt5::Core
)

target_link_libraries(${BIN_NAME} PRIVATE
Qt5::Core
)

install(TARGETS ${BIN_NAME} DESTINATION ${CMAKE_INSTALL_PREFIX}/lib/deepin-devicemanager)
121 changes: 121 additions & 0 deletions deepin-devicemanager-server/customgpuinfo/main.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,121 @@
// SPDX-FileCopyrightText: 2025 UnionTech Software Technology Co., Ltd.
//
// SPDX-License-Identifier: GPL-3.0-or-later

#include <QProcess>

Check warning on line 5 in deepin-devicemanager-server/customgpuinfo/main.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 <QMap>

Check warning on line 6 in deepin-devicemanager-server/customgpuinfo/main.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

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

Check warning on line 7 in deepin-devicemanager-server/customgpuinfo/main.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

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

Check warning on line 8 in deepin-devicemanager-server/customgpuinfo/main.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 <QDebug>

Check warning on line 9 in deepin-devicemanager-server/customgpuinfo/main.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

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

#include <iostream>

Check warning on line 11 in deepin-devicemanager-server/customgpuinfo/main.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

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

// 名称("Name") 厂商("Vendor") 型号("Model") 版本(Version) 显存("Graphics Memory")

constexpr char kName[] { "Name" };
constexpr char kVendor[] { "Vendor" };
constexpr char kModel[] { "Model" };
constexpr char kVersion[] { "Version" };
constexpr char kGraphicsMemory[] { "Graphics Memory" };

bool getGpuBaseInfo(QMap<QString, QString> &mapInfo)
{
QProcess process;
QProcessEnvironment env = QProcessEnvironment::systemEnvironment();
process.setProcessEnvironment(env);
process.start("/usr/bin/glxinfo", QStringList() << "-B");
if (!process.waitForFinished(3000)) {
qCritical() << "Error executing glxinfo:" << process.errorString();
return false;
}

QString output = QString::fromLocal8Bit(process.readAllStandardOutput());
QStringList lines = output.split('\n');
QRegularExpression regex("^([^:]+):\\s*(.+)$");
for (const QString &line : lines) {
QRegularExpressionMatch match = regex.match(line);
if (match.hasMatch()) {
QString key = match.captured(1).trimmed();
QString value = match.captured(2).trimmed();
if (key == "OpenGL renderer string") {
mapInfo.insert(kName, value);
mapInfo.insert(kModel, value);
} else if (key == "OpenGL vendor string") {
mapInfo.insert(kVendor, value);
}
}
}

return true;
}

bool getGpuMemInfoForFTDTM(QMap<QString, QString> &mapInfo)
{
const QString filePath = "/sys/kernel/debug/gc/meminfo";
QString totalValue;
bool foundTotal = false;

QFile file(filePath);
if (!file.open(QIODevice::ReadOnly | QIODevice::Text)) {
qCritical() << "Error opening /sys/kernel/debug/gc/meminfo:" << file.errorString();
return false;
}

QString content = QString::fromUtf8(file.readAll());
file.close();

if (content.isEmpty()) {
qCritical() << "Error: /sys/kernel/debug/gc/meminfo File is empty!";
return false;
}

QRegularExpression system0Regex(R"(POOL SYSTEM0:*(.*?)POOL VIRTUAL:)",
QRegularExpression::DotMatchesEverythingOption);
QRegularExpressionMatch system0Match = system0Regex.match(content);

if (!system0Match.hasMatch()) {
qCritical() << "Error: Failed to find SYSTEM0 section";
return false;
}

QString system0Content = system0Match.captured(1);
QRegularExpression totalRegex(R"(Total\s*:\s*(\d+)\s+B)");
QRegularExpressionMatch totalMatch = totalRegex.match(system0Content);
if (totalMatch.hasMatch()) {
totalValue = totalMatch.captured(1);
foundTotal = true;
}

if (!foundTotal || totalValue.isEmpty()) {
qCritical() << "Error: Failed to find Total value in SYSTEM0 content";
return false;
}

bool ok;
quint64 memSize = totalValue.trimmed().toULong(&ok, 10);
if (ok && memSize >= 1048576) {
memSize /= 1048576;
auto curSize = memSize / 1024.0;
if (curSize >= 1) {
totalValue = QString::number(curSize) + "GB";
} else {
totalValue = QString::number(memSize) + "MB";
}
}

mapInfo.insert(kGraphicsMemory, totalValue);

return true;
}

int main(int argc, char *argv[])
{
QMap<QString, QString> mapInfo;
if (getGpuBaseInfo(mapInfo) && getGpuMemInfoForFTDTM(mapInfo)) {
for (auto it = mapInfo.begin(); it != mapInfo.end(); ++it)
std::cout << it.key().toStdString() << ": " << it.value().toStdString() << std::endl;
return 0;
} else {
return 1;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -140,9 +140,7 @@ bool ControlInterface::enable(const QString &hclass, const QString &name, const

// 先从数据库中查找路径,防止设备更换usb接口
QString sPath = EnableSqlManager::getInstance()->authorizedPath(value);
if (sPath.isEmpty()) {
sPath = path;
}
Comment on lines -143 to -145
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

question (bug_risk): Always overwriting sPath with path may break fallback logic.

This change removes the fallback to the database value, which may cause issues if the fallback is required for some hardware.

sPath = path;

// 判断是内置设备,还是外设,内置设备通过remove文件禁用,外设通过authorized文件禁用
bool res = false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ bool DriverManager::installDriver(const QString &filepath)
//模块已被加载
/*
* 下面代码由 liujun 于 2021年11月9号 注释
* 为修复bug https://pms.uniontech.com/zentao/bug-view-101808.html
* 为修复bug 101808
*/
// if (mp_modcore->modIsLoaded(filepath)) {
// sigProgressDetail(10, QString("could not insert module %1 :file exist").arg(filepath));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,17 +49,20 @@
}
}

void EnableSqlManager::insertDataToAuthorizedTable(const QString &hclass, const QString &name, const QString &path, const QString &unique_id, bool exist, const QString &strDriver)

Check warning on line 52 in deepin-devicemanager-server/deepin-devicecontrol/src/enablecontrol/enablesqlmanager.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

The function 'insertDataToAuthorizedTable' is never used.
{
// 数据库已经存在该设备记录
if (uniqueIDExistedEX(unique_id)) {
if (uniqueIDExistedEX(unique_id, path)) {
return;
}

// 数据库没有该设备记录,则直接插入
// QString sql = QString("INSERT INTO %1 (class, name, path, unique_id, exist, driver) VALUES (%2, %3, %4, %5, %6, %7);")
// .arg(DB_TABLE_AUTHORIZED).arg(":hclass").arg(":name").arg(":path").arg(":unique_id").arg(":exist").arg(":strDriver");
if(!m_sqlQuery.prepare("INSERT INTO authorized (class, name, path, unique_id, exist, driver) VALUES (:hclass, :name, :path, :unique_id, :exist, :strDriver);")) return;
if(!m_sqlQuery.prepare("INSERT INTO authorized (class, name, path, unique_id, exist, driver) VALUES (:hclass, :name, :path, :unique_id, :exist, :strDriver);")){
qDebug() << "insert data to authorized table failed";
return;
}
m_sqlQuery.bindValue(":hclass", QVariant(hclass));
m_sqlQuery.bindValue(":name", QVariant(name));
m_sqlQuery.bindValue(":path", QVariant(path));
Expand Down Expand Up @@ -124,23 +127,29 @@
}
}

bool EnableSqlManager::uniqueIDExisted(const QString &key)
bool EnableSqlManager::uniqueIDExisted(const QString &key, const QString path)

Check warning on line 130 in deepin-devicemanager-server/deepin-devicecontrol/src/enablecontrol/enablesqlmanager.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

Parameter 'path' is passed by value. It could be passed as a const reference which is usually faster and recommended in C++.
{
QString sql = QString("SELECT COUNT(*) FROM %1 WHERE unique_id=%2;").arg(DB_TABLE_AUTHORIZED).arg(":param");
if (!path.isEmpty()){
sql = QString("SELECT COUNT(*) FROM %1 WHERE unique_id=%2 and path=%3;").arg(DB_TABLE_AUTHORIZED).arg(":param").arg(":path");
}
if(!m_sqlQuery.prepare(sql)) return false;
m_sqlQuery.bindValue(":param", QVariant(key));
if (!path.isEmpty()){
m_sqlQuery.bindValue(":path", QVariant(path));
}
if (m_sqlQuery.exec() && m_sqlQuery.next()) {
return m_sqlQuery.value(0).toInt() > 0;
}
return false;
}

bool EnableSqlManager::uniqueIDExistedEX(const QString &key)
bool EnableSqlManager::uniqueIDExistedEX(const QString &key, const QString path)

Check warning on line 147 in deepin-devicemanager-server/deepin-devicecontrol/src/enablecontrol/enablesqlmanager.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

Parameter 'path' is passed by value. It could be passed as a const reference which is usually faster and recommended in C++.
{
return uniqueIDExisted(key);
return uniqueIDExisted(key, path);
}

bool EnableSqlManager::isUniqueIdEnabled(const QString &key)

Check warning on line 152 in deepin-devicemanager-server/deepin-devicecontrol/src/enablecontrol/enablesqlmanager.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

The function 'isUniqueIdEnabled' is never used.
{
QString sql = QString("SELECT enable FROM %1 WHERE unique_id='%2';").arg(DB_TABLE_AUTHORIZED).arg(":key");
if(!m_sqlQuery.prepare(sql)) return false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,14 +90,14 @@ class EnableSqlManager : public QObject
* @param key
* @return
*/
bool uniqueIDExisted(const QString &key);
bool uniqueIDExisted(const QString &key, const QString path = "");

/**
* @brief uniqueIDExistedForEnable
* @param key
* @return
*/
bool uniqueIDExistedEX(const QString &key);
bool uniqueIDExistedEX(const QString &key, const QString path = "");

/**
* @brief isUniqueIdEnabled 判断设备是否被禁用了
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
#include <QFile>
#include <QProcess>
#include <QCryptographicHash>
#include <QDebug>

#include <net/if.h>
#include <sys/ioctl.h>
Expand Down Expand Up @@ -138,34 +139,51 @@ void EnableUtils::disableInDevice()

bool EnableUtils::ioctlOperateNetworkLogicalName(const QString &logicalName, bool enable)
{
// 1. 通过ioctl禁用
int fd = socket(AF_INET, SOCK_STREAM, 0);
if (fd < 0)
return false;
struct ifreq ifr;
strncpy(ifr.ifr_name, logicalName.toStdString().c_str(),IFNAMSIZ);
ifr.ifr_name[IFNAMSIZ - 1] = '\0';
short flag;
if (enable) {
flag = IFF_UP | IFF_PROMISC;
} else {
flag = ~(IFF_UP | IFF_PROMISC);
}
// 先获取标识
if (ioctl(fd, SIOCGIFFLAGS, &ifr) < 0) {
close(fd);
return false;
}
// 获取后重新设置标识
if (enable) {
ifr.ifr_ifru.ifru_flags |= flag;
if (logicalName.startsWith("wlan") || logicalName.startsWith("wlp")) { // Wireless LAN
QString cmd = QString("rfkill %1 $(rfkill list | grep -A 2 \"phy$(iw dev %2 info 2>/dev/null | awk '/wiphy/{print $2}')\" | awk 'NR==1{print $1}' | tr -d ':')")
.arg(enable ? "unblock" : "block")
.arg(logicalName);
int ret = system(cmd.toStdString().c_str());
if (ret != 0) {
qCritical() << "Failed to block/unblock wifi: " << " error code: " << ret ;
}
cmd = QString("/sbin/ifconfig %1 %2").arg(logicalName).arg(enable ? "up" : "down");
ret = system(cmd.toStdString().c_str());
if (ret != 0) {
qCritical() << "Failed to up/down network: " << logicalName << enable << " error code: " << ret ;
return false;
}
} else {
ifr.ifr_ifru.ifru_flags &= flag;
}
// 1. 通过ioctl禁用
int fd = socket(AF_INET, SOCK_STREAM, 0);
if (fd < 0)
return false;

struct ifreq ifr;
strncpy(ifr.ifr_name, logicalName.toStdString().c_str(),IFNAMSIZ);
ifr.ifr_name[IFNAMSIZ - 1] = '\0';
short flag;
if (enable) {
flag = IFF_UP | IFF_PROMISC;
} else {
flag = ~(IFF_UP | IFF_PROMISC);
}
// 先获取标识
if (ioctl(fd, SIOCGIFFLAGS, &ifr) < 0) {
close(fd);
return false;
}
// 获取后重新设置标识
if (enable) {
ifr.ifr_ifru.ifru_flags |= flag;
} else {
ifr.ifr_ifru.ifru_flags &= flag;
}

if (ioctl(fd, SIOCSIFFLAGS, &ifr) < 0) {
close(fd);
return false;
if (ioctl(fd, SIOCSIFFLAGS, &ifr) < 0) {
close(fd);
return false;
}
}
return true;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,12 @@ WakeupUtils::EthStatus WakeupUtils::wakeOnLanIsOpen(const QString &logicalName)
struct ifreq ifr;
struct ethtool_wolinfo wolinfo;
memset(&ifr, 0, sizeof(ifr));
strncpy(ifr.ifr_name, logicalName.toStdString().c_str(), sizeof(logicalName.toStdString().c_str()));
memset(&wolinfo, 0, sizeof(wolinfo));

QByteArray nameBytes = logicalName.toLocal8Bit();
strncpy(ifr.ifr_name, nameBytes.constData(), IFNAMSIZ - 1);
ifr.ifr_name[IFNAMSIZ - 1] = '\0';

wolinfo.cmd = ETHTOOL_GWOL;
ifr.ifr_data = reinterpret_cast<char *>(&wolinfo);
if (0 != ioctl(fd, SIOCETHTOOL, &ifr)) {
Expand Down Expand Up @@ -147,7 +152,12 @@ bool WakeupUtils::setWakeOnLan(const QString &logicalName, bool open)
struct ifreq ifr;
struct ethtool_wolinfo wolinfo;
memset(&ifr, 0, sizeof(ifr));
strncpy(ifr.ifr_name, logicalName.toStdString().c_str(), sizeof(logicalName.toStdString().c_str()));
memset(&wolinfo, 0, sizeof(wolinfo));

QByteArray nameBytes = logicalName.toLocal8Bit();
strncpy(ifr.ifr_name, nameBytes.constData(), IFNAMSIZ - 1);
ifr.ifr_name[IFNAMSIZ - 1] = '\0';

wolinfo.cmd = ETHTOOL_SWOL;
if (open)
wolinfo.wolopts = 0 | WAKE_MAGIC;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@ void MonitorUsb::monitor()
break;
FD_ZERO(&fds);
FD_SET(fd, &fds);
tv.tv_sec = 0;
tv.tv_usec = 10000;
tv.tv_sec = 1;
tv.tv_usec = 0;
int ret = select(fd + 1, &fds, nullptr, nullptr, &tv);

// 判断是否有事件产生
Expand Down
Loading
Loading