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

import java.util.Objects;


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


    private final boolean mHasDirectActivity;
    private final boolean mHasDirectActivity;


    @Nullable private final SurfaceControl mDecorSurface;

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


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


    /** The {@link Configuration} of the parent Task */
    /** The {@link Configuration} of the parent Task */
@@ -92,7 +99,13 @@ public class TaskFragmentParentInfo implements Parcelable {
            return false;
            return false;
        }
        }
        return getWindowingMode() == that.getWindowingMode() && mDisplayId == that.mDisplayId
        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
    @WindowConfiguration.WindowingMode
@@ -107,6 +120,7 @@ public class TaskFragmentParentInfo implements Parcelable {
                + ", displayId=" + mDisplayId
                + ", displayId=" + mDisplayId
                + ", visible=" + mVisible
                + ", visible=" + mVisible
                + ", hasDirectActivity=" + mHasDirectActivity
                + ", hasDirectActivity=" + mHasDirectActivity
                + ", decorSurface=" + mDecorSurface
                + "}";
                + "}";
    }
    }


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


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


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


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


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


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


        mSplitController.updateOverlayContainer(mTransaction, overlayContainer);
        mSplitController.updateOverlayContainer(mTransaction, overlayContainer);


+2 −1
Original line number Original line Diff line number Diff line
@@ -1139,7 +1139,8 @@ public class SplitControllerTest {
    public void testOnTransactionReady_taskFragmentParentInfoChanged() {
    public void testOnTransactionReady_taskFragmentParentInfoChanged() {
        final TaskFragmentTransaction transaction = new TaskFragmentTransaction();
        final TaskFragmentTransaction transaction = new TaskFragmentTransaction();
        final TaskFragmentParentInfo parentInfo = new TaskFragmentParentInfo(Configuration.EMPTY,
        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(
        transaction.addChange(new TaskFragmentTransaction.Change(
                TYPE_TASK_FRAGMENT_PARENT_INFO_CHANGED)
                TYPE_TASK_FRAGMENT_PARENT_INFO_CHANGED)
                .setTaskId(TASK_ID)
                .setTaskId(TASK_ID)
+8 −4
Original line number Original line Diff line number Diff line
@@ -79,14 +79,16 @@ public class TaskContainerTest {


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


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


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


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


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


        assertFalse(taskContainer.isInPictureInPicture());
        assertFalse(taskContainer.isInPictureInPicture());


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


        assertTrue(taskContainer.isInPictureInPicture());
        assertTrue(taskContainer.isInPictureInPicture());
    }
    }
Loading