[Android General] chamonix:
If you already got your Nexus 5 or installed a custom Kitkat ROM you already have noticed that your favorite battery stats tool, whether it is BetterBatteryStats, GSam of wakelock detector, does not work.

Well it is not uncommon for some API to be changed so when a new Android version comes out it usually takes us a few days to get hands on a device and fix things.

But this time is different and important enough for me to take time to summarize the situation.

A little history

Android has a service called 'batteryinfo' that collects a lot of info about what goes on on your phone. That service is not perfect but it provides some pretty important information about what is important to our battery monitoring apps: an insight into what drains our battery.

Our apps communicate with that service and therefore claim the android.permission.BATTERY_STATS permission protecting the access to that service. This permission is of the category "dangerous", notifying users of the fact that they should check why an app requires that permission. For a battery monitoring app it is logical to require it.

This change of course impacts devs as their apps became unusable with that release with no perspective for a fix without an expensive workaround (as e.g. already implemented in BetterBatteryStats 1.15+).

But more alarming, it prevents users to get an insight in what drains their battery and make decisions to keep or drop apps depending on the 'cost' in terms of battery life!

If I was a conspiration theorist I may believe that this change was made on purpose to prevent users from seeing how all the pre-installed apps - including those from google - affect their user experience by reducing the battery life / usability.

What happened

With kitkat starting to ship things happened pretty fast and first feedbacks started to emerge reporting that the service could not be contacted. It took me some time to get hands on a kitkat phone (in fact I flashed my gnex with an inofficial ROM and had to make sure that the errors I got were not cause by that ROM and corresponded to the behavior on a Nexus 5.

After some research two changes in 4.4 are responsible for the problem:

1. batteryinfo was renamed to batterystats

2. the BATTERY_STATS permission has been unavailable to apps (moved from protectionLevel 'dangerous' to 'signature|system'

This is the change preventing apps to be granted that permission: https://android.googlesource.com/pl...it/+/3714141d287c965ea3451831dd5167f63f8db87b

As you can see the change refers to an issue number but this issue is not documented in the public tracker (welcome to not-really-open-source).

I have posted a request on the android-platform forum to request a clarification on why that change was made (https://groups.google.com/forum/#!topic/android-platform/f-7Td9aeFKY) but DID NOT GET ANY satisfying feedback. Therefore I have filed an issue in the public bug tracker for this change to be rolled back (https://code.google.com/p/android/issues/detail?id=61975&thanks=61975&ts=1383910497).

I kindly invite you to upvote this request by staring it.

Please star it, adding a comment "I vote for this" or "Please undo this" to the thread does not do any good:

- comments are not counted, only stars

- that forum is not there to express opinions, it's for bug reports and requests. Unrelated matters like opinion will have no other result than annying the reader.

What devs should know

1. BATTERY_STATS has been moved to protectionLevel=18 (signature|system) and is not accessible to apps anymore

2. On KitKat copying an app to /system/app does not grant protectionLevel=18 anymore. This has been changed in KitKat and the target directory to gain those rights is /system/priv-apps

3. The service delivering battery stats was called 'batteryinfo' in previous Android version and is called 'batterystats' in KitKat

[update 2013-11-16]

*dream out loud*

In an open source world the community owns the source right? Wouldn't it be cool if some senior android devs would review this change and - assuming there is no good reason for it - would revert it in their fork to provide their users with what I believe is an important feature?

[/update]