Loading core/java/android/window/TransitionFilter.java +30 −0 Original line number Diff line number Diff line Loading @@ -30,6 +30,8 @@ import android.os.Parcel; import android.os.Parcelable; import android.view.WindowManager; import com.android.window.flags.Flags; /** * A parcelable filter that can be used for rerouting transitions to a remote. This is a local * representation so that the transition system doesn't need to make blocking queries over Loading Loading @@ -183,6 +185,9 @@ public final class TransitionFilter implements Parcelable { public ComponentName mTopActivity; public IBinder mLaunchCookie; /** If non-null, requires the change to specifically have or not-have a custom animation. */ public Boolean mCustomAnimation = null; public Requirement() { } Loading @@ -196,6 +201,9 @@ public final class TransitionFilter implements Parcelable { mOrder = in.readInt(); mTopActivity = in.readTypedObject(ComponentName.CREATOR); mLaunchCookie = in.readStrongBinder(); // 0: null, 1: false, 2: true final int customAnimRaw = in.readInt(); mCustomAnimation = customAnimRaw == 0 ? null : Boolean.valueOf(customAnimRaw == 2); } /** Go through changes and find if at-least one change matches this filter */ Loading Loading @@ -237,6 +245,23 @@ public final class TransitionFilter implements Parcelable { if (!matchesCookie(change.getTaskInfo())) { continue; } if (mCustomAnimation != null // only applies to activity/task && (change.getTaskInfo() != null || change.getActivityComponent() != null)) { final TransitionInfo.AnimationOptions opts = Flags.moveAnimationOptionsToChange() ? change.getAnimationOptions() : info.getAnimationOptions(); if (opts != null) { boolean canActuallyOverride = change.getTaskInfo() == null || opts.getOverrideTaskTransition(); if (mCustomAnimation != canActuallyOverride) { continue; } } else if (mCustomAnimation) { continue; } } return true; } return false; Loading Loading @@ -286,6 +311,8 @@ public final class TransitionFilter implements Parcelable { dest.writeInt(mOrder); dest.writeTypedObject(mTopActivity, flags); dest.writeStrongBinder(mLaunchCookie); int customAnimRaw = mCustomAnimation == null ? 0 : (mCustomAnimation ? 2 : 1); dest.writeInt(customAnimRaw); } @NonNull Loading Loading @@ -327,6 +354,9 @@ public final class TransitionFilter implements Parcelable { out.append(" order=" + containerOrderToString(mOrder)); out.append(" topActivity=").append(mTopActivity); out.append(" launchCookie=").append(mLaunchCookie); if (mCustomAnimation != null) { out.append(" customAnim=").append(mCustomAnimation.booleanValue()); } out.append("}"); return out.toString(); } Loading libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/transition/ShellTransitionTests.java +21 −0 Original line number Diff line number Diff line Loading @@ -441,6 +441,27 @@ public class ShellTransitionTests extends ShellTestCase { assertTrue(filter.matches(openAct)); } @Test public void testTransitionFilterAnimOverride() { TransitionFilter filter = new TransitionFilter(); filter.mRequirements = new TransitionFilter.Requirement[]{new TransitionFilter.Requirement()}; filter.mRequirements[0].mCustomAnimation = true; filter.mRequirements[0].mModes = new int[]{TRANSIT_OPEN, TRANSIT_TO_FRONT}; final RunningTaskInfo taskInf = createTaskInfo(1); final TransitionInfo openTask = new TransitionInfoBuilder(TRANSIT_OPEN) .addChange(TRANSIT_OPEN, taskInf).build(); assertFalse(filter.matches(openTask)); final TransitionInfo.AnimationOptions overOpts = TransitionInfo.AnimationOptions.makeCustomAnimOptions("pakname", 0, 0, 0, true); final TransitionInfo openTaskOpts = new TransitionInfoBuilder(TRANSIT_OPEN) .addChange(TRANSIT_OPEN, taskInf).build(); openTaskOpts.getChanges().get(0).setAnimationOptions(overOpts); assertTrue(filter.matches(openTaskOpts)); } @Test public void testRegisteredRemoteTransition() { Transitions transitions = createTestTransitions(); Loading Loading
core/java/android/window/TransitionFilter.java +30 −0 Original line number Diff line number Diff line Loading @@ -30,6 +30,8 @@ import android.os.Parcel; import android.os.Parcelable; import android.view.WindowManager; import com.android.window.flags.Flags; /** * A parcelable filter that can be used for rerouting transitions to a remote. This is a local * representation so that the transition system doesn't need to make blocking queries over Loading Loading @@ -183,6 +185,9 @@ public final class TransitionFilter implements Parcelable { public ComponentName mTopActivity; public IBinder mLaunchCookie; /** If non-null, requires the change to specifically have or not-have a custom animation. */ public Boolean mCustomAnimation = null; public Requirement() { } Loading @@ -196,6 +201,9 @@ public final class TransitionFilter implements Parcelable { mOrder = in.readInt(); mTopActivity = in.readTypedObject(ComponentName.CREATOR); mLaunchCookie = in.readStrongBinder(); // 0: null, 1: false, 2: true final int customAnimRaw = in.readInt(); mCustomAnimation = customAnimRaw == 0 ? null : Boolean.valueOf(customAnimRaw == 2); } /** Go through changes and find if at-least one change matches this filter */ Loading Loading @@ -237,6 +245,23 @@ public final class TransitionFilter implements Parcelable { if (!matchesCookie(change.getTaskInfo())) { continue; } if (mCustomAnimation != null // only applies to activity/task && (change.getTaskInfo() != null || change.getActivityComponent() != null)) { final TransitionInfo.AnimationOptions opts = Flags.moveAnimationOptionsToChange() ? change.getAnimationOptions() : info.getAnimationOptions(); if (opts != null) { boolean canActuallyOverride = change.getTaskInfo() == null || opts.getOverrideTaskTransition(); if (mCustomAnimation != canActuallyOverride) { continue; } } else if (mCustomAnimation) { continue; } } return true; } return false; Loading Loading @@ -286,6 +311,8 @@ public final class TransitionFilter implements Parcelable { dest.writeInt(mOrder); dest.writeTypedObject(mTopActivity, flags); dest.writeStrongBinder(mLaunchCookie); int customAnimRaw = mCustomAnimation == null ? 0 : (mCustomAnimation ? 2 : 1); dest.writeInt(customAnimRaw); } @NonNull Loading Loading @@ -327,6 +354,9 @@ public final class TransitionFilter implements Parcelable { out.append(" order=" + containerOrderToString(mOrder)); out.append(" topActivity=").append(mTopActivity); out.append(" launchCookie=").append(mLaunchCookie); if (mCustomAnimation != null) { out.append(" customAnim=").append(mCustomAnimation.booleanValue()); } out.append("}"); return out.toString(); } Loading
libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/transition/ShellTransitionTests.java +21 −0 Original line number Diff line number Diff line Loading @@ -441,6 +441,27 @@ public class ShellTransitionTests extends ShellTestCase { assertTrue(filter.matches(openAct)); } @Test public void testTransitionFilterAnimOverride() { TransitionFilter filter = new TransitionFilter(); filter.mRequirements = new TransitionFilter.Requirement[]{new TransitionFilter.Requirement()}; filter.mRequirements[0].mCustomAnimation = true; filter.mRequirements[0].mModes = new int[]{TRANSIT_OPEN, TRANSIT_TO_FRONT}; final RunningTaskInfo taskInf = createTaskInfo(1); final TransitionInfo openTask = new TransitionInfoBuilder(TRANSIT_OPEN) .addChange(TRANSIT_OPEN, taskInf).build(); assertFalse(filter.matches(openTask)); final TransitionInfo.AnimationOptions overOpts = TransitionInfo.AnimationOptions.makeCustomAnimOptions("pakname", 0, 0, 0, true); final TransitionInfo openTaskOpts = new TransitionInfoBuilder(TRANSIT_OPEN) .addChange(TRANSIT_OPEN, taskInf).build(); openTaskOpts.getChanges().get(0).setAnimationOptions(overOpts); assertTrue(filter.matches(openTaskOpts)); } @Test public void testRegisteredRemoteTransition() { Transitions transitions = createTestTransitions(); Loading