From cb4dbb8b80a52997e179e6f26943aecdd971b3ed Mon Sep 17 00:00:00 2001 From: Catherine Shi Date: Mon, 22 Jun 2020 12:12:03 -0700 Subject: [PATCH] system server watchdog caused by deadlock There is deadlock among ActivityManagerService, ActivityTaskManagerService and ConnectionServiceWrapper. Move stopLockTaskModeInternal out of mGlobalLock scope. This will remove the deadlock Bug: 159213837 Bug: 162950591 Test: presubmit Change-Id: I6aee6f9837bac22e480f42124bfcdba991e0fa1a (cherry picked from commit 3a17ba2f2560405ee8415d2d652eb3dd3c7449fc) --- .../server/wm/ActivityTaskManagerService.java | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/services/core/java/com/android/server/wm/ActivityTaskManagerService.java b/services/core/java/com/android/server/wm/ActivityTaskManagerService.java index 5992ff74dfa20..52d4b6fc78dfe 100644 --- a/services/core/java/com/android/server/wm/ActivityTaskManagerService.java +++ b/services/core/java/com/android/server/wm/ActivityTaskManagerService.java @@ -2997,13 +2997,7 @@ public class ActivityTaskManagerService extends IActivityTaskManager.Stub { @Override public void stopLockTaskModeByToken(IBinder token) { - synchronized (mGlobalLock) { - final ActivityRecord r = ActivityRecord.forTokenLocked(token); - if (r == null) { - return; - } - stopLockTaskModeInternal(r.getTask(), false /* isSystemCaller */); - } + stopLockTaskModeInternal(token, false /* isSystemCaller */); } /** @@ -3045,11 +3039,19 @@ public class ActivityTaskManagerService extends IActivityTaskManager.Stub { } } - private void stopLockTaskModeInternal(@Nullable Task task, boolean isSystemCaller) { + private void stopLockTaskModeInternal(@Nullable IBinder token, boolean isSystemCaller) { final int callingUid = Binder.getCallingUid(); long ident = Binder.clearCallingIdentity(); try { synchronized (mGlobalLock) { + Task task = null; + if (token != null) { + final ActivityRecord r = ActivityRecord.forTokenLocked(token); + if (r == null) { + return; + } + task = r.getTask(); + } getLockTaskController().stopLockTaskMode(task, isSystemCaller, callingUid); } // Launch in-call UI if a call is ongoing. This is necessary to allow stopping the lock