Closed Bug 1050752 Opened 6 years ago Closed 3 years ago

BatteryManager: specify the behavior when a host device has more than one battery

Categories

(Core :: DOM: Device Interfaces, defect, P3)

defect

Tracking

()

RESOLVED WONTFIX

People

(Reporter: NinjaTrappeur, Assigned: s, Mentored)

References

Details

Attachments

(1 file)

In order to support the new W3C draft about the Battery Status API, we need to specify the behaviour when a host device has more than one battery:
https://dvcs.w3.org/hg/dap/raw-file/tip/battery/Overview.html#multiple-batteries
Blocks: 1047119
Assignee: nobody → baylac.felix
Assignee: baylac.felix → nobody
Assignee: nobody → s
Status: UNCONFIRMED → ASSIGNED
Ever confirmed: true
Attachment #8528375 - Flags: feedback?(kchen)
So I was looking for a way to implement this, and I figured out that there are different implementation, regarding to the OS :
* Gonk fore FirefoxOS
* UPower for linux
* Windows ...
* MacOS ..
...

I don't know if I'm doing the right thing, here is a WIP patch for Gonk, if you can provide me a feedback :)
Comment on attachment 8528375 [details] [diff] [review]
WIP - multi battery gonk

Review of attachment 8528375 [details] [diff] [review]:
-----------------------------------------------------------------

::: hal/gonk/GonkHal.cpp
@@ +547,5 @@
>    }
>  
> +  closedir(sysBatDir);
> +
> +  *aCharge = (charge / bat_count);

I think this value should be normalized with the actual battery capacities. As the spec suggests:

 "The level attribute can be set to the average of the levels of batteries of same capacity, or the weighted average of the battery level attributes for batteries of different capacities."
Attachment #8528375 - Flags: feedback?(kchen) → feedback+
(In reply to Kan-Ru Chen [:kanru] from comment #3)
> I think this value should be normalized with the actual battery capacities.
> As the spec suggests:
Yes, I was just testing to understand how it works and to figure out how to solve it.
I asked for a feedback because it seemed to me "hard coded" and I wasn't sure !
I posted a question on dev-b2g asking for documentation on the gonk side.
(In reply to Alexandre BM (:rednaks) from comment #2)
> So I was looking for a way to implement this, and I figured out that there
> are different implementation, regarding to the OS :
> * Gonk fore FirefoxOS
> * UPower for linux
> * Windows ...
> * MacOS ..
> ...
> 
> I don't know if I'm doing the right thing, here is a WIP patch for Gonk, if
> you can provide me a feedback :)

Right, different platforms but one HAL interface. You could implement the necessary HAL support for multiple batteries in this bug and open followup bugs that implement the multiple batteries support for different back-ends.

So it depends on the order you want to tackle each of the dependent bugs of bug 1047119. If you want to implement the back-end support first then you could do in this is 1) to change the HAL interface to expose information for N batteries instead of just one. 2) change the DOM implementation to use this new interface.
Priority: -- → P3
This seems like a WONTFIX given that we only intend to keep this API for Web Extensions in Bug 1313580. Feel free to reopen if you feel this isn't the case.
Status: ASSIGNED → RESOLVED
Closed: 3 years ago
Resolution: --- → WONTFIX
You need to log in before you can comment on or make changes to this bug.