My system likes to restore a variable at random times, so I have a simple flow consisting of a loop that "System setting set" the variable, then "System setting get" the variable but only proceeds "When changed". Automate is also set to "Run on system startup".
However, after a system reboot, if the system restores the variable before Automate runs, the flow does not work because the flow resumes in the get block but does not find the variable to have been changed.
I am wondering if there is a workaround for this? Is there a way to always resume after a restart to the beginning? Or to know there has been a restart?
I am also curious how "When changed" works (I am not familiar with Android system calls). Edit: Android is event based, so it may be something like https://stackoverflow.com/questions/6190779/monitor-android-system-settings-values/6191153, which is better than reading the variable repeatedly and testing for changes myself.
My system likes to restore a variable at random times, so I have a simple flow consisting of a loop that "System setting set" the variable, then "System setting get" the variable but only proceeds "When changed". Automate is also set to "Run on system startup".
However, after a system reboot, if the system restores the variable before Automate runs, the flow does not work because the flow resumes in the get block but does not find the variable to have been changed.
I am wondering if there is a workaround for this? Is there a way to always resume after a restart to the beginning? Or to know there has been a restart?
I am also curious how "When changed" works (I am not familiar with Android system calls). Does it become a flag so the system call is pending (i.e., does not return) until the variable is changed?
My system likes to restore a variable at random times, so I have a simple flow consisting of a loop that "System setting set" the variable, then "System setting get" the variable but only proceeds "When changed". Automate is also set to "Run on system startup".
However, after a system reboot, if the system restores the variable before Automate runs, the flow does not work because the flow resumes in the get block but does not find the variable to have been changed.
I am wondering if there is a workaround for this? Is there a way to always resume after a restart to the beginning? Or to know there has been a restart?
I am also curious how "When changed" works (I am not familiar with Android system calls). Does it become a flag so the system call is pending (i.e., does not return) until the variable is changed?
After a reboot, it seems a flow resumes in the same block as before, not the beginning.
Thank you very much!
I notice there are actually "Boot completed" and "Automate service started". Would "Automate service started" better capture all restart events, for example also after Automate is force stopped (and then restarted)?
Edit: Boot completed is an intent. I am guessing "Automate service started" happens after startService() is called.
https://developer.android.com/reference/android/content/Intent#ACTION_BOOT_COMPLETED
As to how to use the "Broadcast receive" block, I found this topic:
https://groups.google.com/forum/#!msg/automate-user/Yr7GI3vzTMs/PGTvFmhbAgAJ
So I connected "Flow beginning" to "Fork". One side of "Fork" goes to the existing set/get loop. Another side of "Fork" goes to "Broadcast receive", which goes to set, then loops back to "Broadcast receive" as a separate new loop.
The get in the existing loop becomes unstuck by virtue of the set in the new loop.
So far it seems to work (I tried to "force stop" Automate, changed the variable using Settings Database Editor, then ran Automate again). I will see if it continues to work, but wow, Automate is really powerful!
Thank you very much again!
Thank you very much!
I notice there are actually "Boot completed" and "Automate service started". Would "Automate service started" better capture all restart events, for example also after Automate is force stopped (and then restarted)?
Edit: Boot completed is an intent. I am guessing "Automate service started" happens after startService() is called.
https://developer.android.com/reference/android/content/Intent#ACTION_BOOT_COMPLETED
As to how to use the "Broadcast receive" block, I found this topic:
https://groups.google.com/forum/#!msg/automate-user/Yr7GI3vzTMs/PGTvFmhbAgAJ
So I connected "Flow beginning" to "Fork". One side of "Fork" goes to the existing set/get loop. Another side of "Fork" goes to "Broadcast receive", which goes to set, then loop back to "Broadcast receive" as a separate new loop.