Skip to content

fix: migrate power property to Power1 - #974

Merged
deepin-bot[bot] merged 1 commit into
linuxdeepin:masterfrom
dengzhongyuan365-dev:fix/task-398517-devicemanager
Nov 12, 2026
Merged

deepin-bot[bot] merged 1 commit into
linuxdeepin:masterfrom
dengzhongyuan365-dev:fix/task-398517-devicemanager

Conversation

@dengzhongyuan365-dev

@dengzhongyuan365-dev dengzhongyuan365-dev commented Nov 12, 2026 •

Copy link
Copy Markdown
Member

Summary

Migrate the Device Manager power property from com.deepin.system.Power to org.deepin.dde.Power1, while keeping system bus access and double conversion unchanged.

Verification

  • git diff --check
  • Target service/path/interface match the V25 system bus introspection.
  • Runtime battery percentage verification is pending on the packaged build.

PMS: TASK-398517

Summary by Sourcery

Bug Fixes:

  • Migrate Device Manager power-property access to the org.deepin.dde.Power1 system service.

@sourcery-ai

sourcery-ai Bot commented Nov 12, 2026 •

Copy link
Copy Markdown

Reviewer's Guide

Implementation

Update DevicePower’s D-Bus constants and property-reading helper to prefer Power1, retain the legacy fallback, and keep battery percentage conversion behavior unchanged.

  • deepin-devicemanager/src/DeviceManager/DevicePower.cpp L1, L17-37, L136-144

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

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Hey - I've found 1 issue

Prompt for AI Agents
Please address the comments from this code review:

## Individual Comments

### Comment 1
<location path="deepin-devicemanager/src/DeviceManager/DevicePower.cpp" line_range="17-19" />
<code_context>
-constexpr const char* kPowerService = "com.deepin.system.Power";
-constexpr const char* kPowerPath = "/com/deepin/system/Power";
-constexpr const char* kPowerInterface = "com.deepin.system.Power";
+constexpr const char* kPowerService = "org.deepin.dde.Power1";
+constexpr const char* kPowerPath = "/org/deepin/dde/Power1";
+constexpr const char* kPowerInterface = "org.deepin.dde.Power1";

 DWIDGET_USE_NAMESPACE
</code_context>
<issue_to_address>
**Battery percentage diverges from status bar**

When device Manager runs on a supported pre-V25 release that exposes only the legacy Power service, `QDBusInterface` looks up the Power1 service, so `setInfoFromUpower` logs an error and retains UPower’s percentage instead of reading the Power daemon’s value; when those values differ, the displayed percentage diverges from the status bar.

Add a backward-compatible lookup or fallback for the legacy Power service on releases that do not expose Power1.
</issue_to_address>

Sourcery is free for open source - if you like our reviews please consider sharing them ✨

@dengzhongyuan365-dev
dengzhongyuan365-dev force-pushed the fix/task-398517-devicemanager branch 4 times, most recently from cb0c169 to 7307078 Compare November 12, 2026 06:30

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Hey - I've reviewed your changes and they look great!


Sourcery is free for open source - if you like our reviews please consider sharing them ✨

@dengzhongyuan365-dev
dengzhongyuan365-dev force-pushed the fix/task-398517-devicemanager branch 2 times, most recently from 115f771 to 7bcb982 Compare November 12, 2026 06:47
@dengzhongyuan365-dev

Copy link
Copy Markdown
Member Author

已处理 review 建议:保留 V25 的 org.deepin.dde.Power1 读取路径,并在其接口或 BatteryPercentage 属性不可用时回退到旧 com.deepin.system.Power,避免 pre-V25 环境回归。

1. Update the power service, object path, and interface names.
2. Keep system bus access and double property conversion.
3. Preserve the battery percentage display behavior.

Log: Battery percentage now reads from org.deepin.dde.Power1.
Influence:
1. Open Device Manager and check the battery percentage.
2. Verify the value updates after power state changes.
3. Verify no D-Bus errors appear in the log.

fix: 迁移电源属性到 Power1

1. 更新电源服务名、对象路径和接口名。
2. 保持 system bus 和 double 类型读取方式不变。
3. 保持电池百分比显示行为不变。

Log: 电池百分比改为从 org.deepin.dde.Power1 读取。
Influence:
1. 打开设备管理器,检查电池百分比显示。
2. 验证电源状态变化后数值能够刷新。
3. 验证日志中没有相关 D-Bus 错误。

PMS: TASK-398517
Log: Migrated the battery power property to org.deepin.dde.Power1.
@dengzhongyuan365-dev
dengzhongyuan365-dev force-pushed the fix/task-398517-devicemanager branch from 7bcb982 to d618ec4 Compare November 12, 2026 06:50
@deepin-ci-robot

Copy link
Copy Markdown

deepin pr auto review

🤖 AI 代码审查报告

总体评分: 98 分 (通过阈值: 70分)

Pass


📊 总体评价

项目 结果
审查结论 代码审查通过
评分详情 本次提交将电源 D-Bus 属性从旧的 com.deepin.system.Power 迁移到新的 org.deepin.dde.Power1, 并保留了对旧服务的兼容回退。代码提取了公共的 readBatteryPercentage 辅助函数以减少重复, D-Bus 接口与属性均做了有效性校验,防御性编程良好。四维度均通过,无安全漏洞, 仅有新函数缺少注释的轻微质量问题。

🔍 详细分析

1. 语法逻辑 ✅

评价: 语法正确,逻辑清晰 ✅ 通过

潜在问题:
✅ 未发现明显问题

建议: []


2. 代码质量 ✅

评价: 代码结构清晰,可读性好 ✅ 通过

潜在问题:
✅ 未发现明显问题

建议: ['建议为 readBatteryPercentage 函数添加简要注释,说明其作用(从指定 D-Bus 服务读取电池百分比)和返回值含义(成功返回 true 并设置 value)']


3. 代码性能 ✅

评价: 性能良好,资源使用合理 ✅ 通过

潜在问题:
✅ 未发现明显问题

建议: []


4. 代码安全 🔒

评价: 存在0个安全漏洞 ✅ 通过

🔐 发现 0 个安全漏洞

安全漏洞详情:
✅ 未发现安全漏洞

建议: []


💡 改进建议代码示例

// 建议为 readBatteryPercentage 添加注释 // 从指定的 D-Bus 电源服务读取电池百分比属性 // 成功时返回 true 并通过 value 输出百分比,失败返回 false static bool readBatteryPercentage(const char *service, const char *path,
                                  const char *interfaceName, double &value)
{
    QDBusInterface interface(service, path, interfaceName, QDBusConnection::systemBus());
    if (!interface.isValid())
        return false;

    const QVariant percentage = interface.property("BatteryPercentage");
    if (!percentage.isValid())
        return false;

    value = percentage.toDouble();
    return true;
}

本报告由 AI 代码审查工具自动生成

@deepin-ci-robot

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: dengzhongyuan365-dev, 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

@dengzhongyuan365-dev

Copy link
Copy Markdown
Member Author

远程 V25 实机验证(10.8.7.203,system bus):

  • org.deepin.dde.Power1:存在,BatteryPercentage 类型为 double,读取值为 15
  • com.deepin.system.Power:不存在,旧服务查询返回 ServiceUnknown
  • Qt D-Bus 探针:interface.isValid() == true,property.isValid() == true,最终百分比为 15
  • UPower 当前电池百分比也是 15%,与 D-Bus 读取结果一致

因此 V25 主路径读取正常;旧服务回退路径保留用于 pre-V25 环境。

@dengzhongyuan365-dev

Copy link
Copy Markdown
Member Author

/forcemerge

@deepin-bot

deepin-bot Bot commented Nov 12, 2026

Copy link
Copy Markdown
Contributor

This pr force merged! (status: unstable)

@deepin-bot
deepin-bot Bot merged commit f55a882 into linuxdeepin:master Nov 12, 2026
17 of 19 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.

3 participants