!135 fix(power):Fix has really battery while it is present

From: @meizhigang 
Reviewed-by: @liubuguiii 
Signed-off-by: @liubuguiii
This commit is contained in:
openeuler-ci-bot 2024-04-10 11:05:19 +00:00 committed by Gitee
commit 2b2b33ae8b
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
2 changed files with 61 additions and 1 deletions

View File

@ -0,0 +1,56 @@
From 25384cbcc740634b4c3ee80026728a11603111cf Mon Sep 17 00:00:00 2001
From: meizhigang <meizhigang@kylinsec.com.cn>
Date: Mon, 8 Apr 2024 16:13:17 +0800
Subject: [PATCH 3/3] fix(power):Fix has really battery while it is present
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
- 适配真实电池存在场景
Related #31917
---
plugins/power/upower-interface.cpp | 11 ++++++++---
1 file changed, 8 insertions(+), 3 deletions(-)
diff --git a/plugins/power/upower-interface.cpp b/plugins/power/upower-interface.cpp
index 4c964a6..4c04130 100644
--- a/plugins/power/upower-interface.cpp
+++ b/plugins/power/upower-interface.cpp
@@ -14,8 +14,8 @@
#include "upower-interface.h"
#include <upower.h>
-#include <cstdio>
#include <QtGlobal>
+#include <cstdio>
// 由于Glib定义与Qt内部相关定义冲突将该函数单独封装起来
bool UPowerInterface::haveBattery()
@@ -43,16 +43,21 @@ bool UPowerInterface::haveBattery()
#endif
void *device = nullptr;
UpDeviceKind kind;
+ gboolean is_present = FALSE;
for (unsigned int i = 0; i < devices->len; i++)
{
device = g_ptr_array_index(devices, i);
g_object_get(device,
"kind", &kind,
NULL);
- if (kind == UP_DEVICE_KIND_BATTERY)
+
+ g_object_get(device,
+ "is-present", &is_present,
+ NULL);
+ if (kind == UP_DEVICE_KIND_BATTERY && is_present)
hasBattery = true;
}
- g_ptr_array_unref (devices);
+ g_ptr_array_unref(devices);
g_object_unref(upClient);
return hasBattery;
}
--
2.27.0

View File

@ -1,6 +1,6 @@
Name: kiran-control-panel
Version: 2.6.1
Release: 3%{?dist}
Release: 4%{?dist}
Summary: Kiran Control Panel
Summary(zh_CN): Kiran桌面控制面板
@ -10,6 +10,7 @@ Source0: %{name}-%{version}.tar.gz
Patch000: 0000-fix-audio-when-the-tray-is-initialized-determine-whe.patch
Patch001: 0001-fix-keybinding-don-t-convert-normal-key-if-use-shift.patch
Patch002: 0002-fix-audio-network-Compatible-for-versions-below-5.15.patch
Patch003: 0003-fix-power-Fix-has-really-battery-while-it-is-present.patch
BuildRequires: gcc-c++
BuildRequires: cmake >= 3.2
@ -159,6 +160,9 @@ make %{?_smp_mflags}
rm -rf %{buildroot}
%changelog
* Wed Apr 10 2024 meizhigang <meizhigang@kylinsec.com.cn> - 2.6.1-4
- KYOS-B: Fix has really battery while it is present (#31917)
* Tue Apr 9 2024 youzhengcai <youzhengcai@kylinsec.com.cn> - 2.6.1-3
- KYOS-F: fix(audio&network):Compatible for versions below 5.15