I'm using an app called Gravity and trying to have Automagic kill or start it every time the display turns off or on. The reason is that all programs I tried that tinkle with the wakelock functions (nci) (Gravity, Screebl, Smart Screen, et al.) prevent my phone from entering the deep sleep state by maintaining the "proximity" wakelock on all the time even when the screen is reported to have been off (checked with BetterBatteryStats and CPU Spy). So I thought I'd use Automagic to (partially) do the job properly.
Some of the issues I'm having are that Gravity is a bit difficult to kill or restart. I understand because it's the nature of the program. Still I made it through by using the "Control UI" actions instead of Kill or Launch app. So I have 2 flows:
#1 Display off - Kill Gravity
Trigger: Display off
Action: Sleep 20000ms
Action: Launch Gravity - default
Control UI: check(on);sleep(500);click(close settings)
#2 Display on - Start Gravity
Trigger: Display on
Action: Launch Gravity - default
Control UI: uncheck(off);sleep(500);click(close settings)
The problem is that Automagic stalls at the step display off (I think, I could not test further), and nothing gets done. After the display gets on again, I do have the Gravity app page but the buttons were not triggered as expected. Both flows work fine when I execute them in Automagic but not outside, i.e. when the display goes on-off by itself.
Any suggestion, pointers or even the whole shebang to execute the flows
