Skip to content

fix: add missing audio-avrcp-target icon mapping for bluetooth - #508

Draft
mhduiy wants to merge 1 commit into
masterfrom
agent/pms-bug-bot/7ff158b69f3c
Draft

mhduiy wants to merge 1 commit into
masterfrom
agent/pms-bug-bot/7ff158b69f3c

Conversation

@mhduiy

@mhduiy mhduiy commented Sep 14, 2026 •

Copy link
Copy Markdown
Contributor

Root Cause Analysis

The deviceType2Icon static map in plugins/dde-dock/bluetooth/componments/device.cpp was missing the audio-avrcp-target icon string introduced by BlueZ 5.85. When a bluetooth audio device supports the AVRCP profile, BlueZ sets its Icon property to audio-avrcp-target, which fails the map lookup. The QMap::operator[] returns an empty QString for unmatched keys, causing the rendering logic in bluetoothadapteritem.cpp to fall back to bluetooth_other (unknown icon). A previous fix (BUG-275675) added audio-headset and audio-headphones but omitted audio-avrcp-target.

Fix

Added {"audio-avrcp-target", "pheadset"} to the deviceType2Icon map, and changed QMap::operator[] to .value(deviceType, "other") in setDeviceType() so that any future unmapped icon string falls back to "other" instead of an empty string, providing a more robust default.

Change Safety Assessment

Code Safety

  • Risk Level: Low
  • The target code was part of a previous bug fix (BUG-275675); this change extends that fix in the same direction without reverting any historical behavior
  • All 3 callers of setDeviceType (adapter.cpp:55, adapter.cpp:101, adapter.cpp:140) pass BlueZ device type strings and are unaffected by the lookup method change — previously unmatched types returned empty string (falling back to bluetooth_other), now return "other" directly (same visual result)

Business Impact Scope

Bluetooth device icon display in the taskbar. AVRCP-capable bluetooth audio devices (headsets, speakers) will now show the correct headset icon instead of the unknown device icon. All other device types (keyboard, mouse, phone, etc.) are unaffected.

Verification Suggestion

Test bluetooth headset/speaker with AVRCP profile shows the correct icon. Verify common bluetooth devices (keyboard, mouse, phone) still show correct icons with no regression.


根因分析

plugins/dde-dock/bluetooth/componments/device.cpp 中的 deviceType2Icon 静态映射表缺少 BlueZ 5.85 引入的 audio-avrcp-target 图标字符串。当蓝牙音频设备支持 AVRCP 配置文件时,BlueZ 将其 Icon 属性设为 audio-avrcp-target,映射查找失败后 QMap::operator[] 返回空 QString,导致 bluetoothadapteritem.cpp 渲染逻辑回退到 bluetooth_other(未知图标)。此前修复(BUG-275675)添加了 audio-headset 和 audio-headphones 但遗漏了 audio-avrcp-target。

修复方案

在 deviceType2Icon 映射表中添加 {"audio-avrcp-target", "pheadset"} 条目,并将 setDeviceType() 中的 QMap::operator[] 改为 .value(deviceType, "other"),使未来未映射的图标字符串直接回退到 "other" 而非空字符串,提供更健壮的默认值。

改动安全评估

代码安全评估

  • 风险等级: 低风险
  • 目标代码为此前 BUG-275675 修复的产物,本次修改沿同一方向扩展,不回退任何历史行为
  • setDeviceType 的 3 个调用方(adapter.cpp:55、adapter.cpp:101、adapter.cpp:140)均传入 BlueZ 设备类型字符串,查找方式变更对其无影响——此前未匹配类型返回空字符串(回退到 bluetooth_other),现在直接返回 "other"(视觉效果一致)

业务影响范围

任务栏蓝牙设备图标显示。支持 AVRCP 配置文件的蓝牙音频设备(耳机、音箱)现在将显示正确的耳机图标而非未知设备图标。其他设备类型(键盘、鼠标、手机等)不受影响。

验证建议

测试支持 AVRCP 配置文件的蓝牙耳机/音箱显示正确图标。验证常见蓝牙设备(键盘、鼠标、手机)图标显示无回归。

Summary by Sourcery

Fix Bluetooth device icon resolution for AVRCP audio devices and unknown device types.

Bug Fixes:

  • Correct Bluetooth AVRCP audio device icon mapping so compatible headsets and speakers display the headset icon.

Enhancements:

  • Provide a consistent fallback icon type for unmapped Bluetooth device types.

1. Root cause: deviceType2Icon map lacked the "audio-avrcp-target"
   entry introduced by BlueZ 5.85, causing AVRCP-capable bluetooth
   audio devices to show bluetooth_other instead of bluetooth_pheadset
2. Fix: add {"audio-avrcp-target", "pheadset"} to the map, and change
   QMap::operator[] to .value(key, "other") so unmapped icon strings
   fall back to "other" instead of an empty string
3. Impact: bluetooth audio devices with AVRCP profile now display the
   correct headset icon; all other device types unaffected

Log: Fixed bluetooth audio device icon showing as unknown when device supports AVRCP profile

Influence:
1. Test bluetooth headset/speaker with AVRCP profile shows correct icon
2. Test common bluetooth devices (keyboard, mouse, phone) show correct icons
3. Verify unmapped device types fall back to default icon

fix: 补充蓝牙音频设备 audio-avrcp-target 图标映射

1. 根因:deviceType2Icon 映射表缺少 BlueZ 5.85 引入的
   "audio-avrcp-target" 条目,导致支持 AVRCP 配置文件的蓝牙音频
   设备显示 bluetooth_other 而非 bluetooth_pheadset
2. 方案:在映射表中添加 {"audio-avrcp-target", "pheadset"} 条目,
   并将 QMap::operator[] 改为 .value(key, "other"),使未映射的
   图标字符串回退到 "other" 而非空字符串
3. 影响:支持 AVRCP 配置文件的蓝牙音频设备现在显示正确的耳机
   图标,其他设备类型不受影响

Log: 修复支持 AVRCP 配置文件的蓝牙音频设备图标显示为未知的问题

Influence:
1. 测试支持 AVRCP 配置文件的蓝牙耳机/音箱显示正确图标
2. 测试常见蓝牙设备(键盘、鼠标、手机)图标显示无回归
3. 验证未映射设备类型回退到默认图标

PMS: BUG-324977
@deepin-ci-robot

Copy link
Copy Markdown

Skipping CI for Draft Pull Request.
If you want CI signal for your change, please convert it to an actual PR.
You can still manually trigger a test run with /test all

@deepin-ci-robot

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: mhduiy

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

@sourcery-ai

sourcery-ai Bot commented Sep 14, 2026

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

Reviewer's Guide

The PR updates Bluetooth device icon resolution to correctly render AVRCP-capable audio devices as headsets while preserving existing mappings and making unknown BlueZ types resolve explicitly to the generic other icon.

Flow diagram for Bluetooth device icon resolution

flowchart TD
    A[BlueZ device type] --> B{deviceType2Icon lookup}
    B -->|audio-avrcp-target| C[pheadset icon]
    B -->|known device type| D[Mapped icon]
    B -->|unmapped device type| E[other icon]
Loading

File-Level Changes

Change Details Files
Adds BlueZ 5.85 AVRCP audio-type recognition and a direct fallback for unknown device types.
  • Maps audio-avrcp-target to the headset icon category.
  • Uses QMap::value with an other default instead of inserting/returning an empty value for missing keys.
plugins/dde-dock/bluetooth/componments/device.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

@deepin-bot

deepin-bot Bot commented Sep 22, 2026

Copy link
Copy Markdown

TAG Bot

New tag: 2.0.41
DISTRIBUTION: unstable
Suggest: synchronizing this PR through rebase #520

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.

2 participants