!130 fix(power):Fix battery charging and discharging time
From: @meizhigang Reviewed-by: @liubuguiii Signed-off-by: @liubuguiii
This commit is contained in:
commit
146b190155
@ -0,0 +1,79 @@
|
||||
From d24efc2aec6c4fbc00a4536998caf30553dc1e9b Mon Sep 17 00:00:00 2001
|
||||
From: meizhigang <meizhigang@kylinsec.com.cn>
|
||||
Date: Tue, 9 Apr 2024 14:09:04 +0800
|
||||
Subject: [PATCH 13/14] fix(power):Fix battery charging and discharging time
|
||||
MIME-Version: 1.0
|
||||
Content-Type: text/plain; charset=UTF-8
|
||||
Content-Transfer-Encoding: 8bit
|
||||
|
||||
- 适配电池充电和放电时间
|
||||
|
||||
Related #28618
|
||||
---
|
||||
plugins/power/tray/power-tray.cpp | 41 ++++++++++++++++++++-----------
|
||||
1 file changed, 26 insertions(+), 15 deletions(-)
|
||||
|
||||
diff --git a/plugins/power/tray/power-tray.cpp b/plugins/power/tray/power-tray.cpp
|
||||
index 8f76bcb..c372ef9 100644
|
||||
--- a/plugins/power/tray/power-tray.cpp
|
||||
+++ b/plugins/power/tray/power-tray.cpp
|
||||
@@ -107,30 +107,41 @@ void PowerTray::update_status_icon_toolstip(std::shared_ptr<PowerUPowerDevice> d
|
||||
{
|
||||
case UP_DEVICE_STATE_CHARGING:
|
||||
{
|
||||
- auto time_to_full_text = PowerUtils::get_time_translation(device_for_tray->get_props().time_to_full);
|
||||
- auto tooltip_text = fmt::format(_("Remaining electricty: {0:.1f}%, approximately {1} until charged"),
|
||||
- device_for_tray->get_props().percentage,
|
||||
- time_to_full_text);
|
||||
- gtk_status_icon_set_tooltip_text(this->status_icon_, tooltip_text.c_str());
|
||||
+ auto time_to_full = device_for_tray->get_props().time_to_full;
|
||||
+ if (time_to_full > 0)
|
||||
+ {
|
||||
+ auto time_to_full_text = PowerUtils::get_time_translation(time_to_full);
|
||||
+ auto tooltip_text = fmt::format(_("Remaining electricty: {0:.1f}%, approximately {1} until charged"),
|
||||
+ device_for_tray->get_props().percentage,
|
||||
+ time_to_full_text);
|
||||
+ gtk_status_icon_set_tooltip_text(this->status_icon_, tooltip_text.c_str());
|
||||
+
|
||||
+ return;
|
||||
+ }
|
||||
break;
|
||||
}
|
||||
case UP_DEVICE_STATE_DISCHARGING:
|
||||
{
|
||||
- auto time_to_empty_text = PowerUtils::get_time_translation(device_for_tray->get_props().time_to_empty);
|
||||
- auto tooltip_text = fmt::format(_("Remaining electricty: {0:.1f}%, approximately provides {1} runtime"),
|
||||
- device_for_tray->get_props().percentage,
|
||||
- time_to_empty_text);
|
||||
- gtk_status_icon_set_tooltip_text(this->status_icon_, tooltip_text.c_str());
|
||||
+ auto time_to_empty = device_for_tray->get_props().time_to_empty;
|
||||
+ if (time_to_empty > 0)
|
||||
+ {
|
||||
+ auto time_to_empty_text = PowerUtils::get_time_translation(time_to_empty);
|
||||
+ auto tooltip_text = fmt::format(_("Remaining electricty: {0:.1f}%, approximately provides {1} runtime"),
|
||||
+ device_for_tray->get_props().percentage,
|
||||
+ time_to_empty_text);
|
||||
+ gtk_status_icon_set_tooltip_text(this->status_icon_, tooltip_text.c_str());
|
||||
+
|
||||
+ return;
|
||||
+ }
|
||||
break;
|
||||
}
|
||||
case UP_DEVICE_STATE_FULLY_CHARGED:
|
||||
default:
|
||||
- {
|
||||
- auto tooltip_text = fmt::format(_("Remaining electricty: {0:.1f}%"), device_for_tray->get_props().percentage);
|
||||
- gtk_status_icon_set_tooltip_text(this->status_icon_, tooltip_text.c_str());
|
||||
- }
|
||||
- break;
|
||||
+ break;
|
||||
}
|
||||
+
|
||||
+ auto tooltip_text = fmt::format(_("Remaining electricty: {0:.1f}%"), device_for_tray->get_props().percentage);
|
||||
+ gtk_status_icon_set_tooltip_text(this->status_icon_, tooltip_text.c_str());
|
||||
}
|
||||
|
||||
void PowerTray::delay_update_status_icon()
|
||||
--
|
||||
2.27.0
|
||||
|
||||
108
0013-fix-power-Fix-sys-backlight-set-only-in-notebook-wit.patch
Normal file
108
0013-fix-power-Fix-sys-backlight-set-only-in-notebook-wit.patch
Normal file
@ -0,0 +1,108 @@
|
||||
From 66cb46a91c5218b8f26589eb07c5a7569cc08808 Mon Sep 17 00:00:00 2001
|
||||
From: meizhigang <meizhigang@kylinsec.com.cn>
|
||||
Date: Tue, 9 Apr 2024 09:12:43 +0800
|
||||
Subject: [PATCH 14/14] fix(power):Fix sys backlight set only in notebook with
|
||||
battery
|
||||
MIME-Version: 1.0
|
||||
Content-Type: text/plain; charset=UTF-8
|
||||
Content-Transfer-Encoding: 8bit
|
||||
|
||||
- 仅在笔记本环境支持背光设备设置
|
||||
|
||||
Related #31917
|
||||
---
|
||||
plugins/power/tools/CMakeLists.txt | 7 ++++--
|
||||
.../power/tools/power-backlight-helper.cpp | 22 +++++++++++++++++++
|
||||
plugins/power/tools/power-backlight-helper.h | 5 ++++-
|
||||
3 files changed, 31 insertions(+), 3 deletions(-)
|
||||
|
||||
diff --git a/plugins/power/tools/CMakeLists.txt b/plugins/power/tools/CMakeLists.txt
|
||||
index 43d1b35..d6dd7cf 100644
|
||||
--- a/plugins/power/tools/CMakeLists.txt
|
||||
+++ b/plugins/power/tools/CMakeLists.txt
|
||||
@@ -5,8 +5,11 @@ set(TARGET_NAME kiran-power-backlight-helper)
|
||||
file(GLOB_RECURSE POWER_BACKLIGHT_HELPER_H_FILES ./*.h)
|
||||
file(GLOB_RECURSE POWER_BACKLIGHT_HELPER_CPP_FILES ./*.cpp)
|
||||
|
||||
-add_executable(${TARGET_NAME} ${POWER_BACKLIGHT_HELPER_H_FILES}
|
||||
- ${POWER_BACKLIGHT_HELPER_CPP_FILES})
|
||||
+add_executable(
|
||||
+ ${TARGET_NAME}
|
||||
+ ${POWER_BACKLIGHT_HELPER_H_FILES} ${POWER_BACKLIGHT_HELPER_CPP_FILES}
|
||||
+ ${PROJECT_SOURCE_DIR}/plugins/power/wrapper/power-upower.cpp
|
||||
+ ${PROJECT_SOURCE_DIR}/plugins/power/wrapper/power-upower-device.cpp)
|
||||
|
||||
target_link_libraries(${TARGET_NAME} PRIVATE lib-base)
|
||||
|
||||
diff --git a/plugins/power/tools/power-backlight-helper.cpp b/plugins/power/tools/power-backlight-helper.cpp
|
||||
index 830d488..2f59eeb 100644
|
||||
--- a/plugins/power/tools/power-backlight-helper.cpp
|
||||
+++ b/plugins/power/tools/power-backlight-helper.cpp
|
||||
@@ -43,6 +43,7 @@ const std::vector<std::string> PowerBacklightHelper::backlight_search_subdirs_ =
|
||||
PowerBacklightHelper::PowerBacklightHelper() : brightness_value_(-1)
|
||||
{
|
||||
this->backlight_dir_ = this->get_backlight_filepath();
|
||||
+ this->upower_client_ = std::make_shared<PowerUPower>();
|
||||
}
|
||||
|
||||
PowerBacklightHelper::~PowerBacklightHelper()
|
||||
@@ -57,6 +58,27 @@ void PowerBacklightHelper::init()
|
||||
this->brightness_monitor_ = FileUtils::make_monitor_file(filename, sigc::mem_fun(this, &PowerBacklightHelper::on_brightness_changed), Gio::FILE_MONITOR_NONE);
|
||||
this->brightness_value_ = this->get_brightness_value();
|
||||
}
|
||||
+
|
||||
+ this->upower_client_->init();
|
||||
+}
|
||||
+bool PowerBacklightHelper::support_backlight()
|
||||
+{
|
||||
+ std::vector<uint32_t> device_types = {UP_DEVICE_KIND_BATTERY, UP_DEVICE_KIND_UPS};
|
||||
+
|
||||
+ for (auto device_type : device_types)
|
||||
+ {
|
||||
+ for (auto upower_device : this->upower_client_->get_devices())
|
||||
+ {
|
||||
+ auto& device_props = upower_device->get_props();
|
||||
+ if (device_props.type == device_type &&
|
||||
+ device_props.is_present)
|
||||
+ {
|
||||
+ return (this->brightness_value_ >= 0);
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ return false;
|
||||
}
|
||||
|
||||
int32_t PowerBacklightHelper::get_brightness_value()
|
||||
diff --git a/plugins/power/tools/power-backlight-helper.h b/plugins/power/tools/power-backlight-helper.h
|
||||
index 39bcb03..bf5567c 100644
|
||||
--- a/plugins/power/tools/power-backlight-helper.h
|
||||
+++ b/plugins/power/tools/power-backlight-helper.h
|
||||
@@ -15,6 +15,7 @@
|
||||
#pragma once
|
||||
|
||||
#include "lib/base/base.h"
|
||||
+#include "plugins/power/wrapper/power-upower.h"
|
||||
|
||||
namespace Kiran
|
||||
{
|
||||
@@ -27,7 +28,7 @@ public:
|
||||
void init();
|
||||
|
||||
// 是否支持亮度设置
|
||||
- bool support_backlight() { return (this->brightness_value_ >= 0); };
|
||||
+ bool support_backlight();
|
||||
std::string get_backlight_dir() { return this->backlight_dir_; };
|
||||
|
||||
// 获取亮度值
|
||||
@@ -55,5 +56,7 @@ private:
|
||||
int32_t brightness_value_;
|
||||
// 亮度变化信号
|
||||
sigc::signal<void, int32_t> brightness_changed_;
|
||||
+
|
||||
+ std::shared_ptr<PowerUPower> upower_client_;
|
||||
};
|
||||
} // namespace Kiran
|
||||
--
|
||||
2.27.0
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
Name: kiran-cc-daemon
|
||||
Version: 2.6.1
|
||||
Release: 10%{?dist}
|
||||
Release: 11%{?dist}
|
||||
Summary: DBus daemon for Kiran Desktop
|
||||
|
||||
License: MulanPSL-2.0
|
||||
@ -20,6 +20,8 @@ Patch0008: 0008-fix-appearance-Change-the-light-theme-name-to-Kiran-.patch
|
||||
Patch0009: 0009-fix-power-Fix-coredump-while-log-print-in-power.patch
|
||||
Patch0010: 0010-feature-CI-ref-new-CI-entry-point.patch
|
||||
Patch0011: 0011-fix-audio-Fix-audio-stream-volume-retain-while-set-m.patch
|
||||
Patch0012: 0012-fix-power-Fix-battery-charging-and-discharging-time.patch
|
||||
Patch0013: 0013-fix-power-Fix-sys-backlight-set-only-in-notebook-wit.patch
|
||||
|
||||
BuildRequires: cmake >= 3.2
|
||||
BuildRequires: pkgconfig(glibmm-2.4)
|
||||
@ -206,6 +208,10 @@ glib-compile-schemas /usr/share/glib-2.0/schemas &> /dev/nulls || :
|
||||
%{_libdir}/pkgconfig/kiran-cc-daemon.pc
|
||||
|
||||
%changelog
|
||||
* Wed Apr 10 2024 meizhigang <meizhigang@kylinsec.com.cn> - 2.6.1-11
|
||||
- KYOS-B: Add battery charging and discharging time (#28618)
|
||||
- KYOS-B: Fix sys backlight set only in notebook with battery (#31917)
|
||||
|
||||
* Mon Apr 01 2024 meizhigang <meizhigang@kylinsec.com.cn> - 2.6.1-10
|
||||
- KYOS-B: Change the light theme name to Kiran-white (#24747)
|
||||
- KYOS-B: Fix coredump while log print in power (#31141)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user