From: Kamala Narasimhan Date: Fri, 6 Mar 2009 04:02:54 +0000 (-0500) Subject: Set battery charging/discharging/charged bits appropriately. X-Git-Url: http://xenbits.xensource.com/gitweb?a=commitdiff_plain;h=d3013b9a091e54b4cf2a3049d59d84884bcb607c;p=xenclient%2Fxen.git Set battery charging/discharging/charged bits appropriately. --- diff --git a/tools/xenpmd/xenpmd.c b/tools/xenpmd/xenpmd.c index 507f8f0..1edf4b5 100644 --- a/tools/xenpmd/xenpmd.c +++ b/tools/xenpmd/xenpmd.c @@ -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; }