fix(bluetooth): prevent toggling bluetooth power state in airplane mode#436
Merged
robertkill merged 1 commit intolinuxdeepin:masterfrom Mar 9, 2026
Merged
fix(bluetooth): prevent toggling bluetooth power state in airplane mode#436robertkill merged 1 commit intolinuxdeepin:masterfrom
robertkill merged 1 commit intolinuxdeepin:masterfrom
Conversation
Reviewer's guide (collapsed on small PRs)Reviewer's GuideAdds an airplane-mode guard in the Bluetooth quick panel item so that the Bluetooth adapter power state cannot be toggled or persisted while airplane mode is enabled, preventing Bluetooth from turning on unexpectedly after relogin. Sequence diagram for blocking Bluetooth toggle while airplane mode is enabledsequenceDiagram
actor User
participant QuickPanel
participant BluetoothItem
participant Applet
User->>QuickPanel: click bluetooth toggle
QuickPanel->>BluetoothItem: invokeMenuItem(SHIFT, checked)
BluetoothItem->>Applet: airplaneModeEnable()
Applet-->>BluetoothItem: true
BluetoothItem-->>QuickPanel: return (no action)
%% No call to setAdapterPowered when airplane mode is enabled
Updated class diagram for BluetoothItem and related applet behaviorclassDiagram
class BluetoothItem {
- bool m_adapterPowered
- Applet* m_applet
+ void invokeMenuItem(QString menuId, bool checked)
}
class Applet {
+ bool airplaneModeEnable()
+ void setAdapterPowered(bool powered)
}
BluetoothItem --> Applet : uses
BluetoothItem : invokeMenuItem()
BluetoothItem : checks Applet.airplaneModeEnable()
BluetoothItem : calls Applet.setAdapterPowered(!m_adapterPowered) when airplane mode is disabled
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 left some high level feedback:
- When returning early due to airplane mode being enabled, consider providing some user feedback (e.g., temporary notification or visual state reset) so the user understands why the Bluetooth toggle had no effect.
- If other code paths can change adapter power state, consider centralizing the airplane-mode guard closer to the underlying
setAdapterPoweredlogic to avoid future callers bypassing this check.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- When returning early due to airplane mode being enabled, consider providing some user feedback (e.g., temporary notification or visual state reset) so the user understands why the Bluetooth toggle had no effect.
- If other code paths can change adapter power state, consider centralizing the airplane-mode guard closer to the underlying `setAdapterPowered` logic to avoid future callers bypassing this check.Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
Add a check in BluetoothItem::invokeMenuItem to block shifting the bluetooth power state if airplane mode is currently enabled. This prevents the background daemon from persisting the power-on state while the hardware/software rfkill is active, which causes bluetooth to be enabled unexpectedly after a relogin. Log: Prevent toggling bluetooth power state in airplane mode Influence: 1. Open the quick panel and enable airplane mode 2. Click the bluetooth toggle switch 3. Log out and log back in 4. Verify the bluetooth switch remains disabled in the quick panel fix(bluetooth): 修复在飞行模式下仍能切换蓝牙电源状态的问题 在 BluetoothItem::invokeMenuItem 中添加检查,如果当前已开启 飞行模式,则拒绝切换蓝牙电源状态的执行。这防止了在 rfkill 锁定期间,后台服务错误地将开启状态持久化配置,从而导致用户注销 重登后蓝牙被意外开启。 Log: 修复在飞行模式下仍能切换蓝牙电源状态的问题 Influence: 1. 打开快捷面板并开启飞行模式 2. 点击蓝牙开关图标进行切换 3. 注销并重新登录系统 4. 验证快捷面板中蓝牙开关依然保持关闭状态 PMS: BUG-352161
BLumia
previously approved these changes
Mar 9, 2026
deepin pr auto review针对这段代码的 diff,我将从语法逻辑、代码质量、代码性能和代码安全四个方面进行审查,并提出改进建议。 1. 语法逻辑
2. 代码质量
3. 代码性能
4. 代码安全
综合改进建议代码void BluetoothItem::invokeMenuItem(const QString menuId, const bool checked)
{
Q_UNUSED(checked);
// 安全性改进:增加空指针检查
if (!m_applet) {
qWarning() << "BluetoothItem::invokeMenuItem: m_applet is null!";
return;
}
if (menuId == SHIFT) {
// 性能与逻辑优化:在飞行模式下直接返回,避免不必要的操作
// 假设 airplaneModeEnable() 是一个轻量级的 getter
if (m_applet->airplaneModeEnable()) {
return;
}
m_applet->setAdapterPowered(!m_adapterPowered);
} else if (menuId == SETTINGS) {
// ...总结这段代码的主要目的是在飞行模式下禁用蓝牙切换功能,逻辑上是正确的。主要的改进点在于:
|
BLumia
approved these changes
Mar 9, 2026
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: BLumia, robertkill 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Add a check in BluetoothItem::invokeMenuItem to block shifting the bluetooth power state if airplane mode is currently enabled. This prevents the background daemon from persisting the power-on state while the hardware/software rfkill is active, which causes bluetooth to be enabled unexpectedly after a relogin.
Log: Prevent toggling bluetooth power state in airplane mode
Influence:
fix(bluetooth): 修复在飞行模式下仍能切换蓝牙电源状态的问题
在 BluetoothItem::invokeMenuItem 中添加检查,如果当前已开启
飞行模式,则拒绝切换蓝牙电源状态的执行。这防止了在 rfkill
锁定期间,后台服务错误地将开启状态持久化配置,从而导致用户注销
重登后蓝牙被意外开启。
Log: 修复在飞行模式下仍能切换蓝牙电源状态的问题
Influence:
PMS: BUG-352161
Summary by Sourcery
Bug Fixes: