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

Re: CfC: Battery Last Call

From: Mounir Lamouri <mounir@lamouri.fr>
Date: Tue, 22 Nov 2011 16:34:29 +0100
Message-ID: <4ECBC105.4060309@lamouri.fr>
To: public-device-status@w3.org
On 11/22/2011 10:23 AM, Anssi Kostiainen wrote:
> Currently we can deduce the following based on the chargingTime and dischargingTime alone (I think only a battery widget would be interested in all these states, so not a common use case):
>
> if (0<  chargingTime&&  chargingTime<  Infinity) {
>    // battery is charging, chargingTime seconds until full
> } else if (chargingTime === 0) {
>    // battery is full
> } else if (chargingTime === Infinity&&  dischargingTime<  Infinity) {
>    // battery is discharging, dischargingTime seconds left
> } else if (chargingTime === Infinity&&  dischargingTime === Infinity) {
>    // unable to report [chargingTime and dischargingTime]
>    // no battery
> }
>
> Currently we're unable to differentiate between "no battery" and "unable to report [chargingTime and dischargingTime]" states. And because |level| returns 1.0 for both "no battery" and "unable to report", and |charging| returns false for both the conditions as well, we do not get any better granularity than this.

This is actually not true [1].
No battery is equivalent to :
{
   level = 1.0,
   charging = true,
   chargingTime = Infinity,
   dischargingTime = Infinity,
}

Given that when a battery is fully charged, we have :
{
   level = 1.0,
   charging = true,
   chargingTime = 0,
   dischargingTime = Infinity,
}

We can currently find a situation where we have no battery with:
level === 1.0 && charging === true && chargingTime === Infinity

> By returning |chargingTime = 0| also if there is no battery (in addition to "battery full" state) as Mounir suggests, we could test against |charging| to differentiate between "battery is full" and "no battery" states and be able to identify all the states:

My point was actually the opposite: the postulate we had since the 
beginning is that having no battery should be equivalent to having a 
fully charged battery so websites would be allowed to just check stuff 
as they want without caring about that detail. So we should have 
chargingTime = 0 when there is no battery. In addition, we wouldn't be 
able to know if the device has a battery or not.

To summarize, the requested changes are the following:
* In 4.1, "charging", but that's just fixing an old mistake, see [1]:
[ Represents if the system's battery is charging. The attribute must be 
set to true if the battery is charging or full, and set to false, if the 
battery is discharging, the implementation is unable to report the 
state, or there is no battery attached to the system, or otherwise. ]
should be changed to:
[ Represents if the system's battery is charging. 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. ]
* In 4.1 "chargingTime":
[ Represents the time remaining in seconds until the system's battery is 
fully charged. The attribute must be set to 0, if the battery is full, 
and to the value positive Infinity if the battery is discharging, the 
implementation is unable to report the remaining charging time, there is 
no battery attached to the system, or otherwise. ]
should be changed to:
[ Represents the time remaining in seconds until the system's battery is 
fully charged. The attribute must be set to 0, if the battery is full or 
there is no battery attached to the system, and to the value positive 
Infinity if the battery is discharging, the implementation is unable to 
report the remaining charging time, or otherwise. ]

[1] I realize that this is true according to the specs but I believe 
there is a mistake in the specs, we've never been talking of having 
charging = false when there is no battery.

--
Mounir
Received on Tuesday, 22 November 2011 15:34:59 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Tuesday, 22 November 2011 15:34:59 GMT