Flow to detect a wakelock

General discussions about Automagic and automation in general

Moderator: Martin

Post Reply
bongster
Posts: 2
Joined: 04 Aug 2015 07:24

Flow to detect a wakelock

Post by bongster » 04 Aug 2015 07:55

Hi there,
first I like to thank you for this really great app! Second I'm not really sure where to post my question, so please move the thread to the right section if this is not the right place.

Here my question:
I'm fighting against a not automagic related wakelock that appears from time to time. I'm looking for a way to check, after a minute or so, if my phone is going to deep sleep after the display is off.
That would be an indicator, if there is a wakelock in general and I could restart my phone.
I've checked with "better battery stats" how long it takes for my phone that deep sleep occurs.
I hope I made my self clear and there is a possibility to track deep sleep or use better battery stats in a way.
Thanks again and regards,
Bongster

User avatar
Martin
Posts: 4468
Joined: 09 Nov 2012 14:23

Re: Flow to detect a wakelock

Post by Martin » 04 Aug 2015 19:45

Hi,

It's difficult to do this with Automagic. I would try to track this problem down by connecting your phone to a computer and use adb shell dumpsys batterystats. The log contains a plethora of information about wake locks including the history.
You could also acquire the log on a rooted device with Execute Root Command: dumpsys batterystats followed by Write to File: {stdout}. You might have to switch the SE context in the root action to u:r:shell_s0.

You could also use a flow/script with functions getUptimeMillis() and getElapsedRealtimeMillis() to find the time the device spent in sleep.

Regards,
Martin

bongster
Posts: 2
Joined: 04 Aug 2015 07:24

Re: Flow to detect a wakelock

Post by bongster » 04 Aug 2015 21:02

Hi Martin,
I guess this is exactly what I was looking for!
Martin wrote:
You could also use a flow/script with functions getUptimeMillis() and getElapsedRealtimeMillis() to find the time the device spent in sleep.
Thanks!

Just for info. My phone sometimes gets a wakelock from my camera app and goes only in deep sleep after a reboot. With this I can check after a minute screen off if it happens and send a notification.

Post Reply