Commit graph

530 commits

Author SHA1 Message Date
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
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
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
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
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
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
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
af930df8b1 linux: Add new definitions
Proxy paths, and enumeration from the current API.
2013-10-18 16:58:48 +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
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
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
ac1708e86e daemon: Require newer GLib
And remove ifdef's.
2013-10-14 11:06:53 +02:00
Bastien Nocera
68b9975ad9 daemon: Add CriticalPowerAction
Paraphrasing from the configuration option:
The action to take when "TimeAction" or "PercentageAction" above has
been reached for the batteries (UPS or laptop batteries) supplying
the computer.

This is done 20 seconds after the warning-level variable got set
to UP_DEVICE_LEVEL_ACTION has been set, to give the opportunity
to front-ends to display a (short) warning.

This is only implemented for the Linux backend, using logind.
2013-10-14 11:06:53 +02:00
Bastien Nocera
bd3a57fe04 daemon: Replace "on-low-battery" property
With "warning-level" property.
2013-10-14 10:42:56 +02:00
Bastien Nocera
91df125e39 daemon: Remove unneeded reset of priv struct members
It's already done by GObject.
2013-10-14 10:42:56 +02:00
Bastien Nocera
c842f1a53e Remove obsolete battery recall properties
The recalls for that broken batch of Sony batteries dates back from
2006. All the batteries that could have been recalled have now
been recalled, and somebody particularly interested in supporting
them can match the batteries using the old rules file, in a
user session or a separate daemon.
2013-10-14 10:42:55 +02:00
Bastien Nocera
1ee642e705 daemon: Remove obsolete features 2013-10-14 10:42:55 +02:00
Bastien Nocera
5f26bc5caa daemon: Simplify _new() functions 2013-10-14 10:36:34 +02:00
Bastien Nocera
cb759a05c8 linux: Don't print a warning if the status sysfs attr is missing
This is the case for some devices like the Wacom wireless (Bluetooth)
tablets, and shouldn't produce a warning.
2013-10-14 10:26:53 +02:00
Bastien Nocera
6abd4123ef linux: Opt-out of checking Watts Up devices earlier
Don't wait for tty events from udev if we're not going to
use the Watts Up device anyway. Cuts down on the possible wakeups.
2013-10-14 10:18:21 +02:00
Bastien Nocera
f3898db4d3 linux: Don't guess discharging state for devices
If the device state is unknown, don't guess based on the laptop's
power supplies (battery/power line) as it might not be charging
from there.

https://bugs.freedesktop.org/show_bug.cgi?id=70321#c1
2013-10-14 10:07:21 +02:00
Martin Pitt
9975526265 Linux integration tests: Fix PEP8 errors 2013-10-08 17:19:27 +02:00
Martin Pitt
2aa24aeed2 Linux integration tests: Fix pyflakes errors
Drop a lot of unused variables
2013-10-08 17:13:06 +02:00
Martin Pitt
e89d047680 Linux integration tests: First test case for library
Start testing the client-side library through gobject-introspection.

This covers https://bugs.freedesktop.org/show_bug.cgi?id=70283
2013-10-08 17:06:14 +02:00