Upower doesn't handle bluetooth mice properly

Bug #1449051 reported by Marc Deslauriers
22
This bug affects 3 people
Affects Status Importance Assigned to Milestone
Upower
Fix Released
Medium
upower (Debian)
Fix Released
Unknown
upower (Ubuntu)
Fix Released
Undecided
Unassigned

Bug Description

I have a bluetooth Logitech M557, and it is being mis-detected by Upower as a battery instead of a mouse:

Device: /org/freedesktop/UPower/devices/battery_hid_00o1fo20of5oabob5_battery
  native-path: hid-00:1f:20:f5:ab:b5-battery
  model: Bluetooth Mouse M557
  power supply: no
  updated: Mon 27 Apr 2015 10:05:22 AM EDT (13 seconds ago)
  has history: yes
  has statistics: yes
  battery
    present: yes
    rechargeable: yes
    state: discharging
    warning-level: none
    energy: 0 Wh
    energy-empty: 0 Wh
    energy-full: 0 Wh
    energy-full-design: 0 Wh
    energy-rate: 0 W
    percentage: 100%
    capacity: 100%
    icon-name: 'battery-full-symbolic'
  History (charge):
    1430143522 100.000 discharging

The patch available in the upstream bug improves the situation by parsing it as a hid device, but then mistakes it for a keyboard:
https://bugs.freedesktop.org/show_bug.cgi?id=86510

ProblemType: Bug
DistroRelease: Ubuntu 15.04
Package: upower 0.99.2-2
ProcVersionSignature: Ubuntu 3.19.0-15.15-generic 3.19.3
Uname: Linux 3.19.0-15-generic x86_64
ApportVersion: 2.17.2-0ubuntu1
Architecture: amd64
CurrentDesktop: Unity
Date: Mon Apr 27 10:04:20 2015
InstallationDate: Installed on 2013-11-26 (516 days ago)
InstallationMedia: Ubuntu 13.10 "Saucy Salamander" - Release amd64 (20131016.1)
SourcePackage: upower
UpgradeStatus: Upgraded to vivid on 2015-03-07 (50 days ago)

Revision history for this message
Marc Deslauriers (mdeslaur) wrote :
Revision history for this message
Marc Deslauriers (mdeslaur) wrote :

Attached is the output of:

export LC_ALL=C
ls -lR /sys/class/power_supply/* > /tmp/out.txt 2>&1
echo >> /tmp/out.txt
ls -lR /sys/class/bluetooth/* >> /tmp/out.txt 2>&1
echo >> /tmp/out.txt
udevadm info --export-db >> /tmp/out.txt 2>&1
echo >> /tmp/out.txt
grep -r . /sys/class/power_supply/* /sys/class/bluetooth/* >> /tmp/out.txt 2>&1

(stolen from bug 1153488)

Revision history for this message
Marc Deslauriers (mdeslaur) wrote :

I suspect paths have changed in recent kernels, so this may also affect the HWE kernels.

Revision history for this message
Sebastien Bacher (seb128) wrote :

that might be worth upstreaming as well, since we don't have anyworking actively working on upower downstream there...

Revision history for this message
Marc Deslauriers (mdeslaur) wrote :

Here is the info dump of another model of bluetooth mouse that displays the same problem.

Revision history for this message
Marc Deslauriers (mdeslaur) wrote :

Here is a dump of the same mouse, but running on trusty's kernel 3.13 on a different laptop (instead of vivid from the previous dump)

Revision history for this message
In , Marc Deslauriers (mdeslaur) wrote :

I have a bluetooth Logitech M557, and it is being mis-detected by Upower as a battery instead of a mouse:

Device: /org/freedesktop/UPower/devices/battery_hid_00o1fo20of5oabob5_battery
  native-path: hid-00:1f:20:f5:ab:b5-battery
  model: Bluetooth Mouse M557
  power supply: no
  updated: Mon 27 Apr 2015 10:05:22 AM EDT (13 seconds ago)
  has history: yes
  has statistics: yes
  battery
    present: yes
    rechargeable: yes
    state: discharging
    warning-level: none
    energy: 0 Wh
    energy-empty: 0 Wh
    energy-full: 0 Wh
    energy-full-design: 0 Wh
    energy-rate: 0 W
    percentage: 100%
    capacity: 100%
    icon-name: 'battery-full-symbolic'
  History (charge):
    1430143522 100.000 discharging

Something changed between kernels 3.13 and 3.16 that changed the layout in /sys/class/bluetooth.

See downstream bug report for some info dumps:
https://bugs.launchpad.net/ubuntu/+source/upower/+bug/1449051

Revision history for this message
Marc Deslauriers (mdeslaur) wrote :

Looks like the file layout in /sys/class/bluetooth changed between kernels 3.13 and 3.16.

Changed in upower:
importance: Unknown → Medium
status: Unknown → Confirmed
Revision history for this message
In , Marc Deslauriers (mdeslaur) wrote :

Created attachment 115537
Proposed patch

Revision history for this message
Marc Deslauriers (mdeslaur) wrote :
tags: added: patch
Revision history for this message
In , Martin Pitt (pitti) wrote :

Thank you! Pushed with trivial fix for this warning:

up-device-supply.c: In function 'up_device_supply_coldplug':
up-device-supply.c:989:6: warning: suggest parentheses around assignment used as truth value [-Wparentheses]
      if (dir = g_dir_open (subdir, 0, &error)) {
      ^

Revision history for this message
Martin Pitt (pitti) wrote :

Applied upstream, thanks Marc!

Changed in upower (Ubuntu):
status: New → Fix Committed
Changed in upower:
status: Confirmed → Fix Released
Revision history for this message
In , Martin Pitt (pitti) wrote :

*** Bug 86510 has been marked as a duplicate of this bug. ***

Changed in upower (Debian):
status: Unknown → New
Revision history for this message
redfox7691 (claudio-bizzarri) wrote :

I have a bluetooth mouse, an "HP Touch to Pair Mouse" and it is identified by Upower as a laptop battery instead of a mouse, I use Ubuntu 15.04. How can I get fixed version of upower?

Changed in upower (Debian):
status: New → Fix Released
Revision history for this message
Martin Pitt (pitti) wrote :

Fixed in wily with https://launchpad.net/ubuntu/+source/upower/0.99.3-1, just the changelog referred to the wrong bug, sorry.

Changed in upower (Ubuntu):
status: Fix Committed → Fix Released
Revision history for this message
redfox7691 (claudio-bizzarri) wrote :

Hi Martin, thank you very much for your answer. So this bug will be fixed into 15.10 version: there is a way to try patched upowerd in my 15.04 or I must wait six months? I was curious to see if new upowerd can detect right battery level: with current vesino my kernel says "WARNING **: no valid voltage value found for device /sys/devices/pci0000:00/0000:00:14.0/usb1/1-3/1-3.2/1-3.2:1.0/bluetooth/hci0/hci0:11/0005:03F0:044C.0002/power_supply/hid-00:02:76:4f:9b:cb-battery, assuming 10V" but it has only two AA battery so max level is 2.8V

Revision history for this message
Astor (astor-di) wrote :

redfox7691, i just installed new version of upower on 15.04.
all you need to do is:
1. download sources from 15.10 repo: https://launchpad.net/ubuntu/wily/+source/upower
(https://launchpad.net/ubuntu/+archive/primary/+files/upower_0.99.3.orig.tar.xz)
2. unpack archive
3. check: you must have installed libusb-1.0-dev, and some dependencies.
4. ./configure
(by configuring sources - you can see what dependencies is actually you need, and just install -dev version of it)
5. sudo make
6. sudo make install
7. reboot and enjoy "brand new" icon for M557 mouse in the top right corner of screen.

Thanks to Martin, and other contrubutors.
My current status:

~ $ upower -v
UPower client version 0.99.3
UPower daemon version 0.99.3

~ $ uname -a
Linux laptop 3.19.0-20-generic #20-Ubuntu SMP Fri May 29 10:10:47 UTC 2015 x86_64 x86_64 x86_64 GNU/Linux

~ $ lsb_release -rd
Description: Ubuntu 15.04
Release: 15.04

Revision history for this message
redfox7691 (claudio-bizzarri) wrote :

Thank you very much Astor, I've followed your hints and now battery indicator is ok.

Revision history for this message
redfox7691 (claudio-bizzarri) wrote :

With fully charged battery my percentage is 60%, but if I use two alkaline batteries i've got a 100% indicator: is there a way to inform daemon upower that I'm using a rechargeable batteries and that full level is lower than alkaline?

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Duplicates of this bug

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.