Commit graph

511 commits

Author SHA1 Message Date
Martin Pitt
48edf2f1a8 Fix wrong PowerSupply property for devices without a scope sysfs attribute
Fix NULL pointer comparison in up_device_supply_coldplug(). This caused

  (lt-upowerd:5754): GLib-CRITICAL **: g_ascii_strcasecmp: assertion `s1 != NULL' failed

when a device does not have a "scope" sysfs attribute, and erroneously
considering that device to not power the system.

https://launchpad.net/bugs/1012578
2012-06-14 13:18:10 +02:00
Martin Pitt
55569ac40f integration-test: fail on CRITICALs
Crash the daemon on any CRITICAL message, and also set WARNING and CRITICAL
messages to be fatal on the client side. On the server side we might have some
legitimate warnings, such as failing to load the config file from
/usr/local/etc (if you build a tree without passing correct --sysconfdir
options, etc.).

This exposes the current CRITICAL the daemon raises at startup. As with that
the daemon never starts up, fix the "wait for the daemon" loop to time out
after 10 seconds.
2012-06-14 13:07:30 +02:00
Sascha Silbe
d7c6d0e8da Drop 'type' parameter from CancelRequest() signature
CancelRequest() never worked because the method signature in D-Bus
introspection data didn't match the actual function signature.

Since the 'type' parameter isn't needed by the implementation (cookies
are unique across all requests, not just requests of a certain type),
we drop it from the public API. This makes it easier for clients to
use the API as they only have to remember the cookie, not both cookie
and type. Since it never worked in the first place, there are no
backwards compatibility issues.

Signed-off-by: Richard Hughes <richard@hughsie.com>
2012-05-30 16:19:27 +01:00
Sascha Silbe
79c11814cd Fix use-after-free of qos item
up_qos_init() registers a destroyer callback for the qos item array,
so the current item will be gone after the calls to
g_ptr_array_remove(). By storing the item kind in a local variable we
can pass it to up_qos_latency_perhaps_changed() later. Delaying the
removal from the array is not an option as
up_qos_latency_perhaps_changed() scans that array to re-evaluate the
target latency.

Signed-off-by: Richard Hughes <richard@hughsie.com>
2012-05-30 16:19:25 +01:00
Richard Hughes
a75501f9d1 linux: Treat the battery state 'not charging' as PENDING_CHARGE
Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=826215
2012-05-30 16:17:01 +01:00
Sascha Silbe
944118a879 Fix the LatencyChanged signal
The type of the 'value' parameter of the LatencyChanged signal is
integer, not boolean. Fixing this causes the signal to actually be
emitted.

Signed-off-by: Richard Hughes <richard@hughsie.com>
2012-05-22 18:51:42 +01:00
Gary Ching-Pang Lin
c17a3f0d70 Correct the cap on the energy rate
Signed-off-by: Richard Hughes <richard@hughsie.com>
2012-04-27 16:05:39 +01:00
Richard Hughes
28c8653ed8 Never detect HID devices with batteries as power supplies
Some HID devices with batteries (like bluetooth keyboards) have been creating
power supply devices in sysfs since Linux 3.3.
UPower thinks that they are system devices and shuts down the system if they
get low. This is bad.

This is fixed in Linux 3.4, where there is a new 'scope' file that defines if
the device is powering the system.
Helpfully ACPI batteries don't populate the scope value, but soon will.

Add support for the scope attribute now, and default to system devices if it's
missing. Note, you need to be running a 3.4 kernel or a 3.3 with the patch
backported for this to work.

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=806295
2012-04-18 16:46:46 +01:00
Evan Broder
6fb36eb5eb Re-coldplug dock status when resuming from sleep
It's possible for the docked state of a laptop (i.e. the display
connectivity state) to change while the laptop is asleep.

Signed-off-by: Evan Broder <evan@ebroder.net>
Signed-off-by: Richard Hughes <richard@hughsie.com>
2012-04-11 17:54:11 +01:00
Martin Pitt
1bb2b11b24 Fix crash in up_device_csr_finalize()
Commit 46f1c7f028 has a typo which prevents the fix from actually working.

https://launchpad.net/bugs/972300
2012-04-03 12:28:27 +02:00
Richard Hughes
2c02598806 Clamp the UPS percentage from 0 to 100 to fix syslog spam
This device bug seems to happen with CPS UPS units.
2012-02-17 10:30:47 +00:00
Richard Hughes
e51ffd27de Return all history records for a timespan of zero
This makes the code conform to the documentation.
2012-01-18 14:49:20 +00:00
Kelly Anderson
5b2211cb23 Do not print error message for missing /etc/crypttab.
Signed-off-by: Richard Hughes <richard@hughsie.com>
2012-01-18 10:29:48 +00:00
Benedikt Morbach
07a6c353a2 Install a systemd service file if systemd is used
This makes dbus defer starting upowerd to systemd instead of doing it itself
and thus puts the daemon under proper systemd supervision.

Signed-off-by: Richard Hughes <richard@hughsie.com>
2012-01-17 11:08:18 +00:00
Landry Breuil
19790b99a2 Add boolean RunPowersaveCommand to UPower.conf
Defaulting to true, it controls whether we want the powersave commands
to be run when running on battery/plugging ac.

Signed-off-by: Richard Hughes <richard@hughsie.com>
2012-01-06 16:40:09 +00:00
Landry Breuil
4f3150fb27 openbsd: set powersave command to apm -C/-A
Signed-off-by: Richard Hughes <richard@hughsie.com>
2012-01-06 13:40:50 +00:00
Landry Breuil
1f412fe279 openbsd: no need to pass the fd around
better access it where needed through the singleton.

Signed-off-by: Richard Hughes <richard@hughsie.com>
2012-01-06 13:40:50 +00:00
Landry Breuil
7cd8465811 openbsd: handle case where minutes_left might be negative
might not be useful since apm_fd is accessed through the singleton..

Signed-off-by: Richard Hughes <richard@hughsie.com>
2012-01-06 13:40:50 +00:00
Landry Breuil
3dfc0598f8 openbsd: improve logic wrt sensor type
in case some sensors are in AMPHOUR/AMPS and others in WATTHOUR/WATTS,
don't assume they are all the same type. As a benefit, shrinks the
code a bit.

Signed-off-by: Richard Hughes <richard@hughsie.com>
2012-01-06 13:40:50 +00:00
Landry Breuil
37ff0d4ddb openbsd: fix energy-rate calculation
since acpibat.c r1.59, bst_rate type is SENSOR_AMPS or SENSOR_WATTS
and value has been corrected. Tweak accordingly.

Signed-off-by: Richard Hughes <richard@hughsie.com>
2012-01-06 13:40:50 +00:00
Landry Breuil
60e474ead5 openbsd: use a singleton pattern to access /dev/apm
up_apm_get_fd() opens /dev/apm  only if it's not already opened.

Signed-off-by: Richard Hughes <richard@hughsie.com>
2012-01-06 13:40:50 +00:00
Landry Breuil
6c15694dbb openbsd: Fix history by not trying to refresh if /dev/apm wasn't opened yet
Signed-off-by: Richard Hughes <richard@hughsie.com>
2012-01-06 13:40:46 +00:00
Martin Pitt
6bb3623d46 src/linux/integration-test: Fail gracefully if GI is not available 2011-12-05 10:44:35 +01:00
Martin Pitt
8fc9a1d750 Fix invocation of src/linux/integration-test
In Makefile.am "check", do not call the test suite through "python". Just call
it directly and let the hashbang take care of the interpreter.
2011-12-05 10:32:04 +01:00
Martin Pitt
492a8c2283 Revert "src/linux/integration-test: Do not crash on absent _outcomeForDoCleanups"
This reverts commit 14761c09d2.

The real reason for the failure is that Makefile.am calls the script with
"python" which is Python 2, but we need Python 3.
2011-12-05 10:30:14 +01:00
Martin Pitt
14761c09d2 src/linux/integration-test: Do not crash on absent _outcomeForDoCleanups
unittest.TestCase unfortunately does not have any public API to check whether
a test case succeeded, so we use the private self._outcomeForDoCleanups. This
does not seem to exist every time, so avoid a crash if it doesn't.
2011-12-05 10:24:37 +01:00
Heiko Stübner
88c6d141ef upower: Handle Linux power supplies not exporting a present property
According to Anton Vorontsov (Linux power supply maintainer) power
supplies should not export a present property when they are not
hotpluggable and users of the properties should handle supplies
without present-property as always present.

This patch implements this feature using an additional
sysfs_file_exists call before sysfs_get_bool.

Signed-off-by: Richard Hughes <richard@hughsie.com>
2011-12-03 13:10:08 +00:00
Richard Hughes
6b685799cc trivial: USB devices are assumed to be 5V 2011-11-29 15:59:36 +00:00
Richard Hughes
21da4824a7 trivial: fix the name of the percentage file 2011-11-29 15:47:26 +00:00
Richard Hughes
c7cf8aa16a Don't assert when the power_supply device type is usb 2011-11-29 15:42:24 +00:00
Richard Hughes
3901d902fd Move the wacom hack to allow us to support other types of USB device 2011-11-29 14:05:18 +00:00
Richard Hughes
d4ea1cb566 If a power-supply device doesn't report charge or energy, try to read the percentage 2011-11-29 14:04:22 +00:00
Martin Pitt
46f1c7f028 Fix crash in up_device_csr_finalize()
Spotted when running regression tests in KVM. There, initializing a HID device
causes a "could not initialize libusb: -99" warning, but the device is created
nevertheless. Do not crash in _finalize() by trying to call libusb_exit(NULL).
2011-11-11 15:50:15 +01:00
Martin Pitt
d92aec6520 src/linux/integration-test: Port to Python 3 2011-11-11 15:19:04 +01:00
Leonardo Robol
b971b43c45 Use linear regression to get better predicted battery times
For hardware that has no rate data we use the differences in charge over a time
period to work out the effective rate. Using linear regression this estimation
is much more realistic.

To do this, introduce a simple circular buffer and use an index to calculate
the rate on each update.

Signed-off-by: Richard Hughes <richard@hughsie.com>
2011-10-19 17:13:51 +01:00
Richard Hughes
58f77e8aa6 Don't spam the log when we're saving history when on low power
Resolves: https://bugs.freedesktop.org/show_bug.cgi?id=41486
2011-10-06 09:12:04 +01:00
Landry Breuil
60e5e29188 Add --with-historydir to specify where we want the history files to be stored
Signed-off-by: Richard Hughes <richard@hughsie.com>
2011-10-04 14:53:46 +01:00
Richard Hughes
52bef2b461 Filter all the debugging details unless --verbose is specified
Now systemd is pushing all our debugging to syslog, we're upsetting some people.
2011-09-28 16:13:20 +01:00
Richard Hughes
fe643d6fc0 trivial: remove an overzealous warning when starting up 2011-09-28 16:12:40 +01:00
Christian Seiler
ff23a9c6e2 Fix linux up_backend_supports_sleep_state() return code.
Under Linux, regardless of the exit code of /usr/bin/pm-is-supported, it will
always set CanSuspend and CanHibernate to true due to a logic error in
up_backend_supports_sleep_state in src/linux/up-backend.c: The 'ret' variable
is re-used for the return code without being re-initialized to false after the
call to g_spawn_command_line_sync.

Signed-off-by: Martin Pitt <martin.pitt@ubuntu.com>
2011-09-22 17:34:45 +02:00
Martin Pitt
75d8c449cd src/linux/integration-test: Fully port to GI
Move from static glib to GI GLib module, to avoid mixing static and dynamic
bindings.

This fixes the tests to work with pygobject 3.
2011-09-05 14:38:31 +02:00
Denis Washington
785ecbb6d5 Use g_unix_signal_add_full() which has been renamed in the unstable GLib branch
Signed-off-by: Richard Hughes <richard@hughsie.com>
2011-08-31 22:43:40 +01:00
Richard Hughes
cb37dcc2e8 Hardcode wacom battery devices as not power-supply devices
We'll switch to a kernel property when the power_supply interface is fixed.
2011-07-19 16:14:20 +01:00
Richard Hughes
b19fca9637 Use git.mk and remove the manual .gitignore files 2011-07-19 12:40:21 +01:00
Richard Hughes
2d8358ae4e Fix how we estimate the device rate for batteries that do not provide this data
Based on a patch from Andy Eyre <andrew.eyre@medschool.ox.ac.uk>, many thanks.
2011-07-01 17:14:58 +01:00
Landry Breuil
fed9c33910 Add openbsd missing includes for close() and strcmp() 2011-05-31 11:07:52 +01:00
Landry Breuil
e495d53661 Silence some openbsd warnings about unused vars and bad return values 2011-05-31 11:07:21 +01:00
Richard Hughes
2b42890480 Only include glib-unix.h if the GLib version is >= 2.29.4
Many thanks to Takahiro HASHIMOTO for debugging the problem. Fixes fdo#37489
2011-05-23 09:42:38 +01:00
Richard Hughes
abfb19d472 Ensure up-apm-native.h gets shipped in the tarball 2011-05-17 08:23:55 +01:00
Martin Pitt
a1fe30811d Linux integration tests: check energy vs. charge
So far the test cases only covered drivers which reported energy (µWh). Add
checks that the Energy* properties are correct, and add a test case for drivers
which report charge (µAh).
2011-05-14 14:39:16 +02:00