Android 11 - keep awake does not work

1,027 views
Skip to first unread message

vpfe...@gmail.com

unread,
May 18, 2021, 8:01:25 AM5/18/21
to Automate
Hi all,

keep awake does not work for me on Android 11 - Samsung S21 ...
... having set "CPU+Screen" + "WiFi full" + "Turn ON screen"

Any help/idea pls?
Thanks.

Shari Shark

unread,
May 18, 2021, 8:18:24 AM5/18/21
to automa...@googlegroups.com
Did you keep the fiber running? The keep awake only works is the fiber is alive. I.e. You have to find a way to pause the fiber, either using a delay, notification or whatever.

--
You received this message because you are subscribed to the Google Groups "Automate" group.
To unsubscribe from this group and stop receiving emails from it, send an email to automate-use...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/automate-user/4e44583a-70d1-4cae-b6f4-94a1a1cf3493n%40googlegroups.com.

vpfe...@gmail.com

unread,
May 18, 2021, 10:48:33 AM5/18/21
to Automate
The last block is notification with proceed when dismissed - on Android 9 and Huawei it worked corectly, but now is has no effect ;o(((

Dne úterý 18. května 2021 v 10:18:24 UTC+2 uživatel Shari Shark napsal:

Henrik "The Developer" Lindqvist

unread,
May 18, 2021, 1:49:57 PM5/18/21
to Automate
Ensure there's no "power save" feature interfering, please read:

V. Pfeffer

unread,
May 18, 2021, 3:06:44 PM5/18/21
to automa...@googlegroups.com
Hi Henrik,

the adaptive battery is switched off, and Automate is disabled in battery optimization.
I have also completely switched off the apps sleeping, and unfortunately the keep awake still does not work.

Kind regards, Vladimir P.

***********
Vladimir Pfeffer
Zlin, Czech republic
***********


út 18. 5. 2021 v 15:50 odesílatel Henrik "The Developer" Lindqvist <henrik.l...@gmail.com> napsal:
--
You received this message because you are subscribed to a topic in the Google Groups "Automate" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/automate-user/gZOk_UMXKDw/unsubscribe.
To unsubscribe from this group and all its topics, send an email to automate-use...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/automate-user/3c719b52-486d-4f83-af6b-357d79fa960fn%40googlegroups.com.

Henrik "The Developer" Lindqvist

unread,
May 18, 2021, 5:01:59 PM5/18/21
to Automate
Which part doesn't work, keeping the screen lit, or preventing the device from sleeping?
To test the latter, try a simple test flow:
  1. Flow beginning
  2. Device keep awake: CPU
  3. Delay: Exact, 3s, awake device disabled
  4. (loop back to #3)
Start the flow, push power button, then leave it running for an hour. The log will tell if the flow keeps running while the screen is off.

narf...@gmail.com

unread,
May 22, 2021, 9:22:56 PM5/22/21
to Automate
Hi Henrik,

I was also having the exact same problem on my Galaxy S21 Ultra. I found that having a delay of greater than three seconds as in your example caused the device to either start dimming and then wake up when the delay is around 5 seconds, and if more than around 7 seconds (half my system screen timeout setting of 15 seconds), the wakeup doesn't "catch" the sleep in time and the screen times out. Side note: if Keep Awake catches the screen timeout in time, thereafter longer delay times work. (I was waiting 5 seconds less than whatever the system setting was.) For extra safety, I set the Delay block to "keep awake" when I'm keeping the device awake, and I turn it off when I want it to sleep. That doesn't seem to help the wakeup, though. In my case, it's like the first Keep Awake doesn't do anything, then thereafter it does. Very strange.
 
My question is, did you just happen to choose the 3 second delay in your example, or was there an explicit reason you chose that exact number? -Because it seems that indeed 3 seconds is the maximum it can be, at least in One UI. (This is not the case on Pixels.)

narf...@gmail.com

unread,
May 22, 2021, 9:27:10 PM5/22/21
to Automate
P.S. Adding a toast message to the loop makes the Keep Awake always work! I accidentally discoved this while debugging this problem. I also tried turning off the adaptive screen refresh rate feature on the S21 Ultra, but it made no difference.

Henrik "The Developer" Lindqvist

unread,
May 23, 2021, 9:10:32 AM5/23/21
to Automate
If the delay is longer that 5 seconds, then the block will use Android's timer service (AlarmManager), i.e. relying on the "Timer accuracy workaround". If lesser then it will simply hold a wake-lock while sleeping the thread.

김아린

unread,
May 23, 2021, 9:12:37 AM5/23/21
to automa...@googlegroups.com
Ok

2021년 5월 23일 (일) 오후 6:10, Henrik "The Developer" Lindqvist <henrik.l...@gmail.com>님이 작성:
You received this message because you are subscribed to the Google Groups "Automate" group.
To unsubscribe from this group and stop receiving emails from it, send an email to automate-use...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/automate-user/85614766-e023-40b0-8631-8e485e97e641n%40googlegroups.com.

V. Pfeffer

unread,
May 23, 2021, 2:44:42 PM5/23/21
to automa...@googlegroups.com
Hi Henrik,

I have tested according your instructions (Delay both with keep awake ON and OFF) for 2 hours -
- the display dimmed after a few seconds within any tested conditions
- according the log there was no difference, the timespan between logged-delay was quite the same
... Automate is disabled in battery management, tested with adaptive battery both ON and OFF

Kind regards, Vladimir P.

***********
Vladimir Pfeffer
Zlin, Czech republic
***********


ne 23. 5. 2021 v 11:10 odesílatel Henrik "The Developer" Lindqvist <henrik.l...@gmail.com> napsal:

Henrik "The Developer" Lindqvist

unread,
May 23, 2021, 4:29:23 PM5/23/21
to Automate
With CPU only the screen is allowed to dim.
So what did the log say?

V. Pfeffer

unread,
May 23, 2021, 4:34:03 PM5/23/21
to automa...@googlegroups.com
See in the attachment ...


Kind regards, Vladimir P.

***********
Vladimir Pfeffer
Zlin, Czech republic
***********


ne 23. 5. 2021 v 18:29 odesílatel Henrik "The Developer" Lindqvist <henrik.l...@gmail.com> napsal:
flow-50.log
Message has been deleted

V. Pfeffer

unread,
May 24, 2021, 6:04:17 AM5/24/21
to automa...@googlegroups.com
Hi.

I added between "keep awake" and "notification" block with "toast show", and I have found strange behaviour after keep awake launched:
- if I stay in Automate, the screen is on
- when I go eg. to home screen or another app, the display will dimm after a while
... it looks to me like the keep awake works only for current app

Kind regards, Vladimir P.

***********
Vladimir Pfeffer
Zlin, Czech republic
***********


ne 23. 5. 2021 v 22:43 odesílatel narf...@gmail.com <narf...@gmail.com> napsal:
Vladimir, if you add a short toast message after the Keep Awake, does it help? It did on my S21. I'm beginning to suspect that One UI is doing something deep to determine whether the screen can be dimmed.

BTW guys, if I add just one Interact/swipe of .0001% of the screen, it also makes the Keep Awake work thereafter. Of course I couldn't use that as a workaround because it grabs input focus from the user if you're swiping on the screen yourself, as when moving Automate blocks around 😉

Message has been deleted

Henrik "The Developer" Lindqvist

unread,
May 24, 2021, 9:55:52 AM5/24/21
to Automate
So Automate isn't killed. Did you leave Automate in the foreground? If so, try navigating away from it, e.g. back to the home screen.

V. Pfeffer

unread,
May 24, 2021, 10:06:03 AM5/24/21
to automa...@googlegroups.com
Hi Henrik,

Automate was not in the foreground - homescreen was "up"

Kind regards, Vladimir P.

po 24. 5. 2021 v 11:55 odesílatel Henrik "The Developer" Lindqvist <henrik.l...@gmail.com> napsal:

Henrik "The Developer" Lindqvist

unread,
May 24, 2021, 10:06:42 AM5/24/21
to Automate
It shouldn't. That's exactly the behavior to be expected when a non-standard "power save" feature is interfering, of which Samsung currently has the worst: https://dontkillmyapp.com/samsung

V. Pfeffer

unread,
May 24, 2021, 10:19:53 AM5/24/21
to automa...@googlegroups.com
Hi,

I have switched OFF:
- battery optimization (and daily analysis)
- adaptive battery
- putting apps to sleep comletely
+ Automate is excluded from from battery management
...and "keep awake" still does not work ... ;o(
... it is not crucial for me, but would be nice to have it working

Kind regards, Vladimir P.

po 24. 5. 2021 v 12:06 odesílatel Henrik "The Developer" Lindqvist <henrik.l...@gmail.com> napsal:

Henrik "The Developer" Lindqvist

unread,
May 24, 2021, 10:42:27 AM5/24/21
to Automate

narf...@gmail.com

unread,
May 24, 2021, 4:05:32 PM5/24/21
to Automate
It seems that Vladimir and I have both turned off all battery optimizations for Automate and the problem persists. The thread you referred to mentions something about a bug with Samsung  battery optimization being fixed in the April update and I'm running the May version. Perhaps there's been a regression.

Meanwhile I've been continuing with some experiments.  A completely simple flow which only does a Keep Awake and a Delay seems to work. But a fancier flow which checks device orientation in order to determine whether the device is in hand at a viewing angle does not. It's difficult to say this with certainty as it's inconsistent. The logs show that Automate continues to run normally  regardless, but if there's a locking issue in the internals of the Keep Awake block caused by the OS, this wouldn't matter.

One more piece of information, FWIW: often I'll see the screen start to dim, but if the Keep Awake block "catches" it in time, thereafter the screen will stay awake. This is with screen timeout set to 15 seconds and the delay in the flow set to 3 to 8 seconds. It still often starts to dim with even the shortest delay, however. So it's like One UI ignores the Keep Awake until it successfully gets another one in time.

Henrik "The Developer" Lindqvist

unread,
May 24, 2021, 4:33:01 PM5/24/21
to Automate
It seems the Samsung "feature" doesn't kill the app, it just break, doesn't honor, wake-locks.

narf...@gmail.com

unread,
May 24, 2021, 5:10:14 PM5/24/21
to Automate
Yes, it seems hopeless until and unless Samsung does something to fix it (again?).

Looks like I'll be stuck with the inferior "Keep screen on while viewing" feature, which doesn't work well in the dark and may consume more battery than the flow I wrote for this purpose:

narf...@gmail.com

unread,
May 24, 2021, 5:16:28 PM5/24/21
to Automate
P.S. I tried exempting an app I switch to after Automate from battery optimizations as well, but that had no effect.

vpfe...@gmail.com

unread,
May 26, 2021, 7:28:52 AM5/26/21
to Automate
Hi all,

cause there is a glitch in "keep awake" on S21, I found a workaround that works for me for me ...
... there are Bixby routines, and you can set a routine for your foreground app not to dimm display for 10 minutes max, it is enough for my reading and browsing web/tw/etc.


Shari Shark

unread,
May 26, 2021, 7:39:16 AM5/26/21
to automa...@googlegroups.com
I didn't really read all the messages but what I gathered is to use a flow to keep screen alive for reading purposes? 

Why not set change the device display settings to a larger interval instead? 

Basically I used a system settings set block, settings category and screen off timeout. Works well for me.

--
You received this message because you are subscribed to the Google Groups "Automate" group.
To unsubscribe from this group and stop receiving emails from it, send an email to automate-use...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/automate-user/2c0c1afa-b6ce-47e7-9a41-c093af14fc94n%40googlegroups.com.

V. Pfeffer

unread,
May 26, 2021, 8:01:46 AM5/26/21
to automa...@googlegroups.com
Hi,

not only for reading purposes, and "keep awake" could be used for any purpose ...
... so the bixby routine solves just a particular area for me (or maybe also your suggested flow)
... and it does not solve the issue to keep screen awake until switched off

Kind regards, Vladimir P.

st 26. 5. 2021 v 9:39 odesílatel Shari Shark <sharis...@gmail.com> napsal:
You received this message because you are subscribed to a topic in the Google Groups "Automate" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/automate-user/gZOk_UMXKDw/unsubscribe.
To unsubscribe from this group and all its topics, send an email to automate-use...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/automate-user/CANM9T6G_tqc%3DH2mjKBLfuGAQranGCgb5dymyic7CMWGJfYhZ%3Dw%40mail.gmail.com.

Shari Shark

unread,
May 26, 2021, 8:12:15 AM5/26/21
to automa...@googlegroups.com
Afaik, keeping screen awake pretty much keeps the device awake. 

As for keep screen awake until switched off, you can detect when the screen is switched off, or when power button is pressed etc and reset the display timeout.

Our to create a notification and reset the screen timeout when the notification is dismissed etc. 

Imo many ways of achieving similar functionality.

For one, I used this method to customize display timeout based on foreground app. 


narf...@gmail.com

unread,
May 26, 2021, 1:56:04 PM5/26/21
to Automate
A closer Samsung analog for this is to use the "Keep screen on while viewing" system setting. You can search for that text in the settings to find it. As I said, it doesn't work as well as my old flow which lets you specify exact apps and which keeps the display active while your phone is held at a reading angle. The system setting uses the camera to watch to see if you're looking at the screen, which might take more battery and may not work at low light levels. The Bixby routine isn't ideal either because it'll leave the screen on even after you've put the phone down.

I wrote my flow to get around these problems on my old LG phone.

bandara....@gmail.com

unread,
Sep 8, 2021, 6:26:08 AM9/8/21
to Automate
Hi all I Had same problem and I noticed an app using overlay to keep screen on. So I.asked Henrik.what can show overlay  Henrik suggested use set screen orientation model as it works in a overly. It worked. Hope this helps
Reply all
Reply to author
Forward
0 new messages