]> xenbits.xen.org Git - xenclient/xen.git/commitdiff
Set battery charging/discharging/charged bits appropriately.
authorKamala Narasimhan <kamala.narasimhan@citrix.com>
Fri, 6 Mar 2009 04:02:54 +0000 (23:02 -0500)
committerKamala Narasimhan <kamala.narasimhan@citrix.com>
Fri, 6 Mar 2009 04:02:54 +0000 (23:02 -0500)
tools/xenpmd/xenpmd.c

index 507f8f022b8e31850ed01e6ae4eacbfa24662d35..1edf4b5fd7c51ea03eb13ef363af60e913b0c67b 100644 (file)
@@ -221,13 +221,21 @@ void set_attribute_battery_status(char *attrib_name,
                                   char *attrib_value,
                                   struct battery_status *status)
 {
-    if ( strstr(attrib_name, "charging state") ) 
+    if ( strstr(attrib_name, "charging state") )
     {
-        /* Check this, below is half baked */
-        if ( strstr(attrib_value, "charged") ) 
-            status->state = 0;
-        else 
-            status->state = 1;
+        if ( strstr(attrib_value, "charging/discharging") )
+            status->state |= 0x3;
+        else if ( strstr(attrib_value, "discharging") )
+            status->state |= 0x1;
+        else if ( strstr(attrib_value, "charging") )
+            status->state |= 0x2;
+        return;
+    }
+
+    if ( strstr(attrib_name, "capacity state") )
+    {
+        if ( strstr(attrib_value, "ok") )
+            status->state |= 4;
         return;
     }