Commit graph

412 commits

Author SHA1 Message Date
Benjamin Berg
7192ff481b linux: Set FD to -1 rather than 0 when closing delay inhibitor 2022-02-25 10:08:19 +01:00
Dominique Leuenberger
55f4b165a5 build: link libplist 2022-02-15 10:52:06 +00:00
Benjamin Berg
13aed812fd linux: Only warn about event type if an action was taken
At least for "change" events the device is most likely simply one that
we are not handling at all. For these, we will convert the event to
"add" and continue to ignore it later on.
2022-02-11 15:26:24 +01:00
Bastien Nocera
13157bce08 linux: Update Bluetooth device alias when it changes
Closes: #169
2022-02-07 15:16:50 +00:00
Benjamin Berg
d113f62727 history: Delay saving history even on low power
Otherwise we flush out the data much more often than needed. With this
change, we'll also wait up to 5 seconds even on lower power. Loosing 5s
of data shouldn't be too bad, and it may prevent additional disk writes.

But, more importantly, we need to deferre writing the data to a later
main loop iteration. If we did not do this, then we have an
write-amplification scenario where the history is written at least 4
times instead of once.

Closes: #150
2022-01-27 14:48:51 +01:00
Benjamin Berg
94af9d6f3d linux: Make test compatible with older dbusmock versions
The changes from 37b6d4b039 ("linux: Fix Bluetooth tests for
python-dbusmock changes") require a not-yet-released dbusmock version.
Simply catch the error and fall back to adding the properties in order
to be compatible with both old and new dbusmock versions of the bluez
service.
2022-01-27 13:11:45 +01:00
Thomas Weißschuh
1b1f8f375c linux: explicitly recognize USB power supplies
Prevents a spurious warning:
"did not recognise USB path /sys/devices/platform/USBC000:00/power_supply/ucsi-source-psy-USBC000:001, please report"

This does not actually change any functionality, as the heuristic for
the attribute "online" in up_device_supply_coldplug() would have
matches id, too.

Fixes #148
2022-01-24 14:09:24 +00:00
Bastien Nocera
1fdc0824b6 lib: Implement up_client_get_devices_async() 2022-01-23 23:26:33 +01:00
Bastien Nocera
95618dfad4 linux: Remove libtool support from test suite 2022-01-23 23:04:26 +01:00
Bastien Nocera
8f893964a2 tests: Add test for up_client_async*() functions 2022-01-21 22:35:28 +01:00
Bastien Nocera
04521b9870 linux: Fix warning when using fake UPS
When the battery level is refreshed on a fake UPS:
(upowerd:320760): UPower-Linux-WARNING **: 12:59:26.205: incomplete read (0<8)
2022-01-18 14:22:29 +01:00
Bastien Nocera
870a3a0c5b linux: Only try to open a device if it's not a fake UPS 2022-01-18 14:22:29 +01:00
Bastien Nocera
6996261d28 linux: Remember if a UPS is a fake UPS 2022-01-18 14:22:29 +01:00
Bastien Nocera
37b6d4b039 linux: Fix Bluetooth tests for python-dbusmock changes 2022-01-18 14:19:40 +01:00
Bastien Nocera
0847d0c674 linux: Make sure ChargeCycles is unknown in more cases
In the case where the kernel returns "0" as the cycle_count, we need to
assume this also means that the number of cycles is unknown.
2021-11-02 12:15:28 +01:00
Bastien Nocera
27709f6af4 tests: Add ChargeCycles test 2021-09-13 12:55:36 +02:00
Bastien Nocera
d4c4528dcc linux: Export charge cycles for batteries that support it
Closes: #152
2021-09-13 12:55:36 +02:00
Bastien Nocera
d0d6b633a0 linux: Remove unused variable
src/linux/up-device-supply.c: In function ‘up_device_supply_refresh_line_power’:
src/linux/up-device-supply.c:89:22: warning: unused variable ‘native_path’ [-Wunused-variable]
   89 |         const gchar *native_path;
      |                      ^~~~~~~~~~~
2021-09-07 17:20:48 +02:00
Bastien Nocera
0fd6b11085 all: Remove HAVE_CONFIG_H conditional
We always have a config.h now, and don't rely on autotools setting this
cflags for us to know it.
2021-09-07 17:20:48 +02:00
Bastien Nocera
5f4d16ad4d build: Fix idevice support always being off 2021-09-07 17:20:48 +02:00
Bastien Nocera
bdd2711c2b linux: Postpone importing libraries for tests
They're not needed and might not be available when we're trying to list
the included tests.
2021-09-07 17:16:42 +02:00
Bastien Nocera
68584d33f4 linux: Split the integration test into individual tests
unittest_inspector.py lists the tests in the integration-test.py script,
which are then added as individual tests.
2021-09-07 11:42:24 +02:00
Bastien Nocera
20cb2e9610 linux: Rename integration test script
Add the python suffix.
2021-09-07 11:42:17 +02:00
Bastien Nocera
9b93b6c402 build: Remove autotools 2021-09-06 14:06:40 +02:00
Benjamin Berg
f2e702d4dc build: Support building upower with meson 2021-09-02 17:47:30 +02:00
Benjamin Berg
46ed299451 tests: Return 77 when skipping tests
77 is the special value meaning that the test was skipped. Both meson
make check will display the information correctly.

Note that the test is currently executed directly in check-local. So add
a workaround to ignore the 77 error code and exit 0 instead in that
case.
2021-09-02 17:40:56 +02:00
Dylan Van Assche
3acbedca26 tests: Test inhibitor lock for critical action
Inhibitor lock should be taken between the critical
action notification and the execution of the critical action.

Requires python-dbusmock > 0.23.1, test is skipped on lower versions.

python-dbusmock in the CI is installed from git and bumped version
to 0.23.2 until a new release is available.
2021-08-17 14:31:25 +02:00
Dylan Van Assche
40e5d237cf up-backend: add inhibitor lock interface
Phones are suspended most of the time so they are not awake for > 20s
to allow UPower to take action when battery is critical.
Add an interface to take and release inhibitor locks which
prevent the device from suspending to allow UPower to execute
the critical power action.
2021-08-17 14:12:19 +02:00
Bastien Nocera
26c90728c3 linux: Add test for touchpads being tagged as mice
udev adds both tags to touchpads, so replicate that behaviour.
2021-08-10 10:47:37 +00:00
Bastien Nocera
781e856974 linux: Fix touchpad not being the right type
Touchpads are also tagged as mice, so make sure that we check for
the touchpad property before checking for mouse one.
2021-08-10 10:47:37 +00:00
Bastien Nocera
3b91711e82 linux: Don't throw away large but possible energy rates
USB PD 3.1 allows up to 240W (48V, 5A) and some proprietary supplies
already delivered more than 100W over USB-C (USB PD 3.0 limit).

Closes: #147

Reported by StefanBruens
2021-08-10 12:32:24 +02:00
Pablo Correa Gómez
d8482bc767 tests: Add test for non-default low level 2021-06-30 10:56:25 +02:00
Philipp Zabel
b64902eed2 tests: Add a test case for batteries with zero power draw
Make sure that the issue reported in #7 and #44 is fixed.
The mocked battery has a zero power_now attribute and a non-zero legacy
current_now attribute on purpose, to detect if upowerd tries to read
current_now if the power_now value is small.
2021-06-17 18:15:01 +02:00
Philipp Zabel
2949136b15 linux: Fix < 0.01 W energy-rate readings from power_now sysfs property
Currently, if a power supplies' power_now sysfs file reports discharge
rates < 0.01 W, the code will try to calculate the discharge rate from
the legacy sysfs files. On new kernels where those don't exist, this
produces wrong results.

For example, on a dual-battery Thinkpad T450s, while the external
battery is discharging, the internal battery reports power_now = 0,
but the corresponding upower energy-rate field incorrectly reads
about 2.3 W.

This patch fixes the issue by falling back to the legacy code only if
the legacy current_now sysfs file exists.

Closes: #7, #44
2021-06-17 18:14:53 +02:00
Bastien Nocera
96ea5b3521 linux: Make unknown Bluetooth devices appear as generic
Make Bluetooth devices for which we can't guess the "kind" or form
factor be "generic Bluetooth" devices, rather than "unknown" devices.

That should make it clearer in UIs that the devices are Bluetooth rather
than connected to the computer somehow.

Closes: #137
2021-06-17 13:47:33 +02:00
Bastien Nocera
d2053eff93 linux: Remove user-space support for Logitech Unifying devices
All those devices have been supported in the Linux kernel for a number
of years already, so the user-space support has just not been exercised.
2021-06-17 12:49:59 +02:00
Bastien Nocera
b09846dbed linux: Remove sysfs-utils helpers
They've been replaced by gudev functions.
2021-06-17 12:02:42 +02:00
Bastien Nocera
0e3c511d2a linux: Use new uncached sysfs attr gudev API 2021-06-17 12:01:38 +02:00
Bastien Nocera
fe9332cbe4 linux: Use existing gudev functions in Watts-Up driver 2021-06-17 12:00:18 +02:00
Bastien Nocera
2ab63bd81b linux: Fix typo in test comment 2021-06-17 12:00:08 +02:00
Bastien Nocera
dfce006c21 linux: Simplify is_macbook() function 2021-06-17 12:00:06 +02:00
Bastien Nocera
15fb868cf1 linux: Ignore "capacity" sysfs on Macs
capacity is supposed to be the running battery percentage, not a
representation of its current state of the factory capacity (which
isn't something that's ever shown in Linux or macOS).

Use the new "ignore-system-percentage" property to work-around that
problem.

Closes: #141, #103
2021-06-17 11:13:58 +02:00
Bastien Nocera
4496ebeb0a linux: Move functions
No functional changes.
2021-06-17 10:52:04 +02:00
Bastien Nocera
fa23d1be0c linux: Add property to ignore the "capacity" sysfs value
On some hardware, the "capacity" sysfs contains the capacity of the
battery when full compared to when it was new, instead of the percentage
of battery available.

Make it possible to ignore the "capacity" with this new property.
2021-06-17 10:40:19 +02:00
Marijn Suijten
8e5b1d6b46 tests: Add test cases for Bluetooth device classes 2021-02-02 18:23:19 +01:00
Marijn Suijten
15329e840c tests: Move BlueZ battery setup into helper function 2021-02-02 18:22:42 +01:00
Marijn Suijten
62d7c08289 tests: Convert unpacked tuple constants to range() 2021-02-02 18:22:42 +01:00
Marijn Suijten
98cf71fbcc linux: Parse kind from Class if Appearance is not available
Not all headsets have a GAP profile revealing their appearance, but they
do have a class.
2021-02-02 18:22:41 +01:00
Bastien Nocera
64582256a8 build: Remove libusb dependency in Linux
As the last user, the CSR support code, was removed.
2021-01-19 13:31:25 +01:00
Bastien Nocera
4227d0c439 linux: Remove support for CSR devices
Those devices date back from the mid-2000s. If they still work, and
somebody is still interested in having them export their battery status,
we would recommend moving this information to the appropriate kernel
drivers.
2021-01-19 13:29:23 +01:00