The battery API in phonegap/cordova/callback 1.3.0 [1] is a simple event-based one. However, it doesn't look like it's a full implementation of any existing spec and is event-based only, which is annoying when you just want to know the battery level in a synchronous way. It looks like it's about 80% of the Battery Status Events W3C DAP spec [2]. Ours is missing the 'batteryok' event, as well as the attachment point for event handlers is different (we attach via a window.addEventListener call, whereas the spec calls for a new BatteryEventSource().addEventListener). The event names seem pretty arbitrary (batterycritical, batterylow, batterystatus and batteryok) and don't mention any guidelines for thresholds.
To confuse matters further, there is a newer Battery Status API DAP spec [3] that looks more complete and, in my opinion, is a nicer API and provides a non-evented approach to querying the battery state on top of supporting the events. [3] is the "Stable Draft" whereas [2] is the "Public Working Draft". The events make more sense too: attribute <http://www.w3.org/TR/2011/WD-battery-status-20111129/#widl-BatteryManager-onchargingchange> Function? onchargingchange; attribute Function? onchargingtimechange<http://www.w3.org/TR/2011/WD-battery-status-20111129/#widl-BatteryManager-onchargingtimechange>; attribute Function? onlevelchange<http://www.w3.org/TR/2011/WD-battery-status-20111129/#widl-BatteryManager-onlevelchange>; attribute Function? ondischargingtimechange<http://www.w3.org/TR/2011/WD-battery-status-20111129/#widl-BatteryManager-ondischargingtimechange>; I think we should change our implementation to match the one described in [3], and am wondering what everyone else thinks. If there is consensus on it, perhaps we can figure out when we want to incorporate this change: 1.4, 1.5, etc. Curious to hear what everyone else thinks. -Fil [1] http://docs.phonegap.com/en/1.3.0/phonegap_events_events.md.html#batterycritical [2] http://www.w3.org/TR/2011/WD-battery-status-20110915/ [3] http://www.w3.org/TR/2011/WD-battery-status-20111129/