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

Commit 942bc585 authored by Doris Liu's avatar Doris Liu
Browse files

Fix calls to Rect.intersect(Rect)

This CL checks for the return value for Rect.intersect(Rect) for whether
there is actually an intersection before taking the calling rect as the
intersection. In the case of no intersection (Rect.intersect(Rect) returns
false), the calling rect would not have been changed, so here in this CL
it will be manually set empty.

Bug: 7368679
Change-Id: I7494c1a1649eca09e34412f0a59b795e8b3a82aa
parent c5ff0020
Loading
Loading
Loading
Loading
+3 −1
Original line number Diff line number Diff line
@@ -228,7 +228,9 @@ public abstract class Image implements AutoCloseable {

        if (cropRect != null) {
            cropRect = new Rect(cropRect);  // make a copy
            cropRect.intersect(0, 0, getWidth(), getHeight());
            if (!cropRect.intersect(0, 0, getWidth(), getHeight())) {
                cropRect.setEmpty();
            }
        }
        mCropRect = cropRect;
    }
+2 −4
Original line number Diff line number Diff line
@@ -3240,8 +3240,7 @@ public class AccessibilityManagerService extends IAccessibilityManager.Stub {
                // Clip to the window bounds.
                Rect windowBounds = mTempRect1;
                getWindowBounds(focus.getWindowId(), windowBounds);
                boundsInScreen.intersect(windowBounds);
                if (boundsInScreen.isEmpty()) {
                if (!boundsInScreen.intersect(windowBounds)) {
                    return false;
                }

@@ -3255,8 +3254,7 @@ public class AccessibilityManagerService extends IAccessibilityManager.Stub {
                // Clip to the screen bounds.
                Point screenSize = mTempPoint;
                mDefaultDisplay.getRealSize(screenSize);
                boundsInScreen.intersect(0, 0, screenSize.x, screenSize.y);
                if (boundsInScreen.isEmpty()) {
                if (!boundsInScreen.intersect(0, 0, screenSize.x, screenSize.y)) {
                    return false;
                }