Bug 253874 - powerdevil daemon hibernate twice when battery is critical
Summary: powerdevil daemon hibernate twice when battery is critical
Status: RESOLVED FIXED
Alias: None
Product: solid
Classification: Unmaintained
Component: powermanagement-daemon (other bugs)
Version First Reported In: unspecified
Platform: Ubuntu Linux
: NOR minor
Target Milestone: ---
Assignee: Dario Freddi
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-10-11 20:48 UTC by Lukáš Karas
Modified: 2010-11-10 00:29 UTC (History)
0 users

See Also:
Latest Commit:
Version Fixed In:
Sentry Crash Report:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Lukáš Karas 2010-10-11 20:48:42 UTC
Version:           4.5 (using KDE 4.5.1) 
OS:                Linux

I have set critical level of battery to 5%, when this level is reached, powerdevil hibernate my system - it is ok. But, when I plug charger in and switch notebook on, powedevil hibernate it again after awakening (battery is about 3% at this moment). I have to wait moment before switch on notebook. I can awake my system as far as battery level is higher than 5%.

Reproducible: Always

Steps to Reproduce:
Set action when battery is critical to hibernate, discharge battery (about 5%) and after that set critical level high (about 40%). After hibernate plug charger and awake system. When system is awakening and battery is still lower than 40%, powerdevil hibernate it again.


Expected Results:  
powerdevil never (no automaticaly) hibernate (shut down or suspend) system when charger is pluged in

patch with fix should looks like:

Index: PowerDevilDaemon.cpp
===================================================================
--- PowerDevilDaemon.cpp        (revision 1184888)
+++ PowerDevilDaemon.cpp        (working copy)
@@ -501,7 +501,9 @@
         return;
     }
 
-    if (charge <= PowerDevilSettings::batteryCriticalLevel()) {
+    if (charge <= PowerDevilSettings::batteryCriticalLevel() &&
+               isChargerUnpluged()
+       ) {
         switch (PowerDevilSettings::batLowAction()) {
         case Shutdown:
             if (PowerDevilSettings::waitBeforeSuspending()) {
Comment 1 Lukáš Karas 2010-10-12 23:50:09 UTC
Ou, I overlook this condition before action call... 

if (Solid::Control::PowerManager::acAdapterState() == 
     Solid::Control::PowerManager::Plugged) {
    return;
}

This code in daemon looks right. But why is called hibernate twice? What happen when charge level is decrease twice before system suspend? Is possible call this function synchronized? ...have C++ something similar like Java's synchronize block?
Comment 2 Dario Freddi 2010-11-09 21:34:12 UTC
Should be fixed in 4.6