From a6b481a7d24f83923544eb24d4f68f51b8fa9054 Mon Sep 17 00:00:00 2001 From: Antonio Kantek Date: Wed, 3 May 2023 18:15:06 +0000 Subject: [PATCH] Return the default touch mode for dead displays Certain race conditions may lead to client code trying to manipulate (like adding an window) an already gone virtual display. This CL changes WMS#isInTouchMode to return the default touch mode in case the display passed as argument is already gone. Fix: 280671905 Test: atest FrameworksCoreTests Test: atest WmTests:WindowManagerServiceTests Test: atest CtsInputTestCases:android.input.cts.TouchModeTest Change-Id: Iea61f82ec1945ba0b65ce8af4896b5fb9923af6e --- .../java/com/android/server/wm/WindowManagerService.java | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/services/core/java/com/android/server/wm/WindowManagerService.java b/services/core/java/com/android/server/wm/WindowManagerService.java index 8baf048980edd..f253fb0c72711 100644 --- a/services/core/java/com/android/server/wm/WindowManagerService.java +++ b/services/core/java/com/android/server/wm/WindowManagerService.java @@ -3922,15 +3922,17 @@ public class WindowManagerService extends IWindowManager.Stub /** * Returns the touch mode state for the display id passed as argument. + * + * This method will return the default touch mode state (represented by + * {@code com.android.internal.R.bool.config_defaultInTouchMode}) if the display passed as + * argument is no longer registered in {@RootWindowContainer}). */ @Override // Binder call public boolean isInTouchMode(int displayId) { synchronized (mGlobalLock) { final DisplayContent displayContent = mRoot.getDisplayContent(displayId); if (displayContent == null) { - throw new IllegalStateException("Failed to retrieve the touch mode state for" - + "display {" + displayId + "}: display is not registered in " - + "WindowRootContainer"); + return mContext.getResources().getBoolean(R.bool.config_defaultInTouchMode); } return displayContent.isInTouchMode(); }