Re: Comments about battery status API

On 03/20/2012 09:54 AM, jianglin9 wrote:
> From the performance perspective, if we attach a huge JavaScript
> funcation into ‘onchargingtimechange’ or ‘onunchargingtimechange’
> attributes, then this JavaScript funcation will be called per second,
> this increase the user agent’s payload(especially for mobile device). If
> calculate from ‘level’attribute, ‘onlevelchange’ even handler will only
> be trigger 100 times totally.

You are assuming that implementations will fire a
chargingtimechange/dischargingtimechange event every seconds and a
levelchange event every percentage but how frequently those events are
fired is implementation specific. On a mobile, we can imagine that a
levelchange event will be fired every percentage but on a laptop, it
could for every 0.01% for example. And firing chargingtimechange and
dischargingtimechange events every time a level event is fired seems to
make a lot of sense to me.

> When the laptop’s battery was removed and the charger plugedin. In this
> situation, the ‘charging’ attribute can’t express the current state of
> battery. By ‘state’ attribute, user can know the laptop is using
> external power supply.

If the laptop is plugged, charging will return true. If the laptop has
no battery plugged in, level will return 100. This is per spec and has
been made to make sure the user will follow the code path for non-power
limited devices.

> Represents the current status of the event target. The status may be one
> of the following:
> 
> ·         lowbattery
> 
> ·         fullcharged
> 
> ·         hightemperature
> 
> ·         chargerplugedin
> 
> ·         batteryremoved
> 
> ·         batteryinserted

Actually, even considering the fact that you want to include the fact
that the battery has been removed from the device, you do not explain
what are the use cases. When do an app developer is interested in
knowing if the device is actually plugged to AC with a battery plugged
in or without?

--
Mounir

Received on Tuesday, 20 March 2012 09:03:50 UTC