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

Commit 00226f77 authored by Roy Chou's avatar Roy Chou
Browse files

fix(magnification): ensure the old path is cleared when hiding the fullscreen border

In AccessibilityController drawOrRemoveIfNeeded, if new alpha == 0 then the border surface will hide without clearing the current border path. So if next time show the border surface with different bounds, the old border path would also be showing. Therefore, we cache the last usedalpla for drawing, then if new alpha == 0 and cached alpha != 0, which means currently there exists a border path, we would need to clear the path first then hide the surface.

Bug: 325863281
Flag: NA
Test: manually
Change-Id: I81a16edcdd549dd42cf740ccce336b52060c4b5b
parent 05ef6674
Loading
Loading
Loading
Loading
+13 −5
Original line number Diff line number Diff line
@@ -1191,6 +1191,7 @@ final class AccessibilityController {
                private boolean mShown;
                private boolean mLastSurfaceShown;
                private int mAlpha;
                private int mPreviousAlpha;

                private volatile boolean mInvalidated;

@@ -1326,6 +1327,7 @@ final class AccessibilityController {
                    // using WindowManagerGlobalLock. Grab copies of these values before
                    // drawing on the canvas so that drawing can be performed outside of the lock.
                    int alpha;
                    boolean redrawBounds;
                    Rect drawingRect = null;
                    Region drawingBounds = null;
                    synchronized (mService.mGlobalLock) {
@@ -1343,7 +1345,13 @@ final class AccessibilityController {
                        mInvalidated = false;

                        alpha = mAlpha;
                        if (alpha > 0) {
                        // For b/325863281, we should ensure the drawn border path is cleared when
                        // alpha = 0. Therefore, we cache the last used alpha when drawing as
                        // mPreviousAlpha and check it here. If mPreviousAlpha > 0, which means
                        // the border is showing now, then we should still redraw the clear path
                        // on the canvas so the border is cleared.
                        redrawBounds = mAlpha > 0 || mPreviousAlpha > 0;
                        if (redrawBounds) {
                            drawingBounds = new Region(mBounds);
                            // Empty dirty rectangle means unspecified.
                            if (mDirtyRect.isEmpty()) {
@@ -1360,7 +1368,7 @@ final class AccessibilityController {

                    final boolean showSurface;
                    // Draw without holding WindowManagerGlobalLock.
                    if (alpha > 0) {
                    if (redrawBounds) {
                        Canvas canvas = null;
                        try {
                            canvas = mSurface.lockCanvas(drawingRect);
@@ -1374,11 +1382,11 @@ final class AccessibilityController {
                        mPaint.setAlpha(alpha);
                        canvas.drawPath(drawingBounds.getBoundaryPath(), mPaint);
                        mSurface.unlockCanvasAndPost(canvas);
                        showSurface = true;
                    } else {
                        showSurface = false;
                        mPreviousAlpha = alpha;
                    }

                    showSurface = alpha > 0;

                    if (showSurface && !mLastSurfaceShown) {
                        mTransaction.show(mSurfaceControl).apply();
                        mLastSurfaceShown = true;