Skip to content

fix(power1): comment out pre-login power mode update#1166

Open
MyLeeJiEun wants to merge 1 commit into
linuxdeepin:masterfrom
MyLeeJiEun:fork-from-master-0630-fix-issue-367237
Open

fix(power1): comment out pre-login power mode update#1166
MyLeeJiEun wants to merge 1 commit into
linuxdeepin:masterfrom
MyLeeJiEun:fork-from-master-0630-fix-issue-367237

Conversation

@MyLeeJiEun

@MyLeeJiEun MyLeeJiEun commented Jul 1, 2026

Copy link
Copy Markdown
Contributor
  1. Comment out updatePowerMode(true) in Manager.init() to avoid setting power mode twice in quick succession after login
  2. Setting deepin-power-control twice in a short interval has a probability of failure; this removes the pre-login call
  3. Power mode is now only set after login via the normal flow

Log: Comment out pre-login updatePowerMode to prevent double-setting failure

fix(power1): 注释掉登录前的电源模式更新

  1. 在 Manager.init() 中注释掉 updatePowerMode(true) 调用,避免登录后短时间 内重复设置电源模式
  2. deepin-power-control 短时间内设置两次有概率失败,去掉登录前的设置调用
  3. 电源模式仅在登录后通过正常流程设置

Log: 注释掉登录前的电源模式更新,避免短时间重复设置导致失败
PMS: BUG-367237

Summary by Sourcery

Bug Fixes:

  • Avoid potential failures caused by setting deepin-power-control twice in quick succession by eliminating the pre-login power mode update.

@deepin-ci-robot

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: MyLeeJiEun

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 Jul 1, 2026

Copy link
Copy Markdown
Reviewer's guide (collapsed on small PRs)

Reviewer's Guide

This PR disables the pre-login power mode initialization call in the power manager so that power mode is only applied once via the post-login flow, avoiding double-setting failures in deepin-power-control.

Sequence diagram for updated power mode setting after login

sequenceDiagram
    actor User
    participant LoginSession
    participant PowerManager
    participant deepin_power_control

    User->>LoginSession: startSession
    LoginSession->>PowerManager: updatePowerMode
    PowerManager->>deepin_power_control: setPowerMode

    Note over PowerManager: init no longer calls updatePowerMode before login
Loading

File-Level Changes

Change Details Files
Disable the pre-login power mode update in Manager.init so power mode is no longer set twice in quick succession.
  • Comment out the call to updatePowerMode(true) at the end of Manager.init
  • Leave gudevClient connection, initDone flag, and display manager initialization logic unchanged
system/power1/manager.go

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
Copy Markdown

Hi @MyLeeJiEun. Thanks for your PR.

I'm waiting for a linuxdeepin member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

Details

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@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 left some high level feedback:

  • Instead of commenting out m.updatePowerMode(true), consider removing the call entirely or guarding it with a clear conditional to avoid leaving dead code that may be accidentally re-enabled later.
  • If init-time power mode updates are now intentionally disabled, verify whether any callers or startup flows implicitly relied on that behavior and, if needed, centralize the post-login update logic to make the new lifecycle explicit in code.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- Instead of commenting out `m.updatePowerMode(true)`, consider removing the call entirely or guarding it with a clear conditional to avoid leaving dead code that may be accidentally re-enabled later.
- If init-time power mode updates are now intentionally disabled, verify whether any callers or startup flows implicitly relied on that behavior and, if needed, centralize the post-login update logic to make the new lifecycle explicit in code.

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.

…eepin-power-control

1. Removed sync.Once + time.AfterFunc(2 min) that forcibly restored
   the original power mode after login
2. Changed boot logic to keep performance mode until first user session,
   then set the original mode via updatePowerMode(true)
3. Moved initial updatePowerMode(true) from init() into doSetMode's
   short-idle path to avoid double-setting power mode — deepin-power-control
   may fail when called twice in quick succession
4. Cleaned up unused imports and redundant error check

Log: Fix power mode racing by deferring initialization to post-login,
removing the flawed timer-based reset

fix(power): 将电源模式初始化移到登录后,避免与 deepin-power-control 竞争

1. 移除登录后2分钟强制恢复电源模式的定时器逻辑
2. 启动时保持 performance 模式,直到第一个用户会话登录后才设置
   为原有的电源模式
3. 将 updatePowerMode(true) 从 init() 移到 doSetMode 的短空闲路径,
   避免短时间内重复设置电源模式——deepin-power-control 连续设置2次
   有概率失败
4. 清理未使用的导入和冗余错误检查

Log: 将电源模式初始化延迟到登录后执行,移除有缺陷的定时器复位逻辑
PMS: BUG-367237
@MyLeeJiEun MyLeeJiEun force-pushed the fork-from-master-0630-fix-issue-367237 branch from a2aae5d to a58400b Compare July 1, 2026 08:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants