Skip to content

pick develop/eagle to master #560

Merged
deepin-bot[bot] merged 8 commits intolinuxdeepin:masterfrom
add-uos:master
Nov 28, 2025
Merged

pick develop/eagle to master #560
deepin-bot[bot] merged 8 commits intolinuxdeepin:masterfrom
add-uos:master

Conversation

@add-uos
Copy link
Contributor

@add-uos add-uos commented Nov 28, 2025

pick develop/eagle to master

Summary by Sourcery

Adjust storage, display, and USB monitoring behavior for specific OEM configurations and improve device information presentation.

New Features:

  • Customize disk overview text for a specific OEM type to show size plus interface or media type.
  • Set a specific UFS interface label ("UFS 3.1") for disks on a targeted OEM configuration.

Bug Fixes:

  • Avoid setting the storage model attribute on certain special OEM configurations where it should be suppressed.

Enhancements:

  • Broaden disk size normalization logic beyond UFS-only interfaces and prepare to ignore UFS disks in that path.
  • Localize the display of screen size units by using a translatable string for "inch".
  • Prioritize later xrandr verbose entries by reversing the parsed monitor info list before processing.

add-uos and others added 8 commits November 28, 2025 15:45
fix the storage display

pick from: linuxdeepin@4cce766

Log: fix the storage display
Bug: https://pms.uniontech.com/bug-view-297753.html
Change-Id: I0dc129b531e3cb27a0828ff1847d08227646cab9
fix the monitor get info from xrander

Log: fix the monitor get info from xrander
Bug: https://pms.uniontech.com/bug-view-285297.html
Change-Id: Ib43660c92187ec824d5a832194dbc609e3ee0d52
adjust the select usb timeout, change the timeout 0.01s to 1s.

Log: adjust the select usb timeout, change the timeout 0.01s to 1s.
Task: https://pms.uniontech.com/task-view-371601.html
Change-Id: Ie2922388a8b7fc4e23db94123d3d6ff6be364640
fit the UFS for klv

Log: fit the UFS for klv
Change-Id: I435e4f59b113164fe5a6138c869c85384e1cf5f2
adjust the select usb timeout, change the timeout 0.01s to 1s.

Log: adjust the select usb timeout, change the timeout 0.01s to 1s.
Bug: https://pms.uniontech.com/bug-view-301245.html
add the storage overview info

pick from: linuxdeepin@05b1de7

Log: add the storage overview info
Task: https://pms.uniontech.com/task-view-372725.html
Change-Id: I3e7833c548382653026bcf0a6dec75c88ef9e2d9
 modify the storage size

pick from: linuxdeepin@c6948df

Log: modify the storage size
Task: https://pms.uniontech.com/task-view-372725.html
@sourcery-ai
Copy link

sourcery-ai bot commented Nov 28, 2025

Reviewer's Guide

Ports a set of hardware-specific behaviors from the develop/eagle branch into master: adds specialComType-based conditionals for disk model/overview formatting and UFS interface labeling, broadens disk size normalization logic, adjusts USB hotplug polling interval, localizes screen size units, and reverses xrandr verbose parsing order to prefer a different monitor entry.

Class diagram for updated hardware and display handling

classDiagram
class DeviceStorage {
  - QString m_Name
  - QString m_Vendor
  - QString m_Interface
  - QString m_Size
  - quint64 m_SizeBytes
  - QString m_MediaType
  + bool setHwinfoInfo(QMap<QString, QString> mapInfo)
  + void checkDiskSize()
  + QString getOverviewInfo()
}

class HWGenerator {
  + void generatorDiskDevice()
}

class MonitorUsb {
  + void monitor()
}

class DeviceMonitor {
  - QString m_ScreenSize
  + bool caculateScreenSize(QString edid)
}

class ThreadExecXrandr {
  + void getMonitorInfoFromXrandrVerbose()
}

class Common {
  <<static>>
  + int specialComType
  + QString specialVendorType()
  + QString specialHString()
}

DeviceStorage .. Common : uses
HWGenerator .. Common : uses
MonitorUsb .. Common : uses
DeviceMonitor .. Common : uses
ThreadExecXrandr .. Common : uses
Loading

File-Level Changes

Change Details Files
Gate certain storage attributes and sizing logic behind specialComType and adjust disk overview formatting for a specific OEM configuration.
  • Skip setting the disk Model attribute when specialComType is non-positive while still setting Vendor.
  • Change disk size post-processing guard from a vendor string comparison to a specialComType check and expand size normalization to apply regardless of UFS interface, with a commented-out UFS-only condition for future reference.
  • Add specialComType==5 handling in getOverviewInfo to format disk overview as ' UFS', ' USB', or ' ' depending on interface instead of the default ' ()'.
deepin-devicemanager/src/DeviceManager/DeviceStorage.cpp
Adjust USB monitoring select timeout to reduce polling frequency.
  • Increase select timeout in the USB monitor loop from 10ms to 1s by changing timeval seconds and microseconds fields.
deepin-devicemanager-server/deepin-deviceinfo/src/hotplug/monitorusb.cpp
Customize UFS disk interface string for a particular specialComType.
  • When generating UFS disk devices, override the Interface field to 'UFS 3.1' when specialComType equals 2 before running additional interface version detection.
deepin-devicemanager/src/GenerateDevice/HWGenerator.cpp
Improve monitor size string internationalization and display ordering of xrandr monitors.
  • Use translateStr("inch") instead of the hardcoded 'inch' literal when formatting screen size strings so the unit can be localized.
  • Reverse the list of xrandr --verbose monitor entries before iterating, effectively changing which monitor is processed first or given priority.
deepin-devicemanager/src/DeviceManager/DeviceMonitor.cpp
deepin-devicemanager/src/Tool/ThreadExecXrandr.cpp

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@deepin-ci-robot
Copy link

deepin pr auto review

我来对这段代码的修改进行审查分析:

  1. monitorusb.cpp 中的修改:
tv.tv_sec = 1;
tv.tv_usec = 0;

优点:

  • 将超时时间从10ms改为1s,减少了CPU使用率
  • 代码更清晰,直接使用秒而不是微秒

建议:

  • 可以考虑将超时时间定义为常量,便于统一管理
  • 建议添加注释说明为什么选择1s作为超时时间
  1. DeviceMonitor.cpp 中的修改:
m_ScreenSize = QString("%1 %2(%3mm X %4mm)").arg(QString::number(inch, '0', 1)).arg(translateStr("inch")).arg(width).arg(height);

优点:

  • 使用translateStr函数实现国际化支持
  • 保持了原有的格式化逻辑

建议:

  • 确保translateStr函数已正确实现国际化支持
  • 可以考虑将格式字符串提取为常量
  1. DeviceStorage.cpp 中的修改:
    a) setHwinfoInfo函数:
if (Common::specialComType <= 0) {
    setAttribute(mapInfo, "Model", m_Name);
}

优点:

  • 增加了条件判断,避免不必要的设置

b) checkDiskSize函数:

//    if (m_Interface.contains("UFS", Qt::CaseInsensitive)) { // TODO Ignore ufs disk

优点:

  • 移除了UFS接口的限制,扩大了适用范围

建议:

  • 注释掉的代码应该完全移除,而不是保留
  • TODO注释应该说明具体的后续计划

c) getOverviewInfo函数:

if (Common::specialComType == 5){
    // ...
}

优点:

  • 增加了特殊机型的定制化显示逻辑
  • 添加了详细的配置说明注释

建议:

  • 可以考虑将特殊机型的处理逻辑提取为独立函数
  • 建议使用枚举代替magic number (5)
  1. HWGenerator.cpp 中的修改:
if (Common::specialComType == 2) {
    tempMap["Interface"] = "UFS 3.1";
}

优点:

  • 为特定机型添加了UFS 3.1接口支持

建议:

  • 同样建议使用枚举代替magic number (2)
  • 可以考虑将接口版本定义为常量
  1. ThreadExecXrandr.cpp 中的修改:
std::reverse(lstMap.begin(), lstMap.end());

优点:

  • 修改了列表顺序,可能解决了某些显示顺序问题

建议:

  • 需要添加注释说明为什么需要反转列表
  • 考虑是否会影响其他功能

总体建议:

  1. 统一使用枚举或常量代替magic number
  2. 添加更详细的注释说明特殊处理的原因
  3. 考虑将特殊机型的处理逻辑统一管理
  4. 移除注释掉的无用代码
  5. 对国际化支持进行充分测试
  6. 考虑将一些复杂的条件判断提取为独立函数,提高代码可读性

Copy link

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

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

Hey there - I've reviewed your changes - here's some feedback:

  • There are multiple hard-coded checks against specific Common::specialComType values (e.g., <= 0, == 2, == 5); consider introducing a strongly-typed enum or named constants to make the intent clearer and reduce the risk of misuse when adding future variants.
  • The commented-out m_Interface.contains("UFS") condition in checkDiskSize() leaves dead code and an unclear TODO; either remove it or replace it with a clearer configuration-based condition (e.g., gated by specialComType) so the UFS-specific behavior is explicitly controlled.
  • The change of the select timeout in MonitorUsb::monitor() from 10ms to 1s significantly alters event responsiveness; consider making this interval configurable or documenting why a 1s delay is acceptable to avoid unexpected latency regressions.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- There are multiple hard-coded checks against specific `Common::specialComType` values (e.g., `<= 0`, `== 2`, `== 5`); consider introducing a strongly-typed enum or named constants to make the intent clearer and reduce the risk of misuse when adding future variants.
- The commented-out `m_Interface.contains("UFS")` condition in `checkDiskSize()` leaves dead code and an unclear TODO; either remove it or replace it with a clearer configuration-based condition (e.g., gated by `specialComType`) so the UFS-specific behavior is explicitly controlled.
- The change of the `select` timeout in `MonitorUsb::monitor()` from 10ms to 1s significantly alters event responsiveness; consider making this interval configurable or documenting why a 1s delay is acceptable to avoid unexpected latency regressions.

## Individual Comments

### Comment 1
<location> `deepin-devicemanager/src/DeviceManager/DeviceStorage.cpp:530-539` </location>
<code_context>
-        }
-    }
+
+//    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) {
</code_context>

<issue_to_address>
**issue (bug_risk):** Uncommented UFS guard changes behavior from UFS-only to all disks, which doesn’t match the TODO comment.

With the `if (m_Interface.contains("UFS"...))` guard commented out, the rounding now applies to every disk, even though the TODO says `Ignore ufs disk`, which suggests the opposite intent. If the goal is to skip UFS, make that explicit:

```cpp
if (m_Interface.contains("UFS", Qt::CaseInsensitive)) {
    return; // Ignore UFS disk
}
// apply size normalization for the rest
```

Right now this broadens the behavior and may unintentionally affect non‑UFS devices.
</issue_to_address>

### Comment 2
<location> `deepin-devicemanager/src/DeviceManager/DeviceStorage.cpp:625-634` </location>
<code_context>
+
+    // 见内网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);
+        }
+    }
+
+    return overViewInfo;
 }

</code_context>

<issue_to_address>
**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:

```cpp
    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.
</issue_to_address>

### Comment 3
<location> `deepin-devicemanager-server/deepin-deviceinfo/src/hotplug/monitorusb.cpp:58-59` </location>
<code_context>
         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);

</code_context>

<issue_to_address>
**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.
</issue_to_address>

### Comment 4
<location> `deepin-devicemanager/src/Tool/ThreadExecXrandr.cpp:279` </location>
<code_context>
     QList<QMap<QString, QString>> lstMap;
     loadXrandrVerboseInfo(lstMap, "xrandr --verbose");
-
+    std::reverse(lstMap.begin(), lstMap.end());
     QList<QMap<QString, QString> >::const_iterator it = lstMap.begin();
     for (; it != lstMap.end(); ++it) {
</code_context>

<issue_to_address>
**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.
</issue_to_address>

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

Comment on lines +625 to +634
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);
}
}

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.

Comment on lines +58 to +59
tv.tv_sec = 1;
tv.tv_usec = 0;
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.

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.

@deepin-ci-robot
Copy link

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: add-uos, lzwind

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@add-uos
Copy link
Contributor Author

add-uos commented Nov 28, 2025

/merge

@deepin-bot deepin-bot bot merged commit 40a10cb into linuxdeepin:master Nov 28, 2025
18 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants