Repository navigation
fix(input): fix PS/2 keyboard missing wake-up option in context menu - #835
GongHeng2017 wants to merge 1 commit into
Conversation
1. 根因:getPS2Syspath() 在 event 号匹配失败时不剥离 m_SysPath
尾部 /input/inputN 后缀即返回 true,导致下游 wakeupPath() 拼接
路径多出一级 input,canWakeupMachine() 打开文件失败返回 false,
右键菜单不显示"允许唤起电脑"选项
2. 方案1(根因层):getPS2Syspath() return true 前新增兜底正则剥离
/input/inputN 后缀,确保 m_SysPath 始终为不含后缀的设备路径
3. 方案2(症状层):wakeupPath() 判断条件由 m_Name.contains("PS/2")
补齐为 m_Name.contains("PS/2") || m_Interface.contains("PS/2"),
与同文件 isWakeupMachine() 逻辑统一
4. 影响:PS/2 键盘(如 AT Translated Set 2 keyboard)右键菜单恢复
显示"允许唤起电脑"选项;非 PS/2 设备不受影响
Log: 修复PS/2键盘右键菜单缺少允许唤起电脑选项的问题
Influence:
1. 测试PS/2键盘右键菜单显示"允许唤起电脑"选项
2. 测试非PS/2设备右键菜单和唤醒功能不受影响
3. 验证getPS2Syspath()在event号匹配失败时正确剥离路径后缀
PMS: BUG-294489
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: GongHeng2017 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 missing PS/2 keyboard wake-up actions by correcting fallback sysfs path normalization and aligning wake-up path selection with both the device name and interface identifiers. Sequence diagram for PS/2 keyboard wake-up path selectionsequenceDiagram
participant DeviceManager
participant DeviceInput
participant WakeupCheck
DeviceManager->>DeviceInput: getPS2Syspath(dfs)
alt event number matched
DeviceInput->>DeviceInput: m_SysPath normalized
else event number unmatched
DeviceInput->>DeviceInput: QRegExp.exactMatch(m_SysPath)
DeviceInput->>DeviceInput: m_SysPath = stripReg.cap(1)
end
DeviceInput-->>DeviceManager: return true
DeviceManager->>DeviceInput: wakeupPath()
alt m_Name.contains(PS/2) or m_Interface.contains(PS/2)
DeviceInput-->>DeviceManager: /proc/acpi/wakeup
else non-PS/2 device
DeviceInput-->>DeviceManager: /sys.../power/wakeup
end
DeviceManager->>WakeupCheck: canWakeupMachine()
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
deepin pr auto review🤖 AI 代码审查报告📊 总体评价
🔍 详细分析1. 语法逻辑 ✅评价: 优秀 ✅ 通过 潜在问题: 建议: 语法正确,逻辑清晰,边界处理完善。正则表达式 (.*)/input/input[0-9]{1,2}$ 语法正确,exactMatch() 和 cap(1) 方法使用正确。|| 条件扩展逻辑正确,与 isWakeupMachine() 逻辑统一。不匹配时保持原值不变,边界处理完善。 2. 代码质量 ✅评价: 优秀 ✅ 通过 潜在问题:
建议: 建议将 QRegExp 替换为 QRegularExpression,使用 QRegularExpression::match() 和 captured() 方法。注释完整清晰,代码结构合理,变更最小化。 3. 代码性能 ✅评价: 优秀 ✅ 通过 潜在问题: 建议: 性能良好,资源使用合理。正则匹配操作在短字符串(设备路径)上执行,性能影响可忽略。无频繁系统调用,无资源泄漏。 4. 代码安全 🔒评价: 优秀 ✅ 通过
安全漏洞详情: 建议: 存在0个安全漏洞。m_SysPath 为内部变量,非用户直接输入,无注入风险。无硬编码密钥,无敏感信息泄露。 💡 改进建议代码示例// 建议使用 QRegularExpression 替代 QRegExp
#include <QRegularExpression>
// 兜底:event 号匹配失败时 m_SysPath 仍可能带有 /input/inputN 后缀,剥离之
QRegularExpression stripReg("(.*)/input/input[0-9]{1,2}$");
QRegularExpressionMatch match = stripReg.match(m_SysPath);
if (match.hasMatch()) {
m_SysPath = match.captured(1);
}本报告由 AI 代码审查工具自动生成 |
修复 PMS BUG-294489
问题描述:在华为 L420 笔记本上打开设备管理器→键盘页面,右键键盘设备"AT Translated Set 2 keyboard"时,右键菜单中缺少"允许唤起电脑"选项。
根因分析:
根因层:
DeviceInput::getPS2Syspath()在 event 号匹配失败时不剥离m_SysPath尾部/input/inputN后缀即返回true,导致下游wakeupPath()拼接路径多出一级input,canWakeupMachine()打开文件失败返回false,右键菜单不显示"允许唤起电脑"选项。症状层:
wakeupPath()仅判断m_Name.contains("PS/2"),而 "AT Translated Set 2 keyboard" 的m_Name不含 "PS/2"(但m_Interface = "PS/2"),导致 PS/2 设备误走 sysfs 路径分支。同文件isWakeupMachine()已使用m_Name || m_Interface双条件判断,两者不一致。修复方案(双方案,经方案裁决通过):
DeviceInput.cpp:210getPS2Syspath()return true前兜底正则剥离/input/inputN后缀DeviceInput.cpp:508wakeupPath()m_Interface.contains("PS/2")PMS: https://pms.uniontech.com/bug-view-294489.html
目标分支: develop/eagle
Summary by Sourcery
Bug Fixes: