Skip to content

Conversation

@add-uos
Copy link
Contributor

@add-uos add-uos commented Dec 16, 2025

disable bluetooth failed due to name

log: fix the disable bluetooth failed
bug: https://pms.uniontech.com/bug-view-341783.html
Change-Id: I4495dc67a1480ae3695c253b474e3dd45c11442a

Summary by Sourcery

Bug Fixes:

  • Fix a Bluetooth disable failure caused by strict handling of the device Name attribute in hciconfig output.

disable bluetooth failed due to name

log: fix the disable bluetooth failed
bug: https://pms.uniontech.com/bug-view-341783.html
Change-Id: I4495dc67a1480ae3695c253b474e3dd45c11442a
@sourcery-ai
Copy link

sourcery-ai bot commented Dec 16, 2025

Reviewer's guide (collapsed on small PRs)

Reviewer's Guide

Adjusts how the Bluetooth device name attribute is set from hciconfig so that disabling Bluetooth is not blocked by missing or malformed Name data.

Class diagram for updated DeviceBluetooth attribute handling

classDiagram
    class DeviceBluetooth {
        - QString m_Name
        - QString m_Alias
        - QString m_Vendor
        - QString m_Version
        + DeviceBluetooth()
        + void setInfoFromHciconfig(QMap~QString, QString~ mapInfo)
        + void setAttribute(QMap~QString, QString~ mapInfo, QString key, QString& target)
        + void setAttribute(QMap~QString, QString~ mapInfo, QString key, QString& target, bool required)
    }

    DeviceBluetooth : setInfoFromHciconfig() uses setAttribute(mapInfo, Name, m_Name, required = false)
    DeviceBluetooth : setInfoFromHciconfig() uses setAttribute(mapInfo, Alias, m_Alias)
    DeviceBluetooth : setInfoFromHciconfig() uses setAttribute(mapInfo, Manufacturer, m_Vendor)
    DeviceBluetooth : setInfoFromHciconfig() uses setAttribute(mapInfo, HCI_Version, m_Version, required = true)
Loading

File-Level Changes

Change Details Files
Modify Bluetooth device attribute parsing so the Name field is treated as optional/non-strict, preventing failures when disabling Bluetooth if the Name is absent or invalid.
  • Change the DeviceBluetooth::setInfoFromHciconfig call for the Name field to pass an explicit flag disabling strict handling
  • Keep Alias, Manufacturer, and HCI Version attribute handling unchanged
deepin-devicemanager/src/DeviceManager/DeviceBluetooth.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-ci-robot
Copy link

deepin pr auto review

我来对这个代码变更进行审查:

  1. 语法逻辑:
  • 修改了setAttribute函数的调用,添加了第三个参数false
  • 从上下文看,这应该是控制是否进行某种转换或处理的标志
  • 语法上是正确的,没有问题
  1. 代码质量:
  • 修改后的代码更加明确地表达了意图,通过显式指定false参数来控制行为
  • 建议在setAttribute函数声明处添加注释说明这个布尔参数的具体含义
  • 可以考虑使用枚举类型替代布尔参数,以提高代码可读性
  1. 代码性能:
  • 这个修改不会对性能产生显著影响
  • 只是一个函数调用参数的修改,没有引入额外的计算开销
  1. 代码安全:
  • 修改本身不会引入安全问题
  • 但建议确保setAttribute函数对布尔参数的处理是安全的,特别是当传入false值时

改进建议:

  1. 建议在setAttribute函数声明处添加注释,说明第三个参数的具体作用
  2. 考虑使用枚举类型替代布尔参数,例如:
enum class AttributeHandling {
    Default,
    Special
};
  1. 如果这个参数在多处使用,建议将其定义为常量,避免魔法数字
  2. 建议添加单元测试,确保当第三个参数为false时的行为符合预期

总体来说,这是一个合理的修改,提高了代码的明确性,但可以通过上述建议进一步提升代码质量。

Copy link

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

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

Hey there - I've reviewed your changes - here's some feedback:

  • Consider adding a brief code comment or using a more self-descriptive parameter (e.g., via an enum or named constant) for the false argument to setAttribute(mapInfo, "Name", m_Name, false) so future readers understand why the behavior for Name differs from other attributes.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- Consider adding a brief code comment or using a more self-descriptive parameter (e.g., via an enum or named constant) for the `false` argument to `setAttribute(mapInfo, "Name", m_Name, false)` so future readers understand why the behavior for `Name` differs from other attributes.

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

@deepin-ci-robot
Copy link

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: add-uos, max-lvs

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

@add-uos
Copy link
Contributor Author

add-uos commented Dec 16, 2025

/forcemerge

@deepin-bot
Copy link
Contributor

deepin-bot bot commented Dec 16, 2025

This pr force merged! (status: unstable)

@deepin-bot deepin-bot bot merged commit bc08e5b into linuxdeepin:develop/eagle Dec 16, 2025
16 of 18 checks passed
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