Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit e82b66e2 authored by Lucy Chang's avatar Lucy Chang Committed by Android (Google) Code Review
Browse files

Merge "Account for letterbox space when computing touchable region" into sc-dev

parents 69e34915 f9f2b593
Loading
Loading
Loading
Loading
+21 −20
Original line number Diff line number Diff line
@@ -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);
                }
            }
        }