OSDN Git Service

Fix WM missing stack/task when activity is force stopped and restarted
authorChong Zhang <chz@google.com>
Fri, 5 Aug 2016 00:55:21 +0000 (17:55 -0700)
committerChong Zhang <chz@google.com>
Fri, 5 Aug 2016 19:16:04 +0000 (12:16 -0700)
commitd9d35bdfcf0e18ae16c0f59290b860700fb6e62f
tree66abcf8f745b7bb0134b9099c79a6d1d4770537e
parent6f20514185f836bbab48fe3867d3b249da573ec9
Fix WM missing stack/task when activity is force stopped and restarted

When activity process is force-stopped (like in the case we need to stop
it to allow debugger), activity record is removed and a new instance is
added. Depending on timing, adding of new record could happen before
or after old record is removed. If it added after old record is removed,
then the removal could cause AM to also remove the task AND the stack
(if the activity is the last one).

On WM side however, the task/stack removal could be delayed due to
animation. So when AM attaches a new stack, we end up with two stacks
with the same stack id in the DisplayContent. Also, AM reuses the last
used taskId after it's deleted. So WM is confused and didn't add a new
task record. Then when the delayed stack removal fires everything is gone.

We need to use a different task id when creating a new task record, even
if the last created task is already deleted. Also when attaching a new
stack to WM, first check if we already have such a stack in DisplayContent,
if so, reattach it and don't create a duplicate.

bug: 30465601
Change-Id: Ic399a32c54f6acdcbb9a0c6155599331d55df232
services/core/java/com/android/server/am/ActivityStackSupervisor.java
services/core/java/com/android/server/wm/DisplayContent.java
services/core/java/com/android/server/wm/WindowManagerService.java