Gsam on Nougat - how to grant permissions to see all battery usage on all processes

hachamacha

Senior Member
Jun 15, 2010
1,333
739
133
I just noticed this when I opened up Gsam , the latest version:

Use adb shell so plug in the cable to the PC/Mac/linux whatever:

execute this:
adb shell pm grant com.gsamlabs.bbm android.permission.BATTERY_STATS
That's it. No root necessary.
 
  • Like
Reactions: droid27

droid27

Senior Member
Sep 9, 2016
61
2
0
I just noticed this when I opened up Gsam , the latest version:

Use adb shell so plug in the cable to the PC/Mac/linux whatever:

execute this:


That's it. No root necessary.
Thanks! But do you have to do this every time you reboot or do you need to do this just once and it sticks? And what will happen if you update firmware (minor update)? Do you have to do it again?
 
Last edited:

hachamacha

Senior Member
Jun 15, 2010
1,333
739
133
Thanks! But do you have to do this every time you reboot or do you need to do this just once and it sticks? And what will happen if you update firmware (minor update)? Do you have to do it again?
You have to do it once / release. When you upgrade, these types of settings are usually volatile. I just cut & paste it and do it once / version. It's working for me now on b360.

Edit: I thought about that some more and forgot that I had to rollback to 162 before I went back up to 360. Rollback kills all data, so maybe I had to enter the permissions statement due to that.
 
Last edited:
  • Like
Reactions: droid27

droid27

Senior Member
Sep 9, 2016
61
2
0
You have to do it once / release. When you upgrade, these types of settings are usually volatile. I just cut & paste it and do it once / version. It's working for me now on b360.

Edit: I thought about that some more and forgot that I had to rollback to 162 before I went back up to 360. Rollback kills all data, so maybe I had to enter the permissions statement due to that.
Thanks! So we have to do this every time there's a system update but do we have to do this every time we reboot or it sticks?
 

hachamacha

Senior Member
Jun 15, 2010
1,333
739
133
Thanks! So we have to do this every time there's a system update but do we have to do this every time we reboot or it sticks?
I've done it once when upgrading to b360 Nougat and it has held and worked fine through a few reboots and a number of system changes. So, .. once should do it, but I'd never expect it to outlast an upgrade of OS.
 
  • Like
Reactions: droid27

F1Fanatic27

Senior Member
Mar 23, 2013
154
63
48
King's Lynn
I can't seem to get this to work. I've tried three times now and restarted the app and my phone every time.

I also tried including "-d" between "adb" and "shell" in the command (I saw this version on another page) but still nothing.
 

hachamacha

Senior Member
Jun 15, 2010
1,333
739
133
I can't seem to get this to work. I've tried three times now and restarted the app and my phone every time.

I also tried including "-d" between "adb" and "shell" in the command (I saw this version on another page) but still nothing.
You don't normally need the -d unless you've currently got more than one usb connected phone that adb could get to.

This command comes documented straight out of the latest version of GSAM. It actually tells you under help or in settings. I don't have a phone in front of me but the command is identical to whatever I put ^^ up there. I just tried this command on an unrooted Oneplus 5 running 7.1.1 and it worked fine there as well.

I wonder if there's any way you could have installed it without some basic permission that's a prerequisite for the usually unshown android.permission.BATTERY_STATS permission. You could go into apps and permissions and make sure it's got permission to write or whatever it's basic permissions should be. There's probably two or three.
 

F1Fanatic27

Senior Member
Mar 23, 2013
154
63
48
King's Lynn
You don't normally need the -d unless you've currently got more than one usb connected phone that adb could get to.

This command comes documented straight out of the latest version of GSAM. It actually tells you under help or in settings. I don't have a phone in front of me but the command is identical to whatever I put ^^ up there. I just tried this command on an unrooted Oneplus 5 running 7.1.1 and it worked fine there as well.

I wonder if there's any way you could have installed it without some basic permission that's a prerequisite for the usually unshown android.permission.BATTERY_STATS permission. You could go into apps and permissions and make sure it's got permission to write or whatever it's basic permissions should be. There's probably two or three.
You were bang on with the permissions, I didn't have Storage enabled. Didn't make a difference though. I even checked the advanced permissions (Usage access, draw over other apps etc..) and there wasn't anything there to activate.
 

hachamacha

Senior Member
Jun 15, 2010
1,333
739
133
You were bang on with the permissions, I didn't have Storage enabled. Didn't make a difference though. I even checked the advanced permissions (Usage access, draw over other apps etc..) and there wasn't anything there to activate.
Did you "force-close" the app after you enabled storage and reenabled the android.permission.BATTERY_STATS? If so, other than uninstall/reinstall and try again, I'm not sure. Are you running stock OS? There can always be something quirky in anyone's install that I'll never figure out. Good luck.

The only thing I recall is that the command doesn't do anything until after you've executed it, force closed and re-started the app. If it doesn't work then, then something else is going on.
 

StewMaker

Senior Member
Jun 17, 2017
69
22
0
You were bang on with the permissions, I didn't have Storage enabled. Didn't make a difference though. I even checked the advanced permissions (Usage access, draw over other apps etc..) and there wasn't anything there to activate.
You ever figure this out? I tried granting this permission on several monitoring apps and none work. It's a new phone and I feel like I broke it. :eek:
 

StewMaker

Senior Member
Jun 17, 2017
69
22
0
I've done it on my phone recently. What steps did u follow?

Sent from my Honor 8 using XDA Labs
I basically followed instructions from the apps.

I installed adb, device drivers, then in cmd, "adb devices" then "adb shell pm grant app_goes_here android.permission.BATTERY_STATS".

It worked once for BBS and GSAM, but never stuck. Now it doesn't work at all.
 

ayush rao

Senior Member
Jul 5, 2015
1,757
648
143
Kuwait
I basically followed instructions from the apps.

I installed adb, device drivers, then in cmd, "adb devices" then "adb shell pm grant app_goes_here android.permission.BATTERY_STATS".

It worked once for BBS and GSAM, but never stuck. Now it doesn't work at all.
I did it like 2 months back and it is still working.

Sent from my Honor 8 using XDA Labs
 

Attachments

ayush rao

Senior Member
Jul 5, 2015
1,757
648
143
Kuwait
I am sure it works for you and many other people but there are a few of us like OP who it does not work for. Just saying it works for you doesn't help me. :confused:
U have a point oops. Anyway in ur previous post in ur command there's some "goes here" did u include that in the command or did u just write it for the post?

Sent from my Honor 8 using XDA Labs
 

ayush rao

Senior Member
Jul 5, 2015
1,757
648
143
Kuwait
Here is the exact command to be written. When I was doing it even I couldn't get it to work but later I realized I was writing gasm instead of gsam.

Sent from my Honor 8 using XDA Labs
 

Attachments

hachamacha

Senior Member
Jun 15, 2010
1,333
739
133
Here is the exact command to be written. When I was doing it even I couldn't get it to work but later I realized I was writing gasm instead of gsam.

Sent from my Honor 8 using XDA Labs
Mine worked until I rooted at which point root takes care of that problem without the shell command.

The one thing I can think of is that the command differs (I read this somewhere) if you have GSAMPRO rather than GSAM (by just a word) and you'd have to google the correct word and substitute it. I got this the first time I started GSAM in an unrooted environment and just noted it. It showed up in a dialogue box on GSAM.
 

tasar

Senior Member
Mar 17, 2007
701
123
0
What iam doing wrong? :

adb>adb shell pm grant com.gsamlabs.bbm android.permission.BATTERY_STATS
Bad argument: java.lang.IllegalArgumentException: Unknown package: com.gsamlabs.bbm

Edit: problem solved: I have the Pro version and so the item was: 'com.gsamlabs.bbm.pro'
 
Last edited:

StewMaker

Senior Member
Jun 17, 2017
69
22
0
U have a point oops. Anyway in ur previous post in ur command there's some "goes here" did u include that in the command or did u just write it for the post?

Sent from my Honor 8 using XDA Labs
That's no problem. Hey, a response is better than no response.

I wrote the actual application name, not the goes here. Just a placeholder.