Commit graph

699 commits

Author SHA1 Message Date
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
4d0af3b31b linux: Add NoPollBatteries configuration option
For system integrators. If your firmware is helpful to user space
and automatically sends out uevent when the battery level changes
(rather than just the battery state) as on most machines,
you can enable "NoPollBatteries" in the configuration option,
and reduce power consumption from UPower and its listeners.
2013-10-26 14:55:15 +02:00
Bastien Nocera
64b1cc0f1d linux: Split up battery and device refresh
In up_device_supply_refresh().
2013-10-26 14:55:15 +02:00
Bastien Nocera
f62e7f11a7 linux: Move poll disable to another function 2013-10-26 14:55:15 +02:00
Bastien Nocera
feea39fa43 linux: Only disable timeouts if ever set
We cannot ever set the refresh timeout when we have a power line
device, so don't try and remove it there.
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
7921e97b08 linux: Poll for unknown state like the daemon did
5 times, with 1 second timeouts, instead of 30 times, with
2 seconds timeouts.
2013-10-26 14:55:15 +02:00
Bastien Nocera
7804f8b08e linux: Fix the "unknown state" heavy poll
It was never actually setup, as the fallback state was used
to check whether we should use poll or not.
2013-10-26 14:55:15 +02:00
Martin Pitt
22da1a0bc5 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
2013-10-22 10:02:51 +02:00
Bastien Nocera
cf5d24922e linux: Fix parsing of double values for certain locales
I don't think the kernel exports any numbers with a decimal
portion, but if they did, they would get the wrong values because
some locales use "," as the decimal separator, and not "." as the
kernel/C locale would.
2013-10-20 13:51:21 +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
21ecc70ccd daemon: Restart upowerd when it crashes
When UPower crashes, we would never notice the battery going flat
because UPower clients aren't polling UPower, so won't autostart it.

Instead we rely on systemd to restart us when we crash. libupower-glib
also supports the client coming and going.

https://bugzilla.gnome.org/show_bug.cgi?id=682912
2013-10-19 20:19:11 +02:00
Bastien Nocera
0741e5b591 linux: Finish "fixing" the UPS test case
Update the expected warning levels to match, and add a big
fat FIXME for the test case itself. That's not how UPSes work,
or how UPower is expected to work.
2013-10-18 18:43:50 +02:00
Bastien Nocera
585ff606c0 daemon: No warning with no LEDs class
If there are no LED class devices on the system, no need
to print a warning when we cannot open the directory.
2013-10-18 18:43:07 +02:00
Bastien Nocera
5be178ca5b daemon: Don't get in a bad state when refresh fails
Failure to refresh was supposed to be non-fatal, but since
we started putting objects on the bus *after* refresh, we
were skipping the registration if refresh failed, as is
the case in the UPS test case.
2013-10-18 18:41:30 +02:00
Bastien Nocera
cd52ad6d1c daemon: Fix typos in comments 2013-10-18 18:41:12 +02:00
Bastien Nocera
7389aa9517 linux: More information in the debug output
As was the case in other places, we need to be able to differentiate
warning messages for them to be useful.
2013-10-18 18:40:28 +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
aa8fafca9e linux: Fix tests for "OnLowBattery"
Replace them all with WarningLevel tests.

Note we current crash when adding a UPS, in test_ups_ac.
2013-10-18 17:49:07 +02:00
Bastien Nocera
b3ee72144e linux: Add TODO item for the GetCriticalAction binding 2013-10-18 17:46:41 +02:00
Bastien Nocera
720680d685 linux: get_properties_sync() doesn't exist anymore 2013-10-18 17:37:10 +02:00
Bastien Nocera
fa1fb8404f linux: Add helper to get DisplayDevice property
In the integration tests.
2013-10-18 17:36:00 +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
7fcce91567 daemon: Add small doc update_warning_level 2013-10-18 17:34:09 +02:00
Bastien Nocera
af930df8b1 linux: Add new definitions
Proxy paths, and enumeration from the current API.
2013-10-18 16:58:48 +02:00
Bastien Nocera
dd4f878f12 linux: Fix UMockdev typelib not being found
The Makefile rule was using GI_REPOSITORY_PATH instead of
GI_TYPELIB_PATH meaning that if a custom typelib path was needed
(jhbuild for example) it wouldn't be found.
2013-10-18 16:41:14 +02:00
Bastien Nocera
f989b61d43 linux: Mark devices with 100% battery as full 2013-10-18 16:21:08 +02:00
Bastien Nocera
9bc66af96f linux: Fix Bluetooth devices appearing with 0% battery
When switching off Bluetooth devices, and before they timeout,
we won't be able to read the battery percentage, so don't
overwrite the previous value with "0%", but set the state to
unknown instead.

https://bugs.freedesktop.org/show_bug.cgi?id=70325
2013-10-18 16:16:54 +02:00
Bastien Nocera
4b4caf187f linux: Add a way to check when sysfs_get_double fails 2013-10-18 16:16:54 +02:00
Bastien Nocera
456a9a4ea4 linux: Use up_device_supply_get_string()
In up_device_supply_get_state()
2013-10-18 16:16:54 +02:00
Bastien Nocera
a1a91e7e5d linux: Add a simpler, quicker path for devices
When refreshing the state of device batteries, no need
to get data that won't be there anyway, such as voltage, temperature,
or consumption rate.

This avoids warnings about voltage being unknown for devices, and
cuts down on the properties churn.
2013-10-18 16:16:54 +02:00
Bastien Nocera
2e4ed0c644 linux: Split off device state retrieval
We're going to be reusing this elsewhere.
2013-10-18 16:16:54 +02:00
Bastien Nocera
8aaa59243c linux: Ignore ACs coming from devices
We already have enough information on the device battery.
This avoids having a device for the wacom AC which we won't use.
2013-10-18 16:16:54 +02:00
Bastien Nocera
b3d2368454 linux: Remove incorrect statement
Not all "UpDeviceSupply" actually supply power to the computer.
2013-10-18 15:21:17 +02:00
Bastien Nocera
aa5636e559 daemon: Fix crash when device is removed
When the device was removed, we forgot to cancel sending
out changed properties, causing illegal memory accesses.
2013-10-17 23:33:08 +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
c33729ad2c linux: Use boolean values in sysfs_get_bool, not int 2013-10-17 23:20:22 +02:00
Bastien Nocera
984ca2d5ee linux: Remove unused sysfs utils functions 2013-10-17 23:20:22 +02:00
Bastien Nocera
8460a10c5e linux: Remove debug 2013-10-17 14:41:55 +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
a7870229ee linux: Fix incorrect check for logind sleep methods
A simple reversed check...
2013-10-17 08:56:41 +02:00
Bastien Nocera
b777c63d97 daemon: Make warning-level UpDevice property writable
So we can update the display device warning level.
2013-10-17 01:07:06 +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
c2426adb4b daemon: Add documentation for computed properties
Those are also part of the display device properties that we
will update.
2013-10-16 15:58:39 +02:00
Bastien Nocera
b72973472c daemon: Mention hard-coded display device object path
/org/freedesktop/UPower/devices/DisplayDevice is a stable
object path.
2013-10-16 15:58:13 +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
f065cd202c daemon: Fix sending device's PropertiesChanged signal
The interface name was missing ".Device" at the end, so wasn't
getting registered by clients.
2013-10-16 15:56:19 +02:00