Alternative to installing Better Battery Stats as system app

Search This thread

jark99

Senior Member
Sep 17, 2010
1,509
136
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

Thank you very much for this! :)
 

leeswagger

Senior Member
Dec 18, 2016
85
5
Nexus 6P 7.1.1

I get the error: "pm" is not recognized as an internal or external command?
This also happens if I put "su" in front of it?
 

Antaroo

Senior Member
Aug 9, 2014
148
11
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!
 

Alive08

New member
Jul 14, 2016
1
0
Could anybody explain please why "Permissions granted this way will be preserved across ROM upgrades (even across those completely overwriting /system partition)" ? Where the permissions are kept? How to revoke such permissions if needed?
 
Last edited:

DavisNT

Inactive Recognized Developer
Aug 27, 2011
522
726
Riga
projects.dm.id.lv
Could anybody explain please why "Permissions granted this way will be preserved across ROM upgrades (even across those completely overwriting /system partition)" ? Where the permissions are kept? How to revoke such permissions if needed?

Permissions granted with pm grant are stored on /data partition (most likely in packages.xml). Permissions can be revoked with corresponding pm revoke commands.
 

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?