incubator-callback-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Filip Maj <>
Subject State of battery API
Date Wed, 18 Jan 2012 00:25:55 GMT
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 <>
Function? onchargingchange;
             attribute Function? onchargingtimechange<>;
             attribute Function? onlevelchange<>;
             attribute Function? 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.



  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message