W3C home > Mailing lists > Public > public-device-status@w3.org > December 2011

Re: Last Call spec has charging as true when discharging

From: Mounir Lamouri <mounir@lamouri.fr>
Date: Sat, 03 Dec 2011 00:22:15 +0100
Message-ID: <4ED95DA7.7000105@lamouri.fr>
To: public-device-status@w3.org
On 12/02/2011 11:24 PM, Carr, Wayne wrote:
> Current text for charging attribute: "The attribute must be set to false
> if the battery is discharging, and set to true, if the battery is
> charging, full, the implementation is unable to report the state, or
> there is no battery attached to the system, or otherwise.
>
> No exceptions."
>
> Suggested text for charging attribute: "The attribute must be set to
> false if the battery is discharging, and set to true if the battery is
> charging.If the implementation is unable to determine the state or there
> is no battery attached to the system or for any other state not
> explicitly defined, the attribute must be set to true. No exceptions."

As I said in the previous thread, I believe this change would be okay. 
Actually, that's already what Gecko is doing: the battery can be 
discharging and have level=1.0. There is no valid reason to prevent that 
per-spec. Actually, it is useful for backends like Android where level 
has a precision of 0.01: it could last a few minutes between battery 
being unplugged and level moving from 1.00 to 0.99.

> A Boolean probably isn’t the best thing here.Enumeration of {charging,
> discharging, unknown} is an alternate fix.

Such API would lead to mis-use and errors like:
if (battery.chargingState == "charging") {
}
In addition, it will increase fingerprinting (assuming no battery would 
be in state "unknown").
Finally, it is not following the goal of this specification: always 
defaulting to a charging state (for already given reasons).

--
Mounir
Received on Friday, 2 December 2011 23:22:38 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Friday, 2 December 2011 23:22:39 GMT