Repository navigation
fix(power): play low battery sound via SoundEffect1 DBus service - #206
Conversation
|
Skipping CI for Draft Pull Request. |
Reviewer's GuideRoutes all power-related sounds, including low-battery alerts, through a shared SoundEffect1 DBus utility, allowing the service to apply sound settings and theme resolution consistently while removing duplicated playback code. Sequence diagram for unified power sound playbacksequenceDiagram
participant LowPowerManager
participant PowerManager
participant SoundEffect
participant SoundEffect1DBus
LowPowerManager->>SoundEffect: playSystemSound(power-unplug-battery-low)
PowerManager->>SoundEffect: playSystemSound(power-unplug or power-plug)
PowerManager->>SoundEffect: playSystemSound(suspend-resume)
SoundEffect->>SoundEffect1DBus: PlaySound(soundEvent)
SoundEffect1DBus-->>SoundEffect: Apply sound settings and theme resolution
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
2363993 to
637f962
Compare
|
TAG Bot New tag: 1.0.48 |
|
TAG Bot New tag: 1.0.49 |
|
TAG Bot New tag: 1.0.50 |
f4acdf9 to
96f9a54
Compare
LowPowerManager::playBatterySound() was calling paplay with a hardcoded audio file path, bypassing the SoundEffect1 DBus service. This meant the sound effect toggle and sound theme lookup were skipped entirely. Extract the SoundEffect1 DBus call into a shared header-only utility (SoundEffect::playSystemSound) and use it in both LowPowerManager and PowerManager, making the low battery sound consistent with plug/unplug and suspend-resume sound behavior. PMS bug: https://pms.uniontech.com/bug-view-380987.html
96f9a54 to
85f327e
Compare
deepin pr auto review🤖 AI 代码审查报告📊 总体评价
🔍 详细分析1. 语法逻辑 ✅评价: 语法正确,逻辑清晰 ✅ 通过 潜在问题: 建议: ['无语法逻辑问题,代码可正常编译'] 2. 代码质量 ✅评价: 代码结构清晰,注释完整 ✅ 通过 潜在问题: 建议: ['建议在 soundeffectutil.h 中使用 QDBusPendingCallWatcher 监听异步调用结果, 在失败时输出 qWarning 日志,便于问题排查。示例: QDBusPendingCall call = QDBusConnection::sessionBus().asyncCall(msg); QDBusPendingCallWatcher *watcher = new QDBusPendingCallWatcher(call); QObject::connect(watcher, &QDBusPendingCallWatcher::finished, [](QDBusPendingCallWatcher *w) {\n QDBusPendingReply reply = *w;\n if (reply.isError())\n qWarning() << "Failed to play system sound:" << reply.error().message();\n w->deleteLater();\n});'] 3. 代码性能 ✅评价: 性能良好,资源使用合理 ✅ 通过 潜在问题: 建议: ['无性能问题,重构后性能有所提升'] 4. 代码安全 🔒评价: 存在0个安全漏洞 ✅ 通过
安全漏洞详情: 建议: ['无安全问题'] 💡 改进建议代码示例// soundeffectutil.h - 建议增加错误日志的可选改进版本
#ifndef SOUNDEFFECTUTIL_H
#define SOUNDEFFECTUTIL_H
#include <QString>
#include <QDBusMessage>
#include <QDBusConnection>
#include <QDBusPendingCall>
#include <QDBusPendingCallWatcher>
#include <QDBusPendingReply>
#include <QDebug>
namespace SoundEffect {
inline void playSystemSound(const QString &soundEvent)
{
QDBusMessage msg = QDBusMessage::createMethodCall(
QStringLiteral("org.deepin.dde.SoundEffect1"),
QStringLiteral("/org/deepin/dde/SoundEffect1"),
QStringLiteral("org.deepin.dde.SoundEffect1"),
QStringLiteral("PlaySound"));
msg << soundEvent;
QDBusPendingCall call = QDBusConnection::sessionBus().asyncCall(msg);
QDBusPendingCallWatcher *watcher = new QDBusPendingCallWatcher(call);
QObject::connect(watcher, &QDBusPendingCallWatcher::finished, [](QDBusPendingCallWatcher *w) {
QDBusPendingReply<void> reply = *w;
if (reply.isError())
qWarning() << "Failed to play system sound:" << reply.error().message();
w->deleteLater();
});
}
} // namespace SoundEffect
#endif // SOUNDEFFECTUTIL_H本报告由 AI 代码审查工具自动生成 |
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: 52cyb, 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) |
修复说明
低电量音效未通过 SoundEffect1 DBus 服务播放,
LowPowerManager::playBatterySound()直接调用paplay硬编码路径,绕过了音效开关检查和声音主题查找。修复后统一通过 SoundEffect1 DBus 服务播放,与插拔电源、休眠恢复音效逻辑一致。
变更内容
soundeffectutil.h— header-only 工具函数,在SoundEffect命名空间下通过 SoundEffect1 DBus 服务播放音效lowpowermanager.cpp—playBatterySound()从paplay改为SoundEffect::playSystemSound("power-unplug-battery-low")powermanager.cpp— 删除文件级static playSystemSound(),改用SoundEffect::playSystemSound()CMakeLists.txt— 将soundeffectutil.h加入_src_headers关联
Summary by Sourcery
Use the SoundEffect1 DBus service for all power and low-battery sounds instead of directly invoking a fixed audio player.
Bug Fixes:
Enhancements:
Build: