Skip to content

feat: support device idle power saving flag - #227

Merged
deepin-bot[bot] merged 1 commit into
linuxdeepin:develop/2500u3from
52cyb:feat/2500u3-device-idle-power-saving
Nov 19, 2026
Merged

deepin-bot[bot] merged 1 commit into
linuxdeepin:develop/2500u3from
52cyb:feat/2500u3-device-idle-power-saving

Conversation

@52cyb

@52cyb 52cyb commented Nov 19, 2026 •

Copy link
Copy Markdown
Contributor
  1. Add DeviceIdlePowerSaving property backed by the power DConfig key.
  2. Persist the flag and append --dev-idle when replaying the mode command.
  3. Keep the last DSPC mode so toggling only adds or removes --dev-idle.
  4. Load the flag at startup and apply it once via initializePowerMode.

Log: Add system-side state and CLI support for device idle power saving

Influence:

  1. Toggle DeviceIdlePowerSaving via busctl and verify the property and DConfig value change.
  2. Verify the mode command carries --dev-idle when on and omits it when off.
  3. Restart Power1 and verify the flag is restored and applied only once at startup.
  4. Switch power mode or trigger low battery while enabled and verify --dev-idle is kept.
  5. Confirm the installed deepin-power-control version supports --dev-idle.

feat: 支持设备空闲省电配置

  1. 新增 DeviceIdlePowerSaving 属性,状态持久化到电源 DConfig。
  2. 下发模式命令时根据开关追加或移除 --dev-idle。
  3. 记录最近一次下发的 DSPC 模式,切换开关时原样重放而不重新解析。
  4. 启动时加载该配置,并由 initializePowerMode 统一下发一次。

Log: 为设备空闲省电增加系统侧状态与命令下发支持

Influence:

  1. 通过 busctl 切换 DeviceIdlePowerSaving,确认属性与 DConfig 值同步更新。
  2. 确认开启时命令携带 --dev-idle,关闭时恢复为不带该参数。
  3. 重启 Power1,确认开关状态恢复且仅在启动初始化时下发一次。
  4. 开启后切换性能模式或触发低电量,确认命令仍携带 --dev-idle。
  5. 确认安装的 deepin-power-control 版本支持 --dev-idle。

PMS: TASK-394399


Backport of #218 (merged to master) to develop/2500u3. Cherry-picked commit: c45b61d "feat: support device idle power saving flag".

Summary by Sourcery

Add persistent system-side support for toggling device idle power saving and propagating it to power-control mode commands.

New Features:

  • Expose a DeviceIdlePowerSaving D-Bus property backed by persisted power configuration.

Enhancements:

  • Preserve and reapply the latest power-control mode while adding or removing the device-idle power-saving option.
  • Restore the device-idle power-saving state during startup and apply it through the initial power-mode setup.

Build:

  • Update the Debian package dependency/configuration for device idle power-saving support.

1. Add DeviceIdlePowerSaving property backed by the power DConfig key.
2. Persist the flag and append --dev-idle when replaying the mode command.
3. Keep the last DSPC mode so toggling only adds or removes --dev-idle.
4. Load the flag at startup and apply it once via initializePowerMode.

Log: Add system-side state and CLI support for device idle power saving

Influence:
1. Toggle DeviceIdlePowerSaving via busctl and verify the property and DConfig value change.
2. Verify the mode command carries --dev-idle when on and omits it when off.
3. Restart Power1 and verify the flag is restored and applied only once at startup.
4. Switch power mode or trigger low battery while enabled and verify --dev-idle is kept.
5. Confirm the installed deepin-power-control version supports --dev-idle.

feat: 支持设备空闲省电配置

1. 新增 DeviceIdlePowerSaving 属性,状态持久化到电源 DConfig。
2. 下发模式命令时根据开关追加或移除 --dev-idle。
3. 记录最近一次下发的 DSPC 模式,切换开关时原样重放而不重新解析。
4. 启动时加载该配置,并由 initializePowerMode 统一下发一次。

Influence:
1. 通过 busctl 切换 DeviceIdlePowerSaving,确认属性与 DConfig 值同步更新。
2. 确认开启时命令携带 --dev-idle,关闭时恢复为不带该参数。
3. 重启 Power1,确认开关状态恢复且仅在启动初始化时下发一次。
4. 开启后切换性能模式或触发低电量,确认命令仍携带 --dev-idle。
5. 确认安装的 deepin-power-control 版本支持 --dev-idle。

Log: 为设备空闲省电增加系统侧状态与命令下发支持
PMS: TASK-394399
@deepin-ci-robot

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: 52cyb

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

@sourcery-ai

sourcery-ai Bot commented Nov 19, 2026

Copy link
Copy Markdown

Reviewer's Guide

Schema and migrations

Define the device-idle power-saving DConfig key and its corresponding constant so the setting has a stored representation.

  • src/plugin-qt/power/misc/org.deepin.dde.daemon.power.json L87-98
  • src/plugin-qt/power/powerconstants.h L55

API

Expose DeviceIdlePowerSaving as a D-Bus property with its getter, setter, and change notification.

  • src/plugin-qt/power/system/powermanager.h L40-147 (4 small edits)

Implementation

Track the most recently selected DSPC mode and append the idle flag when replaying it, including when the setting is toggled.

  • src/plugin-qt/power/system/powermanager.cpp L865-876, L1103-1120
  • src/plugin-qt/power/system/powermanager.h L163, L203-207

Load the DConfig value at startup and apply it through the power manager's configuration initialization path.

  • src/plugin-qt/power/system/powermanager.cpp L556-557, L608

Configuration

Update the Debian package configuration required by this feature.

  • debian/control L51

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 3 issues

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

## Individual Comments

### Comment 1
<location path="src/plugin-qt/power/system/powermanager.cpp" line_range="1109" />
<code_context>
+    if (m_deviceIdlePowerSaving == enabled)
+        return;
+
+    if (!m_loadingConfig && !authorizePowerAction())
+        return;
+
</code_context>
<issue_to_address>
**DConfig bypasses power authorization**

When an unprivileged local process writes the public, read-write `deviceIdlePowerSaving` DConfig key, the DConfig change handler calls `SetDeviceIdlePowerSaving` outside a D-Bus invocation, so `authorizePowerAction()` treats the call as authorized and the setter queues the power-control command without Polkit approval.

Restrict write access to this DConfig key or ensure external DConfig changes are authorized before applying them to the system power-control command.

Also at `src/plugin-qt/power/system/powermanager.cpp:556-557`.
</issue_to_address>

### Comment 2
<location path="src/plugin-qt/power/system/powermanager.cpp" line_range="876" />
<code_context>
+    if (m_deviceIdlePowerSaving)
+        args << QStringLiteral("--dev-idle");
+
+    enqueuePowerControl(args);
 }

</code_context>
<issue_to_address>
**Hung command blocks later power changes**

When `deepin-power-control` hangs while applying the mode command, `runNextPowerControl()` waits for the process-finished signal before dequeuing another command, and there is no timeout or kill path. The queued mode update remains unapplied and later power-control commands stay blocked.

Add a bounded execution timeout that terminates the process and advances or otherwise recovers the queue.
</issue_to_address>

### Comment 3
<location path="src/plugin-qt/power/system/powermanager.cpp" line_range="876" />
<code_context>
+    if (m_deviceIdlePowerSaving)
+        args << QStringLiteral("--dev-idle");
+
+    enqueuePowerControl(args);
 }

</code_context>
<issue_to_address>
**Device-idle setting stays unapplied**

When deepin-power-control fails to start or exits nonzero while replaying a device-idle toggle, `enqueueModeCommand` queues the updated command, but `runNextPowerControl` dequeues it before starting the process; on start or nonzero-exit failure, the handlers only log and advance the queue. The property and DConfig value stay updated while device-idle power saving remains unapplied.

Handle process-start and nonzero-exit failures by retrying or reverting the device-idle setting before advancing the queue.
</issue_to_address>

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

@52cyb

52cyb commented Nov 19, 2026

Copy link
Copy Markdown
Contributor Author

/forcemerge

@deepin-bot

deepin-bot Bot commented Nov 19, 2026

Copy link
Copy Markdown

This pr force merged! (status: unstable)

@deepin-bot
deepin-bot Bot merged commit b400856 into linuxdeepin:develop/2500u3 Nov 19, 2026
9 of 10 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.

2 participants