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

Commit cfb4d8ec authored by Candice's avatar Candice
Browse files

fix(window magnification): Set the surface of SurfaceView black

Since the mirrored surface might has an alpha less than 1, users will see the contents below the magnifier. Therefore, we would like to set the parent surface to black to provide a black background below the mirrored contents.

Test: atest WindowMagnificationControllerWindowlessMagnifierTest
Bug: 299981434
Flag: com.android.systemui.add_black_background_for_window_magnifier
Change-Id: I1fffab82b90ec97ea8d9d3cfb63e44e2a2681648
parent 86122dee
Loading
Loading
Loading
Loading
+10 −0
Original line number Original line Diff line number Diff line
@@ -3,6 +3,16 @@ container: "system"


# NOTE: Keep alphabetized to help limit merge conflicts from multiple simultaneous editors.
# NOTE: Keep alphabetized to help limit merge conflicts from multiple simultaneous editors.


flag {
    name: "add_black_background_for_window_magnifier"
    namespace: "accessibility"
    description: "Set the background for SurfaceView in window magnification black."
    bug: "299981434"
    metadata {
      purpose: PURPOSE_BUGFIX
    }
}

flag {
flag {
    name: "create_windowless_window_magnifier"
    name: "create_windowless_window_magnifier"
    namespace: "accessibility"
    namespace: "accessibility"
+6 −0
Original line number Original line Diff line number Diff line
@@ -112,6 +112,7 @@ class WindowMagnificationController implements View.OnTouchListener, SurfaceHold
            MagnificationConstants.SCALE_MAX_VALUE);
            MagnificationConstants.SCALE_MAX_VALUE);
    private static final float A11Y_CHANGE_SCALE_DIFFERENCE = 1.0f;
    private static final float A11Y_CHANGE_SCALE_DIFFERENCE = 1.0f;
    private static final float ANIMATION_BOUNCE_EFFECT_SCALE = 1.05f;
    private static final float ANIMATION_BOUNCE_EFFECT_SCALE = 1.05f;
    private static final float[] COLOR_BLACK_ARRAY = {0f, 0f, 0f};
    private final SparseArray<Float> mMagnificationSizeScaleOptions = new SparseArray<>();
    private final SparseArray<Float> mMagnificationSizeScaleOptions = new SparseArray<>();


    private final Context mContext;
    private final Context mContext;
@@ -1019,6 +1020,11 @@ class WindowMagnificationController implements View.OnTouchListener, SurfaceHold
        if (!mMirrorSurface.isValid()) {
        if (!mMirrorSurface.isValid()) {
            return;
            return;
        }
        }
        // Set the surface of the SurfaceView to black to avoid users seeing the contents below the
        // magnifier when the mirrored surface has an alpha less than 1.
        if (Flags.addBlackBackgroundForWindowMagnifier()) {
            mTransaction.setColor(mMirrorSurfaceView.getSurfaceControl(), COLOR_BLACK_ARRAY);
        }
        mTransaction.show(mMirrorSurface)
        mTransaction.show(mMirrorSurface)
                .reparent(mMirrorSurface, mMirrorSurfaceView.getSurfaceControl());
                .reparent(mMirrorSurface, mMirrorSurfaceView.getSurfaceControl());
        modifyWindowMagnification(false);
        modifyWindowMagnification(false);