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

Commit b04ee60f authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Automerger Merge Worker
Browse files

Merge "Synchronize WCT for TaskView with SurfaceControl.Transaction." into...

Merge "Synchronize WCT for TaskView with SurfaceControl.Transaction." into sc-v2-dev am: 16eeb2c5 am: fc2de1ae

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/14690649

Change-Id: I632de9b8b029c9d7a332df48ee6d20f51d6db065
parents 746e5cb8 fc2de1ae
Loading
Loading
Loading
Loading
+11 −2
Original line number Diff line number Diff line
@@ -1554,12 +1554,21 @@ public class SurfaceView extends View implements ViewRootImpl.SurfaceChangedCall
     * @hide
     */
    public void setResizeBackgroundColor(int bgColor) {
        setResizeBackgroundColor(mTmpTransaction, bgColor);
        mTmpTransaction.apply();
    }

    /**
     * Version of {@link #setResizeBackgroundColor(int)} that allows you to provide
     * {@link SurfaceControl.Transaction}.
     * @hide
     */
    public void setResizeBackgroundColor(@NonNull SurfaceControl.Transaction t, int bgColor) {
        if (mBackgroundControl == null) {
            return;
        }

        mBackgroundColor = bgColor;
        updateBackgroundColor(mTmpTransaction).apply();
        updateBackgroundColor(t);
    }

    @UnsupportedAppUsage
+17 −10
Original line number Diff line number Diff line
@@ -40,6 +40,8 @@ import android.view.ViewTreeObserver;
import android.window.WindowContainerToken;
import android.window.WindowContainerTransaction;

import com.android.wm.shell.common.SyncTransactionQueue;

import java.io.PrintWriter;
import java.util.concurrent.Executor;

@@ -74,6 +76,7 @@ public class TaskView extends SurfaceView implements SurfaceHolder.Callback,

    private final ShellTaskOrganizer mTaskOrganizer;
    private final Executor mShellExecutor;
    private final SyncTransactionQueue mSyncQueue;

    private ActivityManager.RunningTaskInfo mTaskInfo;
    private WindowContainerToken mTaskToken;
@@ -89,11 +92,12 @@ public class TaskView extends SurfaceView implements SurfaceHolder.Callback,
    private final Rect mTmpRootRect = new Rect();
    private final int[] mTmpLocation = new int[2];

    public TaskView(Context context, ShellTaskOrganizer organizer) {
    public TaskView(Context context, ShellTaskOrganizer organizer, SyncTransactionQueue syncQueue) {
        super(context, null, 0, 0, true /* disableBackgroundLayer */);

        mTaskOrganizer = organizer;
        mShellExecutor = organizer.getExecutor();
        mSyncQueue = syncQueue;
        setUseAlpha();
        getHolder().addCallback(this);
        mGuard.open("release");
@@ -189,8 +193,7 @@ public class TaskView extends SurfaceView implements SurfaceHolder.Callback,

        WindowContainerTransaction wct = new WindowContainerTransaction();
        wct.setBounds(mTaskToken, mTmpRect);
        // TODO(b/151449487): Enable synchronization
        mTaskOrganizer.applyTransaction(wct);
        mSyncQueue.queue(wct);
    }

    /**
@@ -236,14 +239,16 @@ public class TaskView extends SurfaceView implements SurfaceHolder.Callback,
    private void updateTaskVisibility() {
        WindowContainerTransaction wct = new WindowContainerTransaction();
        wct.setHidden(mTaskToken, !mSurfaceCreated /* hidden */);
        mTaskOrganizer.applyTransaction(wct);
        // TODO(b/151449487): Only call callback once we enable synchronization
        if (mListener != null) {
            final int taskId = mTaskInfo.taskId;
        mSyncQueue.queue(wct);
        if (mListener == null) {
            return;
        }
        int taskId = mTaskInfo.taskId;
        mSyncQueue.runInSync((t) -> {
            mListenerExecutor.execute(() -> {
                mListener.onTaskVisibilityChanged(taskId, mSurfaceCreated);
            });
        }
        });
    }

    @Override
@@ -264,10 +269,12 @@ public class TaskView extends SurfaceView implements SurfaceHolder.Callback,
            updateTaskVisibility();
        }
        mTaskOrganizer.setInterceptBackPressedOnTaskRoot(mTaskToken, true);
        // TODO: Synchronize show with the resize
        onLocationChanged();
        if (taskInfo.taskDescription != null) {
            setResizeBackgroundColor(taskInfo.taskDescription.getBackgroundColor());
            int backgroundColor = taskInfo.taskDescription.getBackgroundColor();
            mSyncQueue.runInSync((t) -> {
                setResizeBackgroundColor(t, backgroundColor);
            });
        }

        if (mListener != null) {
+5 −3
Original line number Diff line number Diff line
@@ -20,8 +20,8 @@ import android.annotation.UiContext;
import android.content.Context;

import com.android.wm.shell.common.ShellExecutor;
import com.android.wm.shell.common.SyncTransactionQueue;
import com.android.wm.shell.common.annotations.ExternalThread;
import com.android.wm.shell.common.annotations.ShellMainThread;

import java.util.concurrent.Executor;
import java.util.function.Consumer;
@@ -30,12 +30,14 @@ import java.util.function.Consumer;
public class TaskViewFactoryController {
    private final ShellTaskOrganizer mTaskOrganizer;
    private final ShellExecutor mShellExecutor;
    private final SyncTransactionQueue mSyncQueue;
    private final TaskViewFactory mImpl = new TaskViewFactoryImpl();

    public TaskViewFactoryController(ShellTaskOrganizer taskOrganizer,
            ShellExecutor shellExecutor) {
            ShellExecutor shellExecutor, SyncTransactionQueue syncQueue) {
        mTaskOrganizer = taskOrganizer;
        mShellExecutor = shellExecutor;
        mSyncQueue = syncQueue;
    }

    public TaskViewFactory asTaskViewFactory() {
@@ -44,7 +46,7 @@ public class TaskViewFactoryController {

    /** Creates an {@link TaskView} */
    public void create(@UiContext Context context, Executor executor, Consumer<TaskView> onCreate) {
        TaskView taskView = new TaskView(context, mTaskOrganizer);
        TaskView taskView = new TaskView(context, mTaskOrganizer, mSyncQueue);
        executor.execute(() -> {
            onCreate.accept(taskView);
        });
+12 −3
Original line number Diff line number Diff line
@@ -85,6 +85,7 @@ import com.android.wm.shell.common.DisplayChangeController;
import com.android.wm.shell.common.DisplayController;
import com.android.wm.shell.common.FloatingContentCoordinator;
import com.android.wm.shell.common.ShellExecutor;
import com.android.wm.shell.common.SyncTransactionQueue;
import com.android.wm.shell.common.TaskStackListenerCallback;
import com.android.wm.shell.common.TaskStackListenerImpl;
import com.android.wm.shell.pip.PinnedStackListenerForwarder;
@@ -136,6 +137,7 @@ public class BubbleController {
    private final TaskStackListenerImpl mTaskStackListener;
    private final ShellTaskOrganizer mTaskOrganizer;
    private final DisplayController mDisplayController;
    private final SyncTransactionQueue mSyncQueue;

    // Used to post to main UI thread
    private final ShellExecutor mMainExecutor;
@@ -208,7 +210,8 @@ public class BubbleController {
            ShellTaskOrganizer organizer,
            DisplayController displayController,
            ShellExecutor mainExecutor,
            Handler mainHandler) {
            Handler mainHandler,
            SyncTransactionQueue syncQueue) {
        BubbleLogger logger = new BubbleLogger(uiEventLogger);
        BubblePositioner positioner = new BubblePositioner(context, windowManager);
        BubbleData data = new BubbleData(context, logger, positioner, mainExecutor);
@@ -216,7 +219,7 @@ public class BubbleController {
                new BubbleDataRepository(context, launcherApps, mainExecutor),
                statusBarService, windowManager, windowManagerShellWrapper, launcherApps,
                logger, taskStackListener, organizer, positioner, displayController, mainExecutor,
                mainHandler);
                mainHandler, syncQueue);
    }

    /**
@@ -238,7 +241,8 @@ public class BubbleController {
            BubblePositioner positioner,
            DisplayController displayController,
            ShellExecutor mainExecutor,
            Handler mainHandler) {
            Handler mainHandler,
            SyncTransactionQueue syncQueue) {
        mContext = context;
        mLauncherApps = launcherApps;
        mBarService = statusBarService == null
@@ -261,6 +265,7 @@ public class BubbleController {
        mSavedBubbleKeysPerUser = new SparseSetArray<>();
        mBubbleIconFactory = new BubbleIconFactory(context);
        mDisplayController = displayController;
        mSyncQueue = syncQueue;
    }

    public void initialize() {
@@ -544,6 +549,10 @@ public class BubbleController {
        return mTaskOrganizer;
    }

    SyncTransactionQueue getSyncTransactionQueue() {
        return mSyncQueue;
    }

    /** Contains information to help position things on the screen.  */
    BubblePositioner getPositioner() {
        return mBubblePositioner;
+2 −1
Original line number Diff line number Diff line
@@ -338,7 +338,8 @@ public class BubbleExpandedView extends LinearLayout {
            bringChildToFront(mOverflowView);
            mManageButton.setVisibility(GONE);
        } else {
            mTaskView = new TaskView(mContext, mController.getTaskOrganizer());
            mTaskView = new TaskView(mContext, mController.getTaskOrganizer(),
                    mController.getSyncTransactionQueue());
            mTaskView.setListener(mController.getMainExecutor(), mTaskViewListener);
            mExpandedViewContainer.addView(mTaskView);
            bringChildToFront(mTaskView);
Loading