Commit graph

530 commits

Author SHA1 Message Date
Benjamin Berg
dc252aba71 idevice: Simplify startup handling
The startup polling just creates the idevice_t. It is trivial to detect
that, so move it into the refresh handler and set the initial polling to
the shorter period, increasing the poll interval later on.
2022-05-10 11:06:18 +02:00
Benjamin Berg
a69c009748 wup: Use new polling infrastructure 2022-05-10 11:06:18 +02:00
Benjamin Berg
1cf7e32987 hid: Use new polling infrastructure 2022-05-10 11:06:18 +02:00
Benjamin Berg
df14a9bf72 linux: Remove duplicate refresh during initilization
The main coldplug routine already does an explicit refresh. Remove the
duplication in the WUP and power supply classes.
2022-05-10 11:06:18 +02:00
Benjamin Berg
37f8fa2699 linux: Test fast-polling stops after 5 seconds
In some cases we fast-poll for 5 seconds after a uevent. Check that this
type of fast-polling stops when appropriate.
2022-05-10 11:06:18 +02:00
Benjamin Berg
3243ff2a56 supply: Use new polling infrastructure
This means we do the fast-repoll and normal polling with the same method
(no timeout registrations within the supply code anymore).
2022-05-10 11:06:18 +02:00
Benjamin Berg
ce15fa1507 idevice: Use new polling property 2022-05-10 09:31:46 +02:00
Benjamin Berg
dc72b0cb00 daemon: Change start_poll API to refresh the device
There are two users, and both simply force a device refresh. We also
simply force-refresh devices after resume, which ties into
pausing/resuming polling.
2022-05-09 17:47:38 +02:00
Benjamin Berg
7f7839bdde device: Flag refresh reason
The reason of a refresh may be interesting to special case certain
situation (e.g. discontinuity of charge after wakeup, polling again
after an event). As such, add an enum parameter that signals the reason
for the refresh.
2022-05-09 17:47:38 +02:00
Benjamin Berg
25ddb11f08 device: Handle device coldplug using GInitable
There are only a few cases where we separate construction and coldplug.
Porting to GInitable is relatively natural here and makes the code a
little nicer overall. In the case that immediate coldplug/initialization
is not desired, we can still split the operations.
2022-04-20 14:30:00 +02:00
Benjamin Berg
ddc739f38b device-list: Remove unnecessary native argument
We can simply look it up from within the function.
2022-04-20 14:26:50 +02:00
Bastien Nocera
f961ec6154 linux: Detect drawing tablets correctly
See discussion at:
https://patchwork.kernel.org/project/linux-input/patch/20220407115406.115112-1-hadess@hadess.net/
2022-04-20 10:50:19 +02:00
Benjamin Berg
bd488facf1 device: Move daemon/native object into construct only properties
Rather than this weird situation where they are immediately passed in
through the "coldplug" method. Doing this is the first step to make
UpDevice into an initable object (removing the "coldplug" method).
2022-04-01 18:25:20 +02:00
Benjamin Berg
77a20b84e4 device: Remove unplug, moving cycle breaking into dispose
Might as well use g_object_run_dispose to break the cycle to the display
device.
2022-04-01 18:25:20 +02:00
Benjamin Berg
e995ebddc4 linux: Remove unused RefreshResult enum
The refresh functions only ever returned whether data was successfully
fetched or not. The failure return code was unused and the corresponding
code can be removed.
2022-04-01 11:47:41 +02:00
Benjamin Berg
f09a6e209d linux: Fix initial enumeration of Whats Up! device
We would not scan the TTY subsystem during coldplug, which means that
the device would not be detected if it is plugged in at daemon startup
time.
i
2022-04-01 11:47:41 +02:00
Benjamin Berg
1550d50f20 linux: Remove "usb" subsystem match
The hiddev driver has been in the "usbmisc" subsystem since kernel 3.7.0
or so. As such, we can simply drop the "usb" subsystem from our matches
at this point.
2022-04-01 11:47:41 +02:00
Benjamin Berg
72469426b7 input: Fix FD handling and let input stream close it
The open() call needs to check against the FD being <0 for error
detection. Also, add a missing close in one of the error paths and
change the code to let the input stream close the FD when it is not
needed anymore.

We still open() it manually just because we need to do an ioctl once.
2022-02-25 10:27:33 +01:00
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