This case was apparently overlooked when adding systemd support.
Signed-off-by: Jan Alexander Steffens (heftig) <jan.steffens@gmail.com>
Signed-off-by: Richard Hughes <richard@hughsie.com>
When running under systemd, call into systemd for suspend and
hibernate instead of pm-utils. To capture resume events, install
a small script that gets executed by systemd after resume and
sends a dbus signal back to upower.
To make this work, the upower backends gain a new signal, ::resuming,
that they can optionally emit to signal that a resume happened.
Backends opt in to this by returning TRUE from up_backend_emits_resuming().
In this case, upower doesn't assume the sleep command to block until
resume, but instead waits for the ::resuming signal from the backend.
The only backend that uses this mechanism is the linux backend when
built with systemd support.
Signed-off-by: Richard Hughes <richard@hughsie.com>
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
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.
GLib 2.33 and further deprecates GValueArray. However, we still need it as long
as we are using dbus-glib, so selectively disable the deprecation warnings for
the three functions that use GValueArray. This allows us to continue to build
with -Werror.
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>
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>
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>
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
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>
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>
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>
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>
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>
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.
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.
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>