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
diff --git a/packages/SystemUI/aconfig/accessibility.aconfig b/packages/SystemUI/aconfig/accessibility.aconfig
index 8860452..5251246 100644
--- a/packages/SystemUI/aconfig/accessibility.aconfig
+++ b/packages/SystemUI/aconfig/accessibility.aconfig
@@ -4,6 +4,16 @@
# 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 {
name: "create_windowless_window_magnifier"
namespace: "accessibility"
description: "Uses SurfaceControlViewHost to create the magnifier for window magnification."
diff --git a/packages/SystemUI/src/com/android/systemui/accessibility/WindowMagnificationController.java b/packages/SystemUI/src/com/android/systemui/accessibility/WindowMagnificationController.java
index 3828f9f..f0483a5 100644
--- a/packages/SystemUI/src/com/android/systemui/accessibility/WindowMagnificationController.java
+++ b/packages/SystemUI/src/com/android/systemui/accessibility/WindowMagnificationController.java
@@ -112,6 +112,7 @@
MagnificationConstants.SCALE_MAX_VALUE);
private static final float A11Y_CHANGE_SCALE_DIFFERENCE = 1.0f;
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 Context mContext;
@@ -1019,6 +1020,11 @@
if (!mMirrorSurface.isValid()) {
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)
.reparent(mMirrorSurface, mMirrorSurfaceView.getSurfaceControl());
modifyWindowMagnification(false);