Commit 51a5f979 authored by Andreas Henriksson's avatar Andreas Henriksson

Drop debian/patches/00git_clamp_percentage.patch, merged upstream.

parent 8f98b8f1
From 22da1a0bc5943b683189418d8b0f766e91b2bdbe 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
---
Index: upower/src/linux/integration-test
===================================================================
--- upower.orig/src/linux/integration-test 2013-10-23 08:25:31.257239725 +0200
+++ upower/src/linux/integration-test 2013-10-23 08:25:31.253239725 +0200
@@ -442,6 +442,39 @@
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'''
Index: upower/src/linux/up-device-supply.c
===================================================================
--- upower.orig/src/linux/up-device-supply.c 2013-10-23 08:25:31.257239725 +0200
+++ upower/src/linux/up-device-supply.c 2013-10-23 08:25:31.253239725 +0200
@@ -708,6 +708,10 @@
/* 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;
# Debian patches for upower
00git_clamp_percentage.patch
no_deprecation_define.patch
always_use_pm-utils_backend.patch
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment