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

Commit 42191190 authored by Johannes Gallmann's avatar Johannes Gallmann
Browse files

[WM][Floaty] Take assistant screenshot at windowing layer

This CL prevents the floaty squeeze lpp effect from showing up in the
screenshot that's sent to Assistant.

It uses the windowing layer (DisplayContent#getWindowingLayer) as the
root surface for taking the screenshot. Windowing layer is equal to the
root surface of the FEATURE_WINDOWED_MAGNIFICATION display area (if
it exists). That's the same surface the zoom scale effect is applied to.
Taking the screenshot at the same level will exclude the scale effect
from the screenshot.

Additionally, all surfaces that are placed at a higher level than
TYPE_ACCESSIBILITY_MAGNIFICATION_OVERLAY will be excluded from the
screenshot. This includes the TopLevelWindowEffects window containing
the black border effect which is of TYPE_SECURE_SYSTEM_OVERLAY. But it
also includes other windows of TYPE_POINTER, TYPE_BOOT_PROGRESS,
TYPE_SECURE_SYSTEM_OVERLAY and TYPE_ACCESSIBILITY_MAGNIFICATION_OVERLAY.

Bug: 409979948
Flag: com.android.systemui.shared.enable_lpp_assist_invocation_effect
Test: Manual, i.e. verified that squeeze effect and zoom effect do not
      show up in the screenshot that's sent to assistant, by saving
      the bitmap to a file and visual verification.
Test: DisplayContentTest#testValidWindowingLayer
Change-Id: I213c886f669d4a258fcc9ae6882e0dccfe8db8d1
parent df9f3750
Loading
Loading
Loading
Loading
+18 −5
Original line number Diff line number Diff line
@@ -5196,9 +5196,21 @@ class DisplayContent extends RootDisplayArea implements WindowManagerPolicy.Disp
    }

    /**
     * Creates a LayerCaptureArgs object to represent the entire DisplayContent
     */
    LayerCaptureArgs getLayerCaptureArgs(@Nullable ToBooleanFunction<WindowState> predicate) {
     * Creates a {@link LayerCaptureArgs} object.
     *
     * If {@code useWindowingLayerAsScreenshotRoot} is false, the returned
     * {@code LayerCaptureArgs} will represent the entire DisplayContent.
     *
     * If {@code useWindowingLayerAsScreenshotRoot} is true, the
     * {@code LayerCaptureArgs} will represent the surface area of the windowing layer.
     * @param predicate An optional filter function to determine which windows are captured. If
     *                  null, all windows are included.
     * @param useWindowingLayerAsScreenshotRoot Whether to use the windowing layer's
     * surface area as the screenshot root.
     * @return A {@code LayerCaptureArgs} object configured according to the parameters.
     */
    LayerCaptureArgs getLayerCaptureArgs(@Nullable ToBooleanFunction<WindowState> predicate,
            boolean useWindowingLayerAsScreenshotRoot) {
        if (!mWmService.mPolicy.isScreenOn()) {
            if (DEBUG_SCREENSHOT) {
                Slog.i(TAG_WM, "Attempted to take screenshot while display was off.");
@@ -5208,8 +5220,9 @@ class DisplayContent extends RootDisplayArea implements WindowManagerPolicy.Disp

        getBounds(mTmpRect);
        mTmpRect.offsetTo(0, 0);
        LayerCaptureArgs.Builder builder = new LayerCaptureArgs.Builder(getSurfaceControl())
                .setSourceCrop(mTmpRect);
        SurfaceControl sc =
                useWindowingLayerAsScreenshotRoot ? getWindowingLayer() : getSurfaceControl();
        LayerCaptureArgs.Builder builder = new LayerCaptureArgs.Builder(sc).setSourceCrop(mTmpRect);

        if (predicate != null) {
            ArrayList<SurfaceControl> excludeLayers = new ArrayList<>();
+3 −1
Original line number Diff line number Diff line
@@ -151,6 +151,7 @@ import static com.android.server.wm.WindowManagerServiceDumpProto.INPUT_METHOD_W
import static com.android.server.wm.WindowManagerServiceDumpProto.POLICY;
import static com.android.server.wm.WindowManagerServiceDumpProto.ROOT_WINDOW_CONTAINER;
import static com.android.server.wm.WindowManagerServiceDumpProto.WINDOW_FRAMES_VALID;
import static com.android.systemui.shared.Flags.enableLppAssistInvocationEffect;
import static com.android.window.flags.Flags.enableDeviceStateAutoRotateSettingRefactor;
import static com.android.window.flags.Flags.enableDisplayFocusInShellTransitions;
import static com.android.window.flags.Flags.enablePresentationForConnectedDisplays;
@@ -4266,7 +4267,8 @@ public class WindowManagerService extends IWindowManager.Stub
                }
                captureArgs = null;
            } else {
                captureArgs = displayContent.getLayerCaptureArgs(predicate);
                captureArgs = displayContent.getLayerCaptureArgs(predicate,
                        /*useWindowingLayerAsScreenshotRoot*/ enableLppAssistInvocationEffect());
            }
        }