W3C home > Mailing lists > Public > public-device-apis@w3.org > June 2014

Device API w3c Working Group Response to Cordova feedback on Battery

From: Lisa Seacat DeLuca <ldeluca@us.ibm.com>
Date: Thu, 26 Jun 2014 13:29:26 -0400
To: "Cordova Dev (dev@cordova.apache.org)" <dev@cordova.apache.org>
Cc: "W3C Device APIs WG" <public-device-apis@w3.org>, Andy B Smith <andybs@us.ibm.com>
Message-ID: <OF889E0D27.F63702D3-ON87257D03.005F643F-85257D03.00601669@us.ibm.com>
Cordova Team~

This morning on the Device API's w3c Working Group call we discussed the 
battery implementation.  I had shared with the team some of the concerns 
some of the Cordova team had around battery as discussed in this thread: 

Anssi went through each of the concerns and sent a note with his 
takeaways.  This note can be publically seen here: 

I am pasting it again here for your reference.  If each of you could take 
a look and see if his response addresses any concerns we have that would 
be great.  The DAP team is very interested in our feedback.


Here are my takeaways from that thread, please let me know if I missed 

### Calculate charging and discharging rate


However, this spec requires that we calculate charging and discharging 
rate as well,
which I think is extra information that we don't need.



This was addressed by the following clarification (the behaviour was like 
this in the previous version, but this clarification aims to make this 
even more clear):


This is what I said on the public-device-apis related to this change:


I think it is fair to assume some platforms may want to implement this API 
even if they could only support a subset of the attributes (say, support 
charging and level, but not chargingTime and dischargingTime). Requiring 
an aggregate would mean we’d cripple such implementations as they’d fall 
back to defaults for all the attributes when the promise resolves, and 
only after the corresponding events fire they’d be able to report the real 


Here’s an attempt to clarify this so that the attributes are not 
considered an aggregate:



### Granularity of events


Couldn't cordova-android-battery just choose to notify on a larger change 
... say 5%?



This would qualify as a conforming implementation given the spec states: 
"The definition of how often the chargingtimechange, 
dischargingtimechange, and levelchange events are fired is left to the 

### Pre-populating BatteryManager


The big problem is that this BatteryManager object has read-only
properties that we'd have to pre-populate.  I really dislike this, and
would like for this plugin to be entirely async if possible.



The concern with "read-only properties that we'd have to pre-populate" is 
addressed by this clarification to the spec:


The async request was addressed by exposing the BatteryManager via 
getBattery() returning a Promise instead of a synchronous accessor.

### Android specifics #1




So, using this, you can tell whether your device is charging and how
it's charging, but you can't get numbers without subscribing to the
ACTION_BATTERY_CHANGED intent.  If you have a receiver for this
intent, it will fire constantly, and this will consume battery.



This seems to suggest Android’s ACTION_BATTERY_CHANGED intent 
implementation has issues with battery consumption. This is something the 
spec cannot mitigate other than saying it is up to the implementation how 
often the events are fired, which it does already.

### Android specifics #2


> It may be a tad offtopic, but does that mean that every app/widget on
> Android suffer from the same issues, including the native ones? It's 
> hard to believe, if it is so.

Yes and no.  Nobody registers a receiver to ACTION_BATTERY_CHANGED,
because this will kill your battery.



Further evidence that suggests this is an issue with the Android 


Further concrete feedback from implementers on how to improve the 
specification is much appreciated, preferably on the public-device-apis 
mailing list. If other venues are used for feedback, please send a pointer 
to the feedback to this mailing list (similarly to what Lisa did).

Lisa - could you bridge the gap between the Cordova and W3C communities 
and make sure that the Cordova folks' feedback is properly addressed? 
Cordova is a significant implementer, and as one of the editors of the 
spec I’d like to do my best and make sure this working group addresses 
Cordova's feedback. That said, we’d like to publish an updated LC within a 
couple of weeks, so we’d appreciated swift feedback.




Lisa Seacat DeLuca
Mobile Engineer | t: +415.787.4589 | ldeluca@apache.org | | 
ldeluca@us.ibm.com | lisaseacat.com | | 

(image/png attachment: 01-part)

(image/png attachment: 02-part)

Received on Thursday, 26 June 2014 17:30:05 UTC

This archive was generated by hypermail 2.4.0 : Friday, 17 January 2020 19:33:09 UTC