Alternative to installing Better Battery Stats as system app

Search This thread

DavisNT

Inactive Recognized Developer
Aug 27, 2011
522
726
Riga
projects.dm.id.lv
Starting with Android 4.4 (KitKat) Better Battery Stats (BBS) require installation as system app to be able to collect the stats.
BBS must re re-installed as system app after each ROM upgrade (upgrade that does not preserve third party system apps).

I have found an alternative to this - the required permissions can be granted to BBS when it is installed as a regular user app by running these commands in Android Terminal (or ADB shell session):
Code:
su
pm grant com.asksven.betterbatterystats android.permission.BATTERY_STATS
pm grant com.asksven.betterbatterystats android.permission.DUMP

After using these commands it might be required to restart BBS process (e.g. reboot the device). Permissions granted this way will be preserved across ROM upgrades (even across those completely overwriting /system partition).

This has been tested on CyanogenMod 12.1 nightlies (Android 5.1.1).

Update! This post on BBS thread describes a related method for granting (at least part of) the permissions without root.
 
Last edited:

BretAB

Member
Dec 24, 2014
17
0
Hi DavisNT,

I'm confirming that your adb code appears to be a successful workaround for the normal version of BBS downloaded from the Play Store when the phone is running Lollipop. I'm running the paid version of BBS, on the current CM12.1 Nightly (jfltetmo for my T-Mobilr SGH-M919 Galaxy S4).

Procedure:
1. Install BBS from the Play Store.
2. Use ADB (easy to cut and paste from here) or another terminal program (you'll be typing) to install the code.
3. Reboot the phone.

You'll notice that when you launch BBS, CM's "Privacy Guard" will see that BBS is trying to gain root access, and will prompt you to allow this. I selected "Always Allow" until I'm done my battery testing. You'll notice that you now see "#" up on the phone's status bar. That indicates an app is running with root access. You could probably quiescence this by choosing "Ignore" via Privacy Guard.

Could the developer please approve that this relatively easy workaround is kosher?

Thanks . . .
 

andycjw

New member
Feb 4, 2009
1
0
I tried this method, but failed on the BATTERY_STATS permission, the error said this 'permission type is not changeable'
is this method still valid?
 

DavisNT

Inactive Recognized Developer
Aug 27, 2011
522
726
Riga
projects.dm.id.lv
Same problem. I'm on CM, Android version 4.4.4. Used 'su' before.
Most likely this method works only on Lollipop and Marshmallow.

Looks like on KitKat BATTERY_STATS permission does not have development in its protectionLevel, but on Lollipop and Marshmallow it has.
I assume (please correct me if I am wrong, preferably with link to some authoritative documentation) that development in protectionLevel allows a permission to be granted by pm grant command.
 
Last edited:
  • Like
Reactions: daniels220

RoxAbout

Senior Member
Sep 13, 2010
627
205
Climax, Ks.
Starting with Android 4.4 (KitKat) Better Battery Stats (BBS) require installation as system app to be able to collect the stats.
BBS must re re-installed as system app after each ROM upgrade (upgrade that does not preserve third party system apps).

I have found an alternative to this - the required permissions can be granted to BBS when it is installed as a regular user app by running these commands in Android Terminal (or ADB shell session):
Code:
su
pm grant com.asksven.betterbatterystats android.permission.BATTERY_STATS
pm grant com.asksven.betterbatterystats android.permission.DUMP

After using these commands it might be required to restart BBS process (e.g. reboot the device). Permissions granted this way will be preserved across ROM upgrades (even across those completely overwriting /system partition).

This has been tested on CyanogenMod 12.1 nightlies (Android 5.1.1).

Does this method work on marshmallow?

Thank you
 

xarmx

Senior Member
Mar 26, 2015
82
31
Thanks dude. The command for xdaedition worked flawlessly on my RR rom. Android 6.0.1 Galaxy S3
 

nuthing03

New member
Mar 27, 2016
3
0
Does this works on a non-rooted phone? if it works, is uninstalling as simple as accessing app under setting to uninstall?

Thanks.
 

DavisNT

Inactive Recognized Developer
Aug 27, 2011
522
726
Riga
projects.dm.id.lv
Does this works on a non-rooted phone? if it works, is uninstalling as simple as accessing app under setting to uninstall?
Thanks.
AFAIK This method should NOT work on non-rooted phones (but you can still try it :fingers-crossed: ). If it will work, uninstalling the app (via Settings - Applications) would also revoke the granted permissions.
 

thodibhen

Member
Nov 21, 2015
43
16
Glad I found this, thought BBS was bugged when it kept wanting the BATTERY_STAT permission despite having the XPosed module :\
Executing those 2 lines fixed the problem.... wonder why it's not like that by default. I even checked AppOpsXposed and didn't see anything about DUMP/BATTERY_STAT

Installing BBS into /system would break OTA, no? I've read somewhere the claim that it doesn't--maybe even in the app itself
 

Top Liked Posts

  • There are no posts matching your filters.
  • 32
    Starting with Android 4.4 (KitKat) Better Battery Stats (BBS) require installation as system app to be able to collect the stats.
    BBS must re re-installed as system app after each ROM upgrade (upgrade that does not preserve third party system apps).

    I have found an alternative to this - the required permissions can be granted to BBS when it is installed as a regular user app by running these commands in Android Terminal (or ADB shell session):
    Code:
    su
    pm grant com.asksven.betterbatterystats android.permission.BATTERY_STATS
    pm grant com.asksven.betterbatterystats android.permission.DUMP

    After using these commands it might be required to restart BBS process (e.g. reboot the device). Permissions granted this way will be preserved across ROM upgrades (even across those completely overwriting /system partition).

    This has been tested on CyanogenMod 12.1 nightlies (Android 5.1.1).

    Update! This post on BBS thread describes a related method for granting (at least part of) the permissions without root.
    8
    For apk downloaded from xda change the code to
    pm grant com.asksven.betterbatterystats_xdaedition android.permission.BATTERY_STATS
    pm grant com.asksven.betterbatterystats_xdaedition android.permission.DUMP
    3
    If anyone wonders if this method works on not rooted devices running Android M im confirming it does!

    – XDA
    adb -d shell pm grant com.asksven.betterbatterystats_xdaedition android.permission.BATTERY_STATS

    – Google Play
    adb -d shell pm grant com.asksven.betterbatterystats android.permission.BATTERY_STATS

    I've tested commands pasted in previous pages which didnt work, while this ones has!
    2
    Tip for those with unrooted phone, ADB and betterbatterystats : adb -d shell pm grant com.asksven.betterbatterystats_xdaedition android.permission.BATTERY_STATS

    Took me a while to find this command, but it works! (credit to alexus' blog). You get full kernel and partial wakelock info
    1
    I'd say this method it's not working in Oreo... Can anyone confirm?