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

Commit a409f98e authored by Treehugger Robot's avatar Treehugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Add display-changes to TransitionFilter" into main

parents 06f4233e 7d5c8b2f
Loading
Loading
Loading
Loading
+12 −0
Original line number Diff line number Diff line
@@ -190,6 +190,9 @@ public final class TransitionFilter implements Parcelable {

        public int mWindowingMode = WINDOWING_MODE_UNDEFINED;

        /** If true, this requirement only matches tasks moving between displays. */
        public boolean mIsCrossDisplayMove = false;

        public Requirement() {
        }

@@ -208,6 +211,7 @@ public final class TransitionFilter implements Parcelable {
            mCustomAnimation = customAnimRaw == 0 ? null : Boolean.valueOf(customAnimRaw == 2);
            mTaskFragmentToken = in.readStrongBinder();
            mWindowingMode = in.readInt();
            mIsCrossDisplayMove = in.readBoolean();
        }

        /** Go through changes and find if at-least one change matches this filter */
@@ -276,6 +280,12 @@ public final class TransitionFilter implements Parcelable {
                        continue;
                    }
                }
                if (mIsCrossDisplayMove) {
                    if (change.getTaskInfo() == null
                            || change.getStartDisplayId() == change.getEndDisplayId()) {
                        continue;
                    }
                }
                return true;
            }
            return false;
@@ -329,6 +339,7 @@ public final class TransitionFilter implements Parcelable {
            dest.writeInt(customAnimRaw);
            dest.writeStrongBinder(mTaskFragmentToken);
            dest.writeInt(mWindowingMode);
            dest.writeBoolean(mIsCrossDisplayMove);
        }

        @NonNull
@@ -378,6 +389,7 @@ public final class TransitionFilter implements Parcelable {
            }
            out.append(" windowingMode="
                    + WindowConfiguration.windowingModeToString(mWindowingMode));
            out.append(" isCrossDisplayMove=" + mIsCrossDisplayMove);
            out.append("}");
            return out.toString();
        }
+28 −0
Original line number Diff line number Diff line
@@ -382,6 +382,34 @@ public class ShellTransitionTests extends ShellTestCase {
        assertTrue(filter.matches(freeformStd));
    }

    @Test
    public void testTransitionFilterCrossDisplayMove() {
        TransitionFilter filter = new TransitionFilter();
        filter.mRequirements =
                new TransitionFilter.Requirement[]{new TransitionFilter.Requirement()};
        filter.mRequirements[0].mIsCrossDisplayMove = true;
        filter.mRequirements[0].mModes = new int[]{ TRANSIT_CHANGE };

        final RunningTaskInfo taskInfo = createTaskInfo(1);
        final TransitionInfo sameDisplay = new TransitionInfoBuilder(
                        TRANSIT_CHANGE, /* flags= */ 0, /* asNoOp= */ false, /* displayId= */ 0)
                .addChange(
                        TRANSIT_CHANGE,
                        taskInfo,
                        /* endDisplayId= */ 0)
                .build();
        assertFalse(filter.matches(sameDisplay));

        final TransitionInfo differentDisplays = new TransitionInfoBuilder(
                        TRANSIT_CHANGE, /* flags= */ 0, /* asNoOp= */ false, /* displayId= */ 0)
                .addChange(
                        TRANSIT_CHANGE,
                        taskInfo,
                        /* endDisplayId= */ 1)
                .build();
        assertTrue(filter.matches(differentDisplays));
    }

    @Test
    public void testTransitionFilterMultiRequirement() {
        // filter that requires at-least one opening and one closing app
+9 −4
Original line number Diff line number Diff line
@@ -70,10 +70,12 @@ class TransitionInfoBuilder @JvmOverloads constructor(
    ) = addChange(mode, flags, activityTransitionInfo = null, taskInfo = taskInfo)

    /** Adds a change to the [TransitionInfo] for task transition. */
    @JvmOverloads
    fun addChange(
        @WindowManager.TransitionType mode: Int,
        taskInfo: ActivityManager.RunningTaskInfo?,
    ) = addChange(mode, activityTransitionInfo = null, taskInfo = taskInfo)
        endDisplayId: Int? = null,
    ) = addChange(mode, activityTransitionInfo = null, taskInfo = taskInfo, endDisplayId = endDisplayId)

    /** Adds a change to the [TransitionInfo] for activity transition. */
    fun addChange(
@@ -113,6 +115,7 @@ class TransitionInfoBuilder @JvmOverloads constructor(
        activityTransitionInfo: ActivityTransitionInfo? = null,
        taskInfo: ActivityManager.RunningTaskInfo? = null,
        taskFragmentToken: IBinder? = null,
        endDisplayId: Int? = null,
    ): TransitionInfoBuilder {
        val container = taskInfo?.token
        val leash = createMockSurface()
@@ -123,18 +126,20 @@ class TransitionInfoBuilder @JvmOverloads constructor(
            setTaskInfo(taskInfo)
            setTaskFragmentToken(taskFragmentToken)
        }
        return addChange(change)
        return addChange(change, endDisplayId)
    }

    /**
     * Adds a pre-configured change to the [TransitionInfo].
     *
     * @param change the TransitionInfo.Change object to add.
     * @param endDisplayId the end display to override the change with
     * @return this TransitionInfoBuilder instance for chaining.
     */
    fun addChange(change: TransitionInfo.Change): TransitionInfoBuilder {
    @JvmOverloads
    fun addChange(change: TransitionInfo.Change, endDisplayId: Int? = null): TransitionInfoBuilder {
        // Set the display ID for the change.
        change.setDisplayId(displayId /* start */, displayId /* end */)
        change.setDisplayId(displayId /* start */, endDisplayId ?: displayId /* end */)
        // Add the change to the internal TransitionInfo object.
        info.addChange(change)
        return this // Return this for fluent builder pattern.