From 6164e01ee4419cd2d6321e8d658be6517d1b784c Mon Sep 17 00:00:00 2001 From: wilsonshih Date: Mon, 6 May 2019 09:31:02 +0800 Subject: [PATCH] Write top focused display ID in WindowManagerServiceDumpProto. Sometimes the focus display is not updated during test because the inject event between two displays may be too fast, the input window info may not been applied to InputFlinger yet before second inject event. Add top focused display ID in proto so test cases can monitor this. Bug: 127741025 Bug: 135104079 Test: stress test on ActivityLifecycleTopResumedStateTests#testTopPositionSwitchAcrossDisplaysOnTap Also enable DEBUG_FOCUS in InputFlinger and check log to make sure the input window is updated during tapOnDisplayCenter. Test: atest WindowInsetsBehaviorTests MultiDisplayPolicyTests MultiDisplaySystemDecorationTests ActivityLifecycleTopResumedStateTests Test: atest MultiDisplayKeyguardTests MultiDisplayLockedKeyguardTests Change-Id: Ie7ca9645553aaa48077a8ccae9a4376cc7d2e0f6 --- core/proto/android/server/windowmanagerservice.proto | 1 + .../core/java/com/android/server/wm/InputMonitor.java | 9 ++++----- .../java/com/android/server/wm/WindowManagerService.java | 2 ++ 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/core/proto/android/server/windowmanagerservice.proto b/core/proto/android/server/windowmanagerservice.proto index e6ae22658f31d..777902578e1b5 100644 --- a/core/proto/android/server/windowmanagerservice.proto +++ b/core/proto/android/server/windowmanagerservice.proto @@ -45,6 +45,7 @@ message WindowManagerServiceDumpProto { optional bool display_frozen = 6; optional int32 rotation = 7; optional int32 last_orientation = 8; + optional int32 focused_display_id = 9; } /* represents RootWindowContainer object */ diff --git a/services/core/java/com/android/server/wm/InputMonitor.java b/services/core/java/com/android/server/wm/InputMonitor.java index d3dba90fe4e67..2eec92680ffc6 100644 --- a/services/core/java/com/android/server/wm/InputMonitor.java +++ b/services/core/java/com/android/server/wm/InputMonitor.java @@ -321,11 +321,10 @@ final class InputMonitor { } void updateInputWindowsImmediately() { - if (mUpdateInputWindowsPending) { - mApplyImmediately = true; - mUpdateInputWindows.run(); - mApplyImmediately = false; - } + mHandler.removeCallbacks(mUpdateInputWindows); + mApplyImmediately = true; + mUpdateInputWindows.run(); + mApplyImmediately = false; } /* Called when the current input focus changes. diff --git a/services/core/java/com/android/server/wm/WindowManagerService.java b/services/core/java/com/android/server/wm/WindowManagerService.java index 9d8b04ec80aca..f765b5604b881 100644 --- a/services/core/java/com/android/server/wm/WindowManagerService.java +++ b/services/core/java/com/android/server/wm/WindowManagerService.java @@ -100,6 +100,7 @@ import static com.android.server.wm.WindowManagerDebugConfig.TAG_WITH_CLASS_NAME import static com.android.server.wm.WindowManagerDebugConfig.TAG_WM; import static com.android.server.wm.WindowManagerServiceDumpProto.DISPLAY_FROZEN; import static com.android.server.wm.WindowManagerServiceDumpProto.FOCUSED_APP; +import static com.android.server.wm.WindowManagerServiceDumpProto.FOCUSED_DISPLAY_ID; import static com.android.server.wm.WindowManagerServiceDumpProto.FOCUSED_WINDOW; import static com.android.server.wm.WindowManagerServiceDumpProto.INPUT_METHOD_WINDOW; import static com.android.server.wm.WindowManagerServiceDumpProto.LAST_ORIENTATION; @@ -5929,6 +5930,7 @@ public class WindowManagerService extends IWindowManager.Stub final DisplayContent defaultDisplayContent = getDefaultDisplayContentLocked(); proto.write(ROTATION, defaultDisplayContent.getRotation()); proto.write(LAST_ORIENTATION, defaultDisplayContent.getLastOrientation()); + proto.write(FOCUSED_DISPLAY_ID, topFocusedDisplayContent.getDisplayId()); } private void dumpWindowsLocked(PrintWriter pw, boolean dumpAll,