Commit graph

1039 commits

Author SHA1 Message Date
Richard Hughes
97ed6c4731 trivial: Fix a compile warning in the linux backend 2013-10-29 12:51:23 +00:00
Bastien Nocera
e673d9e59b linux: Use daemon poll for batteries too
This has 2 effects:
- we never stop polling (we used to stop polling when the
  battery was marked as fully-charged, but that can happen when
  the battery is discharging too)
- when in an unknown state, we will poll through the daemon,
  and through our unknown poll. This isn't a problem as there'll
  another 115 seconds of wait until we get to poll through the
  daemon again.
2013-10-28 16:28:57 +01:00
Bastien Nocera
03591e6e05 linux: Switch non-battery devices to use the new daemon poll
Next up is doing this for batteries, which need to switch between
a normal/slow poll to a faster one when the battery state is unknown.
2013-10-28 15:15:02 +01:00
Bastien Nocera
d1032c562a linux: Switch Unifying devices to use the new daemon poll 2013-10-28 15:15:02 +01:00
Bastien Nocera
988889121e linux: Switch iDevices to use the new daemon poll
And remove the gathering of the battery poll from the device
itself, it's of nearly no use.
2013-10-28 15:15:02 +01:00
Bastien Nocera
8018418a97 linux: Switch CSR devices to use the new daemon poll 2013-10-28 15:15:02 +01: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
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
Benedikt Morbach
a30ad0beae build: Fix --without-systemdunitdir / --without-systemdutildir
would take the with_*=no as a value and try to install to a "no" directory

https://bugs.freedesktop.org/show_bug.cgi?id=62060
2013-10-21 10:29:48 +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
aa62f6a15c lib: Fix possible warning when type changes
UpDevice on the daemon side has a "type" property, but the
libupower-glib object has a "kind" type instead. Translate that.
2013-10-17 23:20:22 +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
088da47833 NEWS: Explain better the *Changed removals 2013-10-17 23:20:16 +02:00
Bastien Nocera
384bae5af8 NEWS: Update for future release 2013-10-17 15:09:48 +02:00
Bastien Nocera
3063bdaf44 lib: Fix compile-time warning 2013-10-17 14:51:07 +02:00