Make our unduplicating code a bit more clever and hide the non-BlueZ
devices with the "unknown" battery state.
When Logitech devices are connected through Unifying and USB, with the
correct Linux patches[1], their serial numbers match, but the Unifying
connection stops exporting the battery information, so hide that one
from the export.
Closes: #206
[1]: https://patchwork.kernel.org/project/linux-input/list/?series=726116
If a power supply has multiple siblings, any guesses to device type
from previous siblings will be overwritten by a sibling with no guess,
as it defaults to keyboard, the highest priority. Instead, while
guessing, use UNKNOWN, and only default to keyboard at the end.
Could also be fixed by changing the keyboard's priority, but that
might have side effects for otherwise working devices.
Closes: #221
The code that handles battery information coming from the kernel didn't
have any code to set audio type of devices. As we add support for USB
wireless headsets in the kernel, add code to detect those and set the
UPDevice kind to the right value.
Closes: #229
up_device_battery_estimate_power() expects a charge/discharge rate of
0.5W to be significant, but the existing code yielded a rate of
-0.000240W.
Fix the units so that the amount of change in energy_now is at least
1W/s converted to µWh.
Now that device loop is fixed, we also need to fix the D-Bus object
path for the devices themselves to match what UPower generates so
we can get its properties.
As we iterate over the expected array, the elements are the basenames
of those object paths. Reconstruct the full object paths by prepending
/org/freedesktop/UPower/devices/
The test uses a generator to get the list of basenames for the devices:
names = (n.split('/')[-1] for n in devs)
Unfortunately, using that "names" varible will consume the generator,
and our array will be lost.
When passing a device dictionary, this code:
print(sorted(names))
print(sorted(names))
will yield:
['battery_hidpp_battery_0']
[]
Save the sorted array, and use that to test for properties equality.
When a kernel device appears after the Bluetooth device, we could be
trying to bind the model property onto itself on the Bluetooth device.
Avoid this possibility by always binding the property from the bluez
device to the non-bluez device.
GLib-GObject-WARNING **: 20:20:50.644: Unable to bind the same property on the same instance
Fixes: 778b93a336 ("linux: Hide duplicate Logitech Bluetooth devices")
Some Bluetooth devices can be hidden if they also export their battery
info through the kernel, so make sure to not throw a warning when they
go away.
(upowerd:133931): UPower-WARNING **: 02:49:48.012: INTERNAL STATE CORRUPT (device-removed): not sending NULL, device:0x1f5dae0
Fixes: 778b93a336 ("linux: Hide duplicate Logitech Bluetooth devices")
Commit 1550d50f ("linux: Remove "usb" subsystem match") broke detection of
some idevices, since it left just the "usbmisc" subsystem match while some
idevice / kernel combinations (at least an iPhone 11 on a 6.0 kernel) don't
present any such udev usbmisc devices.
However, they do present "usb" subsystem ones, so add this match back.
Leave idevice detection also for the "usbmisc" match since that's what the
original (known working) code before aforementioned commit did - it is
possible that it is required for some kernel / idevice combinations.
up-enumerator-udev.c forgot to include the build config file, resulting in
HAVE_IDEVICE macro always being undefined.
This meant that the idevice backend was never actually instantiated - as
evidenced by the file not even compiling when this was fixed, due to
missing "up-device-idevice.h" include.
Fix both of these issues.
A lot of newer Logitech devices support both the BATT Bluetooth LE
service as well the HID++ protocol. This advertises 2 separate battery
interfaces, one HID++ one through the kernel, one BATT one through
BlueZ.
Avoid confusing UIs and hide the Bluetooth battery from the interface by
checking for duplicates each time a new device is added.
Closes: #166
Add up_device_unregister() method to allow backends to hide particular
UpDevices from the D-Bus interface.
Also rename the private up_device_register_device() function, no need to
say "device" twice there, we're registering the only device passed as an
argument.
Newer development versions of libgudev now strip the linefeeds by
themselves, so fix our naive linefeed-stripping which munched on the
last character of the string if there was no linefeed.
Could not find a percentage for capacity level 'Ful'
See https://gitlab.gnome.org/GNOME/libgudev/-/merge_requests/26