multiple "Keep Device Awake" and "Disable Keep Awake" in different macros

J70P

New member
A question. I use the action "Keep Device Awake" (Until Disabled) in various macros and the action "Disable Keep Awake" in various other macros. How is it ensured that all are deactivated again at the end? Is there an internal record or is there a counter? It looks like everything is deactivated again at the end. But I don't understand why.
 

Snurre

Well-known member
I really don't think it's so difficult 😉
It's a system setting that have two possibilities, either on or off
No matter what app or macro that runs, there is only the setting that has been set at some point
If it's not toggled by another app
So if you disable, it would be disabled all over until you enable it again, regardless if it's by a macro or system settings or what ever, and the same if you enable it
Hope it makes sence 😊
 

J70P

New member
I think it's not that easy. I suspect that one or more wake locks are being used. To use just one, you could count up and down a counter, release the wake lock if it's zero, and acquire the wake lock if it's greater than zero. However, several wake locks could also be used, but then the question arises as to when which will be released again.

And that brings us to the reason I asked the question. If multiple wake locks are used, how does MacroDroid know which one to release?

I think that it's not that simple and probably can only be answered by the developer.
 

MacroDroidDev

Administrator
Staff member
There is a single wakelock. Each time the keep device awake action is invoked the wakelock first gets released before the new wakelock is acquired. Therefore there is only a single wakelock taken at any time, so multiple keep device awake actions will only need a single cancel.
 

Abalsam

Active member
There is a single wakelock. Each time the keep device awake action is invoked the wakelock first gets released before the new wakelock is acquired. Therefore there is only a single wakelock taken at any time, so multiple keep device awake actions will only need a single cancel.
So in theory if you track wake lock state with a global variable, you can set a wake lock if it is currently false and cancel if it is currently true (potential constraint).
 
Top