Commit graph

902 commits

Author SHA1 Message Date
Bastien Nocera
5f26bc5caa daemon: Simplify _new() functions 2013-10-14 10:36:34 +02:00
Bastien Nocera
7007fea309 freebsd: Remove useless finalize
It was just chaining up.
2013-10-14 10:36:17 +02:00
Bastien Nocera
f926ee488f lib: Simplify _to_string() calls 2013-10-14 10:36:13 +02:00
Bastien Nocera
cb759a05c8 linux: Don't print a warning if the status sysfs attr is missing
This is the case for some devices like the Wacom wireless (Bluetooth)
tablets, and shouldn't produce a warning.
2013-10-14 10:26:53 +02:00
Bastien Nocera
e385c570d4 daemon: Remove unused _set_property 2013-10-14 10:26:24 +02:00
Bastien Nocera
1f991aa6e0 daemon: Avoid trying to close fd that wasn't opened
If we fail to open the fd for the sysfs keyboard backlight control
file, don't try to close it.
2013-10-14 10:25:47 +02:00
Bastien Nocera
fed403c167 daemon: Fix options parsing
If an unknown option was passed to the daemon, it might fail
to parse some of the passed options, and not take them into account.
For example: "upower -d --timed-exit" would fail to exit

Error out when an unknown option is passed.
2013-10-14 10:25:38 +02:00
Bastien Nocera
6abd4123ef linux: Opt-out of checking Watts Up devices earlier
Don't wait for tty events from udev if we're not going to
use the Watts Up device anyway. Cuts down on the possible wakeups.
2013-10-14 10:18:21 +02:00
Bastien Nocera
d6bfaaf0aa etc: Disable Watts-Up devices by default
They are few are far between, and users of the device can
spare the time to enable this by default.

https://bugs.freedesktop.org/show_bug.cgi?id=33846
2013-10-14 10:18:18 +02:00
Landry Breuil
b622008af3 daemon: Include config.h in up-backend.h
To reach ENABLE_DEPRECATED #define

https://bugs.freedesktop.org/show_bug.cgi?id=70071
2013-10-14 10:14:41 +02:00
Landry Breuil
a1b772af16 openbsd: Use g_thread_try_new()
Instead of deprecated g_thread_create()

https://bugs.freedesktop.org/show_bug.cgi?id=70071
2013-10-14 10:14:41 +02:00
Jasper Lievisse Adriaanse
3a9bd43450 openbsd: recognize when battery is absent or fully charged
https://bugs.freedesktop.org/show_bug.cgi?id=70064
2013-10-14 10:13:40 +02:00
Bastien Nocera
b61f8a72e5 website: Link to bugzilla
https://bugs.freedesktop.org/show_bug.cgi?id=66687
2013-10-14 10:11:20 +02:00
Bastien Nocera
f3898db4d3 linux: Don't guess discharging state for devices
If the device state is unknown, don't guess based on the laptop's
power supplies (battery/power line) as it might not be charging
from there.

https://bugs.freedesktop.org/show_bug.cgi?id=70321#c1
2013-10-14 10:07:21 +02:00
Bastien Nocera
66da41ceac lib: Add missing "element-type" introspection metadata
https://bugs.freedesktop.org/show_bug.cgi?id=55419
2013-10-14 09:58:22 +02:00
Bastien Nocera
fc5793e742 lib: Fix crasher calling _about_to_sleep_sync()
https://bugs.freedesktop.org/show_bug.cgi?id=54976
2013-10-13 00:49:24 +02:00
Bastien Nocera
a10a61e181 rules: Update and correct Toshiba recall list
The list wrongly contained PA3465U, had all the batteries in duplicate,
and didn't contain a number of affected batteries.

https://bugs.freedesktop.org/show_bug.cgi?id=44370
2013-10-13 00:35:59 +02:00
Bastien Nocera
d43ab28a29 lib: Fix a small memory leak
The bus was never unreferenced in the UpWakeups object.
2013-10-10 18:59:08 +02:00
Bastien Nocera
e4858d9434 up-client: Really don't overwrite retval with prop values
db89e5a32b was incomplete and
"ret" was being used instead of prop_val to set some of those
properties. It's likely your laptop would have been seen as
docked for example.
2013-10-10 18:32:41 +02:00
Martin Pitt
ee93745870 trivial: post release version bump 2013-10-08 17:40:18 +02:00
Martin Pitt
e54cc7e9f9 Released UPower 0.9.22 2013-10-08 17:35:34 +02:00
Martin Pitt
9975526265 Linux integration tests: Fix PEP8 errors 2013-10-08 17:19:27 +02:00
Martin Pitt
2aa24aeed2 Linux integration tests: Fix pyflakes errors
Drop a lot of unused variables
2013-10-08 17:13:06 +02:00
Martin Pitt
e89d047680 Linux integration tests: First test case for library
Start testing the client-side library through gobject-introspection.

This covers https://bugs.freedesktop.org/show_bug.cgi?id=70283
2013-10-08 17:06:14 +02:00
Martin Pitt
03c4abbfb5 libupower-glib: Fix error handling
In up_client_get_properties_sync(), don't set the passed GError** to NULL,
instead set the actual pointed-to GError* to NULL by default.

Fixes proper error reporting back to the client if something does fail.
2013-10-08 17:02:57 +02:00
Bastien Nocera
ecc4e379cc up-client: Don't error out gathering deprecated properties
We would error out when trying to get properties that are
disabled by default (deprecated). Ignore those properties
when building without the deprecations.

This is still broken if the library is built with the deprecations
enabled, but not the daemon isn't, but that's an edge case.

https://bugs.freedesktop.org/show_bug.cgi?id=70283

Signed-off-by: Martin Pitt <martinpitt@gnome.org>
2013-10-08 16:47:30 +02:00
Bastien Nocera
db89e5a32b up-client: Don't overwrite retval with property values
If one of the properties is FALSE, we'll end up return FALSE
without setting an error (and making the caller crash if they
expect an error being filled in).

https://bugs.freedesktop.org/show_bug.cgi?id=70283

Signed-off-by: Martin Pitt <martinpitt@gnome.org>
2013-10-08 16:46:41 +02:00
Martin Pitt
5c132c683d linux: Track power_supply devices by name only instead of full sysfs path
The full native sysfs path of wireless HID battery devices contains a lot of
jitter like USB tree layout or sequence numbers which change after every resume
from auto-suspend. Plus, there are kernel bugs which don't give proper remove
events for those: http://bugzilla.kernel.org/show_bug.cgi?id=62041

As device names within the same subsystem must be unique anyway, and we only
use the device name for constructing the D-BUS object path, only consider the
device name for the device list native → upower object lookup table, i. e. in
up_native_get_native_path().

This fixes the "A handler is already registered for <battery>" assertion crash
if a bluetooth device comes back from auto-suspend. This fixes the
test_bluetooth_mouse_reconnect() test case, drop the expected failure.

https://launchpad.net/bugs/1112907
2013-09-27 09:46:02 +02:00
Martin Pitt
6f9ccd35b3 Linux integration tests: Test reconnect of bluetooth mouse
When these power down, we don't get remove uevents for the original
power_supply devices from the kernel, but instead we get new devices with a
different sequence number, but the same name:

  UDEV  [6408.025124] add /devices/pci0000:00/0000:00:1a.0/usb1/1-1/1-1.4/1-1.4:1.0/bluetooth/hci0/hci0:12/0005:0D62:0558.0001/power_supply/hid-00:0f:f6:6d:8e:c0-battery (power_supply)
  UDEV  [23785.90673] add /devices/pci0000:00/0000:00:1a.0/usb1/1-1/1-1.4/1-1.4:1.0/bluetooth/hci0/hci0:12/0005:0D62:0558.0002/power_supply/hid-00:0f:f6:6d:8e:c0-battery (power_supply)

This circumvents the existing "treating add as change" check (as the native
path is different) but breaks later on when building and registering the
(supposedly) new object:

  ERROR **: Failed to register GObject with DBusConnection: org.freedesktop.DBus.Error.ObjectPathInUse A handler is already registered for /org/freedesktop/UPower/devices/mouse_hid_000ff66d8ec0_battery

This reproduces https://launchpad.net/bugs/1112907
2013-09-20 11:59:37 -05:00
Martin Pitt
960d4413f9 Linux integration tests: Run tests under umockdev-wrapper
Don't just cover the test upowerd by umockdev-wrapper, but the test suite
itself as well, so that we can send uevents.

Do this by re-execing the test suite under umockdev-wrapper if it's not already
running under it.
2013-09-20 11:58:18 -05:00
Richard Hughes
ee0a71dd7d openbsd: Do not call g_thread_init() 2013-09-18 08:42:40 +01:00
Shih-Yuan Lee (FourDollars)
5c0a57cfa0 linux: Detect the battery of bluetooth input devices
Check the input subdevices of the bluetooth parent device of a battery, if
present. If there is mouse* input child device, is a mouse battery; otherwise,
it is a keyboard battery. This also fixes the PowerSupply attribute for these
to be false, as the batteries of wireless input devices don't power the system.

https://launchpad.net/bugs/1153488

Signed-Off-By: Martin Pitt <martin.pitt@ubuntu.com>
2013-09-06 14:28:12 +02:00
Martin Pitt
09d41eb759 Linux integration tests: Add bluetooth mouse and keyboard
These should be detected with their proper type (5/6, not 2) and not count as
powering the system, i. e. their PowerSupply property should be False.

This reproduces https://launchpad.net/bugs/1153488
2013-09-06 14:25:31 +02:00
Shih-Yuan Lee (FourDollars)
fdc62ad245 Set locale in daemon and tool
This is necessary to properly show non-UTF8 strings in debug mode (for the
daemon) and upower --dump etc. (for the tool).
2013-09-04 07:19:24 +02:00
Peter Wu
347b8b0b93 hidpp: try harder not to report 0% battery
(1) If the K800 keyboard is charging via the USB cable, it will report
     itself as Charging, but with a discharge level of 0 (which means
     "unknown". In this case, the previous known value (before
     connecting the cable) is always a better approximation than using
     zero.
 (2) When the K800 has fully charged (but with the cable still plugged
     in), it will still report 0 as discharge level. "Full" is 100% by
     definition, so let's fallback to that value.

Signed-off-by: Peter Wu <lekensteyn@gmail.com>
Signed-off-by: Martin Pitt <martinpitt@gnome.org>
2013-09-04 07:12:37 +02:00
Martin Pitt
5867d5432b Linux integration tests: Verify device types
Check "Type" property for AC (1), battery (2), and UPS (3).
2013-09-03 10:17:20 +02:00
Martin Pitt
440ee20f01 Linux integration tests: Verify that UPSes and batteries are power supplies
So far we only have done that for ACs.
2013-09-03 09:35:04 +02:00
Shih-Yuan Lee (FourDollars)
ba363c8bbe linux: Allow valid UTF-8 encoded string
Signed-Off-By: Martin Pitt <martin.pitt@ubuntu.com>
2013-09-03 09:24:06 +02:00
Martin Pitt
d070b4b83b Linux integration tests: add test for vendor/product/serial strings
This exercises the non-ASCII character filtering and the three cases "valid
ASCII", "valid UTF-8", and "invalid/unprintable ASCII".
2013-09-03 09:21:12 +02:00
Peter Wu
578ad1e09b hidpp: simplify setting model and serial
I previously followed the model example for copying part of the string,
but there is a much simpler way to build the name string using
g_strdup_printf. Note that a simple strdup() is not sufficient for model
since it does not have to be NUL terminated.

Reported-by: Martin Pitt <martin.pitt@ubuntu.com>
Signed-off-by: Peter Wu <lekensteyn@gmail.com>
2013-09-03 08:31:28 +02:00
Peter Wu
8113cab7ff hidpp: drop read_msg, print correct buffer
Since "hidpp: split request read/write functions", the request buffer is
not used anymore while reading the response. Therefore the additional
buffer read_msg that was used for preserving the request buffer can be
discarded.

This patch also fixes printing the wrong response buffer (response would
always yield zeroes until the functions exits).

Reported-by: Martin Pitt <martin.pitt@ubuntu.com>
Signed-off-by: Peter Wu <lekensteyn@gmail.com>
2013-09-03 08:31:28 +02:00
Peter Wu
16544c1355 hidpp: ignore remaining garbage for debug print
HidppMessage is currently of size 20 ("long message"). Since short
messages are always of size 7, do not bother printing the remaining 13
bytes. This code path is currently only used by hidpp-test (not
installed).

Reported-by: Martin Pitt <martin.pitt@ubuntu.com>
Signed-off-by: Peter Wu <lekensteyn@gmail.com>
2013-09-03 08:31:28 +02:00
Peter Wu
a7766cfde9 hidpp: fix K750 battery and luminosity properties
Since commit b1f12feb1f ("Factor out the
Logitech Unifying support to support other devices"), the battery status
would always be reported as 1% for the K750 keyboard. Besides that, the
luminosity level was removed. This patch fixes the battery level and
re-adds the luminosity level.

To avoid negativity issues when reading light level into a double type,
make the HidppMessage params unsigned.

Signed-off-by: Peter Wu <lekensteyn@gmail.com>
2013-09-03 08:31:28 +02:00
Peter Wu
789dbb037c hidpp: move timeout checking before reading
When no report matches the report type or device, the previous code
did not terminate the loop early enough because the check was missed.
Now the timeout is always checked before attempting to poll.

Signed-off-by: Peter Wu <lekensteyn@gmail.com>
2013-09-03 08:31:28 +02:00
Peter Wu
5058ede399 hidpp: split request read/write functions
In preparation for reading notifications; the device index is now
also validated before using a message, this avoid matching the wrong
report.

Signed-off-by: Peter Wu <lekensteyn@gmail.com>
2013-09-03 08:31:28 +02:00
Peter Wu
e1ed283930 hidpp: retry when read or g_poll is interrupted
Signed-off-by: Peter Wu <lekensteyn@gmail.com>
2013-09-03 08:31:28 +02:00
Peter Wu
84a9b525be hidpp: more useful error messages
If read, wait or g_poll failed, it would return -1. This information is
not really useful, so print the error string instead where applicable.

Signed-off-by: Peter Wu <lekensteyn@gmail.com>
2013-09-03 08:31:28 +02:00
Peter Wu
cdeaf16629 hidpp: fix memleak while coldplugging
The device returned by g_udev_device_get_parent must be freed by the
caller.

Signed-off-by: Peter Wu <lekensteyn@gmail.com>
2013-09-03 08:31:27 +02:00
Peter Wu
dda9bc21e5 hidpp: fix fd leak
Upon unplugging the USB receiver, the file descriptor of /dev/hidrawX is
not closed.

With commit "HID: hidraw: correctly deallocate memory on device
disconnect"[1] (queued for 3.12), this missing close() causes a
/dev/hidrawX devuce to persist until UPower is restarted.

On earlier kernels, never remove your USB receiver or you will
experience random errors resulting from data structures corruption[2]
(which occurs because UPower tries to poll() or read() an hidraw device
while the kernel has already released the memory for it). Not UPowers
fault, but UPower makes this bug more likely since it runs as daemon.

 [1]: http://lkml.org/lkml/2013/7/22/248
 [2]: http://lkml.org/lkml/2013/8/6/457

Signed-off-by: Peter Wu <lekensteyn@gmail.com>
2013-09-03 08:31:27 +02:00
Peter Wu
984d88f943 hidpp: retrieve serial number for devices (v2)
Before this, history files were saved as history-rate-M525.dat. Since
multiple devices of the same model might be connected, this name is not
unique enough.

The serial number gives a more reliable path for the history files and
allows clients to distinguish their devices (an object path like
/org/freedesktop/UPower/devices/mouse_0003o046DoC52Bx0018 does not stay
the same).

Note: if a serial number cannot be read, instead of reverting this
patch, consider splitting the serial refresh from the version, kind and
model refresh.

 - v2: Fix invalid return value when an invalid parameter is passed to
   hidpp_device_get_serial.

Signed-off-by: Peter Wu <lekensteyn@gmail.com>
2013-09-03 08:31:27 +02:00