From 3f38f2630e52f3f40cce36c50d61181764e86dbd Mon Sep 17 00:00:00 2001 From: Tiger Huang Date: Wed, 18 Dec 2019 21:08:40 +0800 Subject: [PATCH] Call layoutAndAssignWindowLayersIfNeeded while holding mGlobalLock This method should be protected by the lock because itself or its downstream methods access fields which need to be protected by mGlobalLock. Bug: 118118435 Test: 1. Replace the pending transaction in WindowContainer with LockDebuggingTransaction in ag/9944628. 2. Switch to the new insets mode. 3. Let an app to control the system bars and see if system crashes. Change-Id: I08b0fb88d6ceb51139d24f161269017312c0cd5f --- .../java/com/android/server/wm/InsetsSourceProvider.java | 7 ++++--- .../java/com/android/server/wm/WindowManagerService.java | 8 ++++++++ 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/services/core/java/com/android/server/wm/InsetsSourceProvider.java b/services/core/java/com/android/server/wm/InsetsSourceProvider.java index 0821873846463..184e7d61c3550 100644 --- a/services/core/java/com/android/server/wm/InsetsSourceProvider.java +++ b/services/core/java/com/android/server/wm/InsetsSourceProvider.java @@ -24,6 +24,8 @@ import static android.view.ViewRootImpl.NEW_INSETS_MODE_IME; import static android.view.ViewRootImpl.NEW_INSETS_MODE_NONE; import static android.view.ViewRootImpl.sNewInsetsMode; +import static com.android.server.wm.WindowManagerService.H.LAYOUT_AND_ASSIGN_WINDOW_LAYERS_IF_NEEDED; + import android.annotation.NonNull; import android.annotation.Nullable; import android.graphics.Point; @@ -36,7 +38,6 @@ import android.view.SurfaceControl; import android.view.SurfaceControl.Transaction; import com.android.internal.util.function.TriConsumer; -import com.android.internal.util.function.pooled.PooledLambda; import com.android.server.wm.SurfaceAnimator.OnAnimationFinishedCallback; import java.io.PrintWriter; @@ -222,8 +223,8 @@ class InsetsSourceProvider { return; } mClientVisible = clientVisible; - mDisplayContent.mWmService.mH.sendMessage(PooledLambda.obtainMessage( - DisplayContent::layoutAndAssignWindowLayersIfNeeded, mDisplayContent)); + mDisplayContent.mWmService.mH.obtainMessage( + LAYOUT_AND_ASSIGN_WINDOW_LAYERS_IF_NEEDED, mDisplayContent).sendToTarget(); updateVisibility(); } diff --git a/services/core/java/com/android/server/wm/WindowManagerService.java b/services/core/java/com/android/server/wm/WindowManagerService.java index acaaed9b615c0..68de4cd84bbfc 100644 --- a/services/core/java/com/android/server/wm/WindowManagerService.java +++ b/services/core/java/com/android/server/wm/WindowManagerService.java @@ -4511,6 +4511,7 @@ public class WindowManagerService extends IWindowManager.Stub public static final int ANIMATION_FAILSAFE = 60; public static final int RECOMPUTE_FOCUS = 61; public static final int ON_POINTER_DOWN_OUTSIDE_FOCUS = 62; + public static final int LAYOUT_AND_ASSIGN_WINDOW_LAYERS_IF_NEEDED = 63; /** * Used to denote that an integer field in a message will not be used. @@ -4885,6 +4886,13 @@ public class WindowManagerService extends IWindowManager.Stub } break; } + case LAYOUT_AND_ASSIGN_WINDOW_LAYERS_IF_NEEDED: { + synchronized (mGlobalLock) { + final DisplayContent displayContent = (DisplayContent) msg.obj; + displayContent.layoutAndAssignWindowLayersIfNeeded(); + } + break; + } } if (DEBUG_WINDOW_TRACE) { Slog.v(TAG_WM, "handleMessage: exit");