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
3 changes: 1 addition & 2 deletions deepin-devicemanager-server/customgpuinfo/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,7 @@ bool getGpuMemInfoForFTDTM(QMap<QString, QString> &mapInfo)
int main(int argc, char *argv[])
{
QMap<QString, QString> mapInfo;
if (getGpuBaseInfo(mapInfo)) {
getGpuMemInfoForFTDTM(mapInfo);
if (getGpuMemInfoForFTDTM(mapInfo)) {
for (auto it = mapInfo.begin(); it != mapInfo.end(); ++it)
std::cout << it.key().toStdString() << ": " << it.value().toStdString() << std::endl;
return 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,27 +93,22 @@ void DeviceInterface::setMonitorDeviceFlag(bool flag)

QString DeviceInterface::getGpuInfoByCustom(const QString &cmd, const QStringList &arguments)
{
static bool firstFlag = true;
static QString gpuinfo;
if (firstFlag) {
firstFlag = false;

QProcess process;
QProcessEnvironment env = QProcessEnvironment::systemEnvironment();
if (arguments.size() > 1) {
env.insert("DISPLAY", arguments[0]);
env.insert("XAUTHORITY", arguments[1]);
}
process.setProcessEnvironment(env);
process.start(cmd, arguments);
if (!process.waitForFinished(4000)) {
qCritical() << QString("Error executing %1 :").arg(cmd) << process.errorString();
return gpuinfo;
}

if (process.exitCode() == 0)
gpuinfo = QString::fromLocal8Bit(process.readAllStandardOutput());
QString gpuinfo;
QProcess process;
QProcessEnvironment env = QProcessEnvironment::systemEnvironment();
if (arguments.size() > 1) {
env.insert("DISPLAY", arguments[0]);
env.insert("XAUTHORITY", arguments[1]);
}
process.setProcessEnvironment(env);
process.start(cmd, arguments);
if (!process.waitForFinished()) {
qCritical() << QString("Error executing %1 :").arg(cmd) << process.errorString();
return gpuinfo;
}

if (process.exitCode() == 0)
gpuinfo = QString::fromLocal8Bit(process.readAllStandardOutput());

return gpuinfo;
}
2 changes: 1 addition & 1 deletion deepin-devicemanager/src/DeviceManager/DeviceInfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -688,7 +688,7 @@ bool DeviceBaseInfo::driverIsKernelIn(const QString &driver)
return isKernelIn;
}

void DeviceBaseInfo::setCanEnale(bool can)
void DeviceBaseInfo::setCanEnable(bool can)
{
// qCDebug(appLog) << "DeviceBaseInfo::setCanEnale called with can: " << can;
m_CanEnable = can;
Expand Down
4 changes: 2 additions & 2 deletions deepin-devicemanager/src/DeviceManager/DeviceInfo.h
Original file line number Diff line number Diff line change
Expand Up @@ -164,10 +164,10 @@ class DeviceBaseInfo : public QObject
virtual bool driverIsKernelIn(const QString &driver);

/**
* @brief setCanEnale : set can enable or not
* @brief setCanEnable : set can enable or not
* @param can
*/
void setCanEnale(bool can);
void setCanEnable(bool can);

/**
* @brief canEnable : 该设备是否可以禁用
Expand Down
2 changes: 1 addition & 1 deletion deepin-devicemanager/src/DeviceManager/DeviceOthers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ void DeviceOthers::setInfoFromLshw(const QMap<QString, QString> &mapInfo)
if(m_Driver.isEmpty() && !m_Avail.compare("yes", Qt::CaseInsensitive)){
qCDebug(appLog) << "DeviceOthers::setInfoFromLshw, driver is empty and avail is yes";
setForcedDisplay(true);
setCanEnale(false);
setCanEnable(false);
if(!(tmp_Name.contains("fingerprint", Qt::CaseInsensitive) || tmp_Name. contains("MOH", Qt::CaseInsensitive)))
setCanUninstall(false);
}
Expand Down
21 changes: 19 additions & 2 deletions deepin-devicemanager/src/DeviceManager/DevicePower.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,19 @@
// 项目自身文件
#include "DevicePower.h"
#include "commonfunction.h"
#include "DDLog.h"

Check warning on line 8 in deepin-devicemanager/src/DeviceManager/DevicePower.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: "DDLog.h" not found.

Check warning on line 8 in deepin-devicemanager/src/DeviceManager/DevicePower.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: "DDLog.h" not found.

// Qt库文件
#include<QFileInfo>
#include <QFileInfo>

Check warning on line 11 in deepin-devicemanager/src/DeviceManager/DevicePower.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

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

Check warning on line 11 in deepin-devicemanager/src/DeviceManager/DevicePower.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

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

Check warning on line 12 in deepin-devicemanager/src/DeviceManager/DevicePower.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

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

Check warning on line 12 in deepin-devicemanager/src/DeviceManager/DevicePower.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

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

// Dtk头文件
#include <DApplication>

Check warning on line 15 in deepin-devicemanager/src/DeviceManager/DevicePower.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

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

Check warning on line 15 in deepin-devicemanager/src/DeviceManager/DevicePower.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

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

constexpr const char* kPowerService = "com.deepin.system.Power";
constexpr const char* kPowerPath = "/com/deepin/system/Power";
constexpr const char* kPowerInterface = "com.deepin.system.Power";

DWIDGET_USE_NAMESPACE
using namespace DDLog;

Expand Down Expand Up @@ -107,7 +112,19 @@
m_Temp = QString("%1 degrees C").arg(temp);
}*/

getOtherMapInfo(mapInfo);
// 当前电池容量修改成通过DDE接口获得,目的是与状态栏的当前电池容量保持一致(bug#333825)
QMap<QString, QString> tmpMapInfo = mapInfo;
if (tmpMapInfo.contains("percentage")) {
QDBusInterface interface(kPowerService, kPowerPath, kPowerInterface, QDBusConnection::systemBus());
if (interface.isValid()) {
double tmpValue = interface.property("BatteryPercentage").toDouble();
tmpMapInfo["percentage"] = QString("%1%").arg(static_cast<int>(tmpValue));
} else {
qCritical() << QString("Dbus %1 is not valid!").arg(kPowerService);
}
}

getOtherMapInfo(tmpMapInfo);
return true;
}

Expand Down
8 changes: 3 additions & 5 deletions deepin-devicemanager/src/DeviceManager/DeviceStorage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -252,11 +252,9 @@ bool DeviceStorage::setHwinfoInfo(const QMap<QString, QString> &mapInfo)
QFile file(Path);
if (file.open(QIODevice::ReadOnly)) {
qCDebug(appLog) << "DeviceStorage::setHwinfoInfo, open spec_version success";
QString output2 = file.readAll();
if (output2.contains("310", Qt::CaseInsensitive)) {
m_Interface = "UFS 3.1";
} else if (output2.contains("300", Qt::CaseInsensitive)) {
m_Interface = "UFS 3.0";
QString output = file.readAll();
if (!output.isEmpty()) {
m_Interface = "UFS";
}
file.close();
}
Expand Down
13 changes: 1 addition & 12 deletions deepin-devicemanager/src/GenerateDevice/CustomGenerator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,18 +26,7 @@ void CustomGenerator::generatorGpuDevice()
return;
}

QStringList arguments;
QProcessEnvironment env = QProcessEnvironment::systemEnvironment();
QString display = env.value("DISPLAY");
QString xauthority = env.value("XAUTHORITY");
if (display.isEmpty() || xauthority.isEmpty()) {
qWarning() << "DISPLAY or XAUTHORITY is not set!";
} else {
arguments << display << xauthority;
}

QString tmpGpuInfo;
DBusInterface::getInstance()->getGpuInfoByCustom(cmd, arguments, tmpGpuInfo);
QString tmpGpuInfo = CommonTools::preGenerateGpuInfo();
if (tmpGpuInfo.isEmpty()) {
qCritical() << "Failed to get gpu info by commad " << cmd;
return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1097,7 +1097,7 @@ void DeviceGenerator::getKeyboardInfoFromHwinfo()
DeviceInput *device = new DeviceInput();
device->setInfoFromHwinfo(*it);
device->setHardwareClass("keyboard");
device->setCanEnale(false);
device->setCanEnable(false);
DeviceManager::instance()->addKeyboardDevice(device);
addBusIDFromHwinfo((*it)["SysFS BusID"]);
}
Expand Down
14 changes: 7 additions & 7 deletions deepin-devicemanager/src/GenerateDevice/HWGenerator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -311,7 +311,7 @@ void HWGenerator::generatorDiskDevice()
tempMap["Name"] = "nouse";

if (Common::specialComType == 2) {
tempMap["Interface"] = "UFS 3.1";
tempMap["Interface"] = "UFS";
}

// 读取interface版本
Expand All @@ -327,10 +327,10 @@ void HWGenerator::generatorDiskDevice()
exitCode = process.exitCode();
if (exitCode != 127 && exitCode != 126) {
deviceInfo = process.readAllStandardOutput();
if (deviceInfo.trimmed() == "310") {
tempMap["interface"] = "UFS 3.1";
} else if (deviceInfo.trimmed() == "300")
tempMap["interface"] = "UFS 3.0";

if (!deviceInfo.trimmed().isEmpty()) {
tempMap["interface"] = "UFS";
}
}
}
}
Expand Down Expand Up @@ -366,7 +366,7 @@ void HWGenerator::getAudioInfoFromCatAudio()
}

DeviceAudio *device = new DeviceAudio();
device->setCanEnale(false);
device->setCanEnable(false);
device->setCanUninstall(false);
device->setForcedDisplay(true);
device->setInfoFromCatAudio(tempMap);
Expand All @@ -387,7 +387,7 @@ void HWGenerator::getBluetoothInfoFromHciconfig()
continue;
}
DeviceBluetooth *device = new DeviceBluetooth();
device->setCanEnale(false);
device->setCanEnable(false);
device->setForcedDisplay(true);
device->setInfoFromHciconfig(*it);
DeviceManager::instance()->addBluetoothDevice(device);
Expand Down
5 changes: 3 additions & 2 deletions deepin-devicemanager/src/Tool/EDIDParser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,8 @@ bool EDIDParser::setEdid(const QString &edid, QString &errorMsg, const QString &

// 解析厂商信息
qCDebug(appLog) << "Parsing vendor info";
parserVendor();
parseVendor();

// 解析发布日期
qCDebug(appLog) << "Parsing release date";
parseReleaseDate();
Expand Down Expand Up @@ -136,7 +137,7 @@ int EDIDParser::height()
return m_Height;
}

void EDIDParser::parserVendor()
void EDIDParser::parseVendor()
{
qCDebug(appLog) << "Parsing vendor info from EDID";

Expand Down
8 changes: 4 additions & 4 deletions deepin-devicemanager/src/Tool/EDIDParser.h
Original file line number Diff line number Diff line change
Expand Up @@ -66,16 +66,16 @@ class EDIDParser

/**
* @brief height : get screen height
* @return
* @return screen height
*/
int height();

private:

/**
* @brief parserVendor:从edid中获取厂商信息
* @brief parseVendor:从edid中获取厂商信息
*/
void parserVendor();
void parseVendor();

/**
* @brief parseReleaseDate:从edid中获取发布日期
Expand Down Expand Up @@ -154,7 +154,7 @@ class EDIDParser
QString m_MonitorName; // 监视器名称
bool m_LittleEndianMode; // 小端模式
int m_Width; // width
int m_Height; // heigth
int m_Height; // height
QStringList m_ListEdid; // edid数据
QMap<QString, QString> m_MapCh; // 二进制字符串映射到字母A-Z

Expand Down
79 changes: 79 additions & 0 deletions deepin-devicemanager/src/Tool/commontools.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,14 @@ using namespace DDLog;
#define ICON_SIZE_WIDTH 36
#define ICON_SIZE_HEIGHT 36

// 名称("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" };

QMap<DriverType, QString> CommonTools::m_MapDriverIcon = {
{DR_Bluetooth, QString(":/icons/deepin/builtin/icons/bluetooth.svg")}
, {DR_Camera, QString(":/icons/deepin/builtin/icons/image.svg")}
Expand Down Expand Up @@ -274,3 +282,74 @@ QString CommonTools::getGpuInfoCommandFromDConfig()
cmd = dconfig->value("CommandToGetGPUInfo").toString();
return cmd;
}

QString CommonTools::preGenerateGpuInfo()
{
static QString gpuInfo { "" };

if (gpuInfo.isEmpty()) {
QStringList arguments;
QProcessEnvironment env = QProcessEnvironment::systemEnvironment();
QString display = env.value("DISPLAY");
QString xauthority = env.value("XAUTHORITY");
if (display.isEmpty() || xauthority.isEmpty()) {
qCritical() << "DISPLAY or XAUTHORITY is not set!";
} else {
arguments << display << xauthority;
}

QDBusInterface iface("org.deepin.DeviceInfo",
"/org/deepin/DeviceInfo",
"org.deepin.DeviceInfo",
QDBusConnection::systemBus());
if (iface.isValid()) {
QDBusReply<QString> replyList = iface.call("getGpuInfoByCustom", arguments, gpuInfo);
if (replyList.isValid()) {
gpuInfo = replyList.value();
} else {
qCritical() << "Error: failed to call dbus to get gpu memery info! ";
}
}

QMap<QString, QString> mapInfo;
if (getGpuBaseInfo(mapInfo)) {
for (auto it = mapInfo.begin(); it != mapInfo.end(); ++it) {
QString tmpInfo = it.key() + ": " + it.value() + "\n";
gpuInfo.append(tmpInfo);
}
}
}

return gpuInfo;
}

bool CommonTools::getGpuBaseInfo(QMap<QString, QString> &mapInfo)
{
QProcess process;
QProcessEnvironment env = QProcessEnvironment::systemEnvironment();
process.setProcessEnvironment(env);
process.start("/usr/bin/glxinfo", QStringList() << "-B");
if (!process.waitForFinished()) {
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;
}
4 changes: 4 additions & 0 deletions deepin-devicemanager/src/Tool/commontools.h
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,10 @@ class CommonTools : public QObject

static void parseEDID(const QStringList &allEDIDS, const QString &input, bool isHW = true);
static QString getGpuInfoCommandFromDConfig();
static QString preGenerateGpuInfo();

private:
static bool getGpuBaseInfo(QMap<QString, QString> &mapInfo);

signals:

Expand Down
8 changes: 8 additions & 0 deletions deepin-devicemanager/src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,12 @@
#include "environments.h"
#include "DebugTimeManager.h"
#include "SingleDeviceManager.h"
#include "DDLog.h"

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

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: "DDLog.h" not found.

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

View workflow job for this annotation

GitHub Actions / cppcheck

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

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

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: "commontools.h" not found.

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

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: "commontools.h" not found.

#include <DApplication>

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

View workflow job for this annotation

GitHub Actions / cppcheck

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

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

View workflow job for this annotation

GitHub Actions / cppcheck

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

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

View workflow job for this annotation

GitHub Actions / cppcheck

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

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

View workflow job for this annotation

GitHub Actions / cppcheck

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

Check warning on line 20 in deepin-devicemanager/src/main.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

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

Check warning on line 20 in deepin-devicemanager/src/main.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

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

#include <QDBusConnection>
Expand Down Expand Up @@ -133,6 +135,12 @@
qCDebug(appLog) << "DBus service registered successfully";
dbus.registerObject("/com/deepin/DeviceManagerNotify", &app, QDBusConnection::ExportScriptableSlots);
app.parseCmdLine();

QString cmd = CommonTools::getGpuInfoCommandFromDConfig();
if (!cmd.isEmpty()) {
CommonTools::preGenerateGpuInfo();
}

app.activateWindow();
return app.exec();
} else {
Expand Down