Conversation
1. Root cause: DeviceInput::wakeupPath() only checked
m_Name.contains("PS/2") to select the PS/2 wakeup path, while
isWakeupMachine() already used m_Name || m_Interface check
2. PS/2 keyboards named "AT Translated Set 2 keyboard" do not contain
"PS/2" in name, so wakeupPath() returned wrong sysfs path instead
of /proc/acpi/wakeup, causing canWakeupMachine() to return false
3. Fix: add m_Interface.contains("PS/2") to the condition in
wakeupPath(), aligning with isWakeupMachine() at line 488
Log: Fix PS/2 keyboard "allow wake computer" menu item greyed out
Influence:
1. Test PS/2 keyboard right-click menu shows "allow wake computer"
2. Test PS/2 mouse wakeup function remains normal
3. Test USB and Bluetooth keyboard/mouse wakeup unaffected
fix: 对齐wakeupPath与isWakeupMachine的PS/2判断条件
1. 根因:DeviceInput::wakeupPath()仅检查m_Name.contains("PS/2")
来选择PS/2唤醒路径,而isWakeupMachine()已使用m_Name||
m_Interface双条件判断
2. PS/2键盘名称通常为"AT Translated Set 2 keyboard",不含"PS/2",
导致wakeupPath()返回错误的sysfs路径而非/proc/acpi/wakeup,
canWakeupMachine()返回false,菜单项被置灰
3. 方案:在wakeupPath()条件中增加m_Interface.contains("PS/2"),
与第488行isWakeupMachine()保持一致
Log: 修复PS/2键盘"允许唤起电脑"菜单项置灰问题
Influence:
1. 测试PS/2键盘右键菜单"允许唤起电脑"选项可正常使用
2. 测试PS/2鼠标唤起功能不受影响
3. 测试USB和蓝牙键盘/鼠标唤起功能不受影响
PMS: BUG-294489
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 GuideFixes PS/2 keyboard wakeup support by extending wakeup-path selection to inspect both the device name and interface, preventing the wakeup menu from being incorrectly disabled while preserving USB and Bluetooth behavior. Flow diagram for PS/2 wakeup path selectionflowchart TD
A["DeviceInput::wakeupPath()"] --> B{PS/2 in name or interface?}
B -->|Yes| C["/proc/acpi/wakeup"]
B -->|No| D["/sys.../power/wakeup"]
C --> E["canWakeupMachine()"]
D --> E
E --> F["Wakeup context menu"]
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
deepin pr auto review🤖 AI 代码审查报告📊 总体评价
🔍 详细分析1. 语法逻辑 ✅评价: 优秀 ✅ 通过 潜在问题: 建议: 语法正确,逻辑清晰。修改在 DeviceInput.cpp 第508行 wakeupPath() 函数中,将单条件 m_Name.contains("PS/2") 扩展为双条件 m_Name.contains("PS/2") || m_Interface.contains("PS/2"),与同文件第488行 isWakeupMachine() 函数的判断逻辑完全一致。QString::contains() 方法和 || 运算符使用正确,无语法错误。 2. 代码质量 ✅评价: 优秀 ✅ 通过 潜在问题: 建议: 代码结构清晰,注释完整。本次修改为最小化的一行变更,精确修复了 PS/2 键盘唤醒路径检测问题。修改后消除了 wakeupPath() 与 isWakeupMachine() 两个函数间的逻辑不一致问题,提升了代码一致性。无重复代码,无残留调试代码。 3. 代码性能 ✅评价: 优秀 ✅ 通过 潜在问题: 建议: 性能良好,资源使用合理。新增的 m_Interface.contains("PS/2") 调用为 QString 短字符串匹配操作,开销极小。wakeupPath() 函数在设备枚举时调用,非高频热路径,对整体性能无影响。 4. 代码安全 🔒评价: 优秀 ✅ 通过
安全漏洞详情: 建议: 安全合规。本次修改仅涉及内部设备成员变量 m_Name 和 m_Interface 的字符串匹配判断,不涉及用户输入、文件操作、网络通信或权限控制,无命令注入、路径遍历、缓冲区溢出等安全风险。返回的路径为硬编码的 /proc/acpi/wakeup 和基于 m_SysPath 构建的 sysfs 路径,不存在路径拼接安全问题。 💡 改进建议代码示例// 当前修复已正确对齐 wakeupPath() 与 isWakeupMachine() 的 PS/2 检测逻辑
// 无需额外修改,代码示例如下:
QString DeviceInput::wakeupPath()
{
// ...
// 修复后:同时检查 m_Name 和 m_Interface,与 isWakeupMachine() 一致
if (m_Name.contains("PS/2") || m_Interface.contains("PS/2")) {
return "/proc/acpi/wakeup";
} else {
return QString("/sys") + m_SysPath.left(index) + QString("/power/wakeup");
}
}本报告由 AI 代码审查工具自动生成 |
Root Cause Analysis
DeviceInput::wakeupPath()(DeviceInput.cpp:508) used onlym_Name.contains("PS/2")to select the PS/2 wakeup path, while the sibling functionisWakeupMachine()(line 488) already usedm_Name.contains("PS/2") || m_Interface.contains("PS/2"). PS/2 keyboards typically have names like "AT Translated Set 2 keyboard" which do not contain "PS/2", sowakeupPath()returned the wrong sysfs path (/sys/.../power/wakeup) instead of/proc/acpi/wakeup. The non-existent sysfs file causedcanWakeupMachine()to return false, greying out the "allow wake computer" context menu item.Key evidence:
isWakeupMachine()at line 488 already has the correct dual-condition check, confirming the intended behavior; PS/2 mice normally contain "PS/2" in their names (e.g., "PS/2 Generic Mouse"), which is why mice worked but keyboards did not—matching the bug report.Fix
Added
m_Interface.contains("PS/2")to the condition inwakeupPath(), aligning it withisWakeupMachine()at line 488. One-line change, only affects PS/2 device path selection; USB/Bluetooth paths are unchanged.Change Safety Assessment
Code Safety
canWakeupMachine(),isWakeupMachine(),PageMultiInfo.cpp) all benefit from the corrected path — no behavior change for USB/Bluetooth devicesBusiness Impact Scope
Affected module: keyboard/mouse "allow wake computer" (允许唤起电脑) context menu in Device Manager. The fix corrects PS/2 keyboard path selection so the menu item is no longer greyed out. PS/2 mouse, USB, and Bluetooth devices are unaffected.
Verification Suggestion
Verify PS/2 keyboard right-click menu shows an enabled "allow wake computer" option. Regression-test PS/2 mouse and USB/Bluetooth keyboard/mouse wakeup functionality to confirm no impact.
根因分析
DeviceInput::wakeupPath()(DeviceInput.cpp:508)仅使用m_Name.contains("PS/2")选择 PS/2 唤醒路径,而同文件isWakeupMachine()(第488行)已使用m_Name.contains("PS/2") || m_Interface.contains("PS/2")双条件判断。PS/2 键盘名称通常为 "AT Translated Set 2 keyboard",不含 "PS/2",导致wakeupPath()返回错误的 sysfs 路径(/sys/.../power/wakeup)而非/proc/acpi/wakeup。该 sysfs 文件不存在使canWakeupMachine()返回 false,"允许唤起电脑"右键菜单项被置灰。关键证据:
isWakeupMachine()(第488行)已有正确的双条件判断,证实预期行为;PS/2 鼠标名称通常含 "PS/2"(如 "PS/2 Generic Mouse"),故鼠标正常而键盘异常——与 bug 现象吻合。修复方案
在
wakeupPath()条件中增加m_Interface.contains("PS/2"),与第488行isWakeupMachine()对齐。一行改动,仅影响 PS/2 设备路径选择,USB/蓝牙路径不变。改动安全评估
代码安全评估
canWakeupMachine()、isWakeupMachine()、PageMultiInfo.cpp)均从修正后的路径受益——USB/蓝牙设备行为无变化业务影响范围
受影响模块:设备管理器中键盘/鼠标"允许唤起电脑"右键菜单。修复修正了 PS/2 键盘路径选择,使菜单项不再置灰。PS/2 鼠标、USB 和蓝牙设备不受影响。
验证建议
验证 PS/2 键盘右键菜单"允许唤起电脑"选项可见且可操作。回归测试 PS/2 鼠标及 USB/蓝牙键盘/鼠标唤起功能,确认无影响。
PMS: BUG-294489
Summary by Sourcery
Bug Fixes: