Loading core/java/android/view/WindowManager.java +7 −1 Original line number Diff line number Diff line Loading @@ -394,6 +394,11 @@ public interface WindowManager extends ViewManager { * @hide */ int TRANSIT_KEYGUARD_UNOCCLUDE = 9; /** * A window is starting to enter PiP. * @hide */ int TRANSIT_PIP = 10; /** * The first slot for custom transition types. Callers (like Shell) can make use of custom * transition types for dealing with special cases. These types are effectively ignored by Loading @@ -403,7 +408,7 @@ public interface WindowManager extends ViewManager { * implementation. * @hide */ int TRANSIT_FIRST_CUSTOM = 10; int TRANSIT_FIRST_CUSTOM = 11; /** * @hide Loading @@ -419,6 +424,7 @@ public interface WindowManager extends ViewManager { TRANSIT_KEYGUARD_GOING_AWAY, TRANSIT_KEYGUARD_OCCLUDE, TRANSIT_KEYGUARD_UNOCCLUDE, TRANSIT_PIP, TRANSIT_FIRST_CUSTOM }) @Retention(RetentionPolicy.SOURCE) Loading libs/WindowManager/Shell/src/com/android/wm/shell/pip/PipTaskOrganizer.java +11 −0 Original line number Diff line number Diff line Loading @@ -463,6 +463,15 @@ public class PipTaskOrganizer implements ShellTaskOrganizer.TaskListener, } private void removePipImmediately() { if (Transitions.ENABLE_SHELL_TRANSITIONS) { final WindowContainerTransaction wct = new WindowContainerTransaction(); wct.setBounds(mToken, null); wct.setWindowingMode(mToken, WINDOWING_MODE_UNDEFINED); wct.reorder(mToken, false); mPipTransitionController.startTransition(null, wct); return; } try { // Reset the task bounds first to ensure the activity configuration is reset as well final WindowContainerTransaction wct = new WindowContainerTransaction(); Loading Loading @@ -524,6 +533,8 @@ public class PipTaskOrganizer implements ShellTaskOrganizer.TaskListener, if (Transitions.ENABLE_SHELL_TRANSITIONS) { if (mOneShotAnimationType == ANIM_TYPE_BOUNDS) { mPipMenuController.attach(mLeash); } else if (mOneShotAnimationType == ANIM_TYPE_ALPHA) { mOneShotAnimationType = ANIM_TYPE_BOUNDS; } return; } Loading libs/WindowManager/Shell/src/com/android/wm/shell/pip/PipTransition.java +44 −3 Original line number Diff line number Diff line Loading @@ -18,6 +18,7 @@ package com.android.wm.shell.pip; import static android.app.WindowConfiguration.WINDOWING_MODE_PINNED; import static android.app.WindowConfiguration.WINDOWING_MODE_UNDEFINED; import static android.view.WindowManager.TRANSIT_PIP; import static android.window.TransitionInfo.FLAG_IS_WALLPAPER; import static com.android.wm.shell.pip.PipAnimationController.ANIM_TYPE_ALPHA; Loading @@ -27,6 +28,7 @@ import static com.android.wm.shell.pip.PipAnimationController.TRANSITION_DIRECTI import static com.android.wm.shell.pip.PipAnimationController.isInPipDirection; import static com.android.wm.shell.pip.PipAnimationController.isOutPipDirection; import static com.android.wm.shell.transition.Transitions.TRANSIT_EXIT_PIP; import static com.android.wm.shell.transition.Transitions.TRANSIT_REMOVE_PIP; import android.app.TaskInfo; import android.content.Context; Loading Loading @@ -73,10 +75,28 @@ public class PipTransition extends PipTransitionController { .getInteger(R.integer.config_pipResizeAnimationDuration); } @Override public void setIsFullAnimation(boolean isFullAnimation) { setOneShotAnimationType(isFullAnimation ? ANIM_TYPE_BOUNDS : ANIM_TYPE_ALPHA); } /** * Sets the preferred animation type for one time. * This is typically used to set the animation type to * {@link PipAnimationController#ANIM_TYPE_ALPHA}. */ private void setOneShotAnimationType(@PipAnimationController.AnimationType int animationType) { mOneShotAnimationType = animationType; } @Override public void startTransition(Rect destinationBounds, WindowContainerTransaction out) { if (destinationBounds != null) { mExitDestinationBounds.set(destinationBounds); mTransitions.startTransition(TRANSIT_EXIT_PIP, out, this); } else { mTransitions.startTransition(TRANSIT_REMOVE_PIP, out, this); } } @Override Loading @@ -96,6 +116,14 @@ public class PipTransition extends PipTransitionController { return success; } if (info.getType() == TRANSIT_REMOVE_PIP) { startTransaction.apply(); finishTransaction.setWindowCrop(info.getChanges().get(0).getLeash(), mPipBoundsState.getDisplayBounds()); finishCallback.onTransitionFinished(null, null); return true; } // Search for an Enter PiP transition (along with a show wallpaper one) TransitionInfo.Change enterPip = null; TransitionInfo.Change wallpaper = null; Loading Loading @@ -129,13 +157,23 @@ public class PipTransition extends PipTransitionController { @Override public WindowContainerTransaction handleRequest(@NonNull IBinder transition, @NonNull TransitionRequestInfo request) { if (request.getType() == TRANSIT_PIP) { WindowContainerTransaction wct = new WindowContainerTransaction(); mPipTransitionState.setTransitionState(PipTransitionState.ENTRY_SCHEDULED); final Rect destinationBounds = mPipBoundsAlgorithm.getEntryDestinationBounds(); wct.setActivityWindowingMode(request.getTriggerTask().token, WINDOWING_MODE_UNDEFINED); wct.setBounds(request.getTriggerTask().token, destinationBounds); return wct; } else { return null; } } @Override public void onFinishResize(TaskInfo taskInfo, Rect destinationBounds, @PipAnimationController.TransitionDirection int direction, SurfaceControl.Transaction tx) { if (isInPipDirection(direction)) { mPipTransitionState.setTransitionState(PipTransitionState.ENTERED_PIP); } Loading Loading @@ -185,6 +223,9 @@ public class PipTransition extends PipTransitionController { 0 /* startingAngle */, Surface.ROTATION_0); } else if (mOneShotAnimationType == ANIM_TYPE_ALPHA) { startTransaction.setAlpha(leash, 0f); // PiP menu is attached late in the process here to avoid any artifacts on the leash // caused by addShellRoot when in gesture navigation mode. mPipMenuController.attach(leash); animator = mPipAnimationController.getAnimator(taskInfo, leash, destinationBounds, 0f, 1f); mOneShotAnimationType = ANIM_TYPE_BOUNDS; Loading libs/WindowManager/Shell/src/com/android/wm/shell/pip/PipTransitionController.java +9 −0 Original line number Diff line number Diff line Loading @@ -100,6 +100,15 @@ public abstract class PipTransitionController implements Transitions.TransitionH SurfaceControl.Transaction tx) { } /** * Called to inform the transition that the animation should start with the assumption that * PiP is not animating from its original bounds, but rather a continuation of another * animation. For example, gesture navigation would first fade out the PiP activity, and the * transition should be responsible to animate in (such as fade in) the PiP. */ public void setIsFullAnimation(boolean isFullAnimation) { } /** * Called when the Shell wants to starts a transition/animation. */ Loading libs/WindowManager/Shell/src/com/android/wm/shell/pip/phone/PipController.java +3 −0 Original line number Diff line number Diff line Loading @@ -67,6 +67,7 @@ import com.android.wm.shell.pip.IPip; import com.android.wm.shell.pip.IPipAnimationListener; import com.android.wm.shell.pip.PinnedStackListenerForwarder; import com.android.wm.shell.pip.Pip; import com.android.wm.shell.pip.PipAnimationController; import com.android.wm.shell.pip.PipBoundsAlgorithm; import com.android.wm.shell.pip.PipBoundsState; import com.android.wm.shell.pip.PipMediaController; Loading Loading @@ -528,6 +529,8 @@ public class PipController implements PipTransitionController.PipTransitionCallb private void setPinnedStackAnimationType(int animationType) { mPipTaskOrganizer.setOneShotAnimationType(animationType); mPipTransitionController.setIsFullAnimation( animationType == PipAnimationController.ANIM_TYPE_BOUNDS); } private void setPinnedStackAnimationListener(IPipAnimationListener callback) { Loading Loading
core/java/android/view/WindowManager.java +7 −1 Original line number Diff line number Diff line Loading @@ -394,6 +394,11 @@ public interface WindowManager extends ViewManager { * @hide */ int TRANSIT_KEYGUARD_UNOCCLUDE = 9; /** * A window is starting to enter PiP. * @hide */ int TRANSIT_PIP = 10; /** * The first slot for custom transition types. Callers (like Shell) can make use of custom * transition types for dealing with special cases. These types are effectively ignored by Loading @@ -403,7 +408,7 @@ public interface WindowManager extends ViewManager { * implementation. * @hide */ int TRANSIT_FIRST_CUSTOM = 10; int TRANSIT_FIRST_CUSTOM = 11; /** * @hide Loading @@ -419,6 +424,7 @@ public interface WindowManager extends ViewManager { TRANSIT_KEYGUARD_GOING_AWAY, TRANSIT_KEYGUARD_OCCLUDE, TRANSIT_KEYGUARD_UNOCCLUDE, TRANSIT_PIP, TRANSIT_FIRST_CUSTOM }) @Retention(RetentionPolicy.SOURCE) Loading
libs/WindowManager/Shell/src/com/android/wm/shell/pip/PipTaskOrganizer.java +11 −0 Original line number Diff line number Diff line Loading @@ -463,6 +463,15 @@ public class PipTaskOrganizer implements ShellTaskOrganizer.TaskListener, } private void removePipImmediately() { if (Transitions.ENABLE_SHELL_TRANSITIONS) { final WindowContainerTransaction wct = new WindowContainerTransaction(); wct.setBounds(mToken, null); wct.setWindowingMode(mToken, WINDOWING_MODE_UNDEFINED); wct.reorder(mToken, false); mPipTransitionController.startTransition(null, wct); return; } try { // Reset the task bounds first to ensure the activity configuration is reset as well final WindowContainerTransaction wct = new WindowContainerTransaction(); Loading Loading @@ -524,6 +533,8 @@ public class PipTaskOrganizer implements ShellTaskOrganizer.TaskListener, if (Transitions.ENABLE_SHELL_TRANSITIONS) { if (mOneShotAnimationType == ANIM_TYPE_BOUNDS) { mPipMenuController.attach(mLeash); } else if (mOneShotAnimationType == ANIM_TYPE_ALPHA) { mOneShotAnimationType = ANIM_TYPE_BOUNDS; } return; } Loading
libs/WindowManager/Shell/src/com/android/wm/shell/pip/PipTransition.java +44 −3 Original line number Diff line number Diff line Loading @@ -18,6 +18,7 @@ package com.android.wm.shell.pip; import static android.app.WindowConfiguration.WINDOWING_MODE_PINNED; import static android.app.WindowConfiguration.WINDOWING_MODE_UNDEFINED; import static android.view.WindowManager.TRANSIT_PIP; import static android.window.TransitionInfo.FLAG_IS_WALLPAPER; import static com.android.wm.shell.pip.PipAnimationController.ANIM_TYPE_ALPHA; Loading @@ -27,6 +28,7 @@ import static com.android.wm.shell.pip.PipAnimationController.TRANSITION_DIRECTI import static com.android.wm.shell.pip.PipAnimationController.isInPipDirection; import static com.android.wm.shell.pip.PipAnimationController.isOutPipDirection; import static com.android.wm.shell.transition.Transitions.TRANSIT_EXIT_PIP; import static com.android.wm.shell.transition.Transitions.TRANSIT_REMOVE_PIP; import android.app.TaskInfo; import android.content.Context; Loading Loading @@ -73,10 +75,28 @@ public class PipTransition extends PipTransitionController { .getInteger(R.integer.config_pipResizeAnimationDuration); } @Override public void setIsFullAnimation(boolean isFullAnimation) { setOneShotAnimationType(isFullAnimation ? ANIM_TYPE_BOUNDS : ANIM_TYPE_ALPHA); } /** * Sets the preferred animation type for one time. * This is typically used to set the animation type to * {@link PipAnimationController#ANIM_TYPE_ALPHA}. */ private void setOneShotAnimationType(@PipAnimationController.AnimationType int animationType) { mOneShotAnimationType = animationType; } @Override public void startTransition(Rect destinationBounds, WindowContainerTransaction out) { if (destinationBounds != null) { mExitDestinationBounds.set(destinationBounds); mTransitions.startTransition(TRANSIT_EXIT_PIP, out, this); } else { mTransitions.startTransition(TRANSIT_REMOVE_PIP, out, this); } } @Override Loading @@ -96,6 +116,14 @@ public class PipTransition extends PipTransitionController { return success; } if (info.getType() == TRANSIT_REMOVE_PIP) { startTransaction.apply(); finishTransaction.setWindowCrop(info.getChanges().get(0).getLeash(), mPipBoundsState.getDisplayBounds()); finishCallback.onTransitionFinished(null, null); return true; } // Search for an Enter PiP transition (along with a show wallpaper one) TransitionInfo.Change enterPip = null; TransitionInfo.Change wallpaper = null; Loading Loading @@ -129,13 +157,23 @@ public class PipTransition extends PipTransitionController { @Override public WindowContainerTransaction handleRequest(@NonNull IBinder transition, @NonNull TransitionRequestInfo request) { if (request.getType() == TRANSIT_PIP) { WindowContainerTransaction wct = new WindowContainerTransaction(); mPipTransitionState.setTransitionState(PipTransitionState.ENTRY_SCHEDULED); final Rect destinationBounds = mPipBoundsAlgorithm.getEntryDestinationBounds(); wct.setActivityWindowingMode(request.getTriggerTask().token, WINDOWING_MODE_UNDEFINED); wct.setBounds(request.getTriggerTask().token, destinationBounds); return wct; } else { return null; } } @Override public void onFinishResize(TaskInfo taskInfo, Rect destinationBounds, @PipAnimationController.TransitionDirection int direction, SurfaceControl.Transaction tx) { if (isInPipDirection(direction)) { mPipTransitionState.setTransitionState(PipTransitionState.ENTERED_PIP); } Loading Loading @@ -185,6 +223,9 @@ public class PipTransition extends PipTransitionController { 0 /* startingAngle */, Surface.ROTATION_0); } else if (mOneShotAnimationType == ANIM_TYPE_ALPHA) { startTransaction.setAlpha(leash, 0f); // PiP menu is attached late in the process here to avoid any artifacts on the leash // caused by addShellRoot when in gesture navigation mode. mPipMenuController.attach(leash); animator = mPipAnimationController.getAnimator(taskInfo, leash, destinationBounds, 0f, 1f); mOneShotAnimationType = ANIM_TYPE_BOUNDS; Loading
libs/WindowManager/Shell/src/com/android/wm/shell/pip/PipTransitionController.java +9 −0 Original line number Diff line number Diff line Loading @@ -100,6 +100,15 @@ public abstract class PipTransitionController implements Transitions.TransitionH SurfaceControl.Transaction tx) { } /** * Called to inform the transition that the animation should start with the assumption that * PiP is not animating from its original bounds, but rather a continuation of another * animation. For example, gesture navigation would first fade out the PiP activity, and the * transition should be responsible to animate in (such as fade in) the PiP. */ public void setIsFullAnimation(boolean isFullAnimation) { } /** * Called when the Shell wants to starts a transition/animation. */ Loading
libs/WindowManager/Shell/src/com/android/wm/shell/pip/phone/PipController.java +3 −0 Original line number Diff line number Diff line Loading @@ -67,6 +67,7 @@ import com.android.wm.shell.pip.IPip; import com.android.wm.shell.pip.IPipAnimationListener; import com.android.wm.shell.pip.PinnedStackListenerForwarder; import com.android.wm.shell.pip.Pip; import com.android.wm.shell.pip.PipAnimationController; import com.android.wm.shell.pip.PipBoundsAlgorithm; import com.android.wm.shell.pip.PipBoundsState; import com.android.wm.shell.pip.PipMediaController; Loading Loading @@ -528,6 +529,8 @@ public class PipController implements PipTransitionController.PipTransitionCallb private void setPinnedStackAnimationType(int animationType) { mPipTaskOrganizer.setOneShotAnimationType(animationType); mPipTransitionController.setIsFullAnimation( animationType == PipAnimationController.ANIM_TYPE_BOUNDS); } private void setPinnedStackAnimationListener(IPipAnimationListener callback) { Loading