-
Notifications
You must be signed in to change notification settings - Fork 11
refactor: remove PowerManager interface dependency #50
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Synchronize source files from linuxdeepin/dde-session-shell. Source-pull-request: linuxdeepin/dde-session-shell#50
| return canHibernate == "yes"; | ||
| } | ||
|
|
||
| bool AuthInterface::detectVirtualMachine() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
大括号换行
Synchronize source files from linuxdeepin/dde-session-shell. Source-pull-request: linuxdeepin/dde-session-shell#50
Synchronize source files from linuxdeepin/dde-session-shell. Source-pull-request: linuxdeepin/dde-session-shell#50
Synchronize source files from linuxdeepin/dde-session-shell. Source-pull-request: linuxdeepin/dde-session-shell#50
1. Removed PowerManager D-Bus interface dependency from the authentication system 2. Replaced PowerManager calls with direct login1 D-Bus interface calls for power management 3. Added local power capability detection methods (canSuspend/ canHibernate) that check system files and login1 interface 4. Implemented virtual machine detection to disable power features in VM environments 5. Removed all PowerManager related XML definitions, adaptors, and constants 6. Simplified power info checking logic by removing environment variable fallbacks This change eliminates the dependency on the deprecated PowerManager service and uses the standard login1 interface directly, making the code more maintainable and reducing external dependencies. Influence: 1. Test suspend/hibernate functionality on physical machines 2. Verify power options are disabled in virtual machine environments 3. Test power actions with different system configurations 4. Ensure power state detection works correctly with login1 interface 5. Verify no regression in lock screen power management features 重构:移除 PowerManager 接口依赖 1. 从认证系统中移除了 PowerManager D-Bus 接口依赖 2. 将 PowerManager 调用替换为直接的 login1 D-Bus 接口调用进行电源管理 3. 添加了本地电源能力检测方法(canSuspend/canHibernate),检查系统文件和 login1 接口 4. 实现了虚拟机检测功能,在虚拟环境中禁用电源功能 5. 移除了所有与 PowerManager 相关的 XML 定义、适配器和常量 6. 通过移除环境变量回退简化了电源信息检查逻辑 此更改消除了对已弃用的 PowerManager 服务的依赖,直接使用标准的 login1 接 口,使代码更易于维护并减少外部依赖。 影响: 1. 在物理机上测试挂起/休眠功能 2. 验证虚拟环境中电源选项被禁用 3. 使用不同系统配置测试电源操作 4. 确保通过 login1 接口的电源状态检测正常工作 5. 验证锁屏电源管理功能没有回归问题
Synchronize source files from linuxdeepin/dde-session-shell. Source-pull-request: linuxdeepin/dde-session-shell#50
deepin pr auto review我来对这段代码变更进行审查:
a) 虚拟机检测部分: bool AuthInterface::detectVirtualMachine()
{
QProcess process;
process.start("/usr/bin/systemd-detect-virt", QStringList());
if (!process.waitForFinished(3000)) {
qWarning() << "Timeout detecting virtual machine";
return false;
}
if (process.exitCode() != 0) {
qWarning() << "Failed to detect virtual machine, error:" << process.errorString();
return false;
}
QString name = QString::fromUtf8(process.readAllStandardOutput()).trimmed();
return name != "none" && !name.isEmpty();
}建议改进:
b) 电源状态检测部分: bool AuthInterface::canSuspend()
{
if (QString(getenv("POWER_CAN_SLEEP")) == "0" || m_isVM)
return false;
if (!QFile::exists("/sys/power/mem_sleep"))
return false;
QString canSuspend = m_login1Inter->CanSuspend();
return canSuspend == "yes";
}建议改进:
这些变更总体上是好的,移除了不必要的依赖,简化了代码结构,但在错误处理和健壮性方面还有改进空间。 |
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: fly602, yixinshark The full list of commands accepted by this bot can be found here.
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
Synchronize source files from linuxdeepin/dde-session-shell. Source-pull-request: linuxdeepin/dde-session-shell#50
This change eliminates the dependency on the deprecated PowerManager service and uses the standard login1 interface directly, making the code more maintainable and reducing external dependencies.
Influence:
重构:移除 PowerManager 接口依赖
此更改消除了对已弃用的 PowerManager 服务的依赖,直接使用标准的 login1 接
口,使代码更易于维护并减少外部依赖。
影响: