summaryrefslogtreecommitdiff
path: root/extra/upower
diff options
context:
space:
mode:
authorroot <root@rshg054.dnsready.net>2013-10-29 01:05:02 -0700
committerroot <root@rshg054.dnsready.net>2013-10-29 01:05:02 -0700
commit38b1ce25596ae456fefb3214a73c3d1005da568f (patch)
tree5cb69842c94bdd2b34b01be22f97b5949237550f /extra/upower
parent1a32448c2c53b0e66ce0fe14c5dd2057afd432bc (diff)
Tue Oct 29 01:04:23 PDT 2013
Diffstat (limited to 'extra/upower')
-rw-r--r--extra/upower/PKGBUILD14
-rw-r--r--extra/upower/git-fixes.patch112
-rw-r--r--extra/upower/linux-clamp-percentage-for-overfull-batteries.patch72
3 files changed, 79 insertions, 119 deletions
diff --git a/extra/upower/PKGBUILD b/extra/upower/PKGBUILD
index a3b18fe7f..1cfb22527 100644
--- a/extra/upower/PKGBUILD
+++ b/extra/upower/PKGBUILD
@@ -1,9 +1,9 @@
-# $Id: PKGBUILD 196663 2013-10-16 09:25:32Z jgc $
+# $Id: PKGBUILD 197688 2013-10-28 13:45:39Z jgc $
# Maintainer: Jan de Groot <jgc@archlinux.org>
pkgname=upower
-pkgver=0.9.22
-pkgrel=1
+pkgver=0.9.23
+pkgrel=2
pkgdesc="Abstraction for enumerating power devices, listening to device events and querying history and statistics"
arch=('i686' 'x86_64')
url="http://upower.freedesktop.org"
@@ -13,13 +13,13 @@ makedepends=('intltool' 'docbook-xsl' 'gobject-introspection' 'systemd')
backup=('etc/UPower/UPower.conf')
options=('!libtool')
source=($url/releases/$pkgname-$pkgver.tar.xz
- git-fixes.patch)
-md5sums=('22b0b13c16ceb1516b5edf5cf0e99d6d'
- 'd47377f5f8a02e38f81b6a63d8a19ef3')
+ linux-clamp-percentage-for-overfull-batteries.patch)
+md5sums=('39cfd97bfaf7d30908f20cf937a57634'
+ 'cd8eeb40c2338d28df46e22529bece62')
prepare() {
cd $pkgname-$pkgver
- patch -Np1 -i ../git-fixes.patch
+ patch -Np1 -i ../linux-clamp-percentage-for-overfull-batteries.patch
}
build() {
diff --git a/extra/upower/git-fixes.patch b/extra/upower/git-fixes.patch
deleted file mode 100644
index 83c407454..000000000
--- a/extra/upower/git-fixes.patch
+++ /dev/null
@@ -1,112 +0,0 @@
-From e4858d94343bba2afbebcd1a4925c981a38a9579 Mon Sep 17 00:00:00 2001
-From: Bastien Nocera <hadess@hadess.net>
-Date: Thu, 10 Oct 2013 16:32:41 +0000
-Subject: up-client: Really don't overwrite retval with prop values
-
-db89e5a32bf2c16c0d3d00f6c8f0ef7e5e7efa8f was incomplete and
-"ret" was being used instead of prop_val to set some of those
-properties. It's likely your laptop would have been seen as
-docked for example.
----
-diff --git a/libupower-glib/up-client.c b/libupower-glib/up-client.c
-index 757e4a1..2334a68 100644
---- a/libupower-glib/up-client.c
-+++ b/libupower-glib/up-client.c
-@@ -360,7 +360,7 @@ up_client_get_properties_sync (UpClient *client, GCancellable *cancellable, GErr
-
- prop_val = g_value_get_boolean (value) && allowed;
- if (prop_val != client->priv->can_suspend) {
-- client->priv->can_suspend = ret;
-+ client->priv->can_suspend = prop_val;
- g_object_notify (G_OBJECT(client), "can-suspend");
- }
-
-@@ -376,7 +376,7 @@ up_client_get_properties_sync (UpClient *client, GCancellable *cancellable, GErr
-
- prop_val = g_value_get_boolean (value) && allowed;
- if (prop_val != client->priv->can_hibernate) {
-- client->priv->can_hibernate = ret;
-+ client->priv->can_hibernate = prop_val;
- g_object_notify (G_OBJECT(client), "can-hibernate");
- }
- #endif /* ENABLE_DEPRECATED */
-@@ -388,7 +388,7 @@ up_client_get_properties_sync (UpClient *client, GCancellable *cancellable, GErr
- }
- prop_val = g_value_get_boolean (value);
- if (prop_val != client->priv->lid_is_closed) {
-- client->priv->lid_is_closed = ret;
-+ client->priv->lid_is_closed = prop_val;
- g_object_notify (G_OBJECT(client), "lid-is-closed");
- }
-
-@@ -399,7 +399,7 @@ up_client_get_properties_sync (UpClient *client, GCancellable *cancellable, GErr
- }
- prop_val = g_value_get_boolean (value);
- if (prop_val != client->priv->on_battery) {
-- client->priv->on_battery = ret;
-+ client->priv->on_battery = prop_val;
- g_object_notify (G_OBJECT(client), "on-battery");
- }
-
-@@ -410,7 +410,7 @@ up_client_get_properties_sync (UpClient *client, GCancellable *cancellable, GErr
- }
- prop_val = g_value_get_boolean (value);
- if (prop_val != client->priv->on_low_battery) {
-- client->priv->on_low_battery = ret;
-+ client->priv->on_low_battery = prop_val;
- g_object_notify (G_OBJECT(client), "on-low-battery");
- }
-
-@@ -421,7 +421,7 @@ up_client_get_properties_sync (UpClient *client, GCancellable *cancellable, GErr
- }
- prop_val = g_value_get_boolean (value);
- if (prop_val != client->priv->lid_is_present) {
-- client->priv->lid_is_present = ret;
-+ client->priv->lid_is_present = prop_val;
- g_object_notify (G_OBJECT(client), "lid-is-present");
- }
-
-@@ -431,8 +431,8 @@ up_client_get_properties_sync (UpClient *client, GCancellable *cancellable, GErr
- goto out;
- }
- prop_val = g_value_get_boolean (value);
-- if (ret != client->priv->is_docked) {
-- client->priv->is_docked = ret;
-+ if (prop_val != client->priv->is_docked) {
-+ client->priv->is_docked = prop_val;
- g_object_notify (G_OBJECT(client), "is-docked");
- }
-
-@@ -443,7 +443,7 @@ up_client_get_properties_sync (UpClient *client, GCancellable *cancellable, GErr
- }
- prop_val = g_value_get_boolean (value);
- if (prop_val != client->priv->lid_force_sleep) {
-- client->priv->lid_force_sleep = ret;
-+ client->priv->lid_force_sleep = prop_val;
- g_object_notify (G_OBJECT(client), "lid-force-sleep");
- }
-
---
-cgit v0.9.0.2-2-gbebe
-From d43ab28a29420a61d031908abbf1d13b2cb35796 Mon Sep 17 00:00:00 2001
-From: Bastien Nocera <hadess@hadess.net>
-Date: Thu, 10 Oct 2013 16:59:08 +0000
-Subject: lib: Fix a small memory leak
-
-The bus was never unreferenced in the UpWakeups object.
----
-diff --git a/libupower-glib/up-wakeups.c b/libupower-glib/up-wakeups.c
-index 3729ad7..ed6bf80 100644
---- a/libupower-glib/up-wakeups.c
-+++ b/libupower-glib/up-wakeups.c
-@@ -377,6 +377,8 @@ up_wakeups_finalize (GObject *object)
- g_object_unref (wakeups->priv->proxy);
- if (wakeups->priv->prop_proxy != NULL)
- g_object_unref (wakeups->priv->prop_proxy);
-+ if (wakeups->priv->bus)
-+ dbus_g_connection_unref (wakeups->priv->bus);
-
- G_OBJECT_CLASS (up_wakeups_parent_class)->finalize (object);
- }
---
-cgit v0.9.0.2-2-gbebe
diff --git a/extra/upower/linux-clamp-percentage-for-overfull-batteries.patch b/extra/upower/linux-clamp-percentage-for-overfull-batteries.patch
new file mode 100644
index 000000000..6e643c42d
--- /dev/null
+++ b/extra/upower/linux-clamp-percentage-for-overfull-batteries.patch
@@ -0,0 +1,72 @@
+From b8fe9902f3c6c50ca6a23e24fcea99582beebc65 Mon Sep 17 00:00:00 2001
+From: Martin Pitt <martinpitt@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 8489bf3..4be1922 100755
+--- a/src/linux/integration-test
++++ b/src/linux/integration-test
+@@ -442,6 +442,39 @@ class Tests(unittest.TestCase):
+ self.assertEqual(self.get_dbus_property('OnLowBattery'), False)
+ 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 8020277..b953d65 100644
+--- a/src/linux/up-device-supply.c
++++ b/src/linux/up-device-supply.c
+@@ -708,6 +708,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