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

Commit 4c425b2a authored by Jerry Chang's avatar Jerry Chang
Browse files

Adjust split layout with IME animation in split (2/N)

Add surface utils to help establishing dim surface layer for splits.

Bug: 179262787
Test: atest WMShellUnitTests
Change-Id: I0c268e0b1891fddcf717e8e54e0d29acbf8c5f24
parent dda6e07e
Loading
Loading
Loading
Loading
+14 −1
Original line number Diff line number Diff line
@@ -25,6 +25,7 @@ import static com.android.wm.shell.protolog.ShellProtoLogGroup.WM_SHELL_TASK_ORG
import android.app.ActivityManager;
import android.graphics.Rect;
import android.view.SurfaceControl;
import android.view.SurfaceSession;
import android.window.WindowContainerToken;
import android.window.WindowContainerTransaction;

@@ -35,6 +36,7 @@ import com.android.internal.protolog.common.ProtoLog;
import com.android.wm.shell.ShellTaskOrganizer;
import com.android.wm.shell.common.DisplayController;
import com.android.wm.shell.common.DisplayImeController;
import com.android.wm.shell.common.SurfaceUtils;
import com.android.wm.shell.common.SyncTransactionQueue;
import com.android.wm.shell.common.split.SplitLayout;

@@ -54,6 +56,9 @@ class AppPair implements ShellTaskOrganizer.TaskListener, SplitLayout.LayoutChan
    private SurfaceControl mTaskLeash1;
    private ActivityManager.RunningTaskInfo mTaskInfo2;
    private SurfaceControl mTaskLeash2;
    private SurfaceControl mDimLayer1;
    private SurfaceControl mDimLayer2;
    private final SurfaceSession mSurfaceSession = new SurfaceSession();

    private final AppPairsController mController;
    private final SyncTransactionQueue mSyncQueue;
@@ -153,9 +158,13 @@ class AppPair implements ShellTaskOrganizer.TaskListener, SplitLayout.LayoutChan
        } else if (taskInfo.taskId == getTaskId1()) {
            mTaskInfo1 = taskInfo;
            mTaskLeash1 = leash;
            mSyncQueue.runInSync(t -> mDimLayer1 =
                    SurfaceUtils.makeDimLayer(t, mTaskLeash1, "Dim layer", mSurfaceSession));
        } else if (taskInfo.taskId == getTaskId2()) {
            mTaskInfo2 = taskInfo;
            mTaskLeash2 = leash;
            mSyncQueue.runInSync(t -> mDimLayer2 =
                    SurfaceUtils.makeDimLayer(t, mTaskLeash2, "Dim layer", mSurfaceSession));
        } else {
            throw new IllegalStateException("Unknown task=" + taskInfo.taskId);
        }
@@ -212,8 +221,12 @@ class AppPair implements ShellTaskOrganizer.TaskListener, SplitLayout.LayoutChan
        if (taskInfo.taskId == getRootTaskId()) {
            // We don't want to release this object back to the pool since the root task went away.
            mController.unpair(mRootTaskInfo.taskId, false /* releaseToPool */);
        } else if (taskInfo.taskId == getTaskId1() || taskInfo.taskId == getTaskId2()) {
        } else if (taskInfo.taskId == getTaskId1()) {
            mController.unpair(mRootTaskInfo.taskId);
            mSyncQueue.runInSync(t -> t.remove(mDimLayer1));
        } else if (taskInfo.taskId == getTaskId2()) {
            mController.unpair(mRootTaskInfo.taskId);
            mSyncQueue.runInSync(t -> t.remove(mDimLayer2));
        }
    }

+38 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2021 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.android.wm.shell.common;

import android.view.SurfaceControl;
import android.view.SurfaceSession;

/**
 * Helpers for handling surface.
 */
public class SurfaceUtils {
    /** Creates a dim layer above indicated host surface. */
    public static SurfaceControl makeDimLayer(SurfaceControl.Transaction t, SurfaceControl host,
            String name, SurfaceSession surfaceSession) {
        SurfaceControl dimLayer = new SurfaceControl.Builder(surfaceSession)
                .setParent(host)
                .setColorLayer()
                .setName(name)
                .setCallsite("SurfaceUtils.makeDimLayer")
                .build();
        t.setLayer(dimLayer, Integer.MAX_VALUE).setColor(dimLayer, new float[]{0f, 0f, 0f});
        return dimLayer;
    }
}
+8 −17
Original line number Diff line number Diff line
@@ -38,6 +38,7 @@ import androidx.annotation.NonNull;

import com.android.internal.protolog.common.ProtoLog;
import com.android.wm.shell.ShellTaskOrganizer;
import com.android.wm.shell.common.SurfaceUtils;
import com.android.wm.shell.common.SyncTransactionQueue;
import com.android.wm.shell.transition.Transitions;

@@ -146,21 +147,11 @@ class LegacySplitScreenTaskListener implements ShellTaskOrganizer.TaskListener {
                ProtoLog.v(WM_SHELL_TASK_ORG, "%s onTaskAppeared Supported", TAG);

                // Initialize dim surfaces:
                mPrimaryDim = new SurfaceControl.Builder(mSurfaceSession)
                        .setParent(mPrimarySurface).setColorLayer()
                        .setName("Primary Divider Dim")
                        .setCallsite("SplitScreenTaskOrganizer.onTaskAppeared")
                        .build();
                mSecondaryDim = new SurfaceControl.Builder(mSurfaceSession)
                        .setParent(mSecondarySurface).setColorLayer()
                        .setName("Secondary Divider Dim")
                        .setCallsite("SplitScreenTaskOrganizer.onTaskAppeared")
                        .build();
                SurfaceControl.Transaction t = getTransaction();
                t.setLayer(mPrimaryDim, Integer.MAX_VALUE);
                t.setColor(mPrimaryDim, new float[]{0f, 0f, 0f});
                t.setLayer(mSecondaryDim, Integer.MAX_VALUE);
                t.setColor(mSecondaryDim, new float[]{0f, 0f, 0f});
                mPrimaryDim = SurfaceUtils.makeDimLayer(
                        t, mPrimarySurface, "Primary Divider Dim", mSurfaceSession);
                mSecondaryDim = SurfaceUtils.makeDimLayer(
                        t, mSecondarySurface, "Secondary Divider Dim", mSurfaceSession);
                t.apply();
                releaseTransaction(t);
            }
+4 −2
Original line number Diff line number Diff line
@@ -19,6 +19,7 @@ package com.android.wm.shell.splitscreen;
import static android.app.WindowConfiguration.WINDOWING_MODE_MULTI_WINDOW;

import android.graphics.Rect;
import android.view.SurfaceSession;
import android.window.WindowContainerToken;
import android.window.WindowContainerTransaction;

@@ -36,8 +37,9 @@ class MainStage extends StageTaskListener {
    private boolean mIsActive = false;

    MainStage(ShellTaskOrganizer taskOrganizer, int displayId,
            StageListenerCallbacks callbacks, SyncTransactionQueue syncQueue) {
        super(taskOrganizer, displayId, callbacks, syncQueue);
            StageListenerCallbacks callbacks, SyncTransactionQueue syncQueue,
            SurfaceSession surfaceSession) {
        super(taskOrganizer, displayId, callbacks, syncQueue, surfaceSession);
    }

    boolean isActive() {
+4 −2
Original line number Diff line number Diff line
@@ -18,6 +18,7 @@ package com.android.wm.shell.splitscreen;

import android.app.ActivityManager;
import android.graphics.Rect;
import android.view.SurfaceSession;
import android.window.WindowContainerToken;
import android.window.WindowContainerTransaction;

@@ -33,8 +34,9 @@ class SideStage extends StageTaskListener {
    private static final String TAG = SideStage.class.getSimpleName();

    SideStage(ShellTaskOrganizer taskOrganizer, int displayId,
            StageListenerCallbacks callbacks, SyncTransactionQueue syncQueue) {
        super(taskOrganizer, displayId, callbacks, syncQueue);
            StageListenerCallbacks callbacks, SyncTransactionQueue syncQueue,
            SurfaceSession surfaceSession) {
        super(taskOrganizer, displayId, callbacks, syncQueue, surfaceSession);
    }

    void addTask(ActivityManager.RunningTaskInfo task, Rect rootBounds,
Loading