Commit graph

266 commits

Author SHA1 Message Date
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
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
Bastien Nocera
377dd73424 linux: Name the iDevice start poll timeout 2016-06-08 14:22:32 +02:00
Bastien Nocera
c015e6b21e linux: Fix deprecation warning in integration-test 2015-09-23 16:14:40 +02:00
Bastien Nocera
b6dfa473f8 build: Fix missing includes
Include $(top_builddir) when building so that we can find the newly
generated D-Bus helper files. Note that, because we ship generated files
in the tarball, we'll also need to include $(top_srcdir).
2015-09-23 16:09:50 +02:00
Cosimo Cecchi
16537df546 daemon: remove custom marshal setup
Just use the default marshaller.
2015-07-29 13:38:13 +01:00
Cosimo Cecchi
da7517137e integration-test: fix typo in interface name
The display device will use the org.freedesktop.UPower.Device interface,
not org.freedesktop.UPower.
2015-07-29 13:37:11 +01:00
Cosimo Cecchi
b549d8928b build: remove dependency on dbus-glib and libdbus
Nothing depends on it any more.
2015-07-29 13:37:11 +01:00
Cosimo Cecchi
7258c4cce0 up-backend: remove unused private member 2015-07-29 13:37:11 +01:00
Bastien Nocera
1e4f711df4 Revert "linux: Work-around broken battery on the Onda v975w"
This reverts commit 31b2b8ec78.

A better work-around has been found kernel-side:
https://bugzilla.kernel.org/show_bug.cgi?id=83941

We'll need to add some code to ignore the incorrect "time left" values
though.
2015-07-16 11:26:17 +02:00
Bastien Nocera
c9b2e17726 linux: Fix possible double-free
When reopening the lockdown daemon with upower as the client, don't
double-free if the user says "No" to trusting the laptop.

https://bugzilla.redhat.com/show_bug.cgi?id=1231763
2015-06-26 14:07:13 +02:00
Marc Deslauriers
6c706ff033 linux: Properly detect bluetooth mice and keyboards that are HID devices
https://bugs.freedesktop.org/show_bug.cgi?id=90222
2015-05-20 14:56:27 +02:00
Bastien Nocera
31b2b8ec78 linux: Work-around broken battery on the Onda v975w
Until https://bugzilla.kernel.org/show_bug.cgi?id=83941 is fixed,
this allow to have a bit more information than "0% battery" displayed in
the UI.

https://bugs.freedesktop.org/show_bug.cgi?id=90214
2015-04-28 13:19:48 +02:00
Bastien Nocera
abaf635ce4 linux: Use CLAMP() instead of a series of ifs 2015-04-28 13:01:11 +02:00
Bastien Nocera
f3706d7a29 linux: More memory handling fixes in iDevice
We could crash if up_device_idevice_refresh() failed during
start_poll_cb().
2015-02-03 23:20:26 +01:00
Bastien Nocera
a410c26991 linux: Bail out when iDevice state is malformed
If there's no BatteryCurrentCapacity value, we've failed updating
the device.
2015-02-03 23:07:31 +01:00
Bastien Nocera
e37fcd1db1 linux: Defer getting iDevice info until ready
We're a bit too fast for usbmuxd to have noticed the USB device getting
plugged in, so defer until either the device is 1) noticed by usbmuxd
and 2) paired.

https://bugs.freedesktop.org/show_bug.cgi?id=88950
2015-02-03 23:07:31 +01:00
Peter Wu
90994b0d81 daemon: release resources at shutdown
This makes it easier to find real memory leaks with valgrind. After
calling the up_backend_unplug functions, you cannot restart it with
up_backend_coldplug since the lists are cleared.

Tested with Linux only (not on *BSD; dummy compiles).

https://bugs.freedesktop.org/show_bug.cgi?id=82659
2014-11-26 11:56:16 +00:00
Peter Wu
a91d03a3a9 daemon: fix various reference leaks
up_daemon_get_daemon takes a reference on UpDaemon, so it must be
properly dereferenced. Similar for up_daemon_get_devices_list which
references an UpDeviceList.

The display device was allocated in init, but never released either.

https://bugs.freedesktop.org/show_bug.cgi?id=82659
2014-11-26 11:56:15 +00:00
Peter Wu
1f9c094119 hidpp: fix memleak for each Feature
The name of each Logitech HID++ 2.0 Feature will now be freed.

https://bugs.freedesktop.org/show_bug.cgi?id=82659
2014-11-26 11:56:12 +00:00
Peter Wu
71cbf8dfb9 linux: fix memleak when reading critical action
g_variant_get for string types must be freed as documented at
https://developer.gnome.org/glib/stable/gvariant-format-strings.html#gvariant-format-strings-strings
Since we just want to compare it, use a pointer as documented at
https://developer.gnome.org/glib/stable/gvariant-format-strings.html#gvariant-format-strings-pointers

https://bugs.freedesktop.org/show_bug.cgi?id=82659
2014-11-26 11:56:05 +00:00
Peter Wu
b3e5143f5a hidpp-device: avoid unaligned memory access
Fixes a -Wcast-align warning and a -fsanitize=undefined error.

https://bugs.freedesktop.org/show_bug.cgi?id=71079
2014-11-18 19:47:40 +01:00
Nikolay Martynov
3a5f3e5526 upowerd: Fix cleanup in up_device_idevice_coldplug/finalize
Under certain conditions lockdownd_client_free was called
twice for same client. This caused SIGSEGV.

This patch addresses this issue

Signed-off-by: Nikolay Martynov <mar.kolya@gmail.com>
Signed-off-by: Richard Hughes <richard@hughsie.com>
2014-10-08 19:36:18 +01:00
Evangelos Foutras
bbe15b14de all: convert value from g_get_real_time() to seconds
Commit 5ddfe0d (all: Use g_get_real_time() when possible) replaced calls
to g_get_current_time() with g_get_real_time(), however, we also need to
convert the return value from microseconds to seconds.

Signed-off-by: Richard Hughes <richard@hughsie.com>
2014-10-08 19:32:05 +01:00
Bastien Nocera
5ddfe0dba1 all: Use g_get_real_time() when possible
Instead of a call to g_get_current_time().
2014-09-24 15:16:11 +02:00
Eric Koegel
1a8ccbcefc Correct check to prevent the display of invalid ASCII codes
Cppcheck found it as a logical conjunction always evaluates to
false: EXPR < 32 && EXPR > 126. Change the expression to an Or.
https://bugs.freedesktop.org/show_bug.cgi?id=71066

Signed-off-by: Richard Hughes <richard@hughsie.com>
2014-09-16 10:34:42 +01:00
Bastien Nocera
6573310637 linux: Respect the CriticalPowerAction config option
It was documented, but the configuration was never actually read.

https://bugs.freedesktop.org/show_bug.cgi?id=82925
2014-09-02 21:56:38 +02:00
Martin Pitt
90082ec5d4 Linux integration tests: Split big tests into several smaller ones
This is better design to catching regressions and problems in a more
pin-pointed fashion. This also avoids having to restart the umockdev testbed
due to changing the environment variables with stop/start_daemon().
2014-09-02 18:43:33 +02:00
Martin Pitt
01ab81233f Linux integration tests: Fix error handling for Python 3.4
Python 3.4 changed the TestCase._outcome semantics, adjust accordingly.
2014-09-02 17:19:08 +02:00
Martin Pitt
e5bd3e80f3 Linux integration tests: Fix crash if there is no session D-BUS
This can happen in CI environments without a desktop session.
2014-09-02 15:57:09 +02:00
Bastien Nocera
bab2431c1e linux: Simplify list freeing 2014-06-24 16:41:48 +02:00
Bastien Nocera
dbb9bead6d linux: Fix small memleak on startup with Logitech devices 2014-06-24 16:35:06 +02:00
Bastien Nocera
cfbd05deb3 linux: Remove is_docked from the integration test 2014-05-07 09:47:45 +02:00
Bastien Nocera
135339acc1 daemon: Deprecate "IsDocked" property
The IsDocked property has been incorrect for a number of laptops for a
while, as it thought that laptops with hybrid graphics cards were always
docked.

The alternative would have been to use the platform/dock_station
devices, but those are only exported for ACPI docking stations.

Instead, whether an external display is attached (which isn't really
docking) should be checked in the same place where the policy depending
on the value should be applied, such as gnome-settings-daemon.

https://bugs.freedesktop.org/show_bug.cgi?id=36818
2014-05-07 09:27:24 +02:00
Richard Hughes
97ed6c4731 trivial: Fix a compile warning in the linux backend 2013-10-29 12:51:23 +00:00
Bastien Nocera
e673d9e59b linux: Use daemon poll for batteries too
This has 2 effects:
- we never stop polling (we used to stop polling when the
  battery was marked as fully-charged, but that can happen when
  the battery is discharging too)
- when in an unknown state, we will poll through the daemon,
  and through our unknown poll. This isn't a problem as there'll
  another 115 seconds of wait until we get to poll through the
  daemon again.
2013-10-28 16:28:57 +01:00
Bastien Nocera
03591e6e05 linux: Switch non-battery devices to use the new daemon poll
Next up is doing this for batteries, which need to switch between
a normal/slow poll to a faster one when the battery state is unknown.
2013-10-28 15:15:02 +01:00
Bastien Nocera
d1032c562a linux: Switch Unifying devices to use the new daemon poll 2013-10-28 15:15:02 +01:00
Bastien Nocera
988889121e linux: Switch iDevices to use the new daemon poll
And remove the gathering of the battery poll from the device
itself, it's of nearly no use.
2013-10-28 15:15:02 +01:00
Bastien Nocera
8018418a97 linux: Switch CSR devices to use the new daemon poll 2013-10-28 15:15:02 +01:00
Bastien Nocera
6e8e659ca2 daemon: Better timeout source naming
Matching the work done in glib, gtk+, etc.

This also differentiates the unknown and normal timeouts in
the Linux power supply driver.
2013-10-26 14:55:15 +02:00
Bastien Nocera
4d0af3b31b linux: Add NoPollBatteries configuration option
For system integrators. If your firmware is helpful to user space
and automatically sends out uevent when the battery level changes
(rather than just the battery state) as on most machines,
you can enable "NoPollBatteries" in the configuration option,
and reduce power consumption from UPower and its listeners.
2013-10-26 14:55:15 +02:00
Bastien Nocera
64b1cc0f1d linux: Split up battery and device refresh
In up_device_supply_refresh().
2013-10-26 14:55:15 +02:00
Bastien Nocera
f62e7f11a7 linux: Move poll disable to another function 2013-10-26 14:55:15 +02:00
Bastien Nocera
feea39fa43 linux: Only disable timeouts if ever set
We cannot ever set the refresh timeout when we have a power line
device, so don't try and remove it there.
2013-10-26 14:55:15 +02:00
Bastien Nocera
7921e97b08 linux: Poll for unknown state like the daemon did
5 times, with 1 second timeouts, instead of 30 times, with
2 seconds timeouts.
2013-10-26 14:55:15 +02:00
Bastien Nocera
7804f8b08e linux: Fix the "unknown state" heavy poll
It was never actually setup, as the fallback state was used
to check whether we should use poll or not.
2013-10-26 14:55:15 +02:00