The NoPollbatteries option should disable battery polling. Create
a config file with 'NoPollBatteries=true' and ensure we don't get
polling setup for the virtual battery.
https://bugs.freedesktop.org/show_bug.cgi?id=99763
Use an inhibitor lock obtained via logind to make sure the polling
is paused before the system is put to sleep, rather than racing with
the suspension.
https://bugs.freedesktop.org/show_bug.cgi?id=99763
The battery levels might have changed drastically compared to
before sleep. Since we poll batteries at set intervals, it can
take quite some time for the new level to be picked up by the
polling code.
Listen to the "PrepareForSleep" signal emitted by logind, that
gets emitted on suspend and wake up. Pause polling globally on
suspend, and refresh all devices manually and resume polling when
waking up.
https://bugs.freedesktop.org/show_bug.cgi?id=99763
GUdev-CRITICAL **: g_udev_device_get_sysfs_path: assertion 'G_UDEV_IS_DEVICE (device)' failed
This is caused by looking for devices in a particular subsystem which
don't have parents. This can happen with virtual devices, such as the
ones created by test suites.
When setting up polling for our devices, it's possible that the device
hasn't yet been exported on D-Bus, meaning that the object would be
unhelpfully empty.
Use the "native path" instead, so we don't get null in debug outputs, or
timeout names.
Backlights, starting with kernel 4.11 [1] can have a
"brightness_hw_changed" sysfs attribute, which can be polled to detect
hardware initiated brightness changes, such as ones done through
firmware-handled keyboard backlight hotkeys, or firmware controlled
changes (eg. turn off backlight on low battery).
[1] https://patchwork.kernel.org/patch/9544111/https://bugs.freedesktop.org/show_bug.cgi?id=98404
Pass the fd to use to up_kbd_backlight_brightness_read() so that it can
be used with multiple fds. This will be used to support the
"brightness_hw_changed" sysfs attribute.
https://bugs.freedesktop.org/show_bug.cgi?id=98404
There are multiple possible causes for the keyboard brightness to change,
e.g. SetBrightness may get called, or the brightness may get changed
through a hotkey which is handled in firmware.
https://bugs.freedesktop.org/show_bug.cgi?id=98404
When starting up, we would try to connect to the iDevice repeatedly,
once a second. But the process takes between a quarter and half a
second, and is CPU heavy. Lower this timeout to once every 5 seconds to
reduce the initial CPU consumption.
When GetBrightness is called it's better to fetch the current value in the
sysfs attribute since many devices doesn't support the emission of brightness
changes to userland, and this could make settings daemons to handle
this value incorrectly.
Add static up_kbd_backlight_brightness_read that is now called during
initialization too, it returns -1 on errors, and use it everywhere we need
to read or check the current brightness.
https://bugs.freedesktop.org/show_bug.cgi?id=95457
GObject _new constructors should always return a new pointer and not do
anything else than g_{object,initable}_new(). Drop the internal
up_client_object singleton instance.
This simplifies the code and makes the code robust with multiple threads.
Side issue in https://bugs.freedesktop.org/show_bug.cgi?id=95350
This avoids spewing dozens of assertions like
libupower-glib-CRITICAL **: up_client_get_devices: assertion 'UP_IS_CLIENT (client)' failed
libupower-glib-CRITICAL **: up_device_get_object_path: assertion 'UP_IS_DEVICE (device)' failed
and useless default values and then exiting successfully (which might confuse
users or scripts trying to parse the output).
Use the new up_client_new_full() constructor so that we get a proper GError.
Side issue in https://bugs.freedesktop.org/show_bug.cgi?id=95350
A GObject's _init() should never fail or block, but this is currently the case
as up_client_init() connects to upowerd on D-Bus. Convert this to the GInitable
interface and provide a new constructor up_client_new_full() which accepts a
GCancellable and GError, so that clients can do proper error handling
and reporting.
This changes up_client_new() to return NULL when connecting to upowerd fails.
This provides a more well-defined behaviour in this case as clients can check
for this and our methods stop segfaulting as they have checks like
g_return_val_if_fail (UP_IS_CLIENT (client), ...)
Previously we returned a valid object, but trying to call any method on it
segfaulted due to the NULL D-Bus proxy, so client code had no chance to check
whether the UpClient object was really valid.
https://bugs.freedesktop.org/show_bug.cgi?id=95350