Prevent restoring task when updating task

Cherry-pick from: Ie501add4b72a63be0b8514136f10a09fbdd0c6c3

Symptom: App activity shown between launcher & wallpaper.

RootCause:
Some AM public Apis (getTaskInfo(), setExcluteFromRecent()) will calling
AM.anyTaskForIdLocked with MATCH_TASK_IN_STACKS_OR_RECENT_TASKS_AND_RESTORE
parameter to get task record & add task into stack bottom,
that will affect wm side also create task & bring task stack to bottom
due to task.createWindowContainer() in restoreRecentTaskLocked().

Solution:
using MATCH_TASK_IN_STACKS_OR_RECENT_TASKS to get task record without
restore record into stack.

Bug: 67634904
Test: As below issue described sample app flows. b/68038609

Change-Id: I8241c0956a3323a70e754c794dd562540ff4eaf4
Signed-off-by: Winson Chung <winsonc@google.com>
This commit is contained in:
Winson Chung
2017-10-23 11:10:58 -07:00
parent 95111379d5
commit 5d339f001b

View File

@@ -16,6 +16,7 @@
package com.android.server.am;
import static com.android.server.am.ActivityStackSupervisor.MATCH_TASK_IN_STACKS_OR_RECENT_TASKS;
import static com.android.server.am.ActivityStackSupervisor.REMOVE_FROM_RECENTS;
import android.app.ActivityManager;
@@ -76,7 +77,8 @@ class AppTaskImpl extends IAppTask.Stub {
synchronized (mService) {
long origId = Binder.clearCallingIdentity();
try {
TaskRecord tr = mService.mStackSupervisor.anyTaskForIdLocked(mTaskId);
TaskRecord tr = mService.mStackSupervisor.anyTaskForIdLocked(mTaskId,
MATCH_TASK_IN_STACKS_OR_RECENT_TASKS);
if (tr == null) {
throw new IllegalArgumentException("Unable to find task ID " + mTaskId);
}
@@ -110,7 +112,8 @@ class AppTaskImpl extends IAppTask.Stub {
TaskRecord tr;
IApplicationThread appThread;
synchronized (mService) {
tr = mService.mStackSupervisor.anyTaskForIdLocked(mTaskId);
tr = mService.mStackSupervisor.anyTaskForIdLocked(mTaskId,
MATCH_TASK_IN_STACKS_OR_RECENT_TASKS);
if (tr == null) {
throw new IllegalArgumentException("Unable to find task ID " + mTaskId);
}
@@ -131,7 +134,8 @@ class AppTaskImpl extends IAppTask.Stub {
synchronized (mService) {
long origId = Binder.clearCallingIdentity();
try {
TaskRecord tr = mService.mStackSupervisor.anyTaskForIdLocked(mTaskId);
TaskRecord tr = mService.mStackSupervisor.anyTaskForIdLocked(mTaskId,
MATCH_TASK_IN_STACKS_OR_RECENT_TASKS);
if (tr == null) {
throw new IllegalArgumentException("Unable to find task ID " + mTaskId);
}