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

Commit 7fd1bda9 authored by Jiaming Liu's avatar Jiaming Liu Committed by Android (Google) Code Review
Browse files

Merge "Add decor surface API for TaskFragmentOrganizer" into main

parents ec820a85 2b2b5b70
Loading
Loading
Loading
Loading
+14 −0
Original line number Diff line number Diff line
@@ -108,6 +108,18 @@ public final class TaskFragmentOperation implements Parcelable {
     */
    public static final int OP_TYPE_REORDER_TO_TOP_OF_TASK = 13;

    /**
     * Creates a decor surface in the parent Task of the TaskFragment. The created decor surface
     * will be provided in {@link TaskFragmentTransaction#TYPE_TASK_FRAGMENT_PARENT_INFO_CHANGED}
     * event callback.
     */
    public static final int OP_TYPE_CREATE_TASK_FRAGMENT_DECOR_SURFACE = 14;

    /**
     * Removes the decor surface in the parent Task of the TaskFragment.
     */
    public static final int OP_TYPE_REMOVE_TASK_FRAGMENT_DECOR_SURFACE = 15;

    @IntDef(prefix = { "OP_TYPE_" }, value = {
            OP_TYPE_UNKNOWN,
            OP_TYPE_CREATE_TASK_FRAGMENT,
@@ -124,6 +136,8 @@ public final class TaskFragmentOperation implements Parcelable {
            OP_TYPE_SET_ISOLATED_NAVIGATION,
            OP_TYPE_REORDER_TO_BOTTOM_OF_TASK,
            OP_TYPE_REORDER_TO_TOP_OF_TASK,
            OP_TYPE_CREATE_TASK_FRAGMENT_DECOR_SURFACE,
            OP_TYPE_REMOVE_TASK_FRAGMENT_DECOR_SURFACE,
    })
    @Retention(RetentionPolicy.SOURCE)
    public @interface OperationType {}
+21 −3
Original line number Diff line number Diff line
@@ -22,6 +22,9 @@ import android.app.WindowConfiguration;
import android.content.res.Configuration;
import android.os.Parcel;
import android.os.Parcelable;
import android.view.SurfaceControl;

import java.util.Objects;

/**
 * The information about the parent Task of a particular TaskFragment
@@ -37,12 +40,15 @@ public class TaskFragmentParentInfo implements Parcelable {

    private final boolean mHasDirectActivity;

    @Nullable private final SurfaceControl mDecorSurface;

    public TaskFragmentParentInfo(@NonNull Configuration configuration, int displayId,
            boolean visible, boolean hasDirectActivity) {
            boolean visible, boolean hasDirectActivity, @Nullable SurfaceControl decorSurface) {
        mConfiguration.setTo(configuration);
        mDisplayId = displayId;
        mVisible = visible;
        mHasDirectActivity = hasDirectActivity;
        mDecorSurface = decorSurface;
    }

    public TaskFragmentParentInfo(@NonNull TaskFragmentParentInfo info) {
@@ -50,6 +56,7 @@ public class TaskFragmentParentInfo implements Parcelable {
        mDisplayId = info.mDisplayId;
        mVisible = info.mVisible;
        mHasDirectActivity = info.mHasDirectActivity;
        mDecorSurface = info.mDecorSurface;
    }

    /** The {@link Configuration} of the parent Task */
@@ -92,7 +99,13 @@ public class TaskFragmentParentInfo implements Parcelable {
            return false;
        }
        return getWindowingMode() == that.getWindowingMode() && mDisplayId == that.mDisplayId
                && mVisible == that.mVisible && mHasDirectActivity == that.mHasDirectActivity;
                && mVisible == that.mVisible && mHasDirectActivity == that.mHasDirectActivity
                && mDecorSurface == that.mDecorSurface;
    }

    @Nullable
    public SurfaceControl getDecorSurface() {
        return mDecorSurface;
    }

    @WindowConfiguration.WindowingMode
@@ -107,6 +120,7 @@ public class TaskFragmentParentInfo implements Parcelable {
                + ", displayId=" + mDisplayId
                + ", visible=" + mVisible
                + ", hasDirectActivity=" + mHasDirectActivity
                + ", decorSurface=" + mDecorSurface
                + "}";
    }

@@ -128,7 +142,8 @@ public class TaskFragmentParentInfo implements Parcelable {
        return mConfiguration.equals(that.mConfiguration)
                && mDisplayId == that.mDisplayId
                && mVisible == that.mVisible
                && mHasDirectActivity == that.mHasDirectActivity;
                && mHasDirectActivity == that.mHasDirectActivity
                && mDecorSurface == that.mDecorSurface;
    }

    @Override
@@ -137,6 +152,7 @@ public class TaskFragmentParentInfo implements Parcelable {
        result = 31 * result + mDisplayId;
        result = 31 * result + (mVisible ? 1 : 0);
        result = 31 * result + (mHasDirectActivity ? 1 : 0);
        result = 31 * result + Objects.hashCode(mDecorSurface);
        return result;
    }

@@ -146,6 +162,7 @@ public class TaskFragmentParentInfo implements Parcelable {
        dest.writeInt(mDisplayId);
        dest.writeBoolean(mVisible);
        dest.writeBoolean(mHasDirectActivity);
        dest.writeTypedObject(mDecorSurface, flags);
    }

    private TaskFragmentParentInfo(Parcel in) {
@@ -153,6 +170,7 @@ public class TaskFragmentParentInfo implements Parcelable {
        mDisplayId = in.readInt();
        mVisible = in.readBoolean();
        mHasDirectActivity = in.readBoolean();
        mDecorSurface = in.readTypedObject(SurfaceControl.CREATOR);
    }

    public static final Creator<TaskFragmentParentInfo> CREATOR =
+2 −1
Original line number Diff line number Diff line
@@ -443,7 +443,8 @@ public class OverlayPresentationTest {
        assertThat(taskContainer.getTaskFragmentContainers()).containsExactly(overlayContainer);

        taskContainer.updateTaskFragmentParentInfo(new TaskFragmentParentInfo(Configuration.EMPTY,
                DEFAULT_DISPLAY, true /* visible */, false /* hasDirectActivity */));
                DEFAULT_DISPLAY, true /* visible */, false /* hasDirectActivity */,
                null /* decorSurface */));

        mSplitController.updateOverlayContainer(mTransaction, overlayContainer);

+2 −1
Original line number Diff line number Diff line
@@ -1139,7 +1139,8 @@ public class SplitControllerTest {
    public void testOnTransactionReady_taskFragmentParentInfoChanged() {
        final TaskFragmentTransaction transaction = new TaskFragmentTransaction();
        final TaskFragmentParentInfo parentInfo = new TaskFragmentParentInfo(Configuration.EMPTY,
                DEFAULT_DISPLAY, true /* visible */, false /* hasDirectActivity */);
                DEFAULT_DISPLAY, true /* visible */, false /* hasDirectActivity */,
                null /* decorSurface */);
        transaction.addChange(new TaskFragmentTransaction.Change(
                TYPE_TASK_FRAGMENT_PARENT_INFO_CHANGED)
                .setTaskId(TASK_ID)
+8 −4
Original line number Diff line number Diff line
@@ -79,14 +79,16 @@ public class TaskContainerTest {

        configuration.windowConfiguration.setWindowingMode(WINDOWING_MODE_FULLSCREEN);
        taskContainer.updateTaskFragmentParentInfo(new TaskFragmentParentInfo(configuration,
                DEFAULT_DISPLAY, true /* visible */, false /* hasDirectActivity */));
                DEFAULT_DISPLAY, true /* visible */, false /* hasDirectActivity */,
                null /* decorSurface */));

        assertEquals(WINDOWING_MODE_MULTI_WINDOW,
                taskContainer.getWindowingModeForSplitTaskFragment(splitBounds));

        configuration.windowConfiguration.setWindowingMode(WINDOWING_MODE_FREEFORM);
        taskContainer.updateTaskFragmentParentInfo(new TaskFragmentParentInfo(configuration,
                DEFAULT_DISPLAY, true /* visible */, false /* hasDirectActivity */));
                DEFAULT_DISPLAY, true /* visible */, false /* hasDirectActivity */,
                null /* decorSurface */));

        assertEquals(WINDOWING_MODE_FREEFORM,
                taskContainer.getWindowingModeForSplitTaskFragment(splitBounds));
@@ -106,13 +108,15 @@ public class TaskContainerTest {

        configuration.windowConfiguration.setWindowingMode(WINDOWING_MODE_FULLSCREEN);
        taskContainer.updateTaskFragmentParentInfo(new TaskFragmentParentInfo(configuration,
                DEFAULT_DISPLAY, true /* visible */, false /* hasDirectActivity */));
                DEFAULT_DISPLAY, true /* visible */, false /* hasDirectActivity */,
                null /* decorSurface */));

        assertFalse(taskContainer.isInPictureInPicture());

        configuration.windowConfiguration.setWindowingMode(WINDOWING_MODE_PINNED);
        taskContainer.updateTaskFragmentParentInfo(new TaskFragmentParentInfo(configuration,
                DEFAULT_DISPLAY, true /* visible */, false /* hasDirectActivity */));
                DEFAULT_DISPLAY, true /* visible */, false /* hasDirectActivity */,
                null /* decorSurface */));

        assertTrue(taskContainer.isInPictureInPicture());
    }
Loading