From 7c227ebd91b20073b2bafab93863b5b3b264d2c0 Mon Sep 17 00:00:00 2001 From: Prabir Pradhan Date: Wed, 2 Mar 2022 07:37:24 -0800 Subject: [PATCH] AcessibilityController: Use InputConfig to determine window behavior The behavior of an input window is controlled by InputConfig flags in InputWindowHandle. Use these flags to determine the behavior of input windows when we get window information from a SurfaceFlinger callback. Bug: 216806304 Test: presubmit Change-Id: Ifbd47da7470eb6b8fbc257ecb4938712e46740ba --- .../server/wm/AccessibilityController.java | 5 ++- .../wm/AccessibilityWindowsPopulator.java | 33 +++++++++---------- 2 files changed, 18 insertions(+), 20 deletions(-) diff --git a/services/core/java/com/android/server/wm/AccessibilityController.java b/services/core/java/com/android/server/wm/AccessibilityController.java index e37b08f417f20..c52a4e499f1f5 100644 --- a/services/core/java/com/android/server/wm/AccessibilityController.java +++ b/services/core/java/com/android/server/wm/AccessibilityController.java @@ -1598,7 +1598,7 @@ final class AccessibilityController { // Do not account space of trusted non-touchable windows, except the split-screen // divider. // If it's not trusted, touch events are not sent to the windows behind it. - if (((a11yWindow.getFlags() & WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE) != 0) + if (!a11yWindow.isTouchable() && (a11yWindow.getType() != TYPE_DOCK_DIVIDER) && a11yWindow.isTrustedOverlay()) { return false; @@ -1623,8 +1623,7 @@ final class AccessibilityController { // Ignore non-touchable windows, except the split-screen divider, which is // occasionally non-touchable but still useful for identifying split-screen // mode and the PIP menu. - if (((a11yWindow.getFlags() - & WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE) != 0) + if (!a11yWindow.isTouchable() && (a11yWindow.getType() != TYPE_DOCK_DIVIDER && !a11yWindow.isPIPMenu())) { return false; diff --git a/services/core/java/com/android/server/wm/AccessibilityWindowsPopulator.java b/services/core/java/com/android/server/wm/AccessibilityWindowsPopulator.java index d4648a4f313c9..ca98a8c03f31d 100644 --- a/services/core/java/com/android/server/wm/AccessibilityWindowsPopulator.java +++ b/services/core/java/com/android/server/wm/AccessibilityWindowsPopulator.java @@ -600,14 +600,15 @@ public final class AccessibilityWindowsPopulator extends WindowInfosListener { // Data private IWindow mWindow; private int mDisplayId; - private int mFlags; + @WindowManager.LayoutParams.WindowType private int mType; + @InputWindowHandle.InputConfigFlags + private int mInputConfig; private int mPrivateFlags; private boolean mIsPIPMenu; private boolean mIsFocused; private boolean mShouldMagnify; private boolean mIgnoreDuetoRecentsAnimation; - private boolean mIsTrustedOverlay; private final Region mTouchableRegionInScreen = new Region(); private final Region mTouchableRegionInWindow = new Region(); private final Region mLetterBoxBounds = new Region(); @@ -630,7 +631,7 @@ public final class AccessibilityWindowsPopulator extends WindowInfosListener { instance.mWindow = inputWindowHandle.getWindow(); instance.mDisplayId = inputWindowHandle.displayId; - instance.mFlags = inputWindowHandle.layoutParamsFlags; + instance.mInputConfig = inputWindowHandle.inputConfig; instance.mType = inputWindowHandle.layoutParamsType; instance.mIsPIPMenu = inputWindowHandle.getWindow().asBinder().equals(pipIBinder); @@ -643,8 +644,6 @@ public final class AccessibilityWindowsPopulator extends WindowInfosListener { final RecentsAnimationController controller = service.getRecentsAnimationController(); instance.mIgnoreDuetoRecentsAnimation = windowState != null && controller != null && controller.shouldIgnoreForAccessibility(windowState); - instance.mIsTrustedOverlay = - (inputWindowHandle.inputConfig & InputConfig.TRUSTED_OVERLAY) != 0; // TODO (b/199358388) : gets the letterbox bounds of the window from other way. if (windowState != null && windowState.areAppWindowBoundsLetterboxed()) { @@ -681,13 +680,6 @@ public final class AccessibilityWindowsPopulator extends WindowInfosListener { outRegion.set(mTouchableRegionInWindow); } - /** - * @return the layout parameter flag {@link android.view.WindowManager.LayoutParams#flags}. - */ - public int getFlags() { - return mFlags; - } - /** * @return the layout parameter type {@link android.view.WindowManager.LayoutParams#type}. */ @@ -750,7 +742,14 @@ public final class AccessibilityWindowsPopulator extends WindowInfosListener { * @return true if this window is the trusted overlay. */ public boolean isTrustedOverlay() { - return mIsTrustedOverlay; + return (mInputConfig & InputConfig.TRUSTED_OVERLAY) != 0; + } + + /** + * @return true if this window is touchable. + */ + public boolean isTouchable() { + return (mInputConfig & InputConfig.NOT_TOUCHABLE) == 0; } /** @@ -823,8 +822,8 @@ public final class AccessibilityWindowsPopulator extends WindowInfosListener { windowInfo.displayId = window.mDisplayId; windowInfo.type = window.mType; windowInfo.token = window.mWindow.asBinder(); - windowInfo.hasFlagWatchOutsideTouch = (window.mFlags - & WindowManager.LayoutParams.FLAG_WATCH_OUTSIDE_TOUCH) != 0; + windowInfo.hasFlagWatchOutsideTouch = (window.mInputConfig + & InputConfig.WATCH_OUTSIDE_TOUCH) != 0; windowInfo.inPictureInPicture = false; // There only are two windowless windows now, one is split window, and the other @@ -850,13 +849,13 @@ public final class AccessibilityWindowsPopulator extends WindowInfosListener { public String toString() { String builder = "A11yWindow=[" + mWindow.asBinder() + ", displayId=" + mDisplayId - + ", flag=0x" + Integer.toHexString(mFlags) + + ", inputConfig=0x" + Integer.toHexString(mInputConfig) + ", type=" + mType + ", privateFlag=0x" + Integer.toHexString(mPrivateFlags) + ", focused=" + mIsFocused + ", shouldMagnify=" + mShouldMagnify + ", ignoreDuetoRecentsAnimation=" + mIgnoreDuetoRecentsAnimation - + ", isTrustedOverlay=" + mIsTrustedOverlay + + ", isTrustedOverlay=" + isTrustedOverlay() + ", regionInScreen=" + mTouchableRegionInScreen + ", touchableRegion=" + mTouchableRegionInWindow + ", letterBoxBounds=" + mLetterBoxBounds