Loading core/java/android/companion/virtual/flags/flags.aconfig +10 −0 Original line number Diff line number Diff line Loading @@ -256,3 +256,13 @@ flag { purpose: PURPOSE_BUGFIX } } flag { name: "enable_animations_per_display" namespace: "virtual_devices" description: "Enable/disable window and transition animations per display" bug: "427437362" metadata { purpose: PURPOSE_BUGFIX } } core/java/android/view/IDisplayWindowListener.aidl +5 −0 Original line number Diff line number Diff line Loading @@ -79,4 +79,9 @@ oneway interface IDisplayWindowListener { * Called when the system decorations should be removed from the display. */ void onDisplayRemoveSystemDecorations(int displayId); /** * Called when animations are disabled or enabled for a display. */ void onDisplayAnimationsDisabledChanged(int displayId, boolean disabled); } libs/WindowManager/Shell/src/com/android/wm/shell/common/DisplayController.java +25 −0 Original line number Diff line number Diff line Loading @@ -172,6 +172,14 @@ public class DisplayController { return r != null ? r.mInsetsState : null; } /** * Returns whether animations are disabled for the given displayId. */ public boolean isAnimationsDisabled(int displayId) { final DisplayRecord r = mDisplays.get(displayId); return r == null || r.mAnimationsDisabled; } /** * Updates the insets for a given display. */ Loading Loading @@ -411,6 +419,15 @@ public class DisplayController { } } private void onAnimationsDisabled(int displayId, boolean disabled) { synchronized (mDisplays) { DisplayRecord r = mDisplays.get(displayId); if (r != null) { r.mAnimationsDisabled = disabled; } } } private class DisplayRecord { private final int mDisplayId; private String mUniqueId; Loading @@ -418,10 +435,12 @@ public class DisplayController { private DisplayLayout mDisplayLayout; private InsetsState mInsetsState = new InsetsState(); private boolean mHasStatusAndNavBars; private boolean mAnimationsDisabled; private DisplayRecord(int displayId, boolean hasStatusAndNavBars) { mDisplayId = displayId; mHasStatusAndNavBars = hasStatusAndNavBars; mAnimationsDisabled = false; } private DisplayLayout createLayout(Context context, Display display) { Loading Loading @@ -527,6 +546,12 @@ public class DisplayController { @Override public void onDisplayRemoveSystemDecorations(int displayId) { } @Override public void onDisplayAnimationsDisabledChanged(int displayId, boolean disabled) { mMainExecutor.execute( () -> DisplayController.this.onAnimationsDisabled(displayId, disabled)); } } /** Loading libs/WindowManager/Shell/src/com/android/wm/shell/transition/DefaultTransitionHandler.java +12 −2 Original line number Diff line number Diff line Loading @@ -347,7 +347,8 @@ public class DefaultTransitionHandler implements Transitions.TransitionHandler { } // Early check if the transition doesn't warrant an animation. if (TransitionUtil.isAllNoAnimation(info) || TransitionUtil.isAllOrderOnly(info) if (isAnimationsDisabledForAnyDisplay(info) || TransitionUtil.isAllNoAnimation(info) || TransitionUtil.isAllOrderOnly(info) || (info.getFlags() & WindowManager.TRANSIT_FLAG_INVISIBLE) != 0) { startTransaction.apply(); // As a contract, finishTransaction should only be applied in Transitions#onFinish Loading Loading @@ -666,6 +667,15 @@ public class DefaultTransitionHandler implements Transitions.TransitionHandler { return true; } private boolean isAnimationsDisabledForAnyDisplay(@NonNull TransitionInfo info) { boolean disabled = false; int rootCount = info.getRootCount(); for (int i = 0; i < rootCount; i++) { disabled |= mDisplayController.isAnimationsDisabled(info.getRoot(i).getDisplayId()); } return disabled; } private void addBackgroundColor(@NonNull TransitionInfo info, @ColorInt int color, @NonNull SurfaceControl.Transaction startTransaction, @NonNull SurfaceControl.Transaction finishTransaction) { Loading Loading @@ -1032,7 +1042,7 @@ public class DefaultTransitionHandler implements Transitions.TransitionHandler { /** * Returns {@code true} if the default transition handler can run the override animation. * @see #loadAnimation(TransitionInfo, TransitionInfo.Change, int, boolean) * @see #loadAnimation(int, TransitionInfo, TransitionInfo.Change, int, boolean) */ public static boolean isSupportedOverrideAnimation( @NonNull TransitionInfo.AnimationOptions options) { Loading libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/transition/DefaultTransitionHandlerTest.java +12 −2 Original line number Diff line number Diff line Loading @@ -274,7 +274,12 @@ public class DefaultTransitionHandlerTest extends ShellTestCase { @Test public void startAnimation_neverFindsErrors_animationMode() { final TransitionInfo info = mock(TransitionInfo.class); final TransitionInfo.Change open = new ChangeBuilder(TRANSIT_OPEN).build(); final TransitionInfo.Change close = new ChangeBuilder(TRANSIT_TO_BACK).build(); final TransitionInfo info = new TransitionInfoBuilder(TRANSIT_OPEN) .addChange(open) .addChange(close) .build(); final IBinder token = mock(Binder.class); TransitionDispatchState dispatchState = new TransitionDispatchState(token, info); Loading @@ -291,7 +296,12 @@ public class DefaultTransitionHandlerTest extends ShellTestCase { @Test public void startAnimation_neverFindsErrors_dataCollectionMode() { final TransitionInfo info = mock(TransitionInfo.class); final TransitionInfo.Change open = new ChangeBuilder(TRANSIT_OPEN).build(); final TransitionInfo.Change close = new ChangeBuilder(TRANSIT_TO_BACK).build(); final TransitionInfo info = new TransitionInfoBuilder(TRANSIT_OPEN) .addChange(open) .addChange(close) .build(); final IBinder token = mock(Binder.class); TransitionDispatchState dispatchState = new TransitionDispatchState(token, info); Loading Loading
core/java/android/companion/virtual/flags/flags.aconfig +10 −0 Original line number Diff line number Diff line Loading @@ -256,3 +256,13 @@ flag { purpose: PURPOSE_BUGFIX } } flag { name: "enable_animations_per_display" namespace: "virtual_devices" description: "Enable/disable window and transition animations per display" bug: "427437362" metadata { purpose: PURPOSE_BUGFIX } }
core/java/android/view/IDisplayWindowListener.aidl +5 −0 Original line number Diff line number Diff line Loading @@ -79,4 +79,9 @@ oneway interface IDisplayWindowListener { * Called when the system decorations should be removed from the display. */ void onDisplayRemoveSystemDecorations(int displayId); /** * Called when animations are disabled or enabled for a display. */ void onDisplayAnimationsDisabledChanged(int displayId, boolean disabled); }
libs/WindowManager/Shell/src/com/android/wm/shell/common/DisplayController.java +25 −0 Original line number Diff line number Diff line Loading @@ -172,6 +172,14 @@ public class DisplayController { return r != null ? r.mInsetsState : null; } /** * Returns whether animations are disabled for the given displayId. */ public boolean isAnimationsDisabled(int displayId) { final DisplayRecord r = mDisplays.get(displayId); return r == null || r.mAnimationsDisabled; } /** * Updates the insets for a given display. */ Loading Loading @@ -411,6 +419,15 @@ public class DisplayController { } } private void onAnimationsDisabled(int displayId, boolean disabled) { synchronized (mDisplays) { DisplayRecord r = mDisplays.get(displayId); if (r != null) { r.mAnimationsDisabled = disabled; } } } private class DisplayRecord { private final int mDisplayId; private String mUniqueId; Loading @@ -418,10 +435,12 @@ public class DisplayController { private DisplayLayout mDisplayLayout; private InsetsState mInsetsState = new InsetsState(); private boolean mHasStatusAndNavBars; private boolean mAnimationsDisabled; private DisplayRecord(int displayId, boolean hasStatusAndNavBars) { mDisplayId = displayId; mHasStatusAndNavBars = hasStatusAndNavBars; mAnimationsDisabled = false; } private DisplayLayout createLayout(Context context, Display display) { Loading Loading @@ -527,6 +546,12 @@ public class DisplayController { @Override public void onDisplayRemoveSystemDecorations(int displayId) { } @Override public void onDisplayAnimationsDisabledChanged(int displayId, boolean disabled) { mMainExecutor.execute( () -> DisplayController.this.onAnimationsDisabled(displayId, disabled)); } } /** Loading
libs/WindowManager/Shell/src/com/android/wm/shell/transition/DefaultTransitionHandler.java +12 −2 Original line number Diff line number Diff line Loading @@ -347,7 +347,8 @@ public class DefaultTransitionHandler implements Transitions.TransitionHandler { } // Early check if the transition doesn't warrant an animation. if (TransitionUtil.isAllNoAnimation(info) || TransitionUtil.isAllOrderOnly(info) if (isAnimationsDisabledForAnyDisplay(info) || TransitionUtil.isAllNoAnimation(info) || TransitionUtil.isAllOrderOnly(info) || (info.getFlags() & WindowManager.TRANSIT_FLAG_INVISIBLE) != 0) { startTransaction.apply(); // As a contract, finishTransaction should only be applied in Transitions#onFinish Loading Loading @@ -666,6 +667,15 @@ public class DefaultTransitionHandler implements Transitions.TransitionHandler { return true; } private boolean isAnimationsDisabledForAnyDisplay(@NonNull TransitionInfo info) { boolean disabled = false; int rootCount = info.getRootCount(); for (int i = 0; i < rootCount; i++) { disabled |= mDisplayController.isAnimationsDisabled(info.getRoot(i).getDisplayId()); } return disabled; } private void addBackgroundColor(@NonNull TransitionInfo info, @ColorInt int color, @NonNull SurfaceControl.Transaction startTransaction, @NonNull SurfaceControl.Transaction finishTransaction) { Loading Loading @@ -1032,7 +1042,7 @@ public class DefaultTransitionHandler implements Transitions.TransitionHandler { /** * Returns {@code true} if the default transition handler can run the override animation. * @see #loadAnimation(TransitionInfo, TransitionInfo.Change, int, boolean) * @see #loadAnimation(int, TransitionInfo, TransitionInfo.Change, int, boolean) */ public static boolean isSupportedOverrideAnimation( @NonNull TransitionInfo.AnimationOptions options) { Loading
libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/transition/DefaultTransitionHandlerTest.java +12 −2 Original line number Diff line number Diff line Loading @@ -274,7 +274,12 @@ public class DefaultTransitionHandlerTest extends ShellTestCase { @Test public void startAnimation_neverFindsErrors_animationMode() { final TransitionInfo info = mock(TransitionInfo.class); final TransitionInfo.Change open = new ChangeBuilder(TRANSIT_OPEN).build(); final TransitionInfo.Change close = new ChangeBuilder(TRANSIT_TO_BACK).build(); final TransitionInfo info = new TransitionInfoBuilder(TRANSIT_OPEN) .addChange(open) .addChange(close) .build(); final IBinder token = mock(Binder.class); TransitionDispatchState dispatchState = new TransitionDispatchState(token, info); Loading @@ -291,7 +296,12 @@ public class DefaultTransitionHandlerTest extends ShellTestCase { @Test public void startAnimation_neverFindsErrors_dataCollectionMode() { final TransitionInfo info = mock(TransitionInfo.class); final TransitionInfo.Change open = new ChangeBuilder(TRANSIT_OPEN).build(); final TransitionInfo.Change close = new ChangeBuilder(TRANSIT_TO_BACK).build(); final TransitionInfo info = new TransitionInfoBuilder(TRANSIT_OPEN) .addChange(open) .addChange(close) .build(); final IBinder token = mock(Binder.class); TransitionDispatchState dispatchState = new TransitionDispatchState(token, info); Loading