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
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,8 @@ void MonitorUsb::monitor()
}
FD_ZERO(&fds);
FD_SET(fd, &fds);
tv.tv_sec = 0;
tv.tv_usec = 10000;
tv.tv_sec = 1;
tv.tv_usec = 0;
Comment on lines +58 to +59
Copy link

Choose a reason for hiding this comment

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

question (performance): Increasing the select timeout to 1s may introduce noticeable delay for USB hotplug handling.

The timeout has changed from 10ms to 1s, which reduces wakeups and CPU usage but can delay USB event handling by up to 1s. To balance responsiveness and resource usage, consider a smaller value (e.g., 100–200ms) or making the timeout configurable.

int ret = select(fd + 1, &fds, nullptr, nullptr, &tv);

// 判断是否有事件产生
Expand Down
2 changes: 1 addition & 1 deletion deepin-devicemanager/src/DeviceManager/DeviceMonitor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -567,6 +567,6 @@ bool DeviceMonitor::caculateScreenSize(const QString &edid)
return true;

double inch = std::sqrt(height * height + width * width) / 2.54 / 10;
m_ScreenSize = QString("%1 %2(%3mm X %4mm)").arg(QString::number(inch, '0', 1)).arg(("inch")).arg(width).arg(height);
m_ScreenSize = QString("%1 %2(%3mm X %4mm)").arg(QString::number(inch, '0', 1)).arg(translateStr("inch")).arg(width).arg(height);
return true;
}
45 changes: 31 additions & 14 deletions deepin-devicemanager/src/DeviceManager/DeviceStorage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,9 @@ bool DeviceStorage::setHwinfoInfo(const QMap<QString, QString> &mapInfo)
return false;
}

setAttribute(mapInfo, "Model", m_Name);
if (Common::specialComType <= 0) {
setAttribute(mapInfo, "Model", m_Name);
}
setAttribute(mapInfo, "Vendor", m_Vendor);

