3 ms·
The use case is for kiosk style applications to be able to give warnings to the user. Or for other apps to take extra precautions such as saving copies of dynam
by dspillett 9y ago
The use case is for kiosk style applications to be able to give warnings to the user. Or for other apps to take extra precautions such as saving copies of dynamic state to non-volatile locations in case the power fails completely.
Though a battery percentage is not really useful for this as it could mean many things. My current main phone at 25% could last until tomorrow quite easily, my previous main device had at most a couple of hours left at that point. A simple "warning level" API would be more useful, allowing the app to register for events like "less than one hour of power left", "power loss likely in the next ten minutes", "entering super-power-saver mode" & "manual shut-down starting" and/or poll for the same flags. That way the device, which is much better placed to monitor such properties, can manage the warning levels perhaps with an off switch in case users don't want apps to know. Of course, you might have to enforce limited resource use in response to low power events, and you shouldn't allow much time between emitting "entering super power saver" events and actually entering the mode (which will shut off browser tasks until the mode is left).
So while there is a valid use case, that doesn't rely on trusting advertisers or other hogs to do something nice, the API as wasn't fit for that purpose and making something that is might be more complicated than you'd first think (so perhaps not worth the effort for the few apps that would actually make use of it).
- disconnected 9y ago> Or for other apps to take extra precautions such as saving copies of dynamic state to non-volatile locations in case the power fails completely. The system can crash, hang, forcefully reboot or otherwise die at any moment, without warning. All it takes is one "oopsy", for the phone to hit the ground and the battery to fly off. If there is important data that needs to be preserved, applications should already be committing it to non-volatile locations periodically.