Wakelock detection without root

seanubis

Well-known member
Feb 8, 2010
234
9
0
Visit site
Just wanted to share a tip I found while investigating severe battery drain on my 2013 Moto X.

Over the past few weeks, the battery life on my Moto X was horrible - I could get maybe 10 hours off the charger, with minimal screen-on time, like well under 90 minutes.

I noticed from the battery graph that something was keeping the phone awake all of the time. I looked into using a wakelock detector app, but every one I found seemed to require root, which I don't have (4.4.4 on VZW).

I finally found this thread on Reddit, that showed how to get wakelocks through adb shell, like this:

adb shell dumpsys power | grep -i partial_wake_lock

Running that in a loop revealed the culprit:

$ while true ; do adb shell dumpsys power | grep -i wake_lock; sleep 1; done
PARTIAL_WAKE_LOCK 'handleMediaEvent' (uid=1000, pid=909, ws=null)
PARTIAL_WAKE_LOCK 'handleMediaEvent' (uid=1000, pid=909, ws=null)
PARTIAL_WAKE_LOCK 'handleMediaEvent' (uid=1000, pid=909, ws=null)
PARTIAL_WAKE_LOCK 'handleMediaEvent' (uid=1000, pid=909, ws=null)
PARTIAL_WAKE_LOCK 'handleMediaEvent' (uid=1000, pid=909, ws=null)
PARTIAL_WAKE_LOCK 'handleMediaEvent' (uid=1000, pid=909, ws=null)
PARTIAL_WAKE_LOCK 'handleMediaEvent' (uid=1000, pid=909, ws=null)
...


I googled "handleMediaEvent" and found this XDA thread that suggested that it was a problem related to Bluetooth playback controls, and that power cycle was the only way to get things back to normal: http://forum.xda-developers.com/showthread.php?t=2483630

Sure enough, I power-cycled and now my phone is sleeping when it should.

Hope this helps someone else - it sure helped me. Thanks, internets!
 
Last edited:

sixty_four

Well-known member
Nov 29, 2011
510
3
0
Visit site
Yep, seems Tapatalk didn't like the XDA link. I've reformatted things a bit, should load completely now.

Very handy! Thanks for posting this. I'm dumping results to a file so I can filter and look at the results after a good amount of time has elapsed.

One thing I've noticed is "aon_charging" constantly generates partial wakelocks. This looks like something that's associated with Moto's Active Display. If I had to guess this might be the reason why the battery graph shows my phone as always awake when it's connected to a power source.

I don't know if there's a way either to use adb without a USB connection or to disable USB power so I'm kind of in a Schrodinger's Cat situation where I wish I could see what my "real" wakelocks look like but can't do that without influencing the results by observing ;)
 

seanubis

Well-known member
Feb 8, 2010
234
9
0
Visit site
Very handy! Thanks for posting this. I'm dumping results to a file so I can filter and look at the results after a good amount of time has elapsed.

One thing I've noticed is "aon_charging" constantly generates partial wakelocks. This looks like something that's associated with Moto's Active Display. If I had to guess this might be the reason why the battery graph shows my phone as always awake when it's connected to a power source.

I don't know if there's a way either to use adb without a USB connection or to disable USB power so I'm kind of in a Schrodinger's Cat situation where I wish I could see what my "real" wakelocks look like but can't do that without influencing the results by observing ;)

You could filter out the "aon_charging" entries with grep in real time, eg:

while true ; do adb shell dumpsys power | grep -i wake_lock | grep -v aon_charging; sleep 1; done

Hope that helps!
 

sixty_four

Well-known member
Nov 29, 2011
510
3
0
Visit site
You could filter out the "aon_charging" entries with grep in real time, eg:

while true ; do adb shell dumpsys power | grep -i wake_lock | grep -v aon_charging; sleep 1; done

Hope that helps!

Yep - I'm just tee'ing the output to a file and filtering after the fact. Just like digging through polluted syslogs at work ;)
 

Forum statistics

Threads
942,895
Messages
6,916,436
Members
3,158,727
Latest member
thtknt