Skip to content

Commit 88bfbc6

Browse files
committed
fix: Airplane mode not monitoring Bluetooth status
Airplane mode not monitoring Bluetooth status pms: BUG-311349
1 parent f7e60cd commit 88bfbc6

1 file changed

Lines changed: 14 additions & 0 deletions

File tree

net-view/operation/private/netmanagerthreadprivate.cpp

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -541,6 +541,8 @@ void NetManagerThreadPrivate::doInit()
541541
m_airplaneModeEnabled = false;
542542
getAirplaneModeEnabled();
543543
connect(ConfigSetting::instance(), &ConfigSetting::enableAirplaneModeChanged, this, &NetManagerThreadPrivate::getAirplaneModeEnabled);
544+
QDBusConnection::systemBus().connect("org.deepin.dde.Bluetooth1", "/org/deepin/dde/Bluetooth1", "org.deepin.dde.Bluetooth1", "AdapterAdded", this, SLOT(getAirplaneModeEnabled()));
545+
QDBusConnection::systemBus().connect("org.deepin.dde.Bluetooth1", "/org/deepin/dde/Bluetooth1", "org.deepin.dde.Bluetooth1", "AdapterRemoved", this, SLOT(getAirplaneModeEnabled()));
544546
QDBusConnection::systemBus()
545547
.connect("org.deepin.dde.AirplaneMode1", "/org/deepin/dde/AirplaneMode1", "org.freedesktop.DBus.Properties", "PropertiesChanged", this, SLOT(onAirplaneModeEnabledPropertiesChanged(QString, QVariantMap, QStringList)));
546548
}
@@ -859,6 +861,18 @@ bool NetManagerThreadPrivate::supportAirplaneMode() const
859861
return false;
860862
}
861863

864+
// 蓝牙和无线网络,只要有其中一个就允许显示飞行模式
865+
QDBusInterface inter("org.deepin.dde.Bluetooth1", "/org/deepin/dde/Bluetooth1", "org.deepin.dde.Bluetooth1", QDBusConnection::systemBus());
866+
if (inter.isValid()) {
867+
QDBusReply<QString> reply = inter.call("GetAdapters");
868+
QString replyStr = reply.value();
869+
QJsonDocument json = QJsonDocument::fromJson(replyStr.toUtf8());
870+
QJsonArray array = json.array();
871+
if (!array.empty() && !array[0].toObject()["Path"].toString().isEmpty()) {
872+
return true;
873+
}
874+
}
875+
862876
NetworkManager::Device::List devices = NetworkManager::networkInterfaces();
863877
for (NetworkManager::Device::Ptr device : devices) {
864878
if (device->type() == NetworkManager::Device::Type::Wifi && device->managed())

0 commit comments

Comments
 (0)