!69 修复控制中心关于系统无法识别显卡和网卡的问题

From: @wangtaozhi 
Reviewed-by: @tangjie02 
Signed-off-by: @tangjie02
This commit is contained in:
openeuler-ci-bot 2023-05-11 08:07:57 +00:00 committed by Gitee
commit ff418e6d22
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
2 changed files with 175 additions and 1 deletions

View File

@ -0,0 +1,170 @@
From 7c877f7b549fd1466ecf9684f74b70fae1c54709 Mon Sep 17 00:00:00 2001
From: wangtaozhi <wangtaozhi@kylinsec.com.cn>
Date: Thu, 11 May 2023 12:00:55 +0800
Subject: [PATCH] fix-identification-issues-in-control-centers
---
lib/base/str-utils.cpp | 39 +++++++++++++++++-----
lib/base/str-utils.h | 17 +++++-----
plugins/systeminfo/systeminfo-hardware.cpp | 25 +++++++-------
3 files changed, 53 insertions(+), 28 deletions(-)
diff --git a/lib/base/str-utils.cpp b/lib/base/str-utils.cpp
index 8a38b1e..52e028b 100644
--- a/lib/base/str-utils.cpp
+++ b/lib/base/str-utils.cpp
@@ -1,14 +1,14 @@
/**
- * Copyright (c) 2020 ~ 2021 KylinSec Co., Ltd.
+ * Copyright (c) 2020 ~ 2021 KylinSec Co., Ltd.
* kiran-cc-daemon is licensed under Mulan PSL v2.
- * You can use this software according to the terms and conditions of the Mulan PSL v2.
+ * You can use this software according to the terms and conditions of the Mulan PSL v2.
* You may obtain a copy of Mulan PSL v2 at:
- * http://license.coscl.org.cn/MulanPSL2
- * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
- * EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
- * MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
- * See the Mulan PSL v2 for more details.
- *
+ * http://license.coscl.org.cn/MulanPSL2
+ * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
+ * EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
+ * MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
+ * See the Mulan PSL v2 for more details.
+ *
* Author: tangjie02 <tangjie02@kylinos.com.cn>
*/
@@ -95,6 +95,29 @@ std::vector<std::string> StrUtils::split_with_char(const std::string &s, char de
return v;
}
+std::vector<std::string> StrUtils::split_once_with_char(const std::string &s, char delimiter)
+{
+ std::vector<std::string> v;
+ size_t i;
+ for (i = 0; i < s.length(); i++)
+ {
+ if (delimiter == s[i])
+ {
+ v.push_back(s.substr(0, i));
+ break;
+ }
+ }
+ if (s.length() == i)
+ {
+ v.push_back(s);
+ }
+ else
+ {
+ v.push_back(s.substr(i + 1, s.length() - i - 1));
+ }
+ return v;
+}
+
std::string StrUtils::ltrim(const std::string &s)
{
auto iter = std::find_if(s.begin(), s.end(), [](char c) -> bool
diff --git a/lib/base/str-utils.h b/lib/base/str-utils.h
index e7221de..5c8be58 100644
--- a/lib/base/str-utils.h
+++ b/lib/base/str-utils.h
@@ -1,14 +1,14 @@
/**
- * Copyright (c) 2020 ~ 2021 KylinSec Co., Ltd.
+ * Copyright (c) 2020 ~ 2021 KylinSec Co., Ltd.
* kiran-cc-daemon is licensed under Mulan PSL v2.
- * You can use this software according to the terms and conditions of the Mulan PSL v2.
+ * You can use this software according to the terms and conditions of the Mulan PSL v2.
* You may obtain a copy of Mulan PSL v2 at:
- * http://license.coscl.org.cn/MulanPSL2
- * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
- * EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
- * MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
- * See the Mulan PSL v2 for more details.
- *
+ * http://license.coscl.org.cn/MulanPSL2
+ * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
+ * EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
+ * MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
+ * See the Mulan PSL v2 for more details.
+ *
* Author: tangjie02 <tangjie02@kylinos.com.cn>
*/
@@ -48,6 +48,7 @@ public:
static std::string tolower(const std::string &str);
static std::string toupper(const std::string &str);
static std::vector<std::string> split_with_char(const std::string &s, char delimiter, bool is_merge_delimiter = false);
+ static std::vector<std::string> split_once_with_char(const std::string &s, char delimiter);
// 去掉字符串前后的空白字符
static std::string ltrim(const std::string &s);
diff --git a/plugins/systeminfo/systeminfo-hardware.cpp b/plugins/systeminfo/systeminfo-hardware.cpp
index 66b7b49..e9975c1 100644
--- a/plugins/systeminfo/systeminfo-hardware.cpp
+++ b/plugins/systeminfo/systeminfo-hardware.cpp
@@ -1,14 +1,14 @@
/**
- * Copyright (c) 2020 ~ 2021 KylinSec Co., Ltd.
+ * Copyright (c) 2020 ~ 2021 KylinSec Co., Ltd.
* kiran-cc-daemon is licensed under Mulan PSL v2.
- * You can use this software according to the terms and conditions of the Mulan PSL v2.
+ * You can use this software according to the terms and conditions of the Mulan PSL v2.
* You may obtain a copy of Mulan PSL v2 at:
- * http://license.coscl.org.cn/MulanPSL2
- * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
- * EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
- * MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
- * See the Mulan PSL v2 for more details.
- *
+ * http://license.coscl.org.cn/MulanPSL2
+ * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
+ * EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
+ * MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
+ * See the Mulan PSL v2 for more details.
+ *
* Author: tangjie02 <tangjie02@kylinos.com.cn>
*/
@@ -34,7 +34,8 @@ namespace Kiran
#define DISKINFO_CMD "/usr/bin/lsblk"
-#define PCIINFO_CMD "/usr/sbin/lspci"
+// 使用相对路径,避免使用绝对路径时因系统版本导致的错误
+#define PCIINFO_CMD "lspci"
#define PCIINFO_KEY_DELIMITER ':'
SystemInfoHardware::SystemInfoHardware() : mem_size_lshw(0)
@@ -310,7 +311,7 @@ KVList SystemInfoHardware::get_pcis_by_major_class_id(PCIMajorClassID major_clas
{
Glib::spawn_sync("",
argv,
- Glib::SPAWN_DEFAULT,
+ Glib::SPAWN_SEARCH_PATH,
sigc::mem_fun(this, &SystemInfoHardware::set_env),
&cmd_output);
}
@@ -354,7 +355,7 @@ KVList SystemInfoHardware::get_pcis_by_major_class_id(PCIMajorClassID major_clas
{
Glib::spawn_sync("",
argv,
- Glib::SPAWN_DEFAULT,
+ Glib::SPAWN_SEARCH_PATH,
sigc::mem_fun(this, &SystemInfoHardware::set_env),
&cmd_output);
}
@@ -378,7 +379,7 @@ KVList SystemInfoHardware::format_to_kv_list(const std::string& contents)
auto lines = StrUtils::split_lines(block);
for (auto& line : lines)
{
- auto fields = StrUtils::split_with_char(line, PCIINFO_KEY_DELIMITER);
+ auto fields = StrUtils::split_once_with_char(line, PCIINFO_KEY_DELIMITER);
if (fields.size() != 2)
{
continue;
--
2.27.0

View File

@ -1,6 +1,6 @@
Name: kiran-cc-daemon
Version: 2.5.1
Release: 8
Release: 9
Summary: DBus daemon for Kiran Desktop
License: MulanPSL-2.0
@ -11,6 +11,7 @@ Patch0002: 0001-fix-audio-Fix-coredump-problem-caused-by-nullpointer.patch
Patch0003: 0001-fix-audio-Fix-the-type-of-return-value-in-template.patch
Patch0004: 0001-feature-timedate-Prior-to-select-last-ntp-service-in.patch
Patch0005: 0001-feature-power-Delete-LockScreenWhenHibernate-and-Loc.patch
Patch0006: 0001-fix-identification-issues-in-control-centers.patch
BuildRequires: cmake >= 3.2
@ -175,6 +176,9 @@ glib-compile-schemas /usr/share/glib-2.0/schemas &> /dev/nulls || :
%{_libdir}/pkgconfig/kiran-cc-daemon.pc
%changelog
* Thu May 11 2023 wangtaozhi <wangtaozhi@kylinsec.com.cn> - 2.5.1-9
- KYOS-F: Fix identification issues in the control center
* Wed May 10 2023 tangjie02 <tangjie02@kylinsec.com.cn> - 2.5.1-8
- KYOS-F: Delete LockScreenWhenHibernate and LockScreenWhenSuspend functions and replace suspend/hibernate/shutdown api with SessionManager.