Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Battery API experiment #26

Open
Happy-Ferret opened this issue Jan 21, 2018 · 3 comments
Open

Battery API experiment #26

Happy-Ferret opened this issue Jan 21, 2018 · 3 comments

Comments

@Happy-Ferret
Copy link

Happy-Ferret commented Jan 21, 2018

  • Where is your experiment located?

https://github.com/Happy-Ferret/ext-battery

  • Can you provide a brief summary of what it does?

Provides functions to query a device's battery status (current battery charge level, charging status -- whether the device is plugged in or running on battery -- time left, time to fully charge).

  • Are there any bugzilla bugs it addresses?

Not that I can see.

  • Would you like to move the code over to this repository?

Yes.

On that note: I usually release my code under BSD3. Is it possible to do that or will I need to re-license as MPL2?

  • Some implementation details worth discussing

Currently, the returned values for all functions are rather verbatim. As opposed to the old BatteryManager API, I made the decision to return values that are already fairly informational but might make it harder to process further.

i e where BatteryManager's charging property would return either true or false, browser.battery.getStatus() currently returns Plugged-in/charging or Running on battery.

I realize now that's not exactly ideal for, say, l10n, so I'm open for suggestions on that front (I could either return true or false here or, perhaps, Adapter/Battery.

TODO: I still plan on implementing Events.

@aswan
Copy link

aswan commented Jan 22, 2018

@Happy-Ferret
Copy link
Author

Happy-Ferret commented Jan 22, 2018

Doh!

I really need to improve my Bugzilla skills.

Thanks for pointing out that there is indeed an existing bug for it, and for cross referencing the Bugzilla bug and this issue here.

I'm already busy at work with 0.2. That one will expose four events. onStatusChanged, onLevelChanged, onChargeChanged and onDischargeChanged (Event names pending better conventions ;) ).

onStatusChanged works already. I'm running into an issue with onLevelChanged that I'm busily debugging right now. Will keep you posted.

@Happy-Ferret
Copy link
Author

v0.2 of my proposal (which marks the addition of the four aforementioned Events) can be found in the Events branch now (will merge to master after some further clean-up).

I've found one issue that may, however, be Windows specific (from what I remember, it worked fine on a Macbook Air I borrowed. Will have to re-check once I get back home). onChargeChanged (and thus getTime()) either returns Infinity or, once fully charged, 00:00. Never the actual time it takes to recharge the device.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants