Skip to content

Commit e5c61ff

Browse files
committed
fix: resolve hotspot status transition issue
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
1 parent 8274103 commit e5c61ff

File tree

2 files changed

+38
-1
lines changed

2 files changed

+38
-1
lines changed

net-view/operation/private/netmanagerthreadprivate.cpp

Lines changed: 37 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3042,6 +3042,40 @@ NetType::NetConnectionStatus NetManagerThreadPrivate::toNetConnectionStatus(Conn
30423042
return NetType::NetConnectionStatus::CS_UnConnected;
30433043
}
30443044

3045+
bool NetManagerThreadPrivate::isWirelessApMode(NetworkDeviceBase *device)
3046+
{
3047+
if (device->deviceType() != dde::network::DeviceType::Wireless) {
3048+
return false;
3049+
}
3050+
3051+
// 查找 NetworkManager 的接口对象
3052+
auto dev = NetworkManager::findNetworkInterface(device->path());
3053+
if (!dev) {
3054+
return false;
3055+
}
3056+
3057+
// 获取当前活动连接
3058+
auto activeConn = dev->activeConnection();
3059+
if (!activeConn || !activeConn->connection()) {
3060+
return false;
3061+
}
3062+
3063+
// 获取连接设置
3064+
auto settings = activeConn->connection()->settings();
3065+
if (!settings) {
3066+
return false;
3067+
}
3068+
3069+
// 检查无线设置的模式是否为 AP
3070+
// 使用 staticCast 因为前面已经确认了设备类型,性能优于 dynamicCast
3071+
auto wSettings = settings->setting(Setting::Wireless).staticCast<NetworkManager::WirelessSetting>();
3072+
if (wSettings && wSettings->mode() == NetworkManager::WirelessSetting::Ap) {
3073+
return true;
3074+
}
3075+
3076+
return false;
3077+
}
3078+
30453079
NetType::NetDeviceStatus NetManagerThreadPrivate::deviceStatus(NetworkDeviceBase *device)
30463080
{
30473081
// 如果当前网卡是有线网卡,且没有插入网线,那么就返回未插入网线
@@ -3080,7 +3114,9 @@ NetType::NetDeviceStatus NetManagerThreadPrivate::deviceStatus(NetworkDeviceBase
30803114
return NetType::NetDeviceStatus::DS_Disconnected;
30813115
case DeviceStatus::Prepare:
30823116
case DeviceStatus::Config:
3083-
return NetType::NetDeviceStatus::DS_Connecting;
3117+
// 当设备处于 AP 模式时,虽然底层状态可能是 Prepare 或 Config,
3118+
// 但为了避免 UI 显示"正在连接"(用户并未连接外部网络),返回 Disconnected 状态。
3119+
return isWirelessApMode(device) ? NetType::NetDeviceStatus::DS_Disconnected : NetType::NetDeviceStatus::DS_Connecting;
30843120
case DeviceStatus::Needauth:
30853121
return NetType::NetDeviceStatus::DS_Authenticating;
30863122
case DeviceStatus::IpConfig:

net-view/operation/private/netmanagerthreadprivate.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -262,6 +262,7 @@ protected Q_SLOTS:
262262

263263
static NetType::NetDeviceStatus toNetDeviceStatus(ConnectionStatus status);
264264
static NetType::NetConnectionStatus toNetConnectionStatus(ConnectionStatus status);
265+
static bool isWirelessApMode(NetworkDeviceBase *device);
265266
static NetType::NetDeviceStatus deviceStatus(NetworkDeviceBase *device);
266267

267268
private:

0 commit comments

Comments
 (0)