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

Commit 770d8485 authored by Johannes Gallmann's avatar Johannes Gallmann Committed by Android (Google) Code Review
Browse files

Merge changes Icef20272,I213c886f into main

* changes:
  [WM] Clean up requestAssistScreenshot function
  [WM][Floaty] Take assistant screenshot at windowing layer
parents 41e374ba 421f5f83
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -466,7 +466,7 @@ interface IWindowManager
    /**
     * Used only for assist -- request a screenshot of the current application.
     */
    boolean requestAssistScreenshot(IAssistDataReceiver receiver);
    void requestAssistScreenshot(IAssistDataReceiver receiver);

    /**
     * Called by System UI to notify Window Manager to hide transient bars.
+18 −5
Original line number Diff line number Diff line
@@ -5206,9 +5206,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.");
@@ -5218,8 +5230,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<>();
+11 −7
Original line number Diff line number Diff line
@@ -152,6 +152,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.enablePresentationForConnectedDisplays;
import static com.android.window.flags.Flags.multiCrop;
@@ -4311,7 +4312,8 @@ public class WindowManagerService extends IWindowManager.Stub
                }
                captureArgs = null;
            } else {
                captureArgs = displayContent.getLayerCaptureArgs(predicate);
                captureArgs = displayContent.getLayerCaptureArgs(predicate,
                        /*useWindowingLayerAsScreenshotRoot*/ enableLppAssistInvocationEffect());
            }
        }

@@ -4335,12 +4337,16 @@ public class WindowManagerService extends IWindowManager.Stub
    }

    /**
     * Takes a snapshot of the screen.  In landscape mode this grabs the whole screen.
     * In portrait mode, it grabs the upper region of the screen based on the vertical dimension
     * of the target image.
     * Requests a screenshot to be taken for Assist purposes.
     *
     * This method initiates the process of capturing the current screen content and delivering it
     * to the provided {@link IAssistDataReceiver}.
     *
     * @param receiver The {@link IAssistDataReceiver} that will receive the screenshot bitmap. Must
     * not be null.
     */
    @Override
    public boolean requestAssistScreenshot(final IAssistDataReceiver receiver) {
    public void requestAssistScreenshot(final IAssistDataReceiver receiver) {
        final ScreenshotHardwareBuffer shb = takeAssistScreenshot(/* predicate= */ null);
        final Bitmap bm = shb != null ? shb.asBitmap() : null;
        FgThread.getHandler().post(() -> {
@@ -4349,8 +4355,6 @@ public class WindowManagerService extends IWindowManager.Stub
            } catch (RemoteException e) {
            }
        });

        return true;
    }

    /**