diff --git a/deepin-devicemanager-server/deepin-deviceinfo/src/loadinfo/deviceinterface.cpp b/deepin-devicemanager-server/deepin-deviceinfo/src/loadinfo/deviceinterface.cpp index 8411d60f..bd2dc750 100644 --- a/deepin-devicemanager-server/deepin-deviceinfo/src/loadinfo/deviceinterface.cpp +++ b/deepin-devicemanager-server/deepin-deviceinfo/src/loadinfo/deviceinterface.cpp @@ -1,7 +1,6 @@ // SPDX-FileCopyrightText: 2019 ~ 2023 UnionTech Software Technology Co., Ltd. // // SPDX-License-Identifier: GPL-3.0-or-later - #include "deviceinterface.h" #include "deviceinfomanager.h" #include "mainjob.h" @@ -11,6 +10,9 @@ #include #include #include +#include +#include + #if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) #include #else @@ -18,6 +20,8 @@ #endif using namespace DDLog; +constexpr char kGraphicsMemory[] { "Graphics Memory" }; + using namespace PolkitQt1; bool DeviceInterface::getUserAuthorPasswd() { @@ -30,6 +34,52 @@ bool DeviceInterface::getUserAuthorPasswd() return result == Authority::Yes; } +bool DeviceInterface::getGpuMemInfoForFTDTM(QMap &mapInfo) +{ + const QString filePath = "/sys/kernel/debug/gc/total_mem"; + QString totalValue; + + QFile file(filePath); + if (!file.open(QIODevice::ReadOnly | QIODevice::Text)) { + qCritical() << "Error opening /sys/kernel/debug/gc/total_mem:" << file.errorString(); + return false; + } + + QString content = QString::fromUtf8(file.readAll()); + file.close(); + + if (content.isEmpty()) { + qCritical() << "Error: /sys/kernel/debug/gc/total_mem File is empty!"; + return false; + } + + QRegularExpression regex(R"((\d+(?:\.\d+)?)\s*\(?(MB|GB|KB|B)\)?)", + QRegularExpression::CaseInsensitiveOption); + QRegularExpressionMatch memInfoMatch = regex.match(content); + + if (!memInfoMatch.hasMatch()) { + qCritical() << "Error: Failed to find memory info"; + return false; + } + + double value = memInfoMatch.captured(1).toDouble(); + QString unit = memInfoMatch.captured(2).toUpper(); + + if (unit == "MB") { + totalValue = QString("%1GB").arg(value / 1024.0, 0, 'f', 2); + } else if (unit == "GB") { + totalValue = QString("%1GB").arg(value, 0, 'f', 2); + } else if (unit == "KB") { + totalValue = QString("%1GB").arg(value / (1024.0 * 1024.0), 0, 'f', 2); + } else if (unit == "B") { + totalValue = QString("%1GB").arg(value / (1024.0 * 1024.0 * 1024.0), 0, 'f', 2); + } + + mapInfo.insert(kGraphicsMemory, totalValue); + + return true; +} + DeviceInterface::DeviceInterface(const char *name, QObject *parent) : QObject(parent) { @@ -91,24 +141,17 @@ void DeviceInterface::setMonitorDeviceFlag(bool flag) } } -QString DeviceInterface::getGpuInfoByCustom(const QString &cmd, const QStringList &arguments) +QString DeviceInterface::getGpuInfoForFTDTM() { - 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; + static QString gpuMemInfo { "" }; + if (gpuMemInfo.isEmpty()) { + QMap mapInfo; + if (getGpuMemInfoForFTDTM(mapInfo)) { + for (auto it = mapInfo.begin(); it != mapInfo.end(); ++it) { + QString tmpInfo = it.key() + ": " + it.value() + "\n"; + gpuMemInfo.append(tmpInfo); + } + } } - - if (process.exitCode() == 0) - gpuinfo = QString::fromLocal8Bit(process.readAllStandardOutput()); - - return gpuinfo; + return gpuMemInfo; } diff --git a/deepin-devicemanager-server/deepin-deviceinfo/src/loadinfo/deviceinterface.h b/deepin-devicemanager-server/deepin-deviceinfo/src/loadinfo/deviceinterface.h index 01c65610..e3407535 100644 --- a/deepin-devicemanager-server/deepin-deviceinfo/src/loadinfo/deviceinterface.h +++ b/deepin-devicemanager-server/deepin-deviceinfo/src/loadinfo/deviceinterface.h @@ -39,10 +39,11 @@ public slots: */ Q_SCRIPTABLE void setMonitorDeviceFlag(bool flag); - Q_SCRIPTABLE QString getGpuInfoByCustom(const QString &cmd, const QStringList &arguments); + Q_SCRIPTABLE QString getGpuInfoForFTDTM(); private: bool getUserAuthorPasswd(); + bool getGpuMemInfoForFTDTM(QMap &mapInfo); }; #endif // DEVICEINTERFACE_H diff --git a/deepin-devicemanager/src/DeviceManager/DeviceCpu.cpp b/deepin-devicemanager/src/DeviceManager/DeviceCpu.cpp index 005b5067..d3c80598 100644 --- a/deepin-devicemanager/src/DeviceManager/DeviceCpu.cpp +++ b/deepin-devicemanager/src/DeviceManager/DeviceCpu.cpp @@ -307,7 +307,7 @@ void DeviceCpu::setInfoFromDmidecode(const QMap &mapInfo) setAttribute(mapInfo, "product", m_Name); } - if (Common::specialComType > 0) { + if (Common::isHwPlatform()) { if (mapInfo.contains("Version")) { setAttribute(mapInfo, "Version", m_Name); } diff --git a/deepin-devicemanager/src/DeviceManager/DeviceInput.cpp b/deepin-devicemanager/src/DeviceManager/DeviceInput.cpp index b362bd16..f34113de 100644 --- a/deepin-devicemanager/src/DeviceManager/DeviceInput.cpp +++ b/deepin-devicemanager/src/DeviceManager/DeviceInput.cpp @@ -555,12 +555,12 @@ EnableDeviceStatus DeviceInput::setEnable(bool e) } if(e){ //鼠标启用时,唤醒能力打开 - DBusWakeupInterface::getInstance()->setWakeupMachine(wakeupID(), sysPath(), true, name()); + DBusWakeupInterface::getInstance()->setWakeupMachine(wakeupID(), sysPath(), true, name(), m_HardwareClass); m_wakeupChanged = true; } else if (m_wakeupChanged) { //鼠标禁用时,唤醒能力关闭 m_wakeupChanged = false; - DBusWakeupInterface::getInstance()->setWakeupMachine(wakeupID(), sysPath(), false, name()); + DBusWakeupInterface::getInstance()->setWakeupMachine(wakeupID(), sysPath(), false, name(), m_HardwareClass); } bool res = DBusEnableInterface::getInstance()->enable(m_HardwareClass, m_Name, m_SysPath, m_UniqueID, e, m_Driver); if (res) { @@ -587,10 +587,9 @@ bool DeviceInput::enable() bool DeviceInput::canWakeupMachine() { qCDebug(appLog) << "canWakeupMachine"; - if (m_WakeupID.isEmpty() || (m_HardwareClass == "keyboard" && "PS/2" == m_Interface)) { - qCDebug(appLog) << "canWakeupMachine return false"; + if (m_WakeupID.isEmpty()) return false; - } + QFile file(wakeupPath()); if (!file.open(QIODevice::ReadOnly)) { qCDebug(appLog) << "canWakeupMachine open file failed"; @@ -618,7 +617,7 @@ bool DeviceInput::isWakeupMachine() // } qCDebug(appLog) << "return ps2 wakeup"; // /proc/acpi/wakeup文件中状态未刷新,ps2设备通过dbus获取状态 - return DBusWakeupInterface::getInstance()->isInputWakeupMachine(m_SysPath, m_Name); + return DBusWakeupInterface::getInstance()->isInputWakeupMachine(m_SysPath, m_Name, m_HardwareClass, m_Interface); } else { if (info.contains("disabled")) { diff --git a/deepin-devicemanager/src/DeviceManager/DeviceMonitor.cpp b/deepin-devicemanager/src/DeviceManager/DeviceMonitor.cpp index 37f2db94..edce1d36 100644 --- a/deepin-devicemanager/src/DeviceManager/DeviceMonitor.cpp +++ b/deepin-devicemanager/src/DeviceManager/DeviceMonitor.cpp @@ -137,7 +137,7 @@ void DeviceMonitor::setInfoFromHwinfo(const QMap &mapInfo) setAttribute(mapInfo, "", m_DisplayInput); setAttribute(mapInfo, "Size", m_ScreenSize); setAttribute(mapInfo, "", m_MainScreen); - if (Common::specialComType > 0){ + if (Common::isHwPlatform()){ setAttribute(mapInfo, "Resolution", m_SupportResolution); } qCDebug(appLog) << "Basic monitor attributes set - Name:" << m_Name << "Vendor:" << m_Vendor << "Model:" << m_Model; @@ -149,7 +149,7 @@ void DeviceMonitor::setInfoFromHwinfo(const QMap &mapInfo) qCDebug(appLog) << "Screen size parsed:" << m_ScreenSize << "Width:" << size.width() << "Height:" << size.height(); // 获取当前分辨率 和 当前支持分辨率 - if (Common::specialComType > 0){ + if (Common::isHwPlatform()){ QStringList listResolution = m_SupportResolution.split(" "); m_SupportResolution = ""; foreach (const QString &word, listResolution) { @@ -163,7 +163,7 @@ void DeviceMonitor::setInfoFromHwinfo(const QMap &mapInfo) // 计算显示比例 caculateScreenRatio(); - if (Common::specialComType > 0){ + if (Common::isHwPlatform()){ #if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) m_SupportResolution.replace(QRegExp(", $"), ""); #else @@ -386,7 +386,7 @@ bool DeviceMonitor::available() QString DeviceMonitor::subTitle() { // qCDebug(appLog) << "Getting monitor subtitle"; - if (Common::specialComType >= 1) { + if (Common::isHwPlatform()) { m_Name.clear(); } return m_Name; diff --git a/deepin-devicemanager/src/DeviceManager/DeviceNetwork.cpp b/deepin-devicemanager/src/DeviceManager/DeviceNetwork.cpp index 9c39f6db..d015fe46 100644 --- a/deepin-devicemanager/src/DeviceManager/DeviceNetwork.cpp +++ b/deepin-devicemanager/src/DeviceManager/DeviceNetwork.cpp @@ -283,6 +283,14 @@ QString DeviceNetwork::hwAddress() return m_MACAddress; } +bool DeviceNetwork::canDisable() +{ + if (m_SysPath.isEmpty()) { + return false; + } + return true; +} + void DeviceNetwork::initFilterKey() { qCDebug(appLog) << "DeviceNetwork::initFilterKey"; diff --git a/deepin-devicemanager/src/DeviceManager/DeviceNetwork.h b/deepin-devicemanager/src/DeviceManager/DeviceNetwork.h index 1bbda454..f00b6450 100644 --- a/deepin-devicemanager/src/DeviceManager/DeviceNetwork.h +++ b/deepin-devicemanager/src/DeviceManager/DeviceNetwork.h @@ -112,6 +112,8 @@ class DeviceNetwork : public DeviceBaseInfo */ QString hwAddress(); + bool canDisable(); + protected: /** diff --git a/deepin-devicemanager/src/GenerateDevice/CustomGenerator.cpp b/deepin-devicemanager/src/GenerateDevice/CustomGenerator.cpp index d3ab7ade..a4b72130 100644 --- a/deepin-devicemanager/src/GenerateDevice/CustomGenerator.cpp +++ b/deepin-devicemanager/src/GenerateDevice/CustomGenerator.cpp @@ -20,15 +20,9 @@ CustomGenerator::CustomGenerator(QObject *parent) void CustomGenerator::generatorGpuDevice() { - QString cmd = CommonTools::getGpuInfoCommandFromDConfig(); - if (cmd.isEmpty()) { - DeviceGenerator::generatorGpuDevice(); - return; - } - QString tmpGpuInfo = CommonTools::preGenerateGpuInfo(); if (tmpGpuInfo.isEmpty()) { - qCritical() << "Failed to get gpu info by commad " << cmd; + qCritical() << "Error: Failed to get gpu info!"; return; } diff --git a/deepin-devicemanager/src/GenerateDevice/DBusInterface.cpp b/deepin-devicemanager/src/GenerateDevice/DBusInterface.cpp index d18b850e..d0edd5f4 100644 --- a/deepin-devicemanager/src/GenerateDevice/DBusInterface.cpp +++ b/deepin-devicemanager/src/GenerateDevice/DBusInterface.cpp @@ -58,18 +58,6 @@ void DBusInterface::refreshInfo() mp_Iface->asyncCall("refreshInfo"); } -bool DBusInterface::getGpuInfoByCustom(const QString &cmd, const QStringList &arguments, QString &gpuInfo) -{ - QDBusReply replyList = mp_Iface->call("getGpuInfoByCustom", cmd, arguments); - if (replyList.isValid()) { - gpuInfo = replyList.value(); - return true; - } else { - qCritical() << "Error: failed to call dbus to get gpu memery info! "; - return false; - } -} - void DBusInterface::init() { qCDebug(appLog) << "DBusInterface::init start"; diff --git a/deepin-devicemanager/src/GenerateDevice/DBusInterface.h b/deepin-devicemanager/src/GenerateDevice/DBusInterface.h index c6a01898..a154a337 100644 --- a/deepin-devicemanager/src/GenerateDevice/DBusInterface.h +++ b/deepin-devicemanager/src/GenerateDevice/DBusInterface.h @@ -47,8 +47,6 @@ class DBusInterface */ void refreshInfo(); - bool getGpuInfoByCustom(const QString &cmd, const QStringList &arguments, QString &gpuInfo); - protected: DBusInterface(); diff --git a/deepin-devicemanager/src/Page/MainWindow.cpp b/deepin-devicemanager/src/Page/MainWindow.cpp index 63e4b3e5..175b4ff3 100644 --- a/deepin-devicemanager/src/Page/MainWindow.cpp +++ b/deepin-devicemanager/src/Page/MainWindow.cpp @@ -477,19 +477,6 @@ void MainWindow::initWindowTitle() } }); titlebar()->addWidget(mp_ButtonBox); -#ifdef DTKCORE_CLASS_DConfigFile - //需要查询是否支持特殊机型静音恢复,例如hw机型 - DConfig *dconfig = DConfig::create("org.deepin.devicemanager","org.deepin.devicemanager"); - //需要判断Dconfig文件是否合法 - if(dconfig && dconfig->isValid() && dconfig->keyList().contains("specialComType")){ - Common::specialComType = dconfig->value("specialComType").toInt(); - } - qCInfo(appLog) << "Common::specialComType value is:" << Common::specialComType; - if (dconfig && dconfig->isValid() && dconfig->keyList().contains("TomlFilesName")) { - QString tomlFilesName = dconfig->value("TomlFilesName").toString(); - Common::tomlFilesNameSet(tomlFilesName); - } -#endif // 特殊处理 if (!Common::boardVendorType().isEmpty()) mp_ButtonBox->hide(); diff --git a/deepin-devicemanager/src/Page/PageMultiInfo.cpp b/deepin-devicemanager/src/Page/PageMultiInfo.cpp index e1647ec6..cb07b77e 100644 --- a/deepin-devicemanager/src/Page/PageMultiInfo.cpp +++ b/deepin-devicemanager/src/Page/PageMultiInfo.cpp @@ -99,7 +99,7 @@ void PageMultiInfo::updateInfo(const QList &lst) mp_Table->setVisible(true); mp_Table->setFixedHeight(TABLE_HEIGHT); mp_Table->updateTable(m_deviceList, m_menuControlList); - if (Common::specialComType >= 1) { + if (Common::isHwPlatform()) { if (mp_Label->text() == tr("Storage") || mp_Label->text() == tr("Memory") || mp_Label->text() == tr("Monitor")) { mp_Table->setVisible(false); mp_Table->setFixedHeight(0); @@ -148,20 +148,20 @@ void PageMultiInfo::resizeEvent(QResizeEvent *e) if (curHeight < LEAST_PAGE_HEIGHT) { qCDebug(appLog) << "Height too small, resize table"; // 获取多个设备界面表格信息 - if (Common::specialComType <= 0) { - mp_Table->updateTable(m_deviceList, m_menuControlList, true, (LEAST_PAGE_HEIGHT - curHeight) / TREE_ROW_HEIGHT + 1); - } else { + if (Common::isHwPlatform()) { if (mp_Label->text() != tr("Storage") && mp_Label->text() != tr("Memory") && mp_Label->text() != tr("Monitor")) mp_Table->updateTable(m_deviceList, m_menuControlList, true, (LEAST_PAGE_HEIGHT - curHeight) / TREE_ROW_HEIGHT + 1); + } else { + mp_Table->updateTable(m_deviceList, m_menuControlList, true, (LEAST_PAGE_HEIGHT - curHeight) / TREE_ROW_HEIGHT + 1); } } else { qCDebug(appLog) << "Height is enough, resize table"; // 获取多个设备界面表格信息 - if (Common::specialComType <= 0) { - mp_Table->updateTable(m_deviceList, m_menuControlList, true, 0); - } else { + if (Common::isHwPlatform()) { if (mp_Label->text() != tr("Storage") && mp_Label->text() != tr("Memory") && mp_Label->text() != tr("Monitor")) mp_Table->updateTable(m_deviceList, m_menuControlList, true, 0); + } else { + mp_Table->updateTable(m_deviceList, m_menuControlList, true, 0); } } @@ -322,12 +322,15 @@ void PageMultiInfo::getTableListInfo(const QList &lst, QListname().contains("PS/2")) { menuControl.append(input->getBusInfo()); menuControl.append(input->name()); + menuControl.append(input->hardwareClass()); + menuControl.append(input->getInterface()); } } DeviceNetwork *network = dynamic_cast(info); if (network) { menuControl.append(network->logicalName()); + menuControl.append(network->canDisable() ? "true" : "false"); } menuControlList.append(menuControl); diff --git a/deepin-devicemanager/src/Page/PageSingleInfo.cpp b/deepin-devicemanager/src/Page/PageSingleInfo.cpp index 27430db0..65ec4a33 100644 --- a/deepin-devicemanager/src/Page/PageSingleInfo.cpp +++ b/deepin-devicemanager/src/Page/PageSingleInfo.cpp @@ -306,6 +306,10 @@ void PageSingleInfo::slotShowMenu(const QPoint &) qCDebug(appLog) << "Device is disabled, disabling wakeup action."; } mp_Menu->addAction(mp_WakeupMachine); + + // 根据网卡情况判断是否支持禁用 + if (!network->canDisable()) + mp_Menu->removeAction(mp_Enable); } mp_Menu->exec(QCursor::pos()); @@ -412,7 +416,8 @@ void PageSingleInfo::slotWakeupMachine() DBusWakeupInterface::getInstance()->setWakeupMachine(input->wakeupID(), input->sysPath(), mp_WakeupMachine->isChecked(), - input->getInterface()); + input->getInterface(), + input->hardwareClass()); } // 网卡的远程唤醒 diff --git a/deepin-devicemanager/src/Tool/EDIDParser.cpp b/deepin-devicemanager/src/Tool/EDIDParser.cpp index f209bffb..e8e57bfe 100644 --- a/deepin-devicemanager/src/Tool/EDIDParser.cpp +++ b/deepin-devicemanager/src/Tool/EDIDParser.cpp @@ -5,6 +5,7 @@ // 项目自身文件 #include "EDIDParser.h" #include "DDLog.h" +#include "commonfunction.h" // Qt库文件 #include @@ -241,8 +242,14 @@ void EDIDParser::parseScreenSize() } } + if (Common::specialComType == Common::kSpecialType7){ // sepcial task:378963 + m_Width = 296; + m_Height = 197; + } double inch = sqrt((m_Width / 2.54) * (m_Width / 2.54) + (m_Height / 2.54) * (m_Height / 2.54))/10; - m_ScreenSize = QString("%1 %2(%3mm×%4mm)").arg(QString::number(inch, '0', 1)).arg(QObject::tr("inch")).arg(m_Width).arg(m_Height); + m_ScreenSize = QString("%1 %2(%3mm×%4mm)") + .arg(QString::number(inch, '0', Common::specialComType == Common::kSpecialType7 ? 0 : 1)) + .arg(QObject::tr("inch")).arg(m_Width).arg(m_Height); qCDebug(appLog) << "Screen size parsed:" << m_ScreenSize << "Width:" << m_Width << "Height:" << m_Height; } diff --git a/deepin-devicemanager/src/Tool/commontools.cpp b/deepin-devicemanager/src/Tool/commontools.cpp index 90ca0476..622c5821 100644 --- a/deepin-devicemanager/src/Tool/commontools.cpp +++ b/deepin-devicemanager/src/Tool/commontools.cpp @@ -285,42 +285,40 @@ QString CommonTools::getGpuInfoCommandFromDConfig() 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; + static QString gpuBaseInfo { "" }; + static QString gpuMemInfo { "" }; + + if (gpuBaseInfo.isEmpty()) { + QMap mapInfo; + if (getGpuBaseInfo(mapInfo)) { + for (auto it = mapInfo.begin(); it != mapInfo.end(); ++it) { + QString tmpInfo = it.key() + ": " + it.value() + "\n"; + gpuBaseInfo.append(tmpInfo); + } } + } + if (gpuBaseInfo.isEmpty()) { + qCritical() << "Error: failed to get gpu base info!"; + return ""; + } + + if (gpuMemInfo.isEmpty()) { QDBusInterface iface("org.deepin.DeviceInfo", "/org/deepin/DeviceInfo", "org.deepin.DeviceInfo", QDBusConnection::systemBus()); if (iface.isValid()) { - QDBusReply replyList = iface.call("getGpuInfoByCustom", arguments, gpuInfo); + QDBusReply replyList = iface.call("getGpuInfoForFTDTM"); if (replyList.isValid()) { - gpuInfo = replyList.value(); + gpuMemInfo = replyList.value(); } else { qCritical() << "Error: failed to call dbus to get gpu memery info! "; } } - - QMap 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; + return (gpuBaseInfo + gpuMemInfo); } bool CommonTools::getGpuBaseInfo(QMap &mapInfo) diff --git a/deepin-devicemanager/src/WakeupControl/DBusWakeupInterface.cpp b/deepin-devicemanager/src/WakeupControl/DBusWakeupInterface.cpp index 3074c763..d3f0429d 100644 --- a/deepin-devicemanager/src/WakeupControl/DBusWakeupInterface.cpp +++ b/deepin-devicemanager/src/WakeupControl/DBusWakeupInterface.cpp @@ -45,7 +45,11 @@ DBusWakeupInterface::DBusWakeupInterface() init(); } -bool DBusWakeupInterface::setWakeupMachine(const QString &unique_id, const QString &path, bool wakeup, const QString &name) +bool DBusWakeupInterface::setWakeupMachine(const QString &unique_id, + const QString &path, + bool wakeup, + const QString &name, + const QString &hardwareclass) { qCDebug(appLog) << "Setting wakeup for device. ID:" << unique_id << "Path:" << path << "Wakeup:" << wakeup << "Name:" << name; @@ -70,9 +74,9 @@ bool DBusWakeupInterface::setWakeupMachine(const QString &unique_id, const QStri QMap allSupportWakeupDevices; arg >> allSupportWakeupDevices; QStringList wakeupPathList = allSupportWakeupDevices.keys(); - + QString key = (hardwareclass == "mouse") ? "PS2M" : "PS2K"; for (QString path : wakeupPathList) { - if (path.contains("PS2")) { + if (path.contains(key)) { mp_InputIface->call("SetWakeupDevices", path, wakeup ? "enabled" : "disabled"); return true; } @@ -142,7 +146,10 @@ bool DBusWakeupInterface::canInputWakeupMachine(const QString &path) return canOpen; } -bool DBusWakeupInterface::isInputWakeupMachine(const QString &path, const QString &name) +bool DBusWakeupInterface::isInputWakeupMachine(const QString &path, + const QString &name, + const QString &hardwareClass, + const QString &interfaceType) { qCDebug(appLog) << "Checking input wakeup state. Path:" << path << "Name:" << name; @@ -158,9 +165,10 @@ bool DBusWakeupInterface::isInputWakeupMachine(const QString &path, const QStrin QMap allSupportWakeupDevices; arg >> allSupportWakeupDevices; - if (name.contains("PS/2")) { + if (interfaceType.contains("PS/2")) { + QString key = (hardwareClass == "mouse") ? "PS2M" : "PS2K"; for(QString path : allSupportWakeupDevices.keys()) { - if (path.contains("PS2")) { + if (path.contains(key)) { return allSupportWakeupDevices[path] == "enabled"; } } diff --git a/deepin-devicemanager/src/WakeupControl/DBusWakeupInterface.h b/deepin-devicemanager/src/WakeupControl/DBusWakeupInterface.h index d9e8e995..d475c8f5 100644 --- a/deepin-devicemanager/src/WakeupControl/DBusWakeupInterface.h +++ b/deepin-devicemanager/src/WakeupControl/DBusWakeupInterface.h @@ -40,7 +40,11 @@ class DBusWakeupInterface * @param wakeup 可唤醒 不可唤醒 * @return */ - bool setWakeupMachine(const QString &unique_id, const QString &path, bool wakeup, const QString &name); + bool setWakeupMachine(const QString &unique_id, + const QString &path, + bool wakeup, + const QString &name, + const QString &hardwareclass); /** * @brief canWakeupMachine 获取input是否支持唤醒 @@ -54,7 +58,10 @@ class DBusWakeupInterface * @param path 设备节点路径 * @return */ - bool isInputWakeupMachine(const QString &path, const QString &name); + bool isInputWakeupMachine(const QString &path, + const QString &name, + const QString &hardwareClass, + const QString &interfaceType); /** * @brief isNetworkWakeup 获取网卡是否支持远程唤醒 diff --git a/deepin-devicemanager/src/Widget/TableWidget.cpp b/deepin-devicemanager/src/Widget/TableWidget.cpp index 77085208..b03b8b13 100644 --- a/deepin-devicemanager/src/Widget/TableWidget.cpp +++ b/deepin-devicemanager/src/Widget/TableWidget.cpp @@ -324,7 +324,9 @@ void TableWidget::slotShowMenu(const QPoint &point) QString info = file.readAll(); if (wakeupPath.contains("/proc/acpi/wakeup")) { bool wakedUp = DBusWakeupInterface::getInstance()->isInputWakeupMachine(item->data(Qt::UserRole+4).toString(), - item->data(Qt::UserRole+5).toString()); + item->data(Qt::UserRole+5).toString(), + item->data(Qt::UserRole+6).toString(), + item->data(Qt::UserRole+7).toString()); isWakeup = wakedUp; } else { if(info.contains("disabled")) { @@ -349,6 +351,14 @@ void TableWidget::slotShowMenu(const QPoint &point) } mp_Menu->addAction(mp_WakeupMachine); } + + // 根据网卡情况判断是否支持禁用 + QVariant canDisableForNetwork = item->data(Qt::UserRole + 3); + if (canDisableForNetwork.isValid()) { + if (canDisableForNetwork.toString() == "false") + mp_Menu->removeAction(mp_Enable); + } + mp_Menu->exec(QCursor::pos()); } diff --git a/deepin-devicemanager/src/Widget/TextBrowser.cpp b/deepin-devicemanager/src/Widget/TextBrowser.cpp index 236bd31e..6ba728bc 100644 --- a/deepin-devicemanager/src/Widget/TextBrowser.cpp +++ b/deepin-devicemanager/src/Widget/TextBrowser.cpp @@ -129,7 +129,7 @@ void TextBrowser::setWakeupMachine(bool wakeup) DeviceInput *input = qobject_cast(mp_Info); if(input && !input->wakeupID().isEmpty() && !input->sysPath().isEmpty()){ qCDebug(appLog) << "Setting wakeup for input device"; - DBusWakeupInterface::getInstance()->setWakeupMachine(input->wakeupID(),input->sysPath(),wakeup, input->name()); + DBusWakeupInterface::getInstance()->setWakeupMachine(input->wakeupID(),input->sysPath(),wakeup, input->name(), input->hardwareClass()); } // 网卡的远程唤醒 diff --git a/deepin-devicemanager/src/main.cpp b/deepin-devicemanager/src/main.cpp index 5435be93..e734db89 100644 --- a/deepin-devicemanager/src/main.cpp +++ b/deepin-devicemanager/src/main.cpp @@ -14,6 +14,7 @@ #include "SingleDeviceManager.h" #include "DDLog.h" #include "commontools.h" +#include "commonfunction.h" #include #include @@ -129,18 +130,33 @@ int main(int argc, char *argv[]) app.setWindowIcon(appIcon); } +#ifdef DTKCORE_CLASS_DConfigFile + //需要查询是否支持特殊机型静音恢复,例如hw机型 + DConfig *dconfig = DConfig::create("org.deepin.devicemanager","org.deepin.devicemanager"); + //需要判断Dconfig文件是否合法 + if(dconfig && dconfig->isValid() && dconfig->keyList().contains("specialComType")){ + Common::specialComType = dconfig->value("specialComType").toInt(); + } + qCInfo(appLog) << "Common::specialComType value is:" << Common::specialComType; + + if (dconfig && dconfig->isValid() && dconfig->keyList().contains("TomlFilesName")) { + QString tomlFilesName = dconfig->value("TomlFilesName").toString(); + Common::tomlFilesNameSet(tomlFilesName); + } + + // 特殊机型,提前缓存GPU信息 + if (Common::specialComType == Common::kCustomType) { + CommonTools::preGenerateGpuInfo(); + } + +#endif + QDBusConnection dbus = QDBusConnection::sessionBus(); qCDebug(appLog) << "Registering DBus service..."; if (dbus.registerService("com.deepin.DeviceManagerNotify")) { 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 {