[packages/upower] - add upstream patch for battery charge range normalizer - rel 2

atler atler at pld-linux.org
Sun Nov 3 12:30:20 CET 2013


commit 5307022267ad4adb546a91452492551195c2c5f2
Author: Jan Palus <jan.palus at gmail.com>
Date:   Sun Nov 3 12:25:59 2013 +0100

    - add upstream patch for battery charge range normalizer
    - rel 2

 upower-battery_range.patch | 72 ++++++++++++++++++++++++++++++++++++++++++++++
 upower.spec                |  4 ++-
 2 files changed, 75 insertions(+), 1 deletion(-)
---
diff --git a/upower.spec b/upower.spec
index eadad5e..5b7185d 100644
--- a/upower.spec
+++ b/upower.spec
@@ -2,11 +2,12 @@ Summary:	Power management service
 Summary(pl.UTF-8):	Usługa zarządzania energią
 Name:		upower
 Version:	0.9.23
-Release:	1
+Release:	2
 License:	GPL v2+
 Group:		Libraries
 Source0:	http://upower.freedesktop.org/releases/%{name}-%{version}.tar.xz
 # Source0-md5:	39cfd97bfaf7d30908f20cf937a57634
+Patch0:		%{name}-battery_range.patch
 URL:		http://upower.freedesktop.org/
 BuildRequires:	autoconf >= 2.65
 BuildRequires:	automake >= 1:1.11
@@ -107,6 +108,7 @@ Dokumentacja API UPower.
 
 %prep
 %setup -q
+%patch0 -p1
 
 %build
 %{__gtkdocize}
diff --git a/upower-battery_range.patch b/upower-battery_range.patch
new file mode 100644
index 0000000..c8bb5e6
--- /dev/null
+++ b/upower-battery_range.patch
@@ -0,0 +1,72 @@
+From 22da1a0bc5943b683189418d8b0f766e91b2bdbe Mon Sep 17 00:00:00 2001
+From: Martin Pitt <martinpitt at gnome.org>
+Date: Tue, 22 Oct 2013 08:02:51 +0000
+Subject: linux: Clamp percentage for overfull batteries
+
+Some batteries report energy > energy_full and a percentage ("capacity"
+attribute) > 100%. Clamp these within 0 and 100% for both plausibility as well
+as to avoid setting an out-of-range property which would then become 0%.
+
+https://launchpad.net/bugs/1240673
+---
+diff --git a/src/linux/integration-test b/src/linux/integration-test
+index 6adc5c4..b7f11a9 100755
+--- a/src/linux/integration-test
++++ b/src/linux/integration-test
+@@ -458,6 +458,39 @@ class Tests(unittest.TestCase):
+         self.assertEqual(self.get_dbus_display_property('WarningLevel'), UP_DEVICE_LEVEL_NONE)
+         self.stop_daemon()
+ 
++    def test_battery_overfull(self):
++        '''battery which reports a > 100% percentage for a full battery'''
++
++        self.testbed.add_device('power_supply', 'BAT0', None,
++                                ['type', 'Battery',
++                                 'present', '1',
++                                 'status', 'Full',
++                                 'current_now', '1000',
++                                 'charge_now', '11000000',
++                                 'charge_full', '10000000',
++                                 'charge_full_design', '11000000',
++                                 'capacity', '110',
++                                 'voltage_now', '12000000'], [])
++
++        self.start_daemon()
++        devs = self.proxy.EnumerateDevices()
++        self.assertEqual(len(devs), 1)
++        bat0_up = devs[0]
++
++        # should clamp percentage
++        self.assertEqual(self.get_dbus_dev_property(bat0_up, 'Percentage'), 100.0)
++        self.assertEqual(self.get_dbus_dev_property(bat0_up, 'IsPresent'), True)
++        self.assertEqual(self.get_dbus_dev_property(bat0_up, 'State'),
++                         UP_DEVICE_STATE_FULLY_CHARGED)
++        self.assertEqual(self.get_dbus_dev_property(bat0_up, 'Energy'), 132.0)
++        # should adjust EnergyFull to reality, not what the battery claims
++        self.assertEqual(self.get_dbus_dev_property(bat0_up, 'EnergyFull'), 132.0)
++        self.assertEqual(self.get_dbus_dev_property(bat0_up, 'EnergyFullDesign'), 132.0)
++        self.assertEqual(self.get_dbus_dev_property(bat0_up, 'Voltage'), 12.0)
++        self.assertEqual(self.get_dbus_dev_property(bat0_up, 'PowerSupply'), True)
++        self.assertEqual(self.get_dbus_dev_property(bat0_up, 'Type'), 2)
++        self.stop_daemon()
++
+     def test_battery_temperature(self):
+         '''battery which reports temperature'''
+ 
+diff --git a/src/linux/up-device-supply.c b/src/linux/up-device-supply.c
+index fd509c3..977d1b0 100644
+--- a/src/linux/up-device-supply.c
++++ b/src/linux/up-device-supply.c
+@@ -677,6 +677,10 @@ up_device_supply_refresh_battery (UpDeviceSupply *supply)
+ 	/* get a precise percentage */
+         if (sysfs_file_exists (native_path, "capacity")) {
+ 		percentage = sysfs_get_double (native_path, "capacity");
++		if (percentage < 0.0f)
++			percentage = 0.0f;
++		if (percentage > 100.0f)
++			percentage = 100.0f;
+                 /* for devices which provide capacity, but not {energy,charge}_now */
+                 if (energy < 0.1f && energy_full > 0.0f)
+                     energy = energy_full * percentage / 100;
+--
+cgit v0.9.0.2-2-gbebe
================================================================

---- gitweb:

http://git.pld-linux.org/gitweb.cgi/packages/upower.git/commitdiff/5307022267ad4adb546a91452492551195c2c5f2



More information about the pld-cvs-commit mailing list