[gnome-settings-daemon/gnome-3-10] power: Fix time to empty with multiple batteries



commit 6680d0f0812935fa982c2645930e6f0f4c1d93ed
Author: Bastien Nocera <hadess hadess net>
Date:   Sun Oct 20 13:16:55 2013 +0200

    power: Fix time to empty with multiple batteries
    
    If one battery is draining and the other one isn't, the time
    to empty wouldn't be zero, but it would only match the time
    to empty for the single battery.
    
    Instead, short-circuit the time_to_empty re-calculation for
    single battery systems, and ignore the accumulated time to
    empty/time to full for multiple batteries and recalculate it.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=710344

 plugins/power/gsd-power-manager.c |   15 +++++++++------
 1 files changed, 9 insertions(+), 6 deletions(-)
---
diff --git a/plugins/power/gsd-power-manager.c b/plugins/power/gsd-power-manager.c
index 016a5c0..7980a11 100644
--- a/plugins/power/gsd-power-manager.c
+++ b/plugins/power/gsd-power-manager.c
@@ -725,10 +725,6 @@ engine_update_composite_device (GsdPowerManager *manager)
                 goto out;
         }
 
-        /* use percentage weighted for each battery capacity */
-        if (energy_full_total > 0.0)
-                percentage = 100.0 * energy_total / energy_full_total;
-
         /* set composite state */
         if (is_discharging)
                 state = UP_DEVICE_STATE_DISCHARGING;
@@ -739,11 +735,18 @@ engine_update_composite_device (GsdPowerManager *manager)
         else
                 state = UP_DEVICE_STATE_UNKNOWN;
 
+        if (battery_devices == 1)
+                goto out;
+
+        /* use percentage weighted for each battery capacity */
+        if (energy_full_total > 0.0)
+                percentage = 100.0 * energy_total / energy_full_total;
+
         /* calculate a quick and dirty time remaining value */
         if (energy_rate_total > 0) {
-                if (state == UP_DEVICE_STATE_DISCHARGING && time_to_empty_total == 0)
+                if (state == UP_DEVICE_STATE_DISCHARGING)
                         time_to_empty_total = 3600 * (energy_total / energy_rate_total);
-                else if (state == UP_DEVICE_STATE_CHARGING && time_to_full_total == 0)
+                else if (state == UP_DEVICE_STATE_CHARGING)
                         time_to_full_total = 3600 * ((energy_full_total - energy_total) / energy_rate_total);
         }
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]