Desmanto wrote: ↑28 Apr 2019 07:28
{battery_level} only provided after the flow is executing. if we put {battery_level} at the trigger, it won't work, as it is not glovar.
I finally understand what you mean by that.
Desmanto wrote: ↑28 Apr 2019 07:28
Sorry, battey saver level and TWRP flow actually are different, I shouldn't give the examples to compare them. Let just imagine another situation, where we work for normal and overtime. During normal, we set the battey saver will trigger after 30%. But if we work overtime, we want it triggered at 50% (so we can use the phone longer). It is impossible we change the flow everytime we have normal time and overtime. So better put variable to it and use another flow to change the variable as needed (triggered based on calendar or other things).
So you're saying you have one flow for setting or updating the global variable and another that includes the code to make TWRP perform a backup?
As for the example, wouldn't it be better to have a
map variable instead to store the various percentages (eg. 20%, 50%, etc.) at which you want Battery Saver mode to trigger? This is what I would do, for example, rather than have a separate flow for updating the variable's value depending on certain conditions:
Code: Select all
global_battery_saver_trigger_level = newMapFromValues("casual", 20, "work", 50, "pre-backup", 30);
Desmanto wrote: ↑28 Apr 2019 07:28
For TWRP, yes, the condition is actually checked after the flow executed, so yeah, I give wrong example, my bad.
Nah, it makes sense to me now why you would check the level within the trigger; I just didn't quite understand why you would want to store the trigger level for Battery Saver mode in a global variable when you can retrieve it via the
Init Variable System Setting action.
Desmanto wrote: ↑28 Apr 2019 07:28
TWRP support openrecovery script. My flow will check if the battery level is enough, then it will write the script in the /cache/recovery, reboot to TWRP. After booting to TWRP, it will check if the openrecovery script exists. If yes, execute it. My script include reboot after the backup finish, so it will automatically reboot when finish, showing the result of the backup. Today, sunday, is the scheduled time that the flow will be triggered.
I've been completely unaware of TWRP having this functionality so thank you for telling me this! I've found the
guide for the available commands and will be looking into this soon as I've been thinking of creating a flow that would automatically download the necessary files and reboot to TWRP to install/flash the ROM update, GApps and Magisk (to retain root) zip files when I get a notification for a new update
However, I am unsure about what you mean by "showing the result of the backup". Are you saying that somewhere in the script or flow, you somehow store information on the state of the backup (whether it was successful or not)?