Put next task on top of stack if top is finishing.

In the case where the top task is finishing and another task is
launching make sure that the next task will be launched once the
top task actually completes pausing.

In the case of b/10550460 the top task, Dialtacts, was finishing
but had not yet completed pausing. It was configured to return to
the home screen (mLaunchHomeTaskNext true) but because its finishing
flag was set all the tests we have thought that the InCallActivity
task was the top task. When it finally did complete the
mLaunchHomeTaskNext flag caused the home activity to be started
instead of the InCallActivity.

If the InCallActivity task had been moved above the Dialtacts task
at the time it was judged to be the top task the home activity
would not have been launched when Dialtacts completed. This fix
moves the judged top task over the finishing top task.

Fixes bug 10550460.

Change-Id: I14052ad2282008679b560dd7fb16b216664ec24d
1 file changed