Commit graph

449 commits

Author SHA1 Message Date
Alberts Muktupāvels
96bbea846b
linux: use correct object when emitting device-removed signal
TI:14:27:16	BlueZ disappeared
TI:14:27:16	emitting device-removed: /org/bluez/hci0/dev_00_11_67_2A_6D_7A
(upowerd:228434): GLib-GObject-WARNING **: 14:27:16.218: invalid cast from 'GDBusObjectProxy' to 'UpDevice'
TI:14:27:16	up_daemon_device_removed_cb: assertion 'UP_IS_DEVICE (device)' failed
2022-05-16 14:35:22 +03:00
Benjamin Berg
2151d7c0e4 linux: Test that line-power events don't cause battery polling
This verifies that we do not start polling the battery if we got a
spurious event related to a line-power supply.
2022-05-16 09:14:07 +00:00
Benjamin Berg
4cccf81cad supply: Avoid emitting notification for line power changes
Setting the property will create a notification, which in turn causes
the daemon code to trigger a battery refresh. As such, avoid actually
setting the property if it still has the same value.

Note that we shouldn't usually get spurious notifications, but it is
good to be safe here in case e.g. a bad firmware just sends out
notifications when the battery capacity changes.

Related: #184
2022-05-16 09:14:07 +00:00
Benjamin Berg
2d6080d253 supply: Drop is_power_supply attriute that never changes
The class kept track of the power-supply property internally. However,
the value is static, and it is only needed to be queried in very few
cases.

Move the property setting to an earlier time and stop touching it when
it is not needed.
2022-05-16 09:14:07 +00:00
Benjamin Berg
6cfccef2ad device-supply: Assume USB type supplies the system
The USB device type for power supplies are always USB ports of the
system. As such, we should be able to assume that they are power
supplies.

Fixes: #183
2022-05-16 09:07:57 +00:00
Benjamin Berg
b342964400 linux: Re-poll batteries after a line power change
When a change on a line power occurs, then re-poll all batteries
aggressively for a while. It is very common for batteries to take about
a second to refresh their state and many will not send appropriate
notifications in this case.

Closes: #179, #159
2022-05-13 16:07:38 +02:00
Benjamin Berg
90c84ea95c linux: Ensure clean shutdown after tests
Instead of just killing upower, try to send SIGTERM for a clean
shut-down. Kill the process if it doesn't quit within two seconds, and
check that the service exits cleanly.
2022-05-12 14:42:35 +02:00
Benjamin Berg
76b4c31ee9 linux: Add non-hid parent to hidpp tests
While not needed currently, there is a discussion to ignore the "hid"
subsystem parents when searching for siblings. Add in appropriate
parents to the tests so that such a change will not result in a failure.
2022-05-12 11:16:42 +02:00
Benjamin Berg
4fca99a819 device-supply: Fix leak of serial_number string 2022-05-12 11:09:33 +02:00
Benjamin Berg
565b3531d6 linux: Test changes after BT HID power_supply subtree move
This causes an add that we ignore, after that we should still see
updates from the device (and the add itself should trigger an update).

Verify that this works by setting the capacity to 20.
2022-05-11 10:16:50 +02:00
Benjamin Berg
dac0e3bc11 linux: Remove/add device if the sysfs path changed 2022-05-11 10:16:50 +02:00
Benjamin Berg
b78a2ab980 daemon: Stop passing UpDevice reference to the daemon
There is no need to do so, in particular as the signal emission code
will keep a reference to the object internally.
2022-05-10 19:19:08 +02:00
Benjamin Berg
a87cb420cd linux: Store lid input device outside of device list
The device list class now assumes that contained objects are UpDevice
and we cannot store UpInput objects inside it anymore. Switch the lid
switch to be stored in the linux backend directly rather than allocating
a UpDeviceList just for that.

This fixes commit ddc739f38b ("device-list: Remove unnecessary native
argument")
2022-05-10 11:06:25 +02:00
Benjamin Berg
3c520fb590 linux: Use OutputChecker to inspect daemon log
This also means the daemon log is stored even when succeeding, making it
a bit easier to inspect tests overall.
2022-05-10 11:06:18 +02:00
Benjamin Berg
b0f1e28b42 linux/freebsd: Do not print invalid characters into log
Instead, just hex-encode them, they are invalid, it is not like having
them in raw in the log is helpful.
2022-05-10 11:06:18 +02:00
Benjamin Berg
b9bf475459 linux: Enable fatal-warnings for most tests 2022-05-10 11:06:18 +02:00
Benjamin Berg
7f846bcee6 linux: Provide temporary history directory in tests
This avoids a warning when history files need to be saved.
2022-05-10 11:06:18 +02:00
Benjamin Berg
f2da5678f3 linux: Create an empty configuration file for every test
This avoids a warning during startup, allowing enabling fatal-warnings
in more cases.
2022-05-10 11:06:18 +02:00
Benjamin Berg
5fd3c9988c linux: Always start logind during test
This avoids a warning on daemon startup and is a step towards turning on
fatal-warnings most of the time.
2022-05-10 11:06:18 +02:00
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