diff --git a/services/core/java/com/android/server/wm/AccessibilityController.java b/services/core/java/com/android/server/wm/AccessibilityController.java index d23579a1da89f..eb79518da9624 100644 --- a/services/core/java/com/android/server/wm/AccessibilityController.java +++ b/services/core/java/com/android/server/wm/AccessibilityController.java @@ -974,7 +974,7 @@ final class AccessibilityController { } // Count letterbox into nonMagnifiedBounds - if (windowState.isLetterboxedForDisplayCutout()) { + if (windowState.isLetterboxedAppWindow()) { Region letterboxBounds = getLetterboxBounds(windowState); nonMagnifiedBounds.op(letterboxBounds, Region.Op.UNION); availableBounds.op(letterboxBounds, Region.Op.DIFFERENCE); @@ -1030,25 +1030,6 @@ final class AccessibilityController { } } - private Region getLetterboxBounds(WindowState windowState) { - final ActivityRecord appToken = windowState.mActivityRecord; - if (appToken == null) { - return new Region(); - } - - mDisplay.getRealSize(mTempPoint); - final Rect letterboxInsets = appToken.getLetterboxInsets(); - final int screenWidth = mTempPoint.x; - final int screenHeight = mTempPoint.y; - final Rect nonLetterboxRect = mTempRect1; - final Region letterboxBounds = mTempRegion3; - nonLetterboxRect.set(0, 0, screenWidth, screenHeight); - nonLetterboxRect.inset(letterboxInsets); - letterboxBounds.set(0, 0, screenWidth, screenHeight); - letterboxBounds.op(nonLetterboxRect, Region.Op.DIFFERENCE); - return letterboxBounds; - } - void onRotationChanged(SurfaceControl.Transaction t) { // If we are showing the magnification border, hide it immediately so // the user does not see strange artifacts during rotation. The screenshot @@ -1430,6 +1411,20 @@ final class AccessibilityController { return source != null ? source.getFrame() : EMPTY_RECT; } + static Region getLetterboxBounds(WindowState windowState) { + final ActivityRecord appToken = windowState.mActivityRecord; + if (appToken == null) { + return new Region(); + } + final Rect letterboxInsets = appToken.getLetterboxInsets(); + final Rect nonLetterboxRect = windowState.getBounds(); + nonLetterboxRect.inset(letterboxInsets); + final Region letterboxBounds = new Region(); + letterboxBounds.set(windowState.getBounds()); + letterboxBounds.op(nonLetterboxRect, Region.Op.DIFFERENCE); + return letterboxBounds; + } + /** * This class encapsulates the functionality related to computing the windows * reported for accessibility purposes. These windows are all windows a sighted @@ -1734,6 +1729,12 @@ final class AccessibilityController { unaccountedSpace.setEmpty(); } } + + // Account for the space of letterbox. + if (windowState.isLetterboxedAppWindow()) { + unaccountedSpace.op(getLetterboxBounds(windowState), unaccountedSpace, + Region.Op.REVERSE_DIFFERENCE); + } } }