fix(power): respect shutdown inhibitors - #164
Conversation
1. Check logind block inhibitors before scheduled shutdown. 2. Open ShutdownFront when an application blocks shutdown. Log: Prevent scheduled shutdown from bypassing block inhibitors. Influence: Blocking applications are shown instead of logout. fix(power): 遵循关机强阻塞 1. 定时关机前检查 logind 强阻塞项。 2. 存在程序阻止关机时打开 ShutdownFront 提示界面。 Log: 防止定时关机绕过应用程序的关机强阻塞。 PMS: BUG-375851 Influence: 显示阻塞程序,不再异常进入登录界面。 Change-Id: I5de0f44647bb121cd91ebb5535e675fe2b53b4f2
Reviewer's guide (collapsed on small PRs)Reviewer's GuideScheduled shutdowns now check for shutdown block inhibitors, presenting the shutdown UI with the blocking program when necessary while retaining direct shutdown behavior when no inhibitor exists. Sequence diagram for inhibitor-aware scheduled shutdownsequenceDiagram
participant Timer as ScheduledShutdown
participant PowerManager
participant Logind as ShutdownInhibitors
participant ShutdownFront
participant System as PowerSystem
Timer->>PowerManager: doAutoShutdown()
PowerManager->>Logind: isInConfigOrPowerButtonInhibitors(shutdown, who)
alt shutdown inhibitor exists
Logind-->>PowerManager: true, who
PowerManager->>ShutdownFront: requestShutdownByFront()
else no shutdown inhibitor
Logind-->>PowerManager: false
PowerManager->>System: requestShutdown()
end
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
deepin pr auto review🤖 AI 代码审查报告📊 总体评价
🔍 详细分析1. 语法逻辑 ✅评价: 优秀 ✅ 通过 潜在问题: 建议: 语法正确,逻辑清晰。doAutoShutdown() 函数在调用 closeNotify() 后,先通过 isInConfigOrPowerButtonInhibitors 检查是否存在关机强阻塞项,若存在则调用 requestShutdownByFront() 弹出前端提示界面,否则调用 requestShutdown() 直接关机。逻辑与 doSuspend()、doShutdown()、doHibernate() 中的 inhibitor 检查模式一致。 2. 代码质量 ✅评价: 优秀 ✅ 通过 潜在问题: 建议: 代码结构与现有模式一致,可读性好。建议在 doAutoShutdown() 中添加简要注释说明为何使用 blockOnly 默认值 true(仅检查强阻塞),与 doShutdown() 的 blockOnly=false 区分。closeNotify() 在 inhibitor 检查前调用是合理的,因为 requestShutdownByFront() 会展示自己的 UI 界面。 3. 代码性能 ✅评价: 优秀 ✅ 通过 潜在问题: 建议: 性能良好,资源使用合理。isInConfigOrPowerButtonInhibitors() 通过 D-Bus 获取 inhibitor 列表,这是必要的一次性调用,与 doSuspend()、doHibernate() 中的使用方式一致,无性能瓶颈。 4. 代码安全 🔒评价: 优秀 ✅ 通过
安全漏洞详情: 建议: 存在0个安全漏洞,安全合规。who 变量来源于 D-Bus 返回的 inhibitor 信息,仅用于日志输出,不存在注入风险。代码使用 Qt QString 安全处理字符串,无缓冲区溢出风险。 💡 改进建议代码示例// 建议在 doAutoShutdown() 中添加注释说明 blockOnly 差异
void PowerManager::doAutoShutdown()
{
qInfo(logPowerSession) << "Performing auto shutdown";
closeNotify();
QString who;
// 仅检查 block 模式的强阻塞(与 doShutdown 的 blockOnly=false 不同,
// 定时关机不需要响应 delay 模式的延迟阻塞)
if (isInConfigOrPowerButtonInhibitors(QStringLiteral("shutdown"), who)) {
qInfo(logPowerSession) << "Scheduled shutdown blocked by" << who;
m_proxy->requestShutdownByFront();
} else {
m_proxy->requestShutdown();
}
}本报告由 AI 代码审查工具自动生成 |
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: fly602, mhduiy 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 |
|
/forcemerge |
|
This pr force merged! (status: blocked) |
修复定时关机绕过关机强阻塞的问题。
PMS: BUG-375851
Summary by Sourcery
Bug Fixes: