Commit graph

839 commits

Author SHA1 Message Date
Martin Pitt
7933b0e552 trivial: Stop calling deprecated g_type_init()
When building with a recent enough glib (>= 2.36), don't call g_type_init() any
more. This is deprecated and causes ugly compile warnings.
2013-08-29 11:10:15 +02:00
Martin Pitt
2b10e20262 Make GetHistory() array order consistent
When requesting fewer history elements than we actually have, fix the
interpolation loop to not reverse the returned elements; this already does not
happen if we request more elements than available, which led to the returned
list order depending on the history size.

Now the first array element is always the most recent one. Update documentation
accordingly.

Add test case to reproduce the problem. We now add three sample points to be
able to request a subset and still assert its correct order, and make the
charge values be further apart to ensure correct interpolation.

https://bugs.freedesktop.org/show_bug.cgi?id=68384
2013-08-29 10:44:26 +02:00
Timothée Ravier
470bc1150b Linux: More explicit warning when no voltage found
Add device full path in warning if retrieving design voltage fails in
up_device_supply_get_design_voltage(). Also helps diagnose bugs
https://bugzilla.redhat.com/show_bug.cgi?id=847874 and
https://bugzilla.redhat.com/show_bug.cgi?id=863524

Signed-off-by: Martin Pitt <martinpitt@gnome.org>
2013-08-26 15:03:58 +02:00
Timothée Ravier
6d3a68d7d4 Linux: Fix warning in up_device_supply_get_design_voltage
This avoids filling the logs with the unnecessary warning line:
GLib-CRITICAL **: g_ascii_strcasecmp: assertion `s1 != NULL' failed
as seen in https://bugzilla.redhat.com/show_bug.cgi?id=847874 and
https://bugzilla.redhat.com/show_bug.cgi?id=863524

Signed-off-by: Martin Pitt <martinpitt@gnome.org>
2013-08-26 15:02:52 +02:00
Martin Pitt
9b142071d3 Linux integration tests: add test for temperature
Add test case for exporting the temperature, as added in commit 03f67aa.

https://bugs.freedesktop.org/show_bug.cgi?id=68338
2013-08-23 08:52:45 +02:00
Seth Forshee
eaf86482a9 Add temperature property for batteries
Linux's power_supply class supports a temperature attribute, which is
supported by many battery drivers. Add a new property to export this
information and support this property in Linux.

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

Signed-off-by: Seth Forshee <seth.forshee@canonical.com>
Signed-off-by: Martin Pitt <martinpitt@gnome.org>
2013-08-23 08:45:57 +02:00
Martin Pitt
03f67aabfe trivial: In test case of previous commit, check OnLowBattery property 2013-08-23 08:45:57 +02:00
Martin Pitt
07b95b8e27 linux: Fix batteries which report capacity, but not energy/charge
Many Android devices only export charge_full and capacity, but not charge_now
or energy_now. In that case, directly read the percentage (from the capacity
attribute) and calculate current energy from that.

Thanks to Seth Forshee for the original patch!

https://bugs.freedesktop.org/show_bug.cgi?id=68337
2013-08-23 08:31:20 +02:00
Richard Hughes
aa1656f6ed trivial: post release version bump 2013-07-26 15:53:41 +01:00
Richard Hughes
1bcacb296d Released UPower 0.9.21 2013-07-26 15:52:42 +01:00
Tom Gundersen
04faa0e143 build: detect udev rules dir
Udev rules may live in either /lib/udev/rules.d or /usr/lib/udev/rules.d depending on the distro.
Remove the heuristic for deciding the dir, use pkgconfig to detect the location and allow it to be
set manually.

v2: fix specifying --with-udevrulesdir

Signed-off-by: Richard Hughes <richard@hughsie.com>
2013-05-07 14:15:26 +01:00
Richard Hughes
5b02923e01 trivial: Fix the gitignore files 2013-05-07 14:13:08 +01:00
Richard Hughes
efa97d515f Use PIE to better secure installed tools and also use full RELRO in the daemon 2013-05-07 14:07:31 +01:00
Richard Hughes
61d49c3120 Update the upower man page with all the current options 2013-05-07 14:01:28 +01:00
Richard Hughes
181e7fa573 Allow clients to call org.freedesktop.DBus.Peer
This fixes Ping() and GetMachineId() which is needed by systemd.
2013-04-24 08:04:31 +01:00
Arkadiusz Miśkiewicz
09fa9d5463 Locate non-unifying receiver by looking for hidraw with hiddev exposed.
For non unifying receiver we were trying to locate receiver hiddraw
device by looking into INTERFACES property. This doesn't work well
for non-unifying devices from keyboard+mouse sets (which use single
dongle for 2 devices but are still non-unifying).

The only thing that's different between hiddraw receiver and other
devices (mouse, keyboard etc) is that receiver also exposes hiddev
interface.

Use that fact to reliably locate receiver.

Signed-off-by: Arkadiusz Miśkiewicz <arekm@maven.pl>
Signed-off-by: Richard Hughes <richard@hughsie.com>
2013-03-28 12:14:11 +00:00
Arkadiusz Miśkiewicz
d4bec29c82 hid++v1 detection for unreachable devices and features upgrade
We are back to using HIDPP_FEATURE_ROOT_FN_PING for detecting protocol
since it's the official way described in [1].

Unfortunately unreachable devices ("disconnected" in logitech
terminology) don't respond to this v1 ping query as described in docs.
Seems that docs cover only reachable state reply for version checking.
Thus we have to consider HIDPP_ERROR_CODE_UNSUPPORTED to also be v1
(since we actually got some v1 valid answer - error reply).

Introduce HIDPP_REFRESH_FLAGS_FEATURES for checking features provided
by v2 device. This recheck is triggered when we upgrade from any
protocol to v2 in HIDPP_REFRESH_FLAGS_VERSION. This allows us to
properly upgrade from v0/v1 to v2 and also we don't send v2 queries
when we know that the device is v1.

[1] logitech_hidpp10_specification_for_Unifying_Receivers.doc

Signed-off-by: Arkadiusz Miśkiewicz <arekm@maven.pl>
Signed-off-by: Richard Hughes <richard@hughsie.com>
2013-03-28 12:13:31 +00:00
Arkadiusz Miśkiewicz
fadca8ad77 Better method of figuring out v1 vs v2 protocol version.
Protocol version detection isn't very reliable (especially for
hid++ v1).

Version 1 checking was potentially happening in every hidpp_device_cmd()
call and not only when requested. Improve that to do version checking
and priv->version manipulation only when requested by using
HIDPP_REFRESH_FLAGS_VERSION.

When doing version checking first try v2 protocol command and if it
succeeds assume version 2 device. Otherwise try v1 protocol query
and if that successds assume version 1 device.

v2 devices in unreachable/sleep mode seem to do not respond to v2
queries but they respond to v1 queries! Still we want best protocol
possible. To do that we are rechecking version when current protocol
version is below 2 and we are doing up_device_unifying_refresh() and if
recheck succeeds we upgrade protocol to v2.

Signed-off-by: Arkadiusz Miśkiewicz <arekm@maven.pl>
Signed-off-by: Richard Hughes <richard@hughsie.com>
2013-03-22 19:46:23 +00:00
Arkadiusz Miśkiewicz
32daed2dfa Add support for Logitech Wireless (NonUnifying) devices
There are Logitech Wireless devices similar to Unifying ones with the
difference that device is paired with single dongle and dongle doesn't
support pairing multiple devices.

Add support for these. Tested with Wireless Mouse M187 and M185/M225.

Signed-off-by: Arkadiusz Miśkiewicz <arekm@maven.pl>
Signed-off-by: Richard Hughes <richard@hughsie.com>
2013-03-22 19:44:58 +00:00
Arkadiusz Miśkiewicz
fd0286e871 Repair vendor handling for Logitech Unifying devices
Set proper vendor via udev rules for unifying devices and handle
that in code.

Signed-off-by: Arkadiusz Miśkiewicz <arekm@maven.pl>
Signed-off-by: Richard Hughes <richard@hughsie.com>
2013-03-22 19:43:50 +00:00
Arkadiusz Miśkiewicz
e571f840e9 Add support for HIDPP_REFRESH_FLAGS_MODEL in hid++ v1
Add support for checking device model name for hid++ v1 protocol
version.

Signed-off-by: Arkadiusz Miśkiewicz <arekm@maven.pl>
Signed-off-by: Richard Hughes <richard@hughsie.com>
2013-03-22 19:43:15 +00:00
Arkadiusz Miśkiewicz
af24f55c79 Invalid request/response for HIDPP_REFRESH_FLAGS_BATTERY in hid++1
Version 1 hid++ HIDPP_REFRESH_FLAGS_BATTERY packets were incorrect.

Response packets were incorrectly thrown away as invalid. These
packets have HIDPP_HEADER_REQUEST (and not HIDPP_HEADER_RESPONSE as code
expexted). Fix that by allowing both types.

Signed-off-by: Arkadiusz Miśkiewicz <arekm@maven.pl>
Signed-off-by: Richard Hughes <richard@hughsie.com>
2013-03-21 16:23:46 +00:00
Arkadiusz Miśkiewicz
972acff145 Buffer for HIDPP_REFRESH_FLAGS_KIND not big enough
HIDPP_REFRESH_FLAGS_KIND action puts result into 7 bytes buffer and
later tries to access 8th element (with index 7). Make buffer bigger,
so 8th element will fit.

Signed-off-by: Arkadiusz Miśkiewicz <arekm@maven.pl>
Signed-off-by: Richard Hughes <richard@hughsie.com>
2013-03-21 16:23:46 +00:00
Arkadiusz Miśkiewicz
28f396496a Detection of version 1 hid++ is not returned to the caller
HID++ version 1 was properly detected but that information wasn't
reaching caller.

Signed-off-by: Arkadiusz Miśkiewicz <arekm@maven.pl>
Signed-off-by: Richard Hughes <richard@hughsie.com>
2013-03-21 16:23:46 +00:00
Arkadiusz Miśkiewicz
232d70155c Find hidraw devices correctly with systemd udev >= v196.
udev v196 libraries changed behaviour of g_udev_device_get_sysfs_attr()
by stopping following symlinks for "device" attribute [1]. That change
broke hiddev finding for unifying devices. Fix that by getting sysfs
path from parent hiddev device.

1. http://cgit.freedesktop.org/systemd/systemd/commit/?id=5ae18ddc0d86673520c0dd6b59ccac8afc8aa605

Signed-off-by: Arkadiusz Miśkiewicz <arekm@maven.pl>
Signed-off-by: Richard Hughes <richard@hughsie.com>
2013-03-21 16:23:45 +00:00
Martin Pitt
1540b08f9c Drop --enable-systemd and linking to libsystemd-daemon
logind is now being detected at runtime (see previous commit ff39d23), so we do
not need to link against libsystemd-daemon any more. Drop --enable-systemd
configure option as well.
2013-03-21 07:16:56 +01:00
Martin Pitt
ff39d23ff4 Fix test for logind availability
sd_booted() is not an appropriate check for whether we should talk to logind,
test for /run/systemd/seats/ instead.

For details, see:
<https://mail.gnome.org/archives/desktop-devel-list/2013-March/msg00092.html>
2013-03-21 07:10:18 +01:00
Richard Hughes
830c5c5a4e trivial: post release version bump 2013-03-18 16:28:32 +00:00
Richard Hughes
90a8503885 Released UPower 0.9.20 2013-03-18 16:27:23 +00:00
Martin Pitt
161ae4d47f up-self-test.c: Drop usage of up_daemon_set_bus_type()
This is now gone since the previous commit.
2013-02-20 15:04:38 +01:00
Martin Pitt
33dfc13c07 Revert "Add option to run daemon on the session bus for testing"
This reverts commit eddcf0ef3d.

We don't need the --test option any more now that we always run tests on a
(fake) system D-BUS.
2013-02-20 15:02:37 +01:00
Martin Pitt
da066045e4 integration-test: Always run on a fake system bus
Drop the two modes depending on whether or not the test gets run as root or
not. Set up a fake system bus and always use that. This also eliminates the
need for upowerd's --test option.

Drop usage of dbus-launch, as this leaves dbus-daemon running after the tests.
Use GioTestDBus instead, which cleans up properly.
2013-02-20 14:59:56 +01:00
Martin Pitt
7105ed8a04 integration-test: Move to using umockdev
Setting $SYSFS_PATH does not work any more with recent libudev versions, our
homwbrew sysfs sandbox building limits us to coldplug tests only. umockdev
works with both old and new libudevs and can also emulate uevents for future
hotplugging tests.

Skip the test if umockdev is not available, so that check and distcheck don't
bail out.
2013-02-20 14:38:25 +01:00
Richard Hughes
8bbf566dc8 Also deprecate running the powersave scripts
Over the years we've moved all the quirks to the kernel (and fixed most of the
issues properly) so on Fedora we've not actually been shipping any rules in
pm-utils for a couple of releaes now.

Dropping this functionality allows us to finally drop the pm-utils dep for upower.
2013-02-12 11:18:31 +00:00
Richard Hughes
372c2f8d29 Add a --enable-deprecated configure argument
This is turned off by default. If this is not set, then any calls to Suspend(),
SuspendAllowed(), Hibernate() or HibernateAllowed() will fail with an error.
The error mesage tells the user what new method to port to in logind.

I'm expecting to set --enable-deprecated for Fedora 17 and 18, but turn it off
for Fedora 19, so other distributions probably want to follow suit to find out
what other stuff needs to be ported to the new APIs early. GNOME should already
be fine, but KDE will need some solid porting as I understand it.

See http://lists.freedesktop.org/archives/devkit-devel/2013-January/001339.html
for more information on future plans and for rationale.
2013-02-12 11:08:35 +00:00
Richard Hughes
9843589d2d Require applications to define UPOWER_ENABLE_DEPRECATED to use deprecated functionality
This can easily be done by doing #define UPOWER_ENABLE_DEPRECATED before
"#include <upower.h>" or adding -DUPOWER_ENABLE_DEPRECATED to the cflags line in
Makefile.am

See http://lists.freedesktop.org/archives/devkit-devel/2013-January/001339.html
for more information on future plans and for rationale.
2013-02-12 11:08:27 +00:00
Richard Hughes
7cc34d457e trivial: Remove unused configure arguments 2013-02-12 10:24:30 +00:00
Richard Hughes
e9b28d2abd Raise the hard PolKit dep to 0.97 2013-02-12 10:22:30 +00:00
Martin Pitt
275644a1b8 linux: Bump maximum accepted "time to empty" to 10 days
In the days of low-power ARM devices and large laptop batteries, imposing a 20
hour plausibility limit on "time to full" is not appropriate any more. Bump it
to 240 hours to still keep a plausibility check against "factor 1000" errors.

https://bugs.freedesktop.org/show_bug.cgi?id=60110
2013-01-31 12:24:14 +01:00
Martin Pitt
66f8f80023 Add test case for previous commit
Add test case for a battery which reports the current energy, but only the full
charge (no energy_full). This reproduces
https://bugs.freedesktop.org/show_bug.cgi?id=60104
2013-01-31 10:24:35 +01:00
Alex Hornung
cff4f578e5 linux: Fix batteries which report current energy but full charge
The condition should be for energy_full, not energy, since we aim to find some
way of finding energy_full and energy_full_design irrespective of the way we
find energy.

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

Signed-off-by: Alex Hornung <alex@alexhornung.com>
2013-01-31 10:24:13 +01:00
Colin Watson
b59d9848d4 Fix two memory leaks
up_device_supply_get_design_voltage(): up_device_supply_get_string() returns a
newly allocated copy.

up_history_finalize(): Forgot to free history->priv->dir

https://bugs.freedesktop.org/show_bug.cgi?id=60019
2013-01-29 15:08:18 +01:00
Charles Kerr
60732b12d6 Fix memory leak in up_polkit_get_subject()
dbus_g_method_get_sender() returns a newly allocated copy which we need to
free.

https://bugs.freedesktop.org/show_bug.cgi?id=47424
2013-01-29 15:05:26 +01:00
Richard Hughes
5be743c910 Don't use the deprecated INCLUDES in Makefile.am 2013-01-14 09:21:30 +00:00
Richard Hughes
b1f12feb1f Factor out the Logitech Unifying support to support other devices 2013-01-10 12:08:46 +00:00
Richard Hughes
b188a49a9c Never use -WError when building 2013-01-09 10:28:48 +00:00
Julien Danjou
35b0d25b49 lg-unifying: fix K750 features name, use 1 second interval
I've recently got access to some spec on this, so I'm now able to document
his a bit better. Also, change the 0x78 value for the function sending
BattLightMeasureBroadcastEvent to 0x1 since this is the number of event we
want, and one is enough.

Signed-off-by: Julien Danjou <julien@danjou.info>
Signed-off-by: Richard Hughes <richard@hughsie.com>
2013-01-03 09:45:59 +00:00
Richard Hughes
8fe90336de trivial: post release version bump 2013-01-02 09:35:51 +00:00
Richard Hughes
313a92b07e Released UPower 0.9.19 2013-01-02 09:33:59 +00:00
Peter Hurley
9f31068707 Fix device matching for recent kernels
In recent kernels, hiddev* devices now have class "usbmisc", rather
than "usb" (see http://www.spinics.net/lists/linux-usb/msg62276.html).
This change translates into a change in SUBSYSTEM matching for hiddev*
devices. This fix addresses this for recent kernels while retaining
existing behavior. For reference, here is an attribute-walk for a
CyberPower CPS 1500C on kernel 3.7.0:

[Ubuntu bug #1091702: udev rules fail to match hid devices with new kernels]

udevadm info --attribute-walk --path=/devices/pci0000:00/0000:00:1d.2/usb4/4-1/4-1:1.0/usbmisc/hiddev0

Udevadm info starts with the device specified by the devpath and then
walks up the chain of parent devices. It prints for every device
found, all possible attributes in the udev rules key format.
A rule to match, can be composed by the attributes of the device
and the attributes from one single parent device.

  looking at device '/devices/pci0000:00/0000:00:1d.2/usb4/4-1/4-1:1.0/usbmisc/hiddev0':
    KERNEL=="hiddev0"
    SUBSYSTEM=="usbmisc"
    DRIVER==""

  looking at parent device '/devices/pci0000:00/0000:00:1d.2/usb4/4-1/4-1:1.0':
    KERNELS=="4-1:1.0"
    SUBSYSTEMS=="usb"
    DRIVERS=="usbhid"
    ATTRS{bInterfaceClass}=="03"
    ATTRS{bInterfaceSubClass}=="00"
    ATTRS{bInterfaceProtocol}=="00"
    ATTRS{bNumEndpoints}=="01"
    ATTRS{supports_autosuspend}=="1"
    ATTRS{bAlternateSetting}==" 0"
    ATTRS{bInterfaceNumber}=="00"

  looking at parent device '/devices/pci0000:00/0000:00:1d.2/usb4/4-1':
    KERNELS=="4-1"
    SUBSYSTEMS=="usb"
    DRIVERS=="usb"
    ATTRS{bDeviceSubClass}=="00"
    ATTRS{bDeviceProtocol}=="00"
    ATTRS{devpath}=="1"
    ATTRS{idVendor}=="0764"
    ATTRS{speed}=="1.5"
    ATTRS{bNumInterfaces}==" 1"
    ATTRS{bConfigurationValue}=="1"
    ATTRS{bMaxPacketSize0}=="8"
    ATTRS{busnum}=="4"
    ATTRS{devnum}=="2"
    ATTRS{configuration}==""
    ATTRS{bMaxPower}==" 50mA"
    ATTRS{authorized}=="1"
    ATTRS{bmAttributes}=="c0"
    ATTRS{bNumConfigurations}=="1"
    ATTRS{maxchild}=="0"
    ATTRS{bcdDevice}=="0001"
    ATTRS{avoid_reset_quirk}=="0"
    ATTRS{quirks}=="0x0"
    ATTRS{version}==" 1.10"
    ATTRS{urbnum}=="36"
    ATTRS{ltm_capable}=="no"
    ATTRS{manufacturer}=="CPS"
    ATTRS{removable}=="unknown"
    ATTRS{idProduct}=="0501"
    ATTRS{bDeviceClass}=="00"
    ATTRS{product}==" CP 1500C"

  looking at parent device '/devices/pci0000:00/0000:00:1d.2/usb4':
    KERNELS=="usb4"
    SUBSYSTEMS=="usb"
    DRIVERS=="usb"
    ATTRS{bDeviceSubClass}=="00"
    ATTRS{bDeviceProtocol}=="00"
    ATTRS{devpath}=="0"
    ATTRS{idVendor}=="1d6b"
    ATTRS{speed}=="12"
    ATTRS{bNumInterfaces}==" 1"
    ATTRS{bConfigurationValue}=="1"
    ATTRS{bMaxPacketSize0}=="64"
    ATTRS{authorized_default}=="1"
    ATTRS{busnum}=="4"
    ATTRS{devnum}=="1"
    ATTRS{configuration}==""
    ATTRS{bMaxPower}=="  0mA"
    ATTRS{authorized}=="1"
    ATTRS{bmAttributes}=="e0"
    ATTRS{bNumConfigurations}=="1"
    ATTRS{maxchild}=="2"
    ATTRS{bcdDevice}=="0307"
    ATTRS{avoid_reset_quirk}=="0"
    ATTRS{quirks}=="0x0"
    ATTRS{serial}=="0000:00:1d.2"
    ATTRS{version}==" 1.10"
    ATTRS{urbnum}=="50"
    ATTRS{ltm_capable}=="no"
    ATTRS{manufacturer}=="Linux 3.7.0-030700-generic uhci_hcd"
    ATTRS{removable}=="unknown"
    ATTRS{idProduct}=="0001"
    ATTRS{bDeviceClass}=="09"
    ATTRS{product}=="UHCI Host Controller"

  looking at parent device '/devices/pci0000:00/0000:00:1d.2':
    KERNELS=="0000:00:1d.2"
    SUBSYSTEMS=="pci"
    DRIVERS=="uhci_hcd"
    ATTRS{irq}=="18"
    ATTRS{subsystem_vendor}=="0x1028"
    ATTRS{broken_parity_status}=="0"
    ATTRS{class}=="0x0c0300"
    ATTRS{consistent_dma_mask_bits}=="32"
    ATTRS{dma_mask_bits}=="32"
    ATTRS{local_cpus}=="00000000,00000000,00000000,00000000,00000000,00000000,00000000,000000ff"
    ATTRS{device}=="0x268a"
    ATTRS{msi_bus}==""
    ATTRS{local_cpulist}=="0-7"
    ATTRS{vendor}=="0x8086"
    ATTRS{subsystem_device}=="0x021e"
    ATTRS{numa_node}=="-1"
    ATTRS{d3cold_allowed}=="0"

  looking at parent device '/devices/pci0000:00':
    KERNELS=="pci0000:00"
    SUBSYSTEMS==""
    DRIVERS==""

Signed-off-by: Peter Hurley <peter@hurleysoftware.com>
Signed-off-by: Richard Hughes <richard@hughsie.com>
2012-12-29 13:13:56 +00:00