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
This commit is contained in:
Prabir Pradhan
2022-03-02 07:37:24 -08:00
parent f997596611
commit 7c227ebd91
2 changed files with 18 additions and 20 deletions

View File

@@ -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;

View File

@@ -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