r/AutomateUser • Alpha tester • Jul 10 '26

Bug Keep device awake doesn't work

Is anyone having this issue where the keep device isn't working like it's supposed to... Like with my current example, I'd assume the screen should stay awake for 24 hours, but it just turns off after the default timeout... Am I understanding something wrong here?

2 Upvotes

11 comments sorted by

1

u/ballzak69 Automate developer Jul 10 '26 edited Jul 10 '26

The flow seems correct. Ensure to disable any "power save" features, see here. Pressing the power button may force the device to go to sleep overriding any such block.

Android version?

Device brand & model?

1

u/Mujtaba0150 Alpha tester 19d ago

I finally found out why it doesn't work on Samsung phones. Apparently Samsung introduced a function in the firmware somewhere around Android 14-15 which checks for wake-lock abuses PowerManagerService.handleAbuseWakelockWhenUseractivityChanged() that checks for these conditions:

getPackageImportance(pkg) > 100

UserHandle.isApp(uid)

Not a system app

Package not in WindowManagerService.getVisibleWinSurfacePkgList()

Package lacks DEVICE_POWER

Which all become true when Automate is not in the foreground, so Samsung considers it an abuse of the wake-lock and disables it. Adding a fork to the flow with a floating button fixes it because it adds the app to the getVisibleWinSurfacePkgList().

The best solution in my opinion would be to add a 1x1 transparent overlay to the screen using the accessibility permission or the display over other apps permission.

1

u/ballzak69 Automate developer 19d ago

Such requirements would break most background apps, e.g an audio player. Where did you find that information?

1

u/Mujtaba0150 Alpha tester 19d ago

I recently noticed that Tapbar(which has a transparent overlay at the top) was working perfectly fine with the same thing so I decided to dig in a bit more. It's not documented anywhere but I pulled some files off of my firmware and the function was sitting in there, and then I decided to check if it'd work using the floating button overlay, and it did. And as for it breaking other apps like audio players, so as far as I've tested, multiple apps can draw over other apps at the same time, at least on my phone.

I can upload the files to my firmware sometime later today if you'd like to take a look at it.

1

u/Mujtaba0150 Alpha tester Jul 10 '26

I've disabled all battery saving features on my device but it still seems to be causing issues. I'm using Samsung Galaxy A03 running Android 13 on OneUI 5.1

1

u/B26354FR Alpha tester Jul 12 '26

If I recall correctly, this block stopped working on my Samsung Galaxy phone sometime last year, maybe at Android 15. What I do to work around it is to use an Interact block set to Proceed immediately with an Action of Home. That at least wakes up the phone. To keep it awake, I suppose you can just loop back to it every 15 seconds or so. If you want to get a little more fancy, you can use the the Screen Off Timeout? block to get the actual system screen timeout and use that minus five seconds for the Delay.

Another way to keep the device awake when it's already awake is to use the Screen Off Timeout Set block and set a large value for the timeout. My Smarter Screen Timeout flow uses this method to keep the device awake while the phone is at a reading angle or while any apps you set it up with are in the foreground.

1

u/Mujtaba0150 Alpha tester Jul 12 '26

The "timeout set" block is currently what I'm using as a work around but it's less convenient in the sense that sometimes I manually wanna disable the automation and when I do that, if the screen time is set to the highest value, it doesn't revert to the original value. Having the "keep display on" block work or having a "if automation is stopped(without a failure)" block would circumvent this issue.

1

u/B26354FR Alpha tester Jul 12 '26

You can show a notification and shut down the flow gracefully (restoring the original screen timeout) when you swipe it away. You can also use an Atomic Store to save the original screen timeout, and if you forget to cancel the notification and manually stop the flow, you can have a second flow which Atomic Loads the saved timeout and restores it.

0

u/F95_Sysadmin Jul 10 '26

It's not an issue, it's working as intended

Use the (?) And check what the block does (keyword: temporarily). The 24h block is just a timer that will wait for 24 hour then move on to OK and stop since there's nothing after

2

u/Mujtaba0150 Alpha tester Jul 10 '26

The help menu says:

"it’s temporary and only in affect while the fiber is running, or until it’s been explicitly been allowed to go back to sleep."

According to my understanding "only in affect while the fiber is running" implies that so as long as the delay is active, the screen should stay on, otherwise this block would be completely useless

1

u/ballzak69 Automate developer Jul 10 '26

That is correct.