Commit graph

119 commits

Author SHA1 Message Date
Miroslav Sustek
212599f0ee daemon: Fix critical action after resume from hibernate
The take_action_timeout_cb() function returns G_SOURCE_REMOVE which
makes GLib destroy the timeout. However the action_timeout_id
stayed != 0 so when warning level turned to "action" again the daemon
assumed that the timeout is already set and did nothing.
(It only logged: "Not taking action, timeout id already set")

https://bugs.freedesktop.org/show_bug.cgi?id=87791
2017-09-21 17:10:19 +02:00
Bastien Nocera
ef592ca52d Revert bug 99862 patchset
The patchset was pushed by mistake and is still being reviewed.
2017-09-08 18:23:32 +02:00
Christian Kellner
e4b85ef5df daemon: more efficient poll resetting
If the poll timeout is actually changed because the warning level
has changed, only reset the actual poll code, not the warning level
notifications and the booking structures.

https://bugs.freedesktop.org/show_bug.cgi?id=99862
2017-09-08 18:05:19 +02:00
Christian Kellner
7171ce38d6 daemon: move two functions up
No semantic change.

https://bugs.freedesktop.org/show_bug.cgi?id=99862
2017-09-08 18:05:18 +02:00
Christian Kellner
924b42e4f8 daemon: only reset poll if warning-level changed
When a device is refreshed because the poll timeout has been reached,
the warning-level change notification can also be fired, which then
will reset (i.e. disable, re-enable) polling. For batteries this can
happen three times in a row.
Now we reset polling only if the calculated timeout actually differs
from the current one.

https://bugs.freedesktop.org/show_bug.cgi?id=99862
2017-09-08 18:04:15 +02:00
Bastien Nocera
660c8f3268 daemon: Move a number of constants to a shared file
https://bugs.freedesktop.org/show_bug.cgi?id=100359
2017-04-06 16:33:38 +02:00
Bastien Nocera
27a3eea5e5 daemon: Make warning levels for devices inclusive
A 5% battery level should already be in "critical", this matches the
configurable thresholds where the bounds of critical warnings are
inclusive. This also makes it easier to create fake percentages for the
Logitech devices with coarse battery level reporting.

https://bugs.freedesktop.org/show_bug.cgi?id=100359
2017-04-06 14:18:10 +02:00
Christian Kellner
a69d151907 daemon: Add support for pausing and resuming poll
Pausing stops the polling for all registered devices and resuming
re-enables the previously disabled polling, after re-calculating
the poll timeout.

https://bugs.freedesktop.org/show_bug.cgi?id=99763
2017-03-25 18:04:27 +01:00
Bastien Nocera
2b45b82af5 daemon: Fix polling helper debug output
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.
2017-03-24 15:46:40 +01:00
Martin Pitt
28cee8e284 daemon: fix get_critical_action()
Fix copy&paste error from e7e9156f that called the wrong _complete_ function
for up_daemon_get_critical_action().

https://bugs.freedesktop.org/show_bug.cgi?id=94262
2016-02-23 09:51:07 +01:00
Bastien Nocera
3e49e659d0 daemon: Lower the warning levels for input devices
Modern wireless input devices can last for dozens of minutes, or even
hours with a couple of percentage points of battery, so change the
warning levels to be more in line with that data.

See https://bugzilla.gnome.org/show_bug.cgi?id=756314

https://bugs.freedesktop.org/show_bug.cgi?id=92920
2015-11-12 16:38:45 +01:00
Cosimo Cecchi
16537df546 daemon: remove custom marshal setup
Just use the default marshaller.
2015-07-29 13:38:13 +01:00
Cosimo Cecchi
ab4160cad5 daemon: make UpDaemon a subclass of UpExportedDaemon
Simplifies some state tracking.
2015-07-29 13:38:13 +01:00
Cosimo Cecchi
e035f23ae0 daemon: port main() to GDBus
We also change the objects to export not to fetch their own bus object.
2015-07-29 13:37:11 +01:00
Cosimo Cecchi
e7e9156fe9 daemon: port UpDaemon to GDBus 2015-07-29 13:37:11 +01:00
Peter Wu
9639487d4e daemon: fix ulong/gulong typo
Regression in 4221835fae ("daemon:
properly disconnect signals, stop memleak").

https://bugs.freedesktop.org/show_bug.cgi?id=82659

Signed-off-by: Richard Hughes <richard@hughsie.com>
2014-12-03 17:31:59 +00:00
Peter Wu
90994b0d81 daemon: release resources at shutdown
This makes it easier to find real memory leaks with valgrind. After
calling the up_backend_unplug functions, you cannot restart it with
up_backend_coldplug since the lists are cleared.

Tested with Linux only (not on *BSD; dummy compiles).

https://bugs.freedesktop.org/show_bug.cgi?id=82659
2014-11-26 11:56:16 +00:00
Peter Wu
a91d03a3a9 daemon: fix various reference leaks
up_daemon_get_daemon takes a reference on UpDaemon, so it must be
properly dereferenced. Similar for up_daemon_get_devices_list which
references an UpDeviceList.

The display device was allocated in init, but never released either.

https://bugs.freedesktop.org/show_bug.cgi?id=82659
2014-11-26 11:56:15 +00:00
Peter Wu
4221835fae daemon: properly disconnect signals, stop memleak
Whenever the daemon is polling on a device, a new signal is connected to
the object. This signal was not disconnected when polling stops which
resulted in a memory leak. Furthermore, whenever the "warning-level"
property is updated, the signal would result in an exponentially raising
call count (this happens when the battery percentage changes for
example).

https://bugs.freedesktop.org/show_bug.cgi?id=82659

Reported-by: Alexander Jesner <alexander@jesner.eu>
Signed-off-by: Peter Wu <peter@lekensteyn.nl>
2014-11-26 11:56:13 +00:00
Peter Wu
f3dfc1ea83 daemon: fix memleak in queue_changed_property
The control of value is transferred to up_daemon_queue_changed_property,
let it release the memory when an error occurs.

https://bugs.freedesktop.org/show_bug.cgi?id=82659
2014-11-26 11:56:07 +00:00
Peter Wu
5eead9ecf6 daemon: remove unused variable
Introduced in 2e87407eb9

https://bugs.freedesktop.org/show_bug.cgi?id=86144
2014-11-18 11:32:38 +01:00
Bastien Nocera
2e87407eb9 daemon: Use new warning update helper function
Rather than the copy/paste code in commit:
b9bd275890387fb35c185f37ec0ea1f2aa857818

This makes sure that the AC status is updated.

https://bugs.freedesktop.org/show_bug.cgi?id=86144
2014-11-14 23:09:14 +01:00
Bastien Nocera
83ebd3eccb daemon: Update display device when battery is removed
When removing a battery, make sure to go through the batteries, and
update the display device status.

https://bugs.freedesktop.org/show_bug.cgi?id=86144
2014-11-14 23:09:13 +01:00
Bastien Nocera
4fdb9cee21 daemon: Split out updating on_battery and warning_level
So that we can reuse this code.

https://bugs.freedesktop.org/show_bug.cgi?id=86144
2014-11-14 23:09:12 +01:00
Evangelos Foutras
6864699209 daemon: Update aggregate device on battery removal
https://bugs.freedesktop.org/show_bug.cgi?id=84345

Signed-off-by: Richard Hughes <richard@hughsie.com>
2014-10-08 19:34:16 +01:00
Evangelos Foutras
bbe15b14de all: convert value from g_get_real_time() to seconds
Commit 5ddfe0d (all: Use g_get_real_time() when possible) replaced calls
to g_get_current_time() with g_get_real_time(), however, we also need to
convert the return value from microseconds to seconds.

Signed-off-by: Richard Hughes <richard@hughsie.com>
2014-10-08 19:32:05 +01:00
Bastien Nocera
8271045a68 daemon: Set update-time on the aggregate device 2014-09-24 15:16:11 +02:00
Alexander Jesner
47c6974fc0 Free the obtained device list array after use
Signed-off-by: Richard Hughes <richard@hughsie.com>
2014-08-18 12:49:41 +01:00
Eric Koegel
9a2b263309 Remove polkit dependency
With the removal of the suspend/hibernate code, there's no longer
a need for upower to depend on polkit. This patch removes the old
polkit code.

Signed-off-by: Richard Hughes <richard@hughsie.com>
2014-07-14 19:34:46 +01:00
Bastien Nocera
5ed25a7e5f all: Remove IsDocked property
Removes the deprecated (for not very long) property, before we do a 1.0
release.

https://bugs.freedesktop.org/show_bug.cgi?id=78380
2014-05-07 11:01:27 +02:00
Bastien Nocera
135339acc1 daemon: Deprecate "IsDocked" property
The IsDocked property has been incorrect for a number of laptops for a
while, as it thought that laptops with hybrid graphics cards were always
docked.

The alternative would have been to use the platform/dock_station
devices, but those are only exported for ACPI docking stations.

Instead, whether an external display is attached (which isn't really
docking) should be checked in the same place where the policy depending
on the value should be applied, such as gnome-settings-daemon.

https://bugs.freedesktop.org/show_bug.cgi?id=36818
2014-05-07 09:27:24 +02:00
Bastien Nocera
dbf7eb7e55 daemon: Fix shutdown on boot on some machines
On the Lenovo A600 all-in-one, there's a HCI/HID dual-mode Broadcom
device which will try to get the battery level of the supplied
mouse and keyboard, but will usually fail to do so.

So we have a battery of type "battery" (it's not either a mouse or
a keyboard, as it's supposed to handle both) but our display device
battery code doesn't check whether those batteries are power supplies
or not, using this "empty" (0% after the check timed out) battery in
the shutdown policy.

Check better for power supply devices, not all the "battery" types
are power supply batteries, they might be non-power supply ones
from unknown device types.
2014-04-23 15:48:48 +02:00
Bastien Nocera
b7d69524e8 daemon: Add poll helper functions
To be used by all polling backends. This changes the defaults
to poll every 120 seconds when a warning level isn't reached, and
switch automatically to 30 seconds poll when the battery level is low.
2013-10-28 15:15:02 +01:00
Bastien Nocera
6e8e659ca2 daemon: Better timeout source naming
Matching the work done in glib, gtk+, etc.

This also differentiates the unknown and normal timeouts in
the Linux power supply driver.
2013-10-26 14:55:15 +02:00
Bastien Nocera
9ce7b4408f daemon: Let the backends do the polling
When the AC state changes, let the backends poll for battery changes.
They know better what's _really_ happening (whether the real state
is unknown even if they present a fully-charged battery), etc.

This is only possible because we fixed the Linux backend to poll
as it should always have.
2013-10-26 14:55:15 +02:00
Bastien Nocera
498d4491ed daemon: Fix time to empty with multiple batteries
If one battery is draining and the other one isn't, the time
to empty wouldn't be zero, but it would only match the time
to empty for the single battery.

Instead, ignore the accumulated time to empty/time to full
for multiple batteries and recalculate it.

https://bugzilla.gnome.org/show_bug.cgi?id=710344
2013-10-20 13:30:23 +02:00
Bastien Nocera
ef2c951343 daemon: Differentiate 2 warnings
No way to know which one was being called otherwise
2013-10-18 17:52:56 +02:00
Bastien Nocera
b90ade819a daemon: Fix WarningLevel for devices with no "time to empty"
As can happen with missing metadata, we might not have a time
to empty, so rely on the percentage instead.
2013-10-18 17:34:31 +02:00
Bastien Nocera
36f46546e9 daemon: Remove dead code from up_daemon_device_changed_cb() 2013-10-17 23:24:09 +02:00
Bastien Nocera
0010e93251 all: Remove *changed signals
Now that we send out PropertiesChanged signals (on the daemon side)
and "notify" signals (on the client side), there's no need for the
all encompassing DeviceChanged and Changed signals.

They would have woken up any client, even if they were not interested
in receiving the signals.
2013-10-17 14:25:25 +02:00
Bastien Nocera
c9f3a13b29 power: Work-around batteries that are slow to notice charge
This is a hack that was in gnome-settings-daemon's power plugin.
We would check whether we were on AC before saying for certain
that batteries had a low-level, and raising the warning-level.
2013-10-17 11:31:41 +02:00
Bastien Nocera
db31456921 all: Add GetCriticalAction daemon method
This allows desktop front-ends to get which action will
actually be taken when we hit critical battery.

This is not a property as availability of actions might
change over the course of the run of the system, and
we didn't want to make unnecessary D-Bus calls on startup.
2013-10-17 09:04:03 +02:00
Bastien Nocera
b2f72dd69a all: Remove WarningLevel from the daemon properties
The WarningLevel property just replicated the warning level
on the display device, or at least should have. So we fix the latter
to remove the former.
2013-10-17 00:57:27 +02:00
Bastien Nocera
369a2c6d08 daemon: Indentation in UpDaemon struct 2013-10-17 00:37:29 +02:00
Bastien Nocera
511a1dbf7c daemon: Minimise WarningLevel signals
When it doesn't actually change, don't send out signals.
2013-10-16 15:57:34 +02:00
Bastien Nocera
cb9b1aaad8 daemon: Only modify display device when it changes
When none of the properties of the display device change,
do not modify it.
2013-10-16 13:48:25 +02:00
Bastien Nocera
bda51f5284 daemon: Add GetDisplayDevice method
And export a DisplayDevice object which can be used by desktop
shells to show/hide the status icon.
2013-10-16 13:42:34 +02:00
Bastien Nocera
e7eed719f2 daemon: Set the display device type when on battery
When on battery only, we weren't setting the display device type
properly.
2013-10-16 13:39:26 +02:00
Bastien Nocera
473b4c3568 daemon: Remove spurious linefeed 2013-10-16 13:05:54 +02:00
Bastien Nocera
5e5e737948 daemon: Add support for more types for PropertiesChanged
Add code to transform strings, doubles, uint64s, and int64s.
2013-10-15 17:50:18 +02:00