fix: resolve hotspot status transition issue#496
fix: resolve hotspot status transition issue#496caixr23 wants to merge 1 commit intolinuxdeepin:masterfrom
Conversation
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: caixr23 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 |
Reviewer's guide (collapsed on small PRs)Reviewer's GuideAdjusts device status mapping for wireless devices in hotspot (AP) mode so that during Prepare/Config phases they report Disconnected instead of Connecting, fixing UI status jumps while preserving existing behavior for other cases. Sequence diagram for device status resolution with hotspot AP handlingsequenceDiagram
participant UI
participant NetManagerThreadPrivate
participant NetworkDeviceBase
participant NetworkManager
participant NetworkInterface
participant ActiveConnection
participant Connection
participant ConnectionSettings
participant WirelessSetting
UI->>NetManagerThreadPrivate: deviceStatus(device)
NetManagerThreadPrivate->>NetworkDeviceBase: status()
NetworkDeviceBase-->>NetManagerThreadPrivate: DeviceStatus_Prepare_or_Config
alt device is wireless
NetManagerThreadPrivate->>NetworkDeviceBase: deviceType()
NetworkDeviceBase-->>NetManagerThreadPrivate: DeviceType_Wireless
NetManagerThreadPrivate->>NetworkDeviceBase: path()
NetworkDeviceBase-->>NetManagerThreadPrivate: device_path
NetManagerThreadPrivate->>NetworkManager: findNetworkInterface(device_path)
NetworkManager-->>NetManagerThreadPrivate: NetworkInterface
alt interface found
NetManagerThreadPrivate->>NetworkInterface: activeConnection()
NetworkInterface-->>NetManagerThreadPrivate: ActiveConnection
alt activeConnection and connection exist
NetManagerThreadPrivate->>ActiveConnection: connection()
ActiveConnection-->>NetManagerThreadPrivate: Connection
NetManagerThreadPrivate->>Connection: settings()
Connection-->>NetManagerThreadPrivate: ConnectionSettings
NetManagerThreadPrivate->>ConnectionSettings: setting(Wireless)
ConnectionSettings-->>NetManagerThreadPrivate: WirelessSetting
NetManagerThreadPrivate->>WirelessSetting: mode()
WirelessSetting-->>NetManagerThreadPrivate: Mode
alt Mode is Ap
NetManagerThreadPrivate-->>UI: DS_Disconnected
else Mode is not Ap
NetManagerThreadPrivate-->>UI: DS_Connecting
end
else no active connection or connection
NetManagerThreadPrivate-->>UI: DS_Connecting
end
else interface not found
NetManagerThreadPrivate-->>UI: DS_Connecting
end
else device is not wireless
NetManagerThreadPrivate-->>UI: DS_Connecting
end
Class diagram for updated device status mapping logicclassDiagram
class NetManagerThreadPrivate {
+deviceStatus(device NetworkDeviceBase) NetType_NetDeviceStatus
}
class NetworkDeviceBase {
+status() DeviceStatus
+deviceType() DeviceType
+path() string
}
class NetworkManager {
+findNetworkInterface(path string) NetworkInterface_ptr
}
class NetworkInterface {
+activeConnection() ActiveConnection_ptr
}
class ActiveConnection {
+connection() Connection_ptr
}
class Connection {
+settings() ConnectionSettings_ptr
}
class ConnectionSettings {
+setting(type Setting) SettingBase_ptr
}
class WirelessSetting {
+mode() WirelessMode
}
class DeviceStatus {
<<enumeration>>
Prepare
Config
Disconnected
Needauth
IpConfig
}
class NetType_NetDeviceStatus {
<<enumeration>>
DS_Disconnected
DS_Connecting
DS_Authenticating
}
class DeviceType {
<<enumeration>>
Wireless
Wired
Other
}
class Setting {
<<enumeration>>
Wireless
OtherSetting
}
class WirelessMode {
<<enumeration>>
Ap
Station
OtherMode
}
NetManagerThreadPrivate --> NetworkDeviceBase : uses
NetManagerThreadPrivate --> NetworkManager : uses
NetworkManager --> NetworkInterface : returns
NetworkInterface --> ActiveConnection : returns
ActiveConnection --> Connection : returns
Connection --> ConnectionSettings : returns
ConnectionSettings --> WirelessSetting : returns
NetManagerThreadPrivate --> NetType_NetDeviceStatus : returns
NetworkDeviceBase --> DeviceStatus : returns
NetworkDeviceBase --> DeviceType : returns
ConnectionSettings --> Setting : parameter
WirelessSetting --> WirelessMode : returns
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:
- The AP-mode special case logic inside the
Prepare/Configbranch is becoming quite nested; consider extracting it into a small helper (e.g.,isWirelessApMode(device)) to improve readability and reuse if needed elsewhere. - You currently only apply the AP-mode check for
Wirelessdevices; if there are other device types that can enter AP mode, it may be worth centralizing the mode check on the connection rather than the device type to avoid future inconsistencies.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- The AP-mode special case logic inside the `Prepare/Config` branch is becoming quite nested; consider extracting it into a small helper (e.g., `isWirelessApMode(device)`) to improve readability and reuse if needed elsewhere.
- You currently only apply the AP-mode check for `Wireless` devices; if there are other device types that can enter AP mode, it may be worth centralizing the mode check on the connection rather than the device type to avoid future inconsistencies.Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
f45c614 to
a1350b6
Compare
When opening a hotspot, the device status was incorrectly showing as "Connecting" instead of "Disconnected" during the Prepare and Config phases. This caused visual status jump issues in the UI. The fix adds special handling for wireless devices in hotspot mode (AP mode). When a wireless device is in AP mode during Prepare/Config status, it now returns DS_Disconnected status instead of DS_Connecting to properly reflect the hotspot state. Log: Fixed incorrect status display when opening hotspot Influence: 1. Test opening hotspot and verify status shows as Disconnected during setup 2. Verify normal wireless connections still show Connecting status correctly 3. Check status transitions for both hotspot and regular wireless connections 4. Test hotspot functionality end-to-end to ensure no regression fix: 修复热点状态跳变问题 当打开热点时,设备状态在准备和配置阶段错误地显示为"正在连接"而非"已断 开"。这导致了UI中的视觉状态跳变问题。 修复方案为热点模式(AP模式)下的无线设备添加特殊处理。当无线设备在准备/ 配置状态处于AP模式时,现在返回"已断开"状态而非"正在连接"状态,以正确反映 热点状态。 Log: 修复打开热点时状态显示不正确的问题 Influence: 1. 测试打开热点功能,验证设置过程中状态正确显示为已断开 2. 验证普通无线连接仍能正确显示正在连接状态 3. 检查热点和普通无线连接的状态转换 4. 端到端测试热点功能确保无回归问题 Fixes: #345413
deepin pr auto review这段代码主要是为了解决无线网卡处于 AP (Access Point) 模式时,UI 错误显示"正在连接"状态的问题。通过增加 以下是对这段代码的详细审查和改进建议: 1. 语法与逻辑审查
2. 代码质量与可读性
3. 代码性能
4. 代码安全
5. 具体改进代码示例针对性能和代码结构的微调建议: bool NetManagerThreadPrivate::isWirelessApMode(NetworkDeviceBase *device)
{
// 1. 快速路径:如果不是无线设备,直接返回
if (!device || device->deviceType() != dde::network::DeviceType::Wireless) {
return false;
}
// 2. 查找 NetworkManager 的接口对象
// 注意:这里可能有 DBus 调用开销
auto dev = NetworkManager::findNetworkInterface(device->path());
if (!dev) {
return false;
}
// 3. 获取当前活动连接
auto activeConn = dev->activeConnection();
if (!activeConn) {
return false;
}
// 4. 获取连接设置
auto connection = activeConn->connection();
if (!connection) {
return false;
}
auto settings = connection->settings();
if (!settings) {
return false;
}
// 5. 检查无线设置的模式是否为 AP
// 使用 staticCast 因为前面已经确认了设备类型,性能优于 dynamicCast
auto wSettings = settings->setting(Setting::Wireless).staticCast<NetworkManager::WirelessSetting>();
// 确保 wSettings 有效,并且模式匹配
return wSettings && wSettings->mode() == NetworkManager::WirelessSetting::Ap;
}总结这段代码整体质量不错,逻辑清晰,安全性考虑周全。主要关注点在于 |
|
TAG Bot New tag: 2.0.81 |
When opening a hotspot, the device status was incorrectly showing as "Connecting" instead of "Disconnected" during the Prepare and Config phases. This caused visual status jump issues in the UI.
The fix adds special handling for wireless devices in hotspot mode (AP mode). When a wireless device is in AP mode during Prepare/Config status, it now returns DS_Disconnected status instead of DS_Connecting to properly reflect the hotspot state.
Log: Fixed incorrect status display when opening hotspot
Influence:
fix: 修复热点状态跳变问题
当打开热点时,设备状态在准备和配置阶段错误地显示为"正在连接"而非"已断
开"。这导致了UI中的视觉状态跳变问题。
修复方案为热点模式(AP模式)下的无线设备添加特殊处理。当无线设备在准备/
配置状态处于AP模式时,现在返回"已断开"状态而非"正在连接"状态,以正确反映
热点状态。
Log: 修复打开热点时状态显示不正确的问题
Influence:
Fixes: #345413
Summary by Sourcery
Bug Fixes: