Loading
Fix wrong focused stack if there are finishing tasks.
When there is more than one finishing tasks, topTask() may not match the current finishing task to adjust. https://code.google.com/p/android/issues/detail?id=192090 A sample step: 1.Launch task T from home. 2.Press home key. 3.Launch task A from home. 4.A launches task B. 5.B finishes self and A finishes onResume. When adjustFocusedActivityLocked is called from A's finish, both A and B are finishing and B has not destroyed yet, so the top task is B that is not satisfy the original condition to change focused stack. Then it still uses application stack to resume, that is T. After A completed destroy: activityDestroyedLocked -> removeActivityFromHistoryLocked will check if it is over home. So T only shows awile then return to home. To handle this case, still check the behind tasks when the adjusting task is not top task. If the task is alive, then it stays in current stack, and if there is a finishing task over home, then it should go home. For above example, B is finishing (getTopActivity() will be null) but it is not over home, then check the next which is A. And because A is over home, then it can adjust to home stack. Change-Id: Id5d6d58ccdac38bdbebba6df50a063b78182cd4f