Loading core/java/android/window/TransitionFilter.java +12 −0 Original line number Diff line number Diff line Loading @@ -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() { } Loading @@ -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 */ Loading Loading @@ -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; Loading Loading @@ -329,6 +339,7 @@ public final class TransitionFilter implements Parcelable { dest.writeInt(customAnimRaw); dest.writeStrongBinder(mTaskFragmentToken); dest.writeInt(mWindowingMode); dest.writeBoolean(mIsCrossDisplayMove); } @NonNull Loading Loading @@ -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(); } Loading libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/transition/ShellTransitionTests.java +28 −0 Original line number Diff line number Diff line Loading @@ -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 Loading libs/WindowManager/Shell/tests/util/src/com/android/wm/shell/transition/TransitionInfoBuilder.kt +9 −4 Original line number Diff line number Diff line Loading @@ -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( Loading Loading @@ -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() Loading @@ -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. Loading Loading
core/java/android/window/TransitionFilter.java +12 −0 Original line number Diff line number Diff line Loading @@ -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() { } Loading @@ -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 */ Loading Loading @@ -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; Loading Loading @@ -329,6 +339,7 @@ public final class TransitionFilter implements Parcelable { dest.writeInt(customAnimRaw); dest.writeStrongBinder(mTaskFragmentToken); dest.writeInt(mWindowingMode); dest.writeBoolean(mIsCrossDisplayMove); } @NonNull Loading Loading @@ -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(); } Loading
libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/transition/ShellTransitionTests.java +28 −0 Original line number Diff line number Diff line Loading @@ -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 Loading
libs/WindowManager/Shell/tests/util/src/com/android/wm/shell/transition/TransitionInfoBuilder.kt +9 −4 Original line number Diff line number Diff line Loading @@ -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( Loading Loading @@ -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() Loading @@ -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. Loading