Bug 316213 - battery applet shows no battery after suspend w/o battery
Summary: battery applet shows no battery after suspend w/o battery
Status: RESOLVED FIXED
Alias: None
Product: plasma4
Classification: Plasma
Component: widget-battery (show other bugs)
Version: 4.10.0
Platform: openSUSE Linux
: NOR normal
Target Milestone: ---
Assignee: Plasma Bugs List
URL:
Keywords:
: 302310 (view as bug list)
Depends on:
Blocks:
 
Reported: 2013-03-06 09:31 UTC by Jiri Slaby
Modified: 2013-04-16 03:12 UTC (History)
4 users (show)

See Also:
Latest Commit:
Version Fixed In: 4.10.3


Attachments
fix for that issue (1.56 KB, patch)
2013-04-09 14:14 UTC, Jiri Slaby
Details
fix, try 2 (1.59 KB, patch)
2013-04-09 15:23 UTC, Jiri Slaby
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Jiri Slaby 2013-03-06 09:31:33 UTC
I suspended a machine to disk (ie. hibernated) without battery, running on AC adapter. Then I plugged the battery in and resume. But the battery is not shown in the applet. There is an empty battery with red cross.

$ solid-hardware query 'IS Battery'
udi = '/org/freedesktop/UPower/devices/battery_BAT0'

$ rpm -q `rpmqpack |grep kde|sort`
bundle-lang-kde-cs-12.3-3.4.3.noarch
flash-player-kde4-11.2.202.273-2.8.1.x86_64
kdeartwork4-wallpapers-4.10.0-1.1.1.noarch
kdeartwork4-wallpapers-weather-4.10.0-1.1.1.noarch
kdebase4-artwork-4.10.0-1.1.1.noarch
kdebase4-libkonq-4.10.0-1.1.1.x86_64
kdebase4-openSUSE-12.3-10.8.6.x86_64
kdebase4-runtime-4.10.0-1.1.2.x86_64
kdebase4-runtime-branding-openSUSE-12.3-10.8.6.x86_64
kdebase4-session-4.10.0-1.1.1.noarch
kdebase4-wallpapers-4.10.0-1.2.1.noarch
kdebase4-workspace-4.10.0-1.8.1.x86_64
kdebase4-workspace-branding-openSUSE-12.3-10.8.6.x86_64
kdebase4-workspace-ksysguardd-4.10.0-1.8.1.x86_64
kdebase4-workspace-liboxygenstyle-4.10.0-1.8.1.x86_64
kdebase4-workspace-plasma-calendar-4.10.0-1.8.1.x86_64
kde-gtk-config-2.1.1-4.1.1.x86_64
kdelibs3-3.5.10-67.3.1.x86_64
kdelibs3-default-style-3.5.10-67.3.1.x86_64
kdelibs4-4.10.0-1.2.1.x86_64
kdelibs4-branding-openSUSE-12.3-6.7.3.noarch
kdelibs4-core-4.10.0-1.2.1.x86_64
kdenlive-0.9.4-2.8.x86_64
kdepimlibs4-4.10.0-1.2.1.x86_64
kdepim4-runtime-4.10.0-1.1.1.x86_64
kde-susetranslations-12.1-16.1.1.noarch
kde4-filesystem-4.10.0-1.1.1.x86_64
kde4-kgreeter-plugins-4.10.0-1.8.1.x86_64
kde4-l10n-cs-4.10.0-1.1.1.noarch
kde4-l10n-en_GB-data-4.10.0-1.1.1.noarch
kde4-l10n-en_GB-doc-4.10.0-1.1.1.noarch
libkdecore4-4.10.0-1.2.1.x86_64
libkdepimlibs4-4.10.0-1.2.1.x86_64
libkde4-4.10.0-1.2.1.x86_64
liblockdev1-1.0.3_git201003141408-22.1.1.x86_64
liblockdev1-32bit-1.0.3_git201003141408-22.1.1.x86_64
libproxy1-config-kde4-0.4.11-2.1.1.x86_64
lockdev-1.0.3_git201003141408-22.1.1.x86_64
mozilla-kde4-integration-0.6.4-36.1.x86_64
NetworkManager-kde4-libs-0.9.0.7-1.1.1.x86_64
NetworkManager-openvpn-kde4-0.9.0.7-1.1.1.x86_64
NetworkManager-pptp-kde4-0.9.0.7-1.1.1.x86_64
polkit-kde-agent-1-0.99.0-15.1.1.x86_64
polkit-kde-kcmmodules-1-0.98.1+git20110929-5.1.1.x86_64
python-kdebase4-4.10.0-1.8.1.x86_64
python-kde4-4.10.0-1.2.1.x86_64
tomahawk-kde-0.6.0-2.2.2.x86_64

Reproducible: Always

Steps to Reproduce:
1. run on AC adapter
2. hibernate
3. plug in battery
4. resume
Comment 1 Jiri Slaby 2013-03-06 09:34:02 UTC
FWIW (all run as a user running KDE)
$ solid-hardware nonportableinfo /org/freedesktop/UPower/devices/battery_BAT0
udi = '/org/freedesktop/UPower/devices/battery_BAT0'
  Capacity = '99.002574002574'  (string)
  Energy = '19.82'  (string)
  EnergyEmpty = '0'  (string)
  EnergyFull = '61.54'  (string)
  EnergyFullDesign = '62.16'  (string)
  EnergyRate = '5.448'  (string)
  HasHistory = true  (bool)
  HasStatistics = true  (bool)
  IsPresent = true  (bool)
  IsRechargeable = true  (bool)
  Luminosity = '0'  (string)
  Model = '45N1023'  (string)
  NativePath = '/sys/devices/LNXSYSTM:00/LNXSYBUS:00/PNP0A08:00/device:08/PNP0C09:00/PNP0C0A:00/power_supply/BAT0'  (string)
  Online = false  (bool)
  Percentage = '32.2066948326292'  (string)
  PowerSupply = true  (bool)
  RecallNotice = false  (bool)
  RecallUrl = ''  (string)
  RecallVendor = ''  (string)
  Serial = '867'  (string)
  State = 2  (0x2)  (uint)
  Technology = 1  (0x1)  (uint)
  TimeToEmpty = 13096  (0x3328)  (qlonglong)
  TimeToFull = 0  (0x0)  (qlonglong)
  Type = 2  (0x2)  (uint)
  UpdateTime = 1362562414  (0x51370d6e)  (qulonglong)
  Vendor = 'SANYO'  (string)
  Voltage = '11.233'  (string)
Comment 2 HT 2013-03-12 11:15:21 UTC
Same problem on KDE 4.10.1 - distro ArchLinux.
Comment 3 HT 2013-03-14 11:58:01 UTC
One next simmilar problem.

When KDE is started without battery and battery is plugged later, the applet still shows "no battery status". If KDE is started with plugged battery the applet works well.

Version: KDE 4.10.1
Reproducible: Always
Comment 4 Jiri Slaby 2013-04-09 13:36:41 UTC
Ok, I narrowed it a bit. plasmaengineexplorer shows correct battery status when obtained from powermanagement. There is only a problem in the battery plugin proper when accessing "old" data.

* When the plasmoid is run in plasmoidviewer, it shows correct status.
* When I remove all instances of the plasmoid and re-add it, it works OK.

Otherwise printing to a console from within the plugin shows, that the data from powermanagement is obsolete:
            print("per cent = " + percent);
            print("batt = " + pmSource.data["Battery"]["Has Battery"]);
            print("batt0 = " + pmSource.data["Battery0"]["Percent"]);

per cent = 0
batt = true
file:///usr/share/kde4/apps/plasma/plasmoids/battery/contents/ui/batterymonitor.qml:200: TypeError: Result of expression 'pmSource.data["Battery0"]' [undefined] is not an object.

whereas the data is there in the explorer above (and is printed when either of the two workarounds above is used).

Lukas, any ideas? It looks like your patch to disconnect/re-connect to the data source should be used...
Comment 5 Lukáš Tinkl 2013-04-09 13:47:28 UTC
Which patch do you mean?
Comment 6 Jiri Slaby 2013-04-09 13:48:41 UTC
(In reply to comment #5)
> Which patch do you mean?

I thought about something like this:
https://bugs.kde.org/show_bug.cgi?id=301033#c44

But I'm not sure at all. It was jsut shot in the dark. Is there any way to "reload" the data source?
Comment 7 Jiri Slaby 2013-04-09 14:03:10 UTC
Yeah, having this in /usr/share/kde4/apps/plasma/plasmoids/battery/contents/ui/batterymonitor.qml

    property QtObject pmSource: PlasmaCore.DataSource {
        id: pmSource
        engine: "powermanagement"
        connectedSources: sources
        onDataChanged: {
            Logic.updateTooltip();
            Logic.updateBrightness();
        }
        onNewData: {
                print("NEW src1=" + sourceName);
        }
        onSourceAdded: {
                print("NEW src2=" + source);
                if (source == "AC Adapter" || source == "Battery" || source == "Battery0") {
                        connectSource(source)
                }
        }
    }


seems to work...
Comment 8 Jiri Slaby 2013-04-09 14:05:57 UTC
It was removed by the commit below, which is bogus...

commit d7b04c0732c538957aa8a2bf9d53bd98a61eab13
Author: Viranch Mehta <viranch.mehta@gmail.com>
Date:   Tue Jul 10 06:15:03 2012 +0530

    Simply use connectedSources: sources for battery monitor instead of connecti
ng sourceAdded/sourceRemoved signals
Comment 9 Jiri Slaby 2013-04-09 14:14:07 UTC
Created attachment 78752 [details]
fix for that issue
Comment 10 Jiri Slaby 2013-04-09 14:25:44 UTC
(In reply to comment #9)
> Created attachment 78752 [details]
> fix for that issue

Actually not really. Needs more than that. With this patch, it only fixes newly added plasmoids (no need to remove all now).
Comment 11 Jiri Slaby 2013-04-09 14:47:24 UTC
(In reply to comment #10)
> (In reply to comment #9)
> > Created attachment 78752 [details]
> > fix for that issue
> 
> Actually not really. Needs more than that. With this patch, it only fixes
> newly added plasmoids (no need to remove all now).

There is still the question if there is a way to reconnect to the data source. The patch I pasted here improves nothing. Battery0 *is* in the connected sources even when the battery is not there, so the commit above changed the behavior in no way.
Comment 12 Jiri Slaby 2013-04-09 15:23:21 UTC
Created attachment 78753 [details]
fix, try 2

(In reply to comment #11)
> The patch I pasted here improves nothing.

Not really, it makes it actually work in plasmoidviewer and is a pre-requisite for the fix.

> Battery0 *is* in the connected sources even when the battery is not there

And I think this is the bug... Why is there Battery0 as a connected source, whereas there is no Battery0 data in powermanagement? I have to disconnect+re-connect the source to get it working. See the attached patch. Now, it works flawlessly.
Comment 13 HT 2013-04-09 16:10:49 UTC
For me, fix number 2 works fine on kde 4.10.2...
Comment 14 Lukáš Tinkl 2013-04-09 16:20:03 UTC
Git commit 3e9f349f5eef146ded11affd6a98c3b1c1e44510 by Lukáš Tinkl.
Committed on 09/04/2013 at 18:18.
Pushed by lukas into branch 'KDE/4.10'.

fix #316213 - battery applet shows no battery after suspend w/o battery

M  +14   -2    plasma/generic/applets/batterymonitor/contents/ui/batterymonitor.qml

http://commits.kde.org/kde-workspace/3e9f349f5eef146ded11affd6a98c3b1c1e44510
Comment 15 Lukáš Tinkl 2013-04-10 11:10:00 UTC
Git commit ac326b8a57b32758d8b7b7ca89069279679e1d32 by Lukáš Tinkl.
Committed on 09/04/2013 at 18:18.
Pushed by lukas into branch 'master'.

fix #316213 - battery applet shows no battery after suspend w/o battery

M  +3    -2    plasma/generic/applets/batterymonitor/contents/ui/batterymonitor.qml

http://commits.kde.org/kde-workspace/ac326b8a57b32758d8b7b7ca89069279679e1d32
Comment 16 Christoph Feck 2013-04-16 03:12:32 UTC
*** Bug 302310 has been marked as a duplicate of this bug. ***