// 希捷硬盘为ATA硬盘,无法直接获取厂商信息,只能特殊处理
Expand Down Expand Up @@ -520,21 +522,22 @@ void DeviceStorage::appendDisk(DeviceStorage *device)
void DeviceStorage::checkDiskSize()
{
qCDebug(appLog) << "DeviceStorage::checkDiskSize";
if (Common::specialVendorType() != Common::specialHString()) {
if (Common::specialComType <= 0) {
return; //定制机型专用,其它慎用
}
quint64 gbyte = 1000000000;
if (m_Interface.contains("UFS", Qt::CaseInsensitive)) {
if (m_SizeBytes > 255*gbyte && m_SizeBytes < 257*gbyte) {
m_Size = "256 GB";
} else if (m_SizeBytes > 511*gbyte && m_SizeBytes < 513*gbyte) {
m_Size = "512 GB";
} else if (m_SizeBytes > 999*gbyte && m_SizeBytes < 1025*gbyte) {
m_Size = "1 TB";
} else if (m_SizeBytes > 1999*gbyte && m_SizeBytes < 2049*gbyte) {
m_Size = "2 TB";
}
}

// if (m_Interface.contains("UFS", Qt::CaseInsensitive)) { // TODO Ignore ufs disk
if (m_SizeBytes > 255*gbyte && m_SizeBytes < 257*gbyte) {
m_Size = "256 GB";
} else if (m_SizeBytes > 511*gbyte && m_SizeBytes < 513*gbyte) {
m_Size = "512 GB";
} else if (m_SizeBytes > 999*gbyte && m_SizeBytes < 1025*gbyte) {
m_Size = "1 TB";
} else if (m_SizeBytes > 1999*gbyte && m_SizeBytes < 2049*gbyte) {
m_Size = "2 TB";
}
// }
if (m_Interface.contains("USB", Qt::CaseInsensitive)) {
if (m_SizeBytes > 15*gbyte && m_SizeBytes < 17*gbyte) {
m_Size = "16 GB";
Expand Down Expand Up @@ -615,7 +618,21 @@ QString DeviceStorage::subTitle()
const QString DeviceStorage::getOverviewInfo()
{
// qCDebug(appLog) << "DeviceStorage::getOverviewInfo";
return QString("%1 (%2)").arg(m_Name).arg(m_Size);;
QString overViewInfo = QString("%1 (%2)").arg(m_Name).arg(m_Size);

// 见内网gerrit项目 os-config 中机型的 specialComType , 示例配置文件位置如下:
// os-config/hardware/机型/etc/dsg/configs/overrides/org.deepin.devicemanager/org.deepin.devicemanager/4000-org.deepin.devicemanager.override.json
if (Common::specialComType == 5){
if (m_Interface.contains("UFS", Qt::CaseInsensitive)) {
overViewInfo = QString("%1 %2").arg(m_Size).arg("UFS");
} else if (m_Interface.contains("USB", Qt::CaseInsensitive)) {
overViewInfo = QString("%1 %2").arg(m_Size).arg("USB");
} else {
overViewInfo = QString("%1 %2").arg(m_Size).arg(m_MediaType);
}
}

Comment on lines +625 to +634
Copy link

Choose a reason for hiding this comment

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

suggestion: Consider using i18n for media/interface tokens in the overview string or aligning them with existing localization.

In the specialComType == 5 branch, "UFS" and "USB" are hard-coded while m_MediaType might already be localized, so getOverviewInfo() can mix localized and English text. If this string is user-facing, consider wrapping these tokens in translation helpers (as with translateStr("inch") in DeviceMonitor) or reusing existing localized labels for USB/UFS/media types to keep localization consistent.

Suggested implementation:

    if (Common::specialComType == 5) {
        // Use translated labels for interface types to avoid mixing localized and English text
        const QString ufsLabel = tr("UFS");
        const QString usbLabel = tr("USB");

        if (m_Interface.contains("UFS", Qt::CaseInsensitive)) {
            overViewInfo = QString("%1 %2").arg(m_Size, ufsLabel);
        } else if (m_Interface.contains("USB", Qt::CaseInsensitive)) {
            overViewInfo = QString("%1 %2").arg(m_Size, usbLabel);
        } else {
            overViewInfo = QString("%1 %2").arg(m_Size, m_MediaType);
        }
    }

    return overViewInfo;
  • Ensure DeviceStorage is a QObject-derived class with the Q_OBJECT macro so that tr() is available. This is likely already true in this codebase.
  • If your localization setup uses a custom helper (e.g. translateStr() as in DeviceMonitor), you can replace tr("UFS") / tr("USB") with that helper to align with existing conventions.

return overViewInfo;
}

void DeviceStorage::initFilterKey()
Expand Down
3 changes: 3 additions & 0 deletions deepin-devicemanager/src/GenerateDevice/HWGenerator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -310,6 +310,9 @@ void HWGenerator::generatorDiskDevice()
tempMap["Name"] = "nouse";
// 应HW的要求,将描述固定为 Universal Flash Storage
tempMap["Description"] = "Universal Flash Storage";
if (Common::specialComType == 2) {
tempMap["Interface"] = "UFS 3.1";
}

// 读取interface版本
QProcess process;
Expand Down
2 changes: 1 addition & 1 deletion deepin-devicemanager/src/Tool/ThreadExecXrandr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,7 @@ void ThreadExecXrandr::getMonitorInfoFromXrandrVerbose()

QList<QMap<QString, QString>> lstMap;
loadXrandrVerboseInfo(lstMap, "xrandr --verbose");

std::reverse(lstMap.begin(), lstMap.end());
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): Reversing lstMap changes monitor processing order and may impact which monitor is treated as primary or first.

This change makes the first monitor processed in getMonitorInfoFromXrandrVerbose() correspond to the last entry from xrandr --verbose. If any downstream code relies on the first processed entry representing the primary/preferred monitor or stops at the first suitable match, behavior may change. Consider limiting the reversal to the specific logic that requires it, or document this ordering change explicitly.

QList<QMap<QString, QString> >::const_iterator it = lstMap.begin();
for (; it != lstMap.end(); ++it) {
if ((*it).size() < 1)
Expand Down