From 7efc7748bae99e454ab7eb01bd15ce845a2ba0fe Mon Sep 17 00:00:00 2001 From: Yohei Yukawa Date: Fri, 21 Jun 2019 13:33:14 -0700 Subject: [PATCH] Recover simpler WM lock in REPORT_FOCUS_CHANGE This CL follows up previous CLs [1][2][3] to recover the original simplicity regarding WM lock handling in REPORT_FOCUS_CHANGE handler. What happened are: 1. The first CL [1] introduced an IPC that can be issued while WM holds its global lock in the REPORT_FOCUS_CHANGE handler, which ended up causing dead lock between WM and ViewRootImpl. 2. The second CL [2] addressed the above dead lock by temporarily releasing WM lock when issuing IPC from WM to ViewRootImpl. 3. The third CL [3] simplified the logic and removed the code path in question but didn't revert the second CL [2]. In short, this CL logically reverts the second CL [2] since it's not necessary any more. [1]: Ia46738a5da6dbc334bf937b0f6656a57523c28a7 6f13d20b8ecfef97cd98b5564cbf1fca58a4b04d [2]: Ia30a279441def501e53eeee8913d19ac50a620cd 52ef1bf893e27da84c179b91fa864ecb73f809c7 [3]: Ie030eed523599b217060887171710692d050e5d8 51c5a1d0429baf5d508dc287c12f52a5a0bc5135 Bug: 119658889 Test: atest CtsWindowManagerDeviceTestCases Change-Id: Id081851f60d6a2f8f17e9e21408f3052ff1f2cea --- .../com/android/server/wm/WindowManagerService.java | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/services/core/java/com/android/server/wm/WindowManagerService.java b/services/core/java/com/android/server/wm/WindowManagerService.java index 10f09227a1860..264eedafc56ed 100644 --- a/services/core/java/com/android/server/wm/WindowManagerService.java +++ b/services/core/java/com/android/server/wm/WindowManagerService.java @@ -4556,12 +4556,10 @@ public class WindowManagerService extends IWindowManager.Stub lastFocus = displayContent.mLastFocus; newFocus = displayContent.mCurrentFocus; - } - if (lastFocus == newFocus) { - // Focus is not changing, so nothing to do. - return; - } - synchronized (mGlobalLock) { + if (lastFocus == newFocus) { + // Focus is not changing, so nothing to do. + return; + } displayContent.mLastFocus = newFocus; if (DEBUG_FOCUS_LIGHT) Slog.i(TAG_WM, "Focus moving from " + lastFocus + " to " + newFocus + " displayId=" + displayContent.getDisplayId());