Conversation
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
There was a problem hiding this comment.
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.
|
[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. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
Reviewer's guide (collapsed on small PRs)Reviewer's GuideUpdates 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 visibilityflowchart 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"]
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
deepin pr auto review🤖 AI 代码审查报告📊 总体评价
🔍 详细分析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. 代码安全 🔒评价: 优秀 ✅ 通过
安全漏洞详情: 建议: 安全合规。本次变更不涉及用户输入处理、文件路径操作、网络通信、权限提升或敏感信息访问。仅通过设备名称和接口字符串匹配来控制 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 代码审查工具自动生成 |
修复说明
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.cpp—canWakeupMachine()新增 PS/2 Touchpad 判断改动安全评估
测试建议
在配有 PS/2 Mouse + PS/2 Touchpad 的硬件上验证:
Summary by Sourcery
Bug Fixes: