Skip to content

fix: [262699] PS/2 Touchpad 与 Mouse 共享 ACPI 唤醒键导致唤醒选项联动 - #765

Open
pengfeixx wants to merge 1 commit into
develop/eaglefrom
agent/pms-bug-bot/1d9bbad8f2de
Open

pengfeixx wants to merge 1 commit into
develop/eaglefrom
agent/pms-bug-bot/1d9bbad8f2de

Conversation

@pengfeixx

@pengfeixx pengfeixx commented Sep 16, 2026

Copy link
Copy Markdown
Contributor

修复说明

Bug 信息

根因

PS/2 Mouse 和 PS/2 Touchpad 共享同一个 i8042 控制器,ACPI /proc/acpi/wakeup 中只有一个 "PS2M" 条目。DBusWakeupInterface 将所有 hardwareClass == "mouse" 的设备统一映射到 ACPI 键 "PS2M",导致两者的"允许唤起电脑"选项读写同一条目,产生联动。

修复方案

UI 层修复:在 DeviceInput::canWakeupMachine() 中,当设备为 PS/2 Touchpad(名称包含 "Touchpad" 且名称或接口包含 "PS/2")时,返回 false,隐藏其"允许唤起电脑"右键选项。

改动文件

  • src/DeviceManager/DeviceInput.cppcanWakeupMachine() 新增 PS/2 Touchpad 判断

改动安全评估

  • 风险等级: 低
  • 仅缩小唤醒选项显示范围,不涉及写入逻辑或 ACPI 操作
  • 使用与现有代码一致的设备判断模式
  • PS/2 Mouse、USB Mouse、USB Touchpad 均不受影响

测试建议

在配有 PS/2 Mouse + PS/2 Touchpad 的硬件上验证:

  1. Mouse 的"允许唤起电脑"选项正常显示且可独立切换
  2. Touchpad 的"允许唤起电脑"选项不再显示
  3. 切换 Mouse 唤醒状态不影响 Touchpad(因 Touchpad 选项已隐藏)

Summary by Sourcery

Bug Fixes:

  • Prevent PS/2 Touchpad devices from exposing the wake-from-sleep option when they share the ACPI wake key with a PS/2 mouse, eliminating misleading linked controls.

PS/2 Mouse 和 PS/2 Touchpad 共享同一个 i8042 控制器,ACPI 唤醒键
均为 "PS2M",两者唤醒状态无法独立控制。在 canWakeupMachine()
中对 PS/2 Touchpad 返回 false,隐藏其"允许唤起电脑"选项,
避免用户误以为可以独立控制。

Log: 修复 PS/2 Touchpad 唤醒选项与 Mouse 联动问题
Bug: https://pms.uniontech.com/bug-view-262699.html

@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.

Sorry @pengfeixx, you've used your own review budget of 250,000 diff characters for the last 7 days.

You can request another review in 5 days and 10 hours by commenting @sourcery-ai review. Upgrade to get a review now.

@deepin-ci-robot

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: pengfeixx

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 Sep 16, 2026

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

Reviewer's Guide

Updates wakeup capability detection to suppress the misleading “allow this device to wake the computer” option for PS/2 touchpads, preventing UI coupling with PS/2 mouse wakeup state while preserving existing wakeup handling for other devices.

Flow diagram for PS/2 touchpad wakeup option visibility

flowchart TD
    A["DeviceInput::canWakeupMachine()"] --> B["m_WakeupID is empty?"]
    B -- "yes" --> C["Hide wakeup option"]
    B -- "no" --> D["Name contains Touchpad and name or interface contains PS/2?"]
    D -- "yes" --> C
    D -- "no" --> E["Check existing ACPI wakeup state"]
    E --> F["Show wakeup option when supported"]
Loading

File-Level Changes

Change Details Files
Hide the wakeup toggle for PS/2 touchpads whose ACPI wakeup entry is shared with PS/2 mice.
  • Add a case-insensitive device-name check for “Touchpad”.
  • Require “PS/2” in either the device name or interface before disabling wakeup support.
  • Return false before reading ACPI wakeup state, leaving mouse and non-PS/2 touchpad behavior unchanged.
src/DeviceManager/DeviceInput.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
Copy Markdown

deepin pr auto review

🤖 AI 代码审查报告

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

Pass


📊 总体评价

项目 结果
审查结论 代码审查通过
评分详情 总体评分 100 分,大于 70 分通过阈值,代码质量符合要求。本次变更是一个低风险的 UI 层修复,仅缩小唤醒选项显示范围,代码实现清晰、注释完整、无安全问题。

🔍 详细分析

1. 语法逻辑 ✅

评价: 优秀 ✅ 通过

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

建议: 代码逻辑正确,无需修改。条件判断顺序合理:先检查 WakeupID 是否为空(快速失败),再检查 PS/2 Touchpad 特定条件,最后检查文件可读性。使用 Qt::CaseInsensitive 进行大小写不敏感匹配,符合 Qt 编程规范。


2. 代码质量 ✅

评价: 优秀 ✅ 通过

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

建议: 代码质量优秀。注释详细解释了根因(PS/2 Touchpad 和 Mouse 共享 i8042 控制器,ACPI 唤醒键均为 PS2M),说明了修复方案的意图。代码风格与现有代码一致(如 setEnable() 函数中也使用 m_Name.contains("Touchpad", Qt::CaseInsensitive) 进行判断)。函数结构清晰,无冗余代码。


3. 代码性能 ✅

评价: 优秀 ✅ 通过

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

建议: 性能表现优秀。新增代码仅包含字符串 contains() 比较操作,时间复杂度为 O(n)(n 为字符串长度),对于设备名称等短字符串而言性能开销可忽略。不涉及 I/O 操作、内存分配或系统调用。


4. 代码安全 🔒

评价: 优秀 ✅ 通过

🔐 发现 0 个安全漏洞

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

建议: 安全合规。本次变更不涉及用户输入处理、文件路径操作、网络通信、权限提升或敏感信息访问。仅通过设备名称和接口字符串匹配来控制 UI 选项的显示,不改变任何实际的 ACPI 唤醒操作逻辑,安全风险极低。


💡 改进建议代码示例

// 当前代码已是最优实现,无需修改
// canWakeupMachine() 中的 PS/2 Touchpad 判断逻辑清晰正确
bool DeviceInput::canWakeupMachine()
{
    if (m_WakeupID.isEmpty())
        return false;
    // PS/2 Touchpad 和 PS/2 Mouse 共享同一个 i8042 控制器,
    // ACPI 唤醒键均为 "PS2M",两者唤醒状态无法独立控制。
    if (m_Name.contains("Touchpad", Qt::CaseInsensitive) &&
        (m_Name.contains("PS/2") || m_Interface.contains("PS/2"))) {
        return false;
    }
    QFile file(wakeupPath());
    if (!file.open(QIODevice::ReadOnly)) {
        return false;
    }
    return true;
}

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

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