From a61f94ef827bfbaad7c76e8a297bf8d9ecf290be Mon Sep 17 00:00:00 2001 From: Matthew Ng Date: Mon, 5 Feb 2018 15:55:37 -0800 Subject: Fixes crash when pinning unfocused task in multiwindow If an app can invoke pin locked mode such as Play video, and is split to the bottom/right and not focused (focus the primary split task), then it will crash trying to start lock task mode. Fix by moving pinned task to front to become focused. Change-Id: Ifd2c91b90d0f9f29111321f6fb2a1c5cf0073c49 Fixes: 72868672 Test: manual --- .../core/java/com/android/server/am/ActivityManagerService.java | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/services/core/java/com/android/server/am/ActivityManagerService.java b/services/core/java/com/android/server/am/ActivityManagerService.java index 8d1632a3cef6..b666d1015c30 100644 --- a/services/core/java/com/android/server/am/ActivityManagerService.java +++ b/services/core/java/com/android/server/am/ActivityManagerService.java @@ -11283,8 +11283,11 @@ public class ActivityManagerService extends IActivityManager.Stub long ident = Binder.clearCallingIdentity(); try { synchronized (this) { - startLockTaskModeLocked(mStackSupervisor.anyTaskForIdLocked(taskId), - true /* isSystemCaller */); + final TaskRecord task = mStackSupervisor.anyTaskForIdLocked(taskId); + + // When starting lock task mode the stack must be in front and focused + task.getStack().moveToFront("startSystemLockTaskMode"); + startLockTaskModeLocked(task, true /* isSystemCaller */); } } finally { Binder.restoreCallingIdentity(ident); -- cgit v1.2.3-59-g8ed1b