Digiguru.co.uk

How to fix GSAM Battery Monitor in Android Nougat (Using OSX)

24 Nov 2016

Reading time: 2 minutes

I’ve been used to GSAM’s excellent battery monitor tool on android for a year or so, but recently after upgrading to Nougat I’ve noticed that it’s stopped reporting accuratly for most applciations.

There is an Android Root companion that is supposed to fix the issue, but Nougat is unable to run it (thanks to better security built in to the mobile OS).

GSAM kidly request that you star an Issue on the open source issue tracker BUT DO NOT COMMENT ON IT. This can help Android offer users the choice to allow apps to access the Battery APIs built in to the OS.

Until this request is brought into the OS (I don’t think it will be any time soon) there IS actually a way to enable the functionality. It’s hidden in comment number #27 on the page…

 > #27 rjkmadi...
 > In the interim, you can give permissions through an adb shell.
 > pm grant com.gsamlabs.bbm android.permission.BATTERY_STATS
 > or pm grant com.gsamlabs.bbm.pro android.permission.BATTERY_STATS
 >
 > (Thanks for flindaman on Reddit.)
 > Oct 3, 2016

Excellent! But what does that even mean?

Well - let’s try it out. Before I begin a disclaimer.

adb

First let’s see if we have adb…

adb

For me I didn’t. Rather than installing the android development studio, I just want ADB, so I decided to install the minimum bits I needed.

This means getting the “Safe way to install things” using brew. Let’s see if brew is on the machine…

brew

If not - follow the instructions here

If you do have it then make sure it’s working

brew doctor

Since upgrading OSX I had to run an extra command to get Xcode tools working…

xcode-select --install

Now I was ready to install the android-sdk.

brew install android-platform-tools

Now plug in your android and ensure it is connected using PKP connection (the picture communication connection from the menu on your device when you plug it into your mac).

Next let’s ensure we can see the device…

adb devices

It should display your device in a list. Awesome!

Now let’s find the application name installed on the device..

adb shell pm list packages

Somewhere in the list you will see GSAM like com.gsamlabs.bbm or com.gsamlabs.bbm.pro

Take that text and run this next line to enable the hidden permission for this app to monitor battery information.

adb shell pm grant com.gsamlabs.bbm android.permission.BATTERY_STATS

Then next time you restart your Android, GSAM Battery monitor will have what it needs to monitor all the apps running on your device.