Re: Change in the definition of BATTERY_STATS permission and impact on apps

2,820 views
Skip to first unread message

Scott Knight

unread,
Nov 6, 2013, 10:19:20 AM11/6/13
to android-...@googlegroups.com
I would also be interested in finding out why this was changed from dangerous to system|signature.

-Scott

On Sunday, November 3, 2013 4:38:35 PM UTC-5, Sven Knispel wrote:
Hello,


This change to the protectionLevel for BATTERY_STATS to system|signature refers to an issue #10971287 that I believe is not in the public issue tracker and the change was not listed in any changelog that I could find. The comment of the permission in the manifest still says "<!-- Allows an application to collect battery statistics -->"

The problem with the change is that if affects a serie of apps (mine is called BetterBatteryStats) that is using the formerly known batteryinfo now called batterystats service to retrieve valuable detailed info. The same service is used by the settings - battery overview. On the other hand experiencing with copying the apk to /system/app on my phone (on kitkat) shows some difference in behaviour from previous android versions as I still get the error:

W/PackageManager(  458): Not granting permission android.permission.BATTERY_STATS to package ......

Now my questions to that change: 
- I would be really interested in knowing the details about the issue motivating the change from protectionLevel "dangerous" to "system|signature" (a hint about why copying my apk to /system/app does not work as it used to be for would be great too so that I can go on with testing)
- Knowing that there are quite a few apps (like mine) using this permission to improve user experience by showing battery hogs I would like to request moving that permission back to "dangerous"

Cheers
Sven

Sven Knispel

unread,
Nov 3, 2013, 4:38:35 PM11/3/13
to android-...@googlegroups.com

shridutt kothari

unread,
Nov 8, 2013, 4:27:46 AM11/8/13
to android-...@googlegroups.com
Hi Sven,

On Monday, November 4, 2013 3:08:35 AM UTC+5:30, Sven Knispel wrote:
Hello,


This change to the protectionLevel for BATTERY_STATS to system|signature refers to an issue #10971287 that I believe is not in the public issue tracker and the change was not listed in any changelog that I could find. The comment of the permission in the manifest still says "<!-- Allows an application to collect battery statistics -->"

The problem with the change is that if affects a serie of apps (mine is called BetterBatteryStats) that is using the formerly known batteryinfo now called batterystats service to retrieve valuable detailed info. The same service is used by the settings - battery overview. On the other hand experiencing with copying the apk to /system/app on my phone (on kitkat) shows some difference in behaviour from previous android versions as I still get the error:

W/PackageManager(  458): Not granting permission android.permission.BATTERY_STATS to package ......

Now my questions to that change: 
- I would be really interested in knowing the details about the issue motivating the change from protectionLevel "dangerous" to "system|signature" (a hint about why copying my apk to /system/app does not work as it used to be for would be great too so that I can go on with testing)
yea there is no mentioning of any reason for the issue: 10971287 and also i think it is some kind of private issue raised by internal team, since it is also not visible anywhere else including https://code.google.com/p/android/issues/list.
And as far as talking about copying apk to system-app, Yea  definitely it wont work, as because of the simple reason that, putting your app in /system/app/ at runtime doesn't give it the system signature, and while if any app is signed with platform signature than only it will be granted the permission with  system|signature, And thus if you sign your app with any system signature than only your app will get the feature you are desiring.
 
- Knowing that there are quite a few apps (like mine) using this permission to improve user experience by showing battery hogs I would like to request moving that permission back to "dangerous"
 
i think for reverting that commit, you should raise this issue/suggestion @https://code.google.com/p/android/issues/list  with mentioning about this link: (https://android.googlesource.com/platform/frameworks/base/+/3714141d287c965ea3451831dd5167f63f8db87b%5E%21/) and see what happens.


Cheers
Sven

Thanks,
Shridutt kothari
Impetus Infotech Ltd

Sven Knispel

unread,
Nov 8, 2013, 6:27:19 AM11/8/13
to android-...@googlegroups.com
Hello Shridutt,


On Friday, November 8, 2013 10:27:46 AM UTC+1, shridutt kothari wrote:
Hi Sven,

On Monday, November 4, 2013 3:08:35 AM UTC+5:30, Sven Knispel wrote:
Hello,


This change to the protectionLevel for BATTERY_STATS to system|signature refers to an issue #10971287 that I believe is not in the public issue tracker and the change was not listed in any changelog that I could find. The comment of the permission in the manifest still says "<!-- Allows an application to collect battery statistics -->"

The problem with the change is that if affects a serie of apps (mine is called BetterBatteryStats) that is using the formerly known batteryinfo now called batterystats service to retrieve valuable detailed info. The same service is used by the settings - battery overview. On the other hand experiencing with copying the apk to /system/app on my phone (on kitkat) shows some difference in behaviour from previous android versions as I still get the error:

W/PackageManager(  458): Not granting permission android.permission.BATTERY_STATS to package ......

Now my questions to that change: 
- I would be really interested in knowing the details about the issue motivating the change from protectionLevel "dangerous" to "system|signature" (a hint about why copying my apk to /system/app does not work as it used to be for would be great too so that I can go on with testing)
yea there is no mentioning of any reason for the issue: 10971287 and also i think it is some kind of private issue raised by internal team, since it is also not visible anywhere else including https://code.google.com/p/android/issues/list.

That is the reason for my question here: having a trace from issue to commit requires the issue to be public. 
 
And as far as talking about copying apk to system-app, Yea  definitely it wont work, as because of the simple reason that, putting your app in /system/app/ at runtime doesn't give it the system signature, and while if any app is signed with platform signature than only it will be granted the permission with  system|signature, And thus if you sign your app with any system signature than only your app will get the feature you are desiring.

Thanks for clarifying: my assumption was that system|signature was a logical OR so I was expecting the presence in /system/app to be enough to pass the test on permissionLevel 18. I will do some reading and tests with current and older version to learn more on that matter.  

 
- Knowing that there are quite a few apps (like mine) using this permission to improve user experience by showing battery hogs I would like to request moving that permission back to "dangerous"
 
i think for reverting that commit, you should raise this issue/suggestion @https://code.google.com/p/android/issues/list  with mentioning about this link: (https://android.googlesource.com/platform/frameworks/base/+/3714141d287c965ea3451831dd5167f63f8db87b%5E%21/) and see what happens.

I will. 

Mark Murphy

unread,
Nov 8, 2013, 10:26:19 AM11/8/13
to android-...@googlegroups.com
On Fri, Nov 8, 2013 at 6:27 AM, Sven Knispel <sven.k...@gmail.com> wrote:
> Thanks for clarifying: my assumption was that system|signature was a logical
> OR

It is.

> so I was expecting the presence in /system/app to be enough to pass the
> test on permissionLevel 18

It should, though it is conceivable some rules here changed with Android 4.4.

--
Mark Murphy (a Commons Guy)
http://commonsware.com | http://github.com/commonsguy
http://commonsware.com/blog | http://twitter.com/commonsguy

_The Busy Coder's Guide to Android Development_: 2,500+ Pages, Updated
Frequently!

Dianne Hackborn

unread,
Nov 14, 2013, 7:50:30 PM11/14/13
to android-...@googlegroups.com
On Fri, Nov 8, 2013 at 7:26 AM, Mark Murphy <mmu...@commonsware.com> wrote:
> so I was expecting the presence in /system/app to be enough to pass the
> test on permissionLevel 18
It should, though it is conceivable some rules here changed with Android 4.4.

This has been tightened in 4.4 so that you need to be placed in /system/priv-app (for privileged app).  At some point these will be renamed to signature|privileged since we are no longer giving blanket privilege to all apps in the system image.

--
Dianne Hackborn
Android framework engineer
hac...@android.com

Note: please don't send private questions to me, as I don't have time to provide private support, and so won't reply to such e-mails.  All such questions should be posted on public forums, where I and others can see and answer them.

Sven Knispel

unread,
Nov 15, 2013, 5:17:31 PM11/15/13
to android-...@googlegroups.com
Hello Diane,

thank you for clarifying that. I would also be interested in your comments on my original question about the change revoking the access to BATTERY_STATS for "normal" apps.

Cheers
Sven

Liran Barsisa

unread,
Sep 1, 2014, 1:37:01 AM9/1/14
to android-...@googlegroups.com
Why was this permission change?
It's similar to the "GET_TASKS" permission case.
It doesn't serve as a privacy/security protector, as it's always possible to get the currently installed apps and even get a clue about which of them are running.
If you develop a launcher app, you could also easily get which apps the user launches and even get a clue about how long each app runs.
Reply all
Reply to author
Forward
0 new messages