Flow to control AOD mode based on certain configurable conditions.
This flow toggles the 'Always On Display' mode optionally based on specific posted notifications, battery charging and the 'Do Not Disturb' mode.
It contains 2 starting points - a service flow doing the processing and a configurator flow to administrate the options, which are stored persistently in a file.
The flow set has been created and tested on a Google Pixel 4a (Android 11), so no warranties are given it will run smoothly on any other device.
Setting the AOD mode requires the WRITE_SECURE_SETTINGS right on the device. You may be able (as me) to unlook it using the 'Android Debug Bridge' (ADB). Consult the Automate documentation for further details. There should be no issues on a rooted device either.
Once the configurator flow modifies the settings, it provides them to the eventually running service flow within a broadcast message. Synchronization between the processing fiber and the blocking fibers monitoring the conditions and a possibly changed configuration in the service flow is done by applying 'Variables Give' and 'Variables Take' blocks.
Since disabling AOD does not take effect until it is inactive (at least on the Google Pixel 4a), the device needs to be woken up with a 'Device Keep Awake' block for that matter.