fix: fix missing wake option for PS/2 keyboard in device manager - #726
fix: fix missing wake option for PS/2 keyboard in device manager#726tianming-1996 wants to merge 1 commit into
Conversation
There was a problem hiding this comment.
Sorry @tianming-1996, you have reached your weekly rate limit of 500000 diff characters.
Please try again later or upgrade to continue using Sourcery
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: tianming-1996 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 GuideAligns PS/2 keyboard wakeup path detection with existing wake-capability logic by considering both device name and interface, ensuring PS/2 devices without 'PS/2' in their name still use the ACPI wakeup path. Sequence diagram for PS2 wakeupPath selection in DeviceInputsequenceDiagram
participant DeviceManager
participant DeviceInput
participant QFile
DeviceManager->>DeviceInput: canWakeupMachine()
DeviceInput->>DeviceInput: wakeupPath()
alt [m_Name.contains(PS2) or m_Interface.contains(PS2)]
DeviceInput-->>DeviceInput: return /proc/acpi/wakeup
else [no PS2 in name and interface]
DeviceInput-->>DeviceInput: return /sys/.../power/wakeup
end
DeviceInput->>QFile: open(wakeupPath)
QFile-->>DeviceInput: open result
DeviceInput-->>DeviceManager: canWakeupMachine() result
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
1. 修复 wakeupPath() 中 PS/2 设备判断条件不一致问题; 2. 增加对 m_Interface 字段的 PS/2 判断, 使其与 isWakeupMachine() 逻辑一致; 3. PS/2 键盘设备名称不含 "PS/2" 字符串时也能正确返回 /proc/acpi/wakeup 路径; 4. 更新 SPDX 版权年份为 2022-2026; ===================================== 1. fixed inconsistent PS/2 device detection in wakeupPath(); 2. added m_Interface check to align with isWakeupMachine() logic; 3. PS/2 keyboard devices without "PS/2" in name now correctly return /proc/acpi/wakeup path; 4. updated SPDX copyright year to 2022-2026; Log: 修复设备管理器中 PS/2 键盘右键菜单缺少 "允许唤起电脑" 选项的问题, 原因是 wakeupPath() 判断条件与 isWakeupMachine() 不一致 Bug: https://pms.uniontech.com/bug-view-294489.html
d9be2cf to
e6632a7
Compare
deepin pr auto review★ 总体评分:100分■ 【总体评价】
■ 【详细分析】
■ 【改进建议代码示例】 @@ -503,8 +503,10 @@ QString DeviceInput::wakeupPath()
return "";
}
- if (m_Name.contains("PS/2")) {
+ // 增加对 m_Interface 的判空保护与 PS/2 检测
+ if (m_Name.contains("PS/2") || (!m_Interface.isEmpty() && m_Interface.contains("PS/2"))) {
return "/proc/acpi/wakeup";
+
} else {
return QString("/sys") + m_SysPath.left(index) + QString("/power/wakeup");
} |
根因分析
结论:强根因
DeviceInput::wakeupPath()(DeviceInput.cpp:508) 中 PS/2 设备判断条件与同文件的isWakeupMachine()(:484) 不一致。wakeupPath()仅判断m_Name.contains("PS/2"),而isWakeupMachine()正确使用了m_Name.contains("PS/2") || m_Interface.contains("PS/2")。L420 内置 PS/2 键盘名称为 "AT Translated Set 2 keyboard"(不含 "PS/2" 字符串),导致
wakeupPath()返回错误的 sysfs 路径/sys/.../power/wakeup(该路径在 PS/2 设备上不存在),使canWakeupMachine()中QFile::open()失败返回false,右键菜单中"允许唤起电脑"选项因此被禁用。关键证据:
DeviceInput.cpp:508—wakeupPath()仅判断m_NameDeviceInput.cpp:484—isWakeupMachine()判断m_Name || m_InterfaceDBusWakeupInterface.cpp:50注释明确:PS/2 设备只能通过 ACPI 接口控制,无 sysfs wakeup 节点修复方案
在
wakeupPath()的 PS/2 判断中增加m_Interface.contains("PS/2"),与isWakeupMachine()逻辑对齐:改动安全评估
低风险。仅扩展 PS/2 判断条件,函数签名不变。所有调用者(
canWakeupMachine()、isWakeupMachine()、PageMultiInfo::getTableListInfo())均受益或不受影响,无历史回归风险。Summary by Sourcery
Bug Fixes: