Commit graph

1030 commits

Author SHA1 Message Date
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
Bastien Nocera
8460a10c5e linux: Remove debug 2013-10-17 14:41:55 +02:00
Bastien Nocera
c91abb77ed tools: Update for lib API changes 2013-10-17 14:39:16 +02:00
Bastien Nocera
5f43bb78f7 lib: Remove up_client_enumerate_devices_sync()
And make device-removed send an object path, not a UpDevice.

This means that we don't keep all the remote devices as local
UpDevices object, getting woken up any time any of them have a
property changed, without anybody listening.

This should greatly cut down on the wakeups on the client side,
especially for applications that only use a small portion of the API
like the "on-battery" or "warning-level" properties.
2013-10-17 14:36:35 +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
8453da5014 tools: Use notify signals instead of *changed ones 2013-10-17 12:40:05 +02:00
Bastien Nocera
595d72f6b6 lib: Proxy notify changes from UpDevice glue 2013-10-17 12:37:29 +02:00
Bastien Nocera
c33528da7a lib: Simplify proxying glue properties in UpClient 2013-10-17 12:36:44 +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