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

Commit 0de21dad authored by wilsonshih's avatar wilsonshih
Browse files

Support excluding caption bar from task snapshot

This adds the registerExcludeLayersFromTaskSnapshot() method for
TaskOrganizer. It provides a way for clients to register a set of
layers that should be excluded when a task snapshot is taken,
specifically for layers not managed by the Window Manager.
Also extract the bgExecutor to WindowDecoration.

Bug: 399228526
Flag: com.android.window.flags.excluding_layer_from_task_snapshot
Test: enable desktop windowing mode, open app, move the task to back
then enter Overivew, verify the caption bar won't show in the
TaskView

Change-Id: I14f6c72499118e4f7308a1053f152d0a5f334be1
parent c89bedf7
Loading
Loading
Loading
Loading
+20 −0
Original line number Diff line number Diff line
@@ -22,6 +22,7 @@ import android.window.ITaskOrganizer;
import android.window.TaskAppearedInfo;
import android.window.WindowContainerToken;
import android.window.WindowContainerTransaction;
import android.view.SurfaceControl;

/** @hide */
interface ITaskOrganizerController {
@@ -69,4 +70,23 @@ interface ITaskOrganizerController {
     * Restarts the top activity in the given task by killing its process if it is visible.
     */
    void restartTaskTopActivityProcessIfVisible(in WindowContainerToken task);

    /**
     * Set layers to be excluded when taking a task snapshot.
     *
     * Warning: MUST NOT pass layers that are managed by the Window Manager (e.g., from a Task or
     * Activity). Doing so may cause the corresponding layer to be destroyed when
     * clearExcludeLayersFromTaskSnapshot is called.
     */
    @JavaPassthrough(annotation="@android.annotation.RequiresPermission(value = "
            + "android.Manifest.permission.MANAGE_ACTIVITY_TASKS)")
    void setExcludeLayersFromTaskSnapshot(in WindowContainerToken task,
            in SurfaceControl[] layers);

    /**
     * Clears all layers that were registered for exclusion via setExcludeLayersFromTaskSnapshot.
     */
    @JavaPassthrough(annotation="@android.annotation.RequiresPermission(value = "
            + "android.Manifest.permission.MANAGE_ACTIVITY_TASKS)")
    void clearExcludeLayersFromTaskSnapshot(in WindowContainerToken task);
}
+31 −0
Original line number Diff line number Diff line
@@ -320,6 +320,37 @@ public class TaskOrganizer extends WindowOrganizer {
        }
    }

    /**
     * Set layers to be excluded when taking a task snapshot.
     *
     * Warning: MUST NOT pass layers that are managed by the Window Manager (e.g., from a Task or
     * Activity). Doing so may cause the corresponding layer to be destroyed when
     * clearExcludeLayersFromTaskSnapshot is called.
     * @hide
     */
    @RequiresPermission(android.Manifest.permission.MANAGE_ACTIVITY_TASKS)
    public void setExcludeLayersFromTaskSnapshot(@NonNull WindowContainerToken task,
            SurfaceControl[] layers) {
        try {
            mTaskOrganizerController.setExcludeLayersFromTaskSnapshot(task, layers);
        } catch (RemoteException e) {
            throw e.rethrowFromSystemServer();
        }
    }

    /**
     * Clears all layers that were set for exclusion via setExcludeLayersFromTaskSnapshot.
     * @hide
     */
    @RequiresPermission(android.Manifest.permission.MANAGE_ACTIVITY_TASKS)
    public void clearExcludeLayersFromTaskSnapshot(@NonNull WindowContainerToken task) {
        try {
            mTaskOrganizerController.clearExcludeLayersFromTaskSnapshot(task);
        } catch (RemoteException e) {
            throw e.rethrowFromSystemServer();
        }
    }

    /**
     * Gets the executor to run callbacks on.
     * @hide
+1 −3
Original line number Diff line number Diff line
@@ -81,7 +81,6 @@ import java.util.function.BiFunction;
public class CaptionWindowDecoration extends WindowDecoration<WindowDecorLinearLayout> {
    private final Handler mHandler;
    private final @ShellMainThread ShellExecutor mMainExecutor;
    private final @ShellBackgroundThread ShellExecutor mBgExecutor;
    private final Choreographer mChoreographer;
    private final SyncTransactionQueue mSyncQueue;
    private final DesktopConfig mDesktopConfig;
@@ -111,10 +110,9 @@ public class CaptionWindowDecoration extends WindowDecoration<WindowDecorLinearL
            @NonNull WindowDecorViewHostSupplier<WindowDecorViewHost> windowDecorViewHostSupplier,
            DesktopConfig desktopConfig) {
        super(context, handler, transitions, userContext, displayController, taskOrganizer,
                taskInfo, taskSurface, windowDecorViewHostSupplier);
                taskInfo, taskSurface, windowDecorViewHostSupplier, bgExecutor);
        mHandler = handler;
        mMainExecutor = mainExecutor;
        mBgExecutor = bgExecutor;
        mChoreographer = choreographer;
        mSyncQueue = syncQueue;
        mDesktopConfig = desktopConfig;
+1 −3
Original line number Diff line number Diff line
@@ -48,7 +48,6 @@ import com.android.wm.shell.windowdecor.common.viewhost.WindowDecorViewHostSuppl
 */
public class CarWindowDecoration extends WindowDecoration<WindowDecorLinearLayout> {
    private WindowDecorLinearLayout mRootView;
    private @ShellBackgroundThread final ShellExecutor mBgExecutor;
    private final View.OnClickListener mClickListener;
    private final RelayoutParams mRelayoutParams = new RelayoutParams();
    private final RelayoutResult<WindowDecorLinearLayout> mResult = new RelayoutResult<>();
@@ -66,8 +65,7 @@ public class CarWindowDecoration extends WindowDecoration<WindowDecorLinearLayou
            WindowDecorViewHostSupplier<WindowDecorViewHost> windowDecorViewHostSupplier,
            View.OnClickListener clickListener) {
        super(context, handler, transitions, userContext, displayController, taskOrganizer,
                taskInfo, taskSurface, windowDecorViewHostSupplier);
        mBgExecutor = bgExecutor;
                taskInfo, taskSurface, windowDecorViewHostSupplier, bgExecutor);
        mClickListener = clickListener;
    }

+1 −3
Original line number Diff line number Diff line
@@ -156,7 +156,6 @@ public class DesktopModeWindowDecoration extends WindowDecoration<WindowDecorLin
    private final @ShellMainThread MainCoroutineDispatcher mMainDispatcher;
    private final @ShellMainThread CoroutineScope mMainScope;
    private final @ShellBackgroundThread CoroutineScope mBgScope;
    private final @ShellBackgroundThread ShellExecutor mBgExecutor;
    private final Transitions mTransitions;
    private final Choreographer mChoreographer;
    private final SyncTransactionQueue mSyncQueue;
@@ -332,14 +331,13 @@ public class DesktopModeWindowDecoration extends WindowDecoration<WindowDecorLin
                taskInfo, taskSurface, surfaceControlBuilderSupplier,
                surfaceControlTransactionSupplier, windowContainerTransactionSupplier,
                surfaceControlSupplier, surfaceControlViewHostFactory, windowDecorViewHostSupplier,
                desktopModeEventLogger);
                desktopModeEventLogger, bgExecutor);
        mSplitScreenController = splitScreenController;
        mHandler = handler;
        mMainExecutor = mainExecutor;
        mMainDispatcher = mainDispatcher;
        mMainScope = mainScope;
        mBgScope = bgScope;
        mBgExecutor = bgExecutor;
        mTransitions = transitions;
        mChoreographer = choreographer;
        mSyncQueue = syncQueue;
Loading