Cumulative Keep awake/wakelocks vs. time - Java for Android App Development

Is there an app that measures the cumulative keep awake time per app versus time ... Along with battery percentage vs time. This would be useful in diagnosing apps that have excessive wakelocks and correlating there keep awake time periods with periods of excessive battery drain. As it stands right now with apps like better battery stats and the stock Android battery app,, you only know the cumulative keep awake or wake lock time as a single number rather than as a graph plotted versus time to overlay on top of the battery drain percentage graph. One always ends up speculating as to when that keep awake time actually occurred vs the battery drain.
So ideally I would want all of those statistics that come up in the stock Android battery app along with wakelock time, such as a CPU time total CPU time awake time etc versus time. A simple way to implement this would be to listen for battery percentage drops like many of the battery monitoring apps already do, but also record all of those other statistics and the current system time at the same time.
Is there anything already out there or anyone willing to add this functionality to their existing app?

if0rg0t said:
Is there an app that measures the cumulative keep awake time per app versus time ... Along with battery percentage vs time. This would be useful in diagnosing apps that have excessive wakelocks and correlating there keep awake time periods with periods of excessive battery drain. As it stands right now with apps like better battery stats and the stock Android battery app,, you only know the cumulative keep awake or wake lock time as a single number rather than as a graph plotted versus time to overlay on top of the battery drain percentage graph. One always ends up speculating as to when that keep awake time actually occurred vs the battery drain.
So ideally I would want all of those statistics that come up in the stock Android battery app along with wakelock time, such as a CPU time total CPU time awake time etc versus time. A simple way to implement this would be to listen for battery percentage drops like many of the battery monitoring apps already do, but also record all of those other statistics and the current system time at the same time.
Is there anything already out there or anyone willing to add this functionality to their existing app?
Click to expand...
Click to collapse
This is a very late response because I found this thread through searching a question. But, are you trying to figure out if huge number of wakelocks that don't hold the device awake for very long cause battery drain? If so, that's what I'm trying to figure out. I have a wifi wakelock that kept the device awake for less than 1 min over the course of 3 hours. However, the number of wakelocks is over 2,000 so I'm trying to figure out if it is affecting the battery life.

Related

[Q] Battery life not as good as I thought on NAND

Hi everyone. I had NAND installed on my HD2 now for about a month and a half. One of the things that I haven't seen on my phone is better battery life. This is the first phone I have with a data plan so I'm really not sure how much of the battery drains with data. Here is my daily routine. I charge my phone overnight, by 11am-12pm my phone is just about dead. I put it on the charger until about 4pm; usually it's fully charged by then. By the time 10pm comes around it's almost dead again. Doesn't seem like good battery life to me. Someone please let me know if I'm missing something.
Thank you all!
Depends on what you're doing with your hd2.
If you spend a lot of time on the internet with either wifi or 3g, then that drains battery pretty quickly, as with any device. Playing games or watching videos is the same thing, although to a hiigher extent with games. Keeping the phone screen on is also one way to drain battery quickly.
You should install current widget and monitor your standby times, etc. In standy by, your phone should be consuming 4~6 mA ideally.
If you want to monitor your battery usage, first download and install CurrentWidget, enable logging while the phone is on standby to see your standby usage.
Second, need to check battery usage on standby after a call, there are some kernels with a known bug that prevents the phone from going to sleep, consuming 60ma on standby.
Third, Do a battery calibration, it does help a lot if you have never calibrated your battery, android tend to mess up battery reading after a while of not being calibrated. There's a thread about in on forums, search for it, REALLY good info there.
Fourth! check out if you are in a zone with crappy 3G, if the phone has to turn 2g/3g off and on too often it drains battery like whoa.
Fifth, take note of max and min voltage readings with CurrentWidget, your battery might by wearing out (should be maxing at 4.2v and min around 3.3v - 3.6v depending on kernel).
Another thing, before your phone dies, check out battery usage on Settings, see if any program is eating your battery, and check out how long has your screen been on, and post it here
I've always had WAY better battery in Android, even SD, than WMo, MSN/push email killed battery in WMo in about 6 hours, without use, just standby. Android get up to 4 days in standby with Gtalk/Gmail/Exchange Mail, all on Push, along with weather and twitter. With hardcore usage, the battery last between 6 and 7 hours top (Screen on for 4-5 hours), while Gaming, it wont last more than 4 hours (CPU at 100%, Screen always on, GPU at 100%, Brightness 100%).
Normal usage (between 40 mins and 1 hour of Google Maps with GPS on, between 3 and 4 hours of music thru Bluetooth with my car, 10-15 mins talking, about 20-30 SMSs and quite a bit of Gtalk) it makes it thru the day, lasting about 12-14 hours.
Such a low battery life is probably cause your phone is not going to sleep, it should be at 2-5 mah on standby.
Hope it helps
I can play an hour of pokemon (gba rom), listen to pandora whenever im in the car, surf the net for an hour or two, and with a total constant usage of about 5 hours, and at the end of the day ill be left with 30% battery still.
If I don't use it often it will last 40 hours +.
Maybe try a different nand rom?
Im running hyperdroid nand
Zephyrot and kangpeter, Im jealous of your battery life. I'll try what was posted. Thanks for the replies!

[Q] How have you improved your battery life?

I'm looking for best practices and successes rather than commiseration.
I'm running JuiceDefender on aggressive and still not getting more than a day of use (3g+BT off, wifi 2hrs, screen time 3hrs).
If you've managed to get some kind of improvement, please share what you did and how much of a difference it made.
I've installed betterbatterystats and saw that trillian causes a hell of a lot of wakelocks, so I've disabled that. My battery usage graph is much smoother and less steep but I can't put any numbers on it.
PickleHead said:
I've installed betterbatterystats and saw that trillian causes a hell of a lot of wakelocks, so I've disabled that. My battery usage graph is much smoother and less steep but I can't put any numbers on it.
Click to expand...
Click to collapse
Thanks for this. I found out that it was the Smarter Alarm app, which was activating hundreds of times an hour and preventing my phone from going into deep sleep (this app wasn't a problem on my Desire HD, just on the Note).
Here is a shot of BetterBatteryStats showing 4hrs of non-deep sleep followed by 8hrs of deep sleep:
http://i.imgur.com/pXXD3.jpg
And here is the battery graph. You can see in the top left how even when the screen and services were off, the battery was still falling at an unusual rate:
http://i.imgur.com/fjSKi.jpg
An aside: JuiceDefender didn't prevent this from happening, but did heat up the phone noticably. I've since turned it off.
randomstranger99 said:
I'm looking for best practices and successes rather than commiseration.
I'm running JuiceDefender on aggressive and still not getting more than a day of use (3g+BT off, wifi 2hrs, screen time 3hrs).
If you've managed to get some kind of improvement, please share what you did and how much of a difference it made.
Click to expand...
Click to collapse
How long have you had it? Remember that it takes a week or two before the battery reaches its full capacity.
BazookaAce said:
How long have you had it? Remember that it takes a week or two before the battery reaches its full capacity.
Click to expand...
Click to collapse
I've had it 11 days. My battery life has been all over the map, anywhere from 8hrs to 55hrs, depending on usage and wakelock activity. My one-day limit started about four days ago.
randomstranger99 said:
Thanks for this. I found out that it was the Smarter Alarm app, which was activating hundreds of times an hour and preventing my phone from going into deep sleep (this app wasn't a problem on my Desire HD, just on the Note).
Here is a shot of BetterBatteryStats showing 4hrs of non-deep sleep followed by 8hrs of deep sleep:
http://i.imgur.com/pXXD3.jpg
And here is the battery graph. You can see in the top left how even when the screen and services were off, the battery was still falling at an unusual rate:
http://i.imgur.com/fjSKi.jpg
An aside: JuiceDefender didn't prevent this from happening, but did heat up the phone noticably. I've since turned it off.
Click to expand...
Click to collapse
from my understanding of how juice defender works, i believe it closes off non-essential background apps to save battery?
the problem with this is that if the app is designed to remain running at all times, then youre only going to cause problems when running juice defender. juice defender will close the app, the app will reopen itself, juice defender will close the app, the app will reopen itself, etc. its a reboot loop for the app, which will end up draining more battery than simply leaving the background process running.
i dont recommend using any app killers. they all do the same thing and just end up chewing through your battery more. if you want to really disable an app, use titanium background to freeze it.

Standby time

Hey serious question and I'd love a reply. Are there any apps out there that genuinely increase standby time by a significant amount? Yes I've greenified. Yes sync is off. bluetooth nfc etc are all off. I've taken every measure. I've taken out all the rouge apps and all the unneeded apps. But I am still getting a 15% drain battery overnight. This is horrendous for a phone that is supposedly sleeping and not doing anything.
montana r c said:
Hey serious question and I'd love a reply. Are there any apps out there that genuinely increase standby time by a significant amount? Yes I've greenified. Yes sync is off. bluetooth nfc etc are all off. I've taken every measure. I've taken out all the rouge apps and all the unneeded apps. But I am still getting a 15% drain battery overnight. This is horrendous for a phone that is supposedly sleeping and not doing anything.
Click to expand...
Click to collapse
Install better battery stats or wakelock detector to see what app/process is actually draining it

Android system awake

Hi,
New to the Nexus 6p. I can't figure this out - when I am at home on wifi, my phone barely uses battery and Android System "keep awake" is low. When I'm at work, the battery drains much faster, and I notice in both Gsam and the native battery settings that Android System is kept awake for an inordinate amount of time, thus draining the battery at about 8% an hour, even w very limited screen use.
What would cause Android System to stay awake like this? Is there any way to identify the specific thing causing the problem?
Thanks.
Here's screen shots to help.
One more...

Awake with Screen Off percentage

Hi All,
I currently own a Nexus 6P and was find the battery life OK.. not great.
Lasts me the whole day but did expect better considering the size of the battery.
I recently installed BetterBatteryStats - my device unrooted and with stock rom etc. so the detail the app could give me was limited.
But from the screenshot attached you can see that at about 20% battery after about a days use - with around 4hr SOT - it shows that 34% of my entire battery usage was when my screen was off.
Which is more than the whole time the screen was on.
Now, I did use Apple Music on my way to and from work on this day which according to the app had a CPU Total time of around 45mins - so could probably minus that from the awake with screen off stats.
Nevertheless- this would still be a massive amount of the battery usage.
In terms of config of the phone, I have wifi on always on, bluetooth is off and bluetooth scanning is off, wifi scanning is on and location is set to high accuracy.
Was just wondering if anyone else had used this app or similar to get their daily stats. Would like to know if there is possibly an app on my phone which is draining my batter faster than expected.
I've attached additional screenshots as well all taken around the time.
One last thing - one of the screenshots attached is something which keeps showing up in my battery stats - Media Server. I have no idea what this is but any knowledge on that would be great.
Thanks a bunch!
dontmess said:
Hi All,
I currently own a Nexus 6P and was find the battery life OK.. not great.
Lasts me the whole day but did expect better considering the size of the battery.
I recently installed BetterBatteryStats - my device unrooted and with stock rom etc. so the detail the app could give me was limited.
But from the screenshot attached you can see that at about 20% battery after about a days use - with around 4hr SOT - it shows that 34% of my entire battery usage was when my screen was off.
Which is more than the whole time the screen was on.
Now, I did use Apple Music on my way to and from work on this day which according to the app had a CPU Total time of around 45mins - so could probably minus that from the awake with screen off stats.
Nevertheless- this would still be a massive amount of the battery usage.
In terms of config of the phone, I have wifi on always on, bluetooth is off and bluetooth scanning is off, wifi scanning is on and location is set to high accuracy.
Was just wondering if anyone else had used this app or similar to get their daily stats. Would like to know if there is possibly an app on my phone which is draining my batter faster than expected.
I've attached additional screenshots as well all taken around the time.
One last thing - one of the screenshots attached is something which keeps showing up in my battery stats - Media Server. I have no idea what this is but any knowledge on that would be great.
Thanks a bunch!
Click to expand...
Click to collapse
The phone calls may also count towards your screen off drain in better battery stats? Honestly 4 hours is about the average screen on time for a stock 6P. I expected it to be more too. I wouldn't worry too much about Media Server unless it's really chewing up battery. It will run when you're playing music.

Categories

Resources