From 28369c2426ec8ed4c3e8dad596a1e24ade5161de Mon Sep 17 00:00:00 2001
From: tanyulong <tanyulong@kylinos.cn>
Date: Thu, 8 Jul 2021 09:58:50 +0800
Subject: [PATCH] add judgment when Bluetooth does not exist

---
 shell/mainwindow.cpp | 30 +++++++++++++++++++-----------
 shell/mainwindow.h   |  2 +-
 2 files changed, 20 insertions(+), 12 deletions(-)

diff --git a/shell/mainwindow.cpp b/shell/mainwindow.cpp
index ed872de..a85b68a 100755
--- a/shell/mainwindow.cpp
+++ b/shell/mainwindow.cpp
@@ -547,7 +547,6 @@ void MainWindow::loadPlugins(){
         pluginsDir = QDir(qApp->applicationDirPath() + "/plugins");
     }
 
-    bool isExistCloud  = isExitsCloudAccount();
     foreach (QString fileName, pluginsDir.entryList(QDir::Files)){
         //三权分立开启
 #ifdef WITHKYSEC
@@ -558,17 +557,17 @@ void MainWindow::loadPlugins(){
                 continue;
         }
 #endif
-
-        if (!fileName.endsWith(".so"))
-            continue;
-        if (fileName == "libexperienceplan.so")
-            continue;
-        if ("libnetworkaccount.so" == fileName && !isExistCloud) {
-            continue;
-        }
-
-        if (!QGSettings::isSchemaInstalled(kVinoSchemas) && "libvino.so" == fileName) {
+	
+	if (!fileName.endsWith(".so")) {
             continue;
+        } else if (fileName == "libexperienceplan.so") {
+	    continue;
+      	} else if ("libnetworkaccount.so" == fileName && !isExitsCloudAccount()) {
+	    continue;
+	} else if (!QGSettings::isSchemaInstalled(kVinoSchemas) && "libvino.so" == fileName) {
+	    continue;
+        } else if ("libbluetooth.so" == fileName && !isExitBluetooth()) {
+	    continue;
         }
 
         qDebug() << "Scan Plugin: " << fileName;
@@ -822,6 +821,15 @@ void MainWindow::initStyleSheet() {
                             "QPushButton:hover:pressed#closeBtn{background: #E54A50; border-radius: 4px;width:32px;height:32px;}");
 }
 
+bool MainWindow::isExitBluetooth() {
+    QProcess process;
+    process.start("rfkill list");
+    process.waitForFinished();
+    QByteArray output = process.readAllStandardOutput();
+    QString str_output = output;
+    return str_output.contains(QString("bluetooth"), Qt::CaseInsensitive);
+}
+
 void MainWindow::setModuleBtnHightLight(int id) {
     leftBtnGroup->button(id)->setChecked(true);
     leftMicBtnGroup->button(id)->setChecked(true);
diff --git a/shell/mainwindow.h b/shell/mainwindow.h
index d14f1ef..bb44d7e 100755
--- a/shell/mainwindow.h
+++ b/shell/mainwindow.h
@@ -107,7 +107,7 @@ private:
 
     bool dblOnEdge(QMouseEvent *event);
     void initStyleSheet();
-
+    bool isExitBluetooth();
 public slots:
     void functionBtnClicked(QObject * plugin);
     void sltMessageReceived(const QString &msg);
-- 
2.23.0

