Repository navigation
fix: install the missing bluetooth DConfig meta file - #531
Conversation
Reviewer's guide (collapsed on small PRs)Reviewer's GuideInstalls the previously unshipped Bluetooth DConfig metadata for org.deepin.dde.tray-loader and updates scanInterval reads and change notifications to use that app ID, preserving the default 5-second interval. Sequence diagram for Bluetooth scan interval configurationsequenceDiagram
participant BluetoothAdapterItem
participant DConfigHelper
participant QTimer
BluetoothAdapterItem->>DConfigHelper: getConfig(org.deepin.dde.tray-loader, scanInterval, 5)
DConfigHelper-->>BluetoothAdapterItem: configured value or default 5
BluetoothAdapterItem->>QTimer: setInterval(scanInterval * 1000)
DConfigHelper-->>BluetoothAdapterItem: bind scanInterval change
DConfigHelper->>BluetoothAdapterItem: scanInterval callback
BluetoothAdapterItem->>DConfigHelper: getConfig(org.deepin.dde.tray-loader, scanInterval, 5)
DConfigHelper-->>BluetoothAdapterItem: updated value or default 5
BluetoothAdapterItem->>QTimer: setInterval(scanInterval * 1000)
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
Hey - I've found 1 issue
Prompt for AI Agents
Please address the comments from this code review:
## Individual Comments
### Comment 1
<location path="plugins/dde-dock/bluetooth/componments/bluetoothadapteritem.cpp" line_range="407" />
<code_context>
- m_scanTimer->setInterval(DConfigHelper::instance()->getConfig("org.deepin.dde.dock", "org.deepin.dde.dock.plugin.bluetooth", "", "scanInterval", 5).toInt() * 1000);
+ m_scanTimer->setInterval(DConfigHelper::instance()->getConfig("org.deepin.dde.tray-loader", "org.deepin.dde.dock.plugin.bluetooth", "", "scanInterval", 5).toInt() * 1000);
+ DConfigHelper::instance()->bind("org.deepin.dde.tray-loader", "org.deepin.dde.dock.plugin.bluetooth", "", this, "scanInterval", [this] (const QString&, const QVariant&, QObject*) {
+ m_scanTimer->setInterval(DConfigHelper::instance()->getConfig("org.deepin.dde.tray-loader", "org.deepin.dde.dock.plugin.bluetooth", "", "scanInterval", 5).toInt() * 1000);
});
connect(m_scanTimer, &QTimer::timeout, this, [this] {
</code_context>
<issue_to_address>
**Zero interval triggers repeated scans**
When an override sets `scanInterval` to 0, `toInt() * 1000` passes a zero interval to `m_scanTimer`; its timeout emits `requestRefreshAdapter` and stops the timer, so each completed refresh restarts an immediate scan and Bluetooth discovery churns continuously.
Reject or clamp non-positive `scanInterval` values before setting the timer interval.
</issue_to_address>The bluetooth plugin's scanInterval configuration meta exists in the source tree but has no install rule, and the plugin reads it with the legacy org.deepin.dde.dock app id. On a clean system DConfig cannot load the resource, so every scanInterval read logs warnings and the configured value is never used. The configuration was never shipped in a package before, so install it only for org.deepin.dde.tray-loader, and read scanInterval with the tray-loader app id used by the other plugins. DConfig does not enforce a range for scanInterval. A value of 0 makes QTimer fire immediately, so discovery restarts as soon as it finishes and Bluetooth scanning churns continuously. Fall back to the default 5-second interval when the configured value is missing, non-numeric, or not positive. Log: install the missing bluetooth DConfig meta file Influence: 1. Verify org.deepin.dde.dock.plugin.bluetooth.json is installed under /usr/share/dsg/configs/org.deepin.dde.tray-loader/ 2. Verify bluetooth scanInterval is read from DConfig and no DConfig warning is logged for this config at startup 3. Verify the default 5-second interval still applies when the key is not overridden 4. Verify 0, negative, or non-numeric scanInterval values fall back to the 5-second default fix: 补齐蓝牙插件缺失的 DConfig 元数据文件 蓝牙插件的 scanInterval 配置元数据文件在源码中存在,但没有安装规则, 且插件仍使用旧的 org.deepin.dde.dock app id 读取。干净系统上 DConfig 无法加载该资源,导致每次读取 scanInterval 都打印告警,配置值也永远 不生效。 该配置此前从未随包发布,因此仅为 org.deepin.dde.tray-loader 安装 org.deepin.dde.dock.plugin.bluetooth.json,并改用其他插件统一使用的 tray-loader app id 读取 scanInterval。 DConfig 不会校验 scanInterval 的范围。值为 0 时 QTimer 会立即触发, 导致蓝牙发现刚结束就重新开始,形成持续扫描。当配置缺失、非数字或 不是正数时,回退到默认的 5 秒间隔。 Log: 补齐蓝牙插件缺失的 DConfig 元数据文件 Influence: 1. 验证 org.deepin.dde.dock.plugin.bluetooth.json 已安装到 /usr/share/dsg/configs/org.deepin.dde.tray-loader/ 2. 验证蓝牙 scanInterval 从 DConfig 读取,启动时不再打印该配置的 DConfig 告警 3. 验证未覆盖配置时仍使用默认 5 秒间隔 4. 验证 scanInterval 为 0、负数或非数字时回退到默认 5 秒间隔 PMS: TASK-394335
84f7a58 to
e4b218e
Compare
deepin pr auto review🤖 AI 代码审查报告📊 总体评价
🔍 详细分析1. 语法逻辑 ✅评价: 优秀 ✅ 通过 潜在问题: 建议: 语法正确,逻辑清晰。新增 scanIntervalMs() 使用 toInt(&ok) 校验转换结果,并以 !ok || seconds <= 0 兜底默认值,边界处理完善;CMakeLists.txt 新增的 dtk_add_config_meta_files 调用语法与同目录其它插件一致。 2. 代码质量 ✅评价: 优秀 ✅ 通过 潜在问题: 建议: 代码结构清晰,注释完整。将原先在 initConnect() 中重复两处的配置读取抽取为匿名命名空间内的 scanIntervalMs() 单一职责函数,消除重复代码;constexpr DefaultScanIntervalSeconds 命名清晰;关键校验逻辑配有英文注释说明 QTimer 将 0 视为立即触发的设计动机。app id 由 org.deepin.dde.dock 统一替换为 org.deepin.dde.tray-loader,与 power/sound/shutdown 等插件保持一致。 3. 代码性能 ✅评价: 优秀 ✅ 通过 潜在问题: 建议: 性能良好,资源使用合理。scanIntervalMs() 仅在初始化与配置变更回调时调用,计算量极小(单次 DConfig 读取 + 一次乘法),无频繁系统调用、无重复计算、无不必要拷贝。 4. 代码安全 🔒评价: 优秀 ✅ 通过
安全漏洞详情: 建议: 存在0个安全漏洞,安全合规。无用户输入直接进入危险操作,无硬编码密钥/敏感信息。新增的 !ok || seconds <= 0 校验属于防御性编程增强,避免配置被写入 0 或负值导致 QTimer 立即反复触发扫描(潜在的资源耗用),提升了健壮性。 💡 改进建议代码示例// 当前实现已足够完善。如需进一步加固,可对极端大值做上限裁剪,
// 防止 seconds*1000 在 int 上溢出(DConfig 配置值 realistically 较小,
// 此为可选硬化,非缺陷):
//
// int scanIntervalMs()
// {
// bool ok = false;
// int seconds = DConfigHelper::instance()->getConfig(
// "org.deepin.dde.tray-loader",
// "org.deepin.dde.dock.plugin.bluetooth",
// QString(),
// "scanInterval",
// DefaultScanIntervalSeconds).toInt(&ok);
//
// if (!ok || seconds <= 0 || seconds > 86400) // 上限 24 小时
// seconds = DefaultScanIntervalSeconds;
//
// return seconds * 1000;
// }本报告由 AI 代码审查工具自动生成 |
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: BLumia, Ivy233 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 |
The bluetooth plugin's scanInterval configuration meta exists in the source tree but has no install rule, and the plugin reads it with the legacy org.deepin.dde.dock app id. On a clean system DConfig cannot load the resource, so every scanInterval read logs warnings and the configured value is never used.
The configuration was never shipped in a package before, so install it only for org.deepin.dde.tray-loader, and read scanInterval with the tray-loader app id used by the other plugins.
Log: install the missing bluetooth DConfig meta file
Influence:
fix: 补齐蓝牙插件缺失的 DConfig 元数据文件
蓝牙插件的 scanInterval 配置元数据文件在源码中存在,但没有安装规则,
且插件仍使用旧的 org.deepin.dde.dock app id 读取。干净系统上 DConfig 无法加载该资源,导致每次读取 scanInterval 都打印告警,配置值也永远
不生效。
该配置此前从未随包发布,因此仅为 org.deepin.dde.tray-loader 安装
org.deepin.dde.dock.plugin.bluetooth.json,并改用其他插件统一使用的 tray-loader app id 读取 scanInterval。
Log: 补齐蓝牙插件缺失的 DConfig 元数据文件
Influence:
PMS: TASK-394335
Summary by Sourcery
Ensure Bluetooth scan interval configuration is packaged and applied reliably through DConfig.
Bug Fixes:
Enhancements: