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

Commit 05562ecd authored by Daniel Norman's avatar Daniel Norman Committed by Android (Google) Code Review
Browse files

Merge "Adds back using WindowState for magnification letterbox bounds."

parents bfc18c1c 3c44c692
Loading
Loading
Loading
Loading
+29 −0
Original line number Original line Diff line number Diff line
@@ -58,6 +58,7 @@ import android.content.pm.PackageManagerInternal;
import android.graphics.BLASTBufferQueue;
import android.graphics.BLASTBufferQueue;
import android.graphics.Canvas;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Color;
import android.graphics.Insets;
import android.graphics.Matrix;
import android.graphics.Matrix;
import android.graphics.Paint;
import android.graphics.Paint;
import android.graphics.Path;
import android.graphics.Path;
@@ -965,6 +966,13 @@ final class AccessibilityController {
                        availableBounds.op(navBarInsets, Region.Op.DIFFERENCE);
                        availableBounds.op(navBarInsets, Region.Op.DIFFERENCE);
                    }
                    }


                    // Count letterbox into nonMagnifiedBounds
                    if (windowState.areAppWindowBoundsLetterboxed()) {
                        Region letterboxBounds = getLetterboxBounds(windowState);
                        nonMagnifiedBounds.op(letterboxBounds, Region.Op.UNION);
                        availableBounds.op(letterboxBounds, Region.Op.DIFFERENCE);
                    }

                    // Update accounted bounds
                    // Update accounted bounds
                    Region accountedBounds = mTempRegion2;
                    Region accountedBounds = mTempRegion2;
                    accountedBounds.set(mMagnificationRegion);
                    accountedBounds.set(mMagnificationRegion);
@@ -1014,6 +1022,27 @@ final class AccessibilityController {
                }
                }
            }
            }


            private Region getLetterboxBounds(WindowState windowState) {
                final ActivityRecord appToken = windowState.mActivityRecord;
                if (appToken == null) {
                    return new Region();
                }

                final Rect boundsWithoutLetterbox = windowState.getBounds();
                final Rect letterboxInsets = appToken.getLetterboxInsets();

                final Rect boundsIncludingLetterbox = Rect.copyOrNull(boundsWithoutLetterbox);
                // Letterbox insets from mActivityRecord are positive, so we negate them to grow the
                // bounds to include the letterbox.
                boundsIncludingLetterbox.inset(
                        Insets.subtract(Insets.NONE, Insets.of(letterboxInsets)));

                final Region letterboxBounds = new Region();
                letterboxBounds.set(boundsIncludingLetterbox);
                letterboxBounds.op(boundsWithoutLetterbox, Region.Op.DIFFERENCE);
                return letterboxBounds;
            }

            private boolean isExcludedWindowType(int windowType) {
            private boolean isExcludedWindowType(int windowType) {
                return windowType == TYPE_MAGNIFICATION_OVERLAY
                return windowType == TYPE_MAGNIFICATION_OVERLAY
                        // Omit the touch region of window magnification to avoid the cut out of the
                        // Omit the touch region of window magnification to avoid the cut out of the