Loading libs/WindowManager/Shell/src/com/android/wm/shell/pip/IPip.aidl +5 −0 Original line number Diff line number Diff line Loading @@ -70,4 +70,9 @@ interface IPip { * Sets the next pip animation type to be the alpha animation. */ oneway void setPipAnimationTypeToAlpha() = 5; /** * Sets the height and visibility of the Launcher keep clear area. */ oneway void setLauncherKeepClearAreaHeight(boolean visible, int height) = 6; } libs/WindowManager/Shell/src/com/android/wm/shell/pip/PipTaskOrganizer.java +14 −0 Original line number Diff line number Diff line Loading @@ -1178,6 +1178,20 @@ public class PipTaskOrganizer implements ShellTaskOrganizer.TaskListener, destinationBoundsOut.set(newDestinationBounds); } /** * Directly update the animator bounds. */ public void updateAnimatorBounds(Rect bounds) { final PipAnimationController.PipTransitionAnimator animator = mPipAnimationController.getCurrentAnimator(); if (animator != null && animator.isRunning()) { if (animator.getAnimationType() == ANIM_TYPE_BOUNDS) { animator.updateEndValue(bounds); } animator.setDestinationBounds(bounds); } } /** * Handles all changes to the PictureInPictureParams. */ Loading libs/WindowManager/Shell/src/com/android/wm/shell/pip/PipTransitionState.java +10 −0 Original line number Diff line number Diff line Loading @@ -93,6 +93,11 @@ public class PipTransitionState { return hasEnteredPip(mState); } /** Returns true if activity is currently entering PiP mode. */ public boolean isEnteringPip() { return isEnteringPip(mState); } public void setInSwipePipToHomeTransition(boolean inSwipePipToHomeTransition) { mInSwipePipToHomeTransition = inSwipePipToHomeTransition; } Loading Loading @@ -130,6 +135,11 @@ public class PipTransitionState { return state == ENTERED_PIP; } /** Returns true if activity is currently entering PiP mode. */ public static boolean isEnteringPip(@TransitionState int state) { return state == ENTERING_PIP; } public interface OnPipTransitionStateChangedListener { void onPipTransitionStateChanged(@TransitionState int oldState, @TransitionState int newState); Loading libs/WindowManager/Shell/src/com/android/wm/shell/pip/phone/PipController.java +34 −4 Original line number Diff line number Diff line Loading @@ -101,6 +101,7 @@ import com.android.wm.shell.sysui.UserChangeListener; import com.android.wm.shell.transition.Transitions; import java.io.PrintWriter; import java.util.HashSet; import java.util.List; import java.util.Objects; import java.util.Optional; Loading Loading @@ -181,14 +182,20 @@ public class PipController implements PipTransitionController.PipTransitionCallb // early bail out if the keep clear areas feature is disabled return; } // only move if already in pip, other transitions account for keep clear areas if (mPipTransitionState.hasEnteredPip()) { // only move if we're in PiP or transitioning into PiP if (!mPipTransitionState.shouldBlockResizeRequest()) { Rect destBounds = mPipKeepClearAlgorithm.adjust(mPipBoundsState, mPipBoundsAlgorithm); // only move if the bounds are actually different if (destBounds != mPipBoundsState.getBounds()) { if (mPipTransitionState.hasEnteredPip()) { // if already in PiP, schedule separate animation mPipTaskOrganizer.scheduleAnimateResizePip(destBounds, mEnterAnimationDuration, null); } else if (mPipTransitionState.isEnteringPip()) { // while entering PiP we just need to update animator bounds mPipTaskOrganizer.updateAnimatorBounds(destBounds); } } } } Loading Loading @@ -874,6 +881,21 @@ public class PipController implements PipTransitionController.PipTransitionCallb } } private void setLauncherKeepClearAreaHeight(boolean visible, int height) { if (visible) { Rect rect = new Rect( 0, mPipBoundsState.getDisplayBounds().bottom - height, mPipBoundsState.getDisplayBounds().right, mPipBoundsState.getDisplayBounds().bottom); Set<Rect> restrictedKeepClearAreas = new HashSet<>( mPipBoundsState.getRestrictedKeepClearAreas()); restrictedKeepClearAreas.add(rect); mPipBoundsState.setKeepClearAreas(restrictedKeepClearAreas, mPipBoundsState.getUnrestrictedKeepClearAreas()); updatePipPositionForKeepClearAreas(); } } private void setOnIsInPipStateChangedListener(Consumer<Boolean> callback) { mOnIsInPipStateChangedListener = callback; if (mOnIsInPipStateChangedListener != null) { Loading Loading @@ -1236,6 +1258,14 @@ public class PipController implements PipTransitionController.PipTransitionCallb }); } @Override public void setLauncherKeepClearAreaHeight(boolean visible, int height) { executeRemoteCallWithTaskPermission(mController, "setLauncherKeepClearAreaHeight", (controller) -> { controller.setLauncherKeepClearAreaHeight(visible, height); }); } @Override public void setPipAnimationListener(IPipAnimationListener listener) { executeRemoteCallWithTaskPermission(mController, "setPipAnimationListener", Loading Loading
libs/WindowManager/Shell/src/com/android/wm/shell/pip/IPip.aidl +5 −0 Original line number Diff line number Diff line Loading @@ -70,4 +70,9 @@ interface IPip { * Sets the next pip animation type to be the alpha animation. */ oneway void setPipAnimationTypeToAlpha() = 5; /** * Sets the height and visibility of the Launcher keep clear area. */ oneway void setLauncherKeepClearAreaHeight(boolean visible, int height) = 6; }
libs/WindowManager/Shell/src/com/android/wm/shell/pip/PipTaskOrganizer.java +14 −0 Original line number Diff line number Diff line Loading @@ -1178,6 +1178,20 @@ public class PipTaskOrganizer implements ShellTaskOrganizer.TaskListener, destinationBoundsOut.set(newDestinationBounds); } /** * Directly update the animator bounds. */ public void updateAnimatorBounds(Rect bounds) { final PipAnimationController.PipTransitionAnimator animator = mPipAnimationController.getCurrentAnimator(); if (animator != null && animator.isRunning()) { if (animator.getAnimationType() == ANIM_TYPE_BOUNDS) { animator.updateEndValue(bounds); } animator.setDestinationBounds(bounds); } } /** * Handles all changes to the PictureInPictureParams. */ Loading
libs/WindowManager/Shell/src/com/android/wm/shell/pip/PipTransitionState.java +10 −0 Original line number Diff line number Diff line Loading @@ -93,6 +93,11 @@ public class PipTransitionState { return hasEnteredPip(mState); } /** Returns true if activity is currently entering PiP mode. */ public boolean isEnteringPip() { return isEnteringPip(mState); } public void setInSwipePipToHomeTransition(boolean inSwipePipToHomeTransition) { mInSwipePipToHomeTransition = inSwipePipToHomeTransition; } Loading Loading @@ -130,6 +135,11 @@ public class PipTransitionState { return state == ENTERED_PIP; } /** Returns true if activity is currently entering PiP mode. */ public static boolean isEnteringPip(@TransitionState int state) { return state == ENTERING_PIP; } public interface OnPipTransitionStateChangedListener { void onPipTransitionStateChanged(@TransitionState int oldState, @TransitionState int newState); Loading
libs/WindowManager/Shell/src/com/android/wm/shell/pip/phone/PipController.java +34 −4 Original line number Diff line number Diff line Loading @@ -101,6 +101,7 @@ import com.android.wm.shell.sysui.UserChangeListener; import com.android.wm.shell.transition.Transitions; import java.io.PrintWriter; import java.util.HashSet; import java.util.List; import java.util.Objects; import java.util.Optional; Loading Loading @@ -181,14 +182,20 @@ public class PipController implements PipTransitionController.PipTransitionCallb // early bail out if the keep clear areas feature is disabled return; } // only move if already in pip, other transitions account for keep clear areas if (mPipTransitionState.hasEnteredPip()) { // only move if we're in PiP or transitioning into PiP if (!mPipTransitionState.shouldBlockResizeRequest()) { Rect destBounds = mPipKeepClearAlgorithm.adjust(mPipBoundsState, mPipBoundsAlgorithm); // only move if the bounds are actually different if (destBounds != mPipBoundsState.getBounds()) { if (mPipTransitionState.hasEnteredPip()) { // if already in PiP, schedule separate animation mPipTaskOrganizer.scheduleAnimateResizePip(destBounds, mEnterAnimationDuration, null); } else if (mPipTransitionState.isEnteringPip()) { // while entering PiP we just need to update animator bounds mPipTaskOrganizer.updateAnimatorBounds(destBounds); } } } } Loading Loading @@ -874,6 +881,21 @@ public class PipController implements PipTransitionController.PipTransitionCallb } } private void setLauncherKeepClearAreaHeight(boolean visible, int height) { if (visible) { Rect rect = new Rect( 0, mPipBoundsState.getDisplayBounds().bottom - height, mPipBoundsState.getDisplayBounds().right, mPipBoundsState.getDisplayBounds().bottom); Set<Rect> restrictedKeepClearAreas = new HashSet<>( mPipBoundsState.getRestrictedKeepClearAreas()); restrictedKeepClearAreas.add(rect); mPipBoundsState.setKeepClearAreas(restrictedKeepClearAreas, mPipBoundsState.getUnrestrictedKeepClearAreas()); updatePipPositionForKeepClearAreas(); } } private void setOnIsInPipStateChangedListener(Consumer<Boolean> callback) { mOnIsInPipStateChangedListener = callback; if (mOnIsInPipStateChangedListener != null) { Loading Loading @@ -1236,6 +1258,14 @@ public class PipController implements PipTransitionController.PipTransitionCallb }); } @Override public void setLauncherKeepClearAreaHeight(boolean visible, int height) { executeRemoteCallWithTaskPermission(mController, "setLauncherKeepClearAreaHeight", (controller) -> { controller.setLauncherKeepClearAreaHeight(visible, height); }); } @Override public void setPipAnimationListener(IPipAnimationListener listener) { executeRemoteCallWithTaskPermission(mController, "setPipAnimationListener", Loading