4 ms·
There are APIs for this. iOS: https://developer.apple.com/documentation/uikit/uidevice/1620042-batterylevel https://developer.apple.com/documentation/uikit/uid
by jadengeller 5y ago
There are APIs for this.
iOS: https://developer.apple.com/documentation/uikit/uidevice/1620042-batterylevel https://developer.apple.com/documentation/uikit/uidevice/162...
Android: https://developer.android.com/reference/android/os/BatteryManager https://developer.android.com/reference/android/os/BatteryMa...
- angrygoat 5y agoI struggle to see a legitimate reason for an app to be able to access battery level. It's pretty unlikely that app is going to change behaviour to preserve battery life – that's probably better handled by the OS slowing things down. Better to simply deny the app this information.
- jadengeller 5y agoOh, I fully agree: https://twitter.com/jadengeller/status/1427672235028795396?s=21 https://twitter.com/jadengeller/status/1427672235028795396?s... (Seems like many others do too!)
- gregoriol 5y agoStop with all those permissions already: users are tired of those popups, they don't know or understand what they are asked about, and even when a pro user gets one, it's not possible to really know what will happen/break when it is allowed or denied, so this "solution" is not one, it's a bandaid and it's broken.
- shadilay 5y agoMy phone disables the camera flash under 15%. I don't see that as anything particularly nefarious. That said I fully support the principle of least privilege.
- deleted 5y ago[deleted]
- prophesi 5y agoThis is the only app I'd trust with access to my battery level https://diewithme.online/ https://diewithme.online/
- ghaff 5y agoOn the one hand, I generally favor allowing users/their apps to get more granular information out of their phone rather than somewhat arbitrarily deciding what they need to know (e.g. there's more GPS detail that iOS could provide but doesn't). However, in this case, the phone has a battery meter and provides its own low battery warnings. I imagine you could have more sophisticated battery use tracking apps than Apple provides but, in general, not sure why you would legitimately need this info.
- mrob 5y agoIf the OS slows down the app, how will you stop the app from detecting that?
- FDSGSG 5y agoWhatsapp uses this API to alert call participants that one of them is about to run out of battery, this is a very useful feature IMO.
- ghaff 5y agoSo Whatsapp tells other participants in a call what your battery life is? By itself, I suppose that's pretty harmless. But it's really none of your business what the status of my phone is in general.
- FDSGSG 5y agoYes, it says "ghaff's phone battery level is low. Call may end soon." I think this results in a much better experience for everyone on the call.
- ghaff 5y agoI guess I don't really want an app doing that given it could probably tell participants other things that I don't want them to know, especially if I enabled something like location services.
- lupire 5y agoThat's what Permissions controls are for.
- ghaff 5y agoPermission controls are a bandaid as someone else wrote. Let's use the location services example. So some communications app asks me for permission. Do I grant it? Well, as an unsophisticated user, maybe it wants this info to optimize the quality of my connection in some way. So maybe I ought to give it permission? Instead, maybe it's going to broadcast my coordinates to everyone else on the call which is not OK in general.
- 5y ago
- gregoriol 5y agoFirst things first: you could develop a custom interface within your app, think of games for example, to show the battery level, or simply an icon when it's low, in a specific way instead of the system's style. Then, depending on what your app does, you can act on a few things to reduce, or not, battery usage when it gets below some thresholds: reduce GPS precision, remove some animations, limit framerate, make less networking requests, ... It could be limited by the system, but it would probably not be as wise regarding to what is important in the context of one app vs another. We have numerous cases where we adapt to the battery level so the user can get the best of our apps and not empty their battery while they still need it.
- kube-system 5y agoEven worse, some browsers expose this too: https://developer.mozilla.org/en-US/docs/Web/API/Battery_Status_API https://developer.mozilla.org/en-US/docs/Web/API/Battery_Sta...
- toast0 5y agoApps can change behaviors to preserve battery life though. Things like disabling prefetching will likely reduce radio time and thus preserve battery. Delaying maintenance can help too, and that also helps reduce occurances of power failed during complex data operation and the resulting difficulties of resuming from a partial operation when the state may not have been fully persisted at any point, because filesystems and abrupt power loss don't tend to go so well together.
- nostrademons 5y agoAlso things like disabling complex animations, canceling high-CPU background jobs, doing more work on the server side rather than client (trading off latency for battery life), using less complex but less accurate algorithms, etc. There's a lot of reasons why an app might want to know the battery status, and most of them are for the user's benefit.