Commit graph

1200 commits

Author SHA1 Message Date
Bastien Nocera
5ccd4fe959 lib: Add UP_DEVICE_KIND_GAMING_INPUT for gaming devices
Joypads, joysticks, dance mats, paddles, Wiimotes, steering wheels,
tractor cabin simulators, pedals, yokes, breathing controllers, and,
hmm, etc.

https://bugs.freedesktop.org/show_bug.cgi?id=102493
2017-08-31 16:21:18 +02:00
Bastien Nocera
1dc2b96eec linux: Add test for wireless joypad connected via USB
Mostly for the type of device rather than the connections.

https://bugs.freedesktop.org/show_bug.cgi?id=102493
2017-08-31 16:21:14 +02:00
Benjamin Berg
502c63b549 linux: Correctly close inhibitor FD
The unref of the FD list for the inhibitor was missing which means that
the FD was leaked and the lock was never released. This means that for
each suspend/resume cycle a new inhibitor would be added.

Signed-off-by: Richard Hughes <richard@hughsie.com>
2017-08-03 16:21:12 +01:00
Richard Hughes
02b117f5ad trivial: post release version bump 2017-07-24 13:24:17 +01:00
Richard Hughes
82779915be Released UPower 0.99.5 2017-07-24 13:23:07 +01:00
Richard Hughes
798588a480 Do not spin in a loop when /proc/timer_stats cannot be written
Only set up the polling once the write has succeeded.

Fixes: https://bugs.freedesktop.org/show_bug.cgi?id=100626
2017-04-23 20:23:27 +01:00
Bastien Nocera
eb6b1b62a2 lib: Simplify string checks
We don't need to protect against NULL values, we already do at the start
of the function.

Created with:
:%s,g_strcmp0\(.*\) == 0,g_str_equal \1,

Mentioned in:
https://bugs.freedesktop.org/show_bug.cgi?id=100359#c14
2017-04-10 10:37:32 +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
499d05b837 all: Add BatteryLevel property
Export approximate battery levels that devices can use, exported by
the kernel as POWER_SUPPLY_CAPACITY_LEVEL_* values.

This avoids bizarrely accurate values showing up in UIs when we only
have ok/warning levels of accuracy in some cases.

https://bugs.freedesktop.org/show_bug.cgi?id=100359
2017-04-06 16:33:38 +02:00
Bastien Nocera
4f9230900b lib: Add more members to UpDeviceLevel struct
Those levels will not be used to cover warning levels, but approximate
battery levels that devices can use, exported by the kernel as
POWER_SUPPLY_CAPACITY_LEVEL_* values.

See linux/power_supply.h

https://bugs.freedesktop.org/show_bug.cgi?id=100359
2017-04-06 14:18:10 +02:00
Bastien Nocera
6b14798281 linux: Add support for "capacity_level" attribute
Some devices, such as a number of wireless Logitech unifying devices
don't have a precise battery level reporting, and use the Linux
POWER_SUPPLY_CAPACITY_LEVEL_* values.

This minimal fix matches the levels against approximate percentage
values. This is good enough to make the Logitech T650 report battery
again when using the kernel HID++ battery support.

https://bugs.freedesktop.org/show_bug.cgi?id=100359
2017-04-06 14:18:10 +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
c237298297 integration-test: Fix path for unparented device
Paths supplied to testbed.add_device() are relative to /sys/devices
already and therefore must not start with /sys/devices.

This does not change the result of the test.

https://bugs.freedesktop.org/show_bug.cgi?id=100539
2017-04-06 14:16:15 +02:00
Christian Kellner
90aec997ce integration-test: enable running from JHBuild
https://bugs.freedesktop.org/show_bug.cgi?id=99763
2017-03-25 18:08:50 +01:00
Christian Kellner
b292ee2035 integration-test: Check NoPollbatteries is followed
The NoPollbatteries option should disable battery polling. Create
a config file with 'NoPollBatteries=true' and ensure we don't get
polling setup for the virtual battery.

https://bugs.freedesktop.org/show_bug.cgi?id=99763
2017-03-25 18:08:35 +01:00
Christian Kellner
a4d7d84b34 integration-test: Add test for refresh after sleep
This also tests suspending and resuming polling as a
by-product.

https://bugs.freedesktop.org/show_bug.cgi?id=99763
2017-03-25 18:07:57 +01:00
Christian Kellner
09cdb0ccfc linux: Use inhibitor lock to guard poll pausing
Use an inhibitor lock obtained via logind to make sure the polling
is paused before the system is put to sleep, rather than racing with
the suspension.

https://bugs.freedesktop.org/show_bug.cgi?id=99763
2017-03-25 18:07:02 +01:00
Christian Kellner
01cd65c1a7 linux: Refresh devices after waking up from sleep
The battery levels might have changed drastically compared to
before sleep. Since we poll batteries at set intervals, it can
take quite some time for the new level to be picked up by the
polling code.

Listen to the "PrepareForSleep" signal emitted by logind, that
gets emitted on suspend and wake up. Pause polling globally on
suspend, and refresh all devices manually and resume polling when
waking up.

https://bugs.freedesktop.org/show_bug.cgi?id=99763
2017-03-25 18:04:59 +01: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
c885c4c886 integration-test: Add test for unparented input devices
The test would fail without the fix from commit 86e5237, and succeed
with it.
2017-03-24 17:16:32 +01:00
Bastien Nocera
86e5237807 linux: Fix critical when searching for sibling devices
GUdev-CRITICAL **: g_udev_device_get_sysfs_path: assertion 'G_UDEV_IS_DEVICE (device)' failed

This is caused by looking for devices in a particular subsystem which
don't have parents. This can happen with virtual devices, such as the
ones created by test suites.
2017-03-24 17:14:06 +01:00
Bastien Nocera
a2eecff867 integration-test: Use symbolic names for device types
Instead of using comments to explain the magic values.
2017-03-24 17:03:36 +01:00
Christian Kellner
d69121971f integration-test: add get_critical_action() test
https://bugs.freedesktop.org/show_bug.cgi?id=99763
2017-03-24 15:46:40 +01:00
Christian Kellner
305a24a115 integration-test: use dbusmock to mock logind
Derive from dbusmock.DBusTestCase and add {start,stop}_logind
to enable tests that need logind.

https://bugs.freedesktop.org/show_bug.cgi?id=99763
2017-03-24 15:46:40 +01:00
Bastien Nocera
7bf91faa94 device: Remove extraneous linefeed in g_debug()
g_debug() already adds a linefeed.
2017-03-24 15:46:40 +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
Bastien Nocera
4292226e5c linux: Fix compilation warning
duplicate ‘const’ declaration specifier

We can't use a const char const because we actually want to assign
values to elements of the array.
2017-03-24 15:46:40 +01:00
Bastien Nocera
4be1efe819 integration-test: HID++ mouse is a mouse 2017-03-24 15:19:12 +01:00
Hans de Goede
0e256ece04 UpKbdBacklight: Send notifications about hardware brightness changes
Backlights, starting with kernel 4.11 [1] can have a
"brightness_hw_changed" sysfs attribute,  which can be polled to detect
hardware initiated brightness changes, such as ones done through
firmware-handled keyboard backlight hotkeys, or firmware controlled
changes (eg. turn off backlight on low battery).

[1] https://patchwork.kernel.org/patch/9544111/

https://bugs.freedesktop.org/show_bug.cgi?id=98404
2017-02-15 17:33:24 +01:00
Hans de Goede
d28ee53aa5 UpKbdBacklight: Allow reading from alternate fd in _brightness_read()
Pass the fd to use to up_kbd_backlight_brightness_read() so that it can
be used with multiple fds. This will be used to support the
"brightness_hw_changed" sysfs attribute.

https://bugs.freedesktop.org/show_bug.cgi?id=98404
2017-02-15 17:33:24 +01:00
Hans de Goede
112814fd4f UpKbdBacklight: Add new BrightnessChangedWithSource signal
There are multiple possible causes for the keyboard brightness to change,
e.g. SetBrightness may get called, or the brightness may get changed
through a hotkey which is handled in firmware.

https://bugs.freedesktop.org/show_bug.cgi?id=98404
2017-02-15 17:33:16 +01:00
Bastien Nocera
12d34b8a8b Revert "linux: Disable crashing test"
This reverts commit 8aff086b48.

The crash is fixed in umockdev 0.8.13
2017-01-26 11:35:34 +01:00
Bastien Nocera
1de37eb958 linux: Get a serial number for device batteries
And not just for batteries that power the machine itself.
2017-01-24 18:08:52 +01:00
Bastien Nocera
d5c05515a8 linux: Add a serial number to mouse battery test
Which will fail, as the device code doesn't even try to get a serial
number.
2017-01-24 18:08:24 +01:00
Bastien Nocera
efe589a8ce linux: Add a test for HID++ devices 2017-01-24 17:48:47 +01:00
Bastien Nocera
d47f3eb84b linux: Simplify getting the device type
1) Get the sibling device
2) Check its type

This fixes the test_bluetooth_hid_mouse_no_legacy_subdevice test.
2017-01-24 17:45:58 +01:00
Bastien Nocera
8aff086b48 linux: Disable crashing test
Filed as an issue against umockdev:
https://github.com/martinpitt/umockdev/issues/53
2017-01-24 17:45:58 +01:00
Bastien Nocera
f711bc3865 linux: Always stop daemon when started in tests 2017-01-24 17:45:58 +01:00
Bastien Nocera
c5d1660b5c linux: Allow running upowerd under valgrind in tests 2017-01-24 17:45:58 +01:00
Bastien Nocera
caf53bd982 linux: Parent the keyboard device correctly in tests 2017-01-24 17:45:58 +01:00
Bastien Nocera
89a3baad69 linux: Add test without the "mouse" legacy node
Which currently fails. Which is what will happen with an older UPower on
a newer kernel with that removed.
2017-01-24 17:45:58 +01:00
Bastien Nocera
e8e20ac64a linux: Parent Bluetooth mouse test devices properly 2017-01-24 17:45:58 +01:00
Bastien Nocera
e3b6e1426b linux: Simplify up_device_supply_guess_type()
By exiting early.
2017-01-24 17:45:58 +01:00
Bastien Nocera
140b18f8f4 linux: Remove unneeded goto 2017-01-24 17:45:58 +01:00
Bastien Nocera
5b217179be linux: Split off device type detection
The code is far too deep to be left in this function, let's split it
off to make it more readable.
2017-01-24 17:45:58 +01:00
Bastien Nocera
f0ec467d00 linux: Move declaration of variables closer to use
Will make it easier to move to a separate function.
2017-01-24 12:59:43 +01:00
Bastien Nocera
937760f491 linux: Don't talk to HID++ devices ourselves
If the kernel already extract the battery information out of them.
2017-01-23 15:27:33 +01:00
Bastien Nocera
3e06274e00 daemon: Remove unused test declarations
All those test functions were removed in 6ba8629 and are now unused.
2016-07-08 18:51:14 +02:00
Bastien Nocera
402640bee0 linux: Lower initial power usage when iDevice isn't accessible
When starting up, we would try to connect to the iDevice repeatedly,
once a second. But the process takes between a quarter and half a
second, and is CPU heavy. Lower this timeout to once every 5 seconds to
reduce the initial CPU consumption.
2016-06-08 14:50:23 +02:00
Bastien Nocera
54dd83501a linux: Add better debug for iDevice startup poll 2016-06-08 14:47:25 +02:00