Completed tasks replay when TaskService is restarted if the task was started following a long running task
Tasks that are running when the TaskService is killed are resumed when the TaskService can be recreated (as they should). In addition completed tasks that should not resume are incorrectly replayed if they were started after a task which should resume.
Example:
- Task "Long" requires a long time to finish.
- Task "Short1" and "Short2" are done quickly.
- User starts tasks in the order Short2, Long, Short1.
- Tasker finishes Short2 and Short1 but is still working on Long.
- Android terminates the TaskService
- Tasker recreates TaskService
- Tasker resumes Long and Short1 even though Short1 had already finished.
Expected behavior: Tasker resumes Long only.
I've attached an XML of a project that reproduces the bug and a run log showing the incorrect replays.
The demo contains three tasks and a scene. The task Forever waits in a loop forever. The task Short flashes the running tasks. Start shows the scene which has one button that runs Short. To simulate an Android kill (OOM) the scene can be cleared out of the recent apps list.
To run the demo start Forever, then run Start and press the button a few times to complete some short tasks. Then clear the scene from the recent apps list to simulate an Android kill. After a short delay Tasker will resume Forever (correctly) and also (incorrectly) run Start, showing the scene, and attempt to run Short several times.
Bug observed on Samsung Galaxy S4 running Android 5.0.1 and Tasker 5.5.bf2