fix: 无蓝牙和无线网络的机器显示了飞行模式

添加过滤条件,只在有蓝牙或无线网络的机器显示飞行模式

Log: 有条件的显示飞行模式
Influence: 飞行模式
Task: https://pms.uniontech.com/bug-view-147149.html
Change-Id: I3b2edf858882a696272abd69f243aa0b3fcb1df5
This commit is contained in:
zengaoyuan 2022-07-10 15:44:44 +08:00 committed by wubw
parent 0591607674
commit e7a7cf57b3
2 changed files with 29 additions and 1 deletions

View File

@ -50,7 +50,32 @@ void AirplaneModePlugin::init(PluginProxyInterface *proxyInter)
if (!pluginIsDisable())
m_proxyInter->itemAdded(this, AIRPLANEMODE_KEY);
refreshAirplaneEnableState();
bool hasBluetooth = false;
QDBusInterface inter("com.deepin.daemon.Bluetooth",
"/com/deepin/daemon/Bluetooth",
"com.deepin.daemon.Bluetooth",
QDBusConnection::sessionBus());
if (inter.isValid()) {
QDBusReply<QString> reply = inter.call("GetAdapters");
QString replyStr = reply.value();
replyStr = replyStr.replace("[", "");
replyStr = replyStr.replace("]", "");
if (!replyStr.isEmpty()) {
hasBluetooth = true;
}
}
bool hasWireless = false;
NetworkInter networkInter("com.deepin.daemon.Network", "/com/deepin/daemon/Network", QDBusConnection::sessionBus(), this);
if (networkInter.isValid()) {
if (!networkInter.wirelessAccessPoints().isEmpty()) {
hasWireless = true;
}
}
// 蓝牙和无线网络,只要有其中一个就允许显示飞行模式
if (hasBluetooth || hasWireless) {
refreshAirplaneEnableState();
}
}
void AirplaneModePlugin::pluginStateSwitched()

View File

@ -24,6 +24,9 @@
#define AIRPLANEMODEPLUGIN_H
#include "pluginsiteminterface.h"
#include "com_deepin_daemon_network.h"
using NetworkInter = com::deepin::daemon::Network;
class AirplaneModeItem;
class AirplaneModePlugin : public QObject, PluginsItemInterface