Skip to content

fix: install the missing bluetooth DConfig meta file - #531

Merged
Ivy233 merged 1 commit into
linuxdeepin:masterfrom
Ivy233:fix/bluetooth-dconfig-meta
Oct 19, 2026
Merged

Ivy233 merged 1 commit into
linuxdeepin:masterfrom
Ivy233:fix/bluetooth-dconfig-meta

Conversation

@Ivy233

@Ivy233 Ivy233 commented Oct 19, 2026 •

Copy link
Copy Markdown
Contributor

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:

  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

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:

  1. 验证 org.deepin.dde.dock.plugin.bluetooth.json 已安装到 /usr/share/dsg/configs/org.deepin.dde.tray-loader/
  2. 验证蓝牙 scanInterval 从 DConfig 读取,启动时不再打印该配置的 DConfig 告警
  3. 验证未覆盖配置时仍使用默认 5 秒间隔

PMS: TASK-394335

Summary by Sourcery

Ensure Bluetooth scan interval configuration is packaged and applied reliably through DConfig.

Bug Fixes:

  • Install the Bluetooth plugin’s DConfig metadata and use the tray-loader application ID so scanInterval settings load correctly without startup warnings.

Enhancements:

  • Preserve the five-second default interval and reject invalid or non-positive configured values.

@sourcery-ai

sourcery-ai Bot commented Oct 19, 2026

Copy link
Copy Markdown
Reviewer's guide (collapsed on small PRs)

Reviewer's Guide

Installs 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 configuration

sequenceDiagram
    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)
Loading

File-Level Changes

Change Details Files
Install the Bluetooth plugin’s DConfig metadata for the tray-loader application.
  • Add a CMake install rule for the Bluetooth configuration JSON using the tray-loader app ID.
  • Place the metadata under the tray-loader DConfig configuration directory at installation time.
plugins/dde-dock/bluetooth/CMakeLists.txt
Read and monitor scanInterval through the tray-loader DConfig application ID.
  • Switch the initial scanInterval lookup from the legacy dock app ID to org.deepin.dde.tray-loader.
  • Switch the configuration binding and refresh lookup to the same app ID while retaining the 5-second fallback.
plugins/dde-dock/bluetooth/componments/bluetoothadapteritem.cpp

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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>

Sourcery is free for open source - if you like our reviews please consider sharing them ✨

Comment thread plugins/dde-dock/bluetooth/componments/bluetoothadapteritem.cpp Outdated
BLumia
BLumia previously approved these changes Oct 19, 2026
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
@Ivy233
Ivy233 force-pushed the fix/bluetooth-dconfig-meta branch from 84f7a58 to e4b218e Compare October 19, 2026 09:27
@deepin-ci-robot

Copy link
Copy Markdown

deepin pr auto review

🤖 AI 代码审查报告

总体评分: 100 分 (通过阈值: 70分)

Pass


📊 总体评价

项目 结果
审查结论 代码审查通过
评分详情 总体评分 100 分,大于 70 分通过阈值。变更目的明确(补齐蓝牙插件缺失的 DConfig 元数据文件并统一 app id),实现正确、防御性增强,无安全漏洞,与既有插件(power/sound/shutdown/notification)安装规则一致。

🔍 详细分析

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 个安全漏洞

安全漏洞详情:
✅ 未发现安全漏洞

建议: 存在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 代码审查工具自动生成

@deepin-ci-robot

Copy link
Copy Markdown

[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.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@Ivy233
Ivy233 merged commit f757713 into linuxdeepin:master Oct 19, 2026
9 checks passed
@Ivy233
Ivy233 deleted the fix/bluetooth-dconfig-meta branch October 19, 2026 10:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants