Loading libs/WindowManager/Shell/src/com/android/wm/shell/dagger/pip/Pip2Module.java +3 −1 Original line number Diff line number Diff line Loading @@ -77,10 +77,12 @@ public abstract class Pip2Module { PipTaskListener pipTaskListener, @NonNull PipScheduler pipScheduler, @NonNull PipTransitionState pipStackListenerController, @NonNull PipDisplayLayoutState pipDisplayLayoutState, @NonNull PipUiStateChangeController pipUiStateChangeController) { return new PipTransition(context, shellInit, shellTaskOrganizer, transitions, pipBoundsState, null, pipBoundsAlgorithm, pipTaskListener, pipScheduler, pipStackListenerController, pipUiStateChangeController); pipScheduler, pipStackListenerController, pipDisplayLayoutState, pipUiStateChangeController); } @WMSingleton Loading libs/WindowManager/Shell/src/com/android/wm/shell/pip2/phone/PipController.java +8 −2 Original line number Diff line number Diff line Loading @@ -324,10 +324,16 @@ public class PipController implements ConfigurationChangeListener, int launcherRotation, Rect hotseatKeepClearArea) { ProtoLog.d(ShellProtoLogGroup.WM_SHELL_PICTURE_IN_PICTURE, "getSwipePipToHomeBounds: %s", componentName); // preemptively add the keep clear area for Hotseat, so that it is taken into account // when calculating the entry destination bounds of PiP window // Preemptively add the keep clear area for Hotseat, so that it is taken into account // when calculating the entry destination bounds of PiP window. mPipBoundsState.setNamedUnrestrictedKeepClearArea( PipBoundsState.NAMED_KCA_LAUNCHER_SHELF, hotseatKeepClearArea); // Set the display layout rotation early to calculate final orientation bounds that // the animator expects, this will also be used to detect the fixed rotation when // Shell resolves the type of the animation we are undergoing. mPipDisplayLayoutState.rotateTo(launcherRotation); mPipBoundsState.setBoundsStateForEntry(componentName, activityInfo, pictureInPictureParams, mPipBoundsAlgorithm); return mPipBoundsAlgorithm.getEntryDestinationBounds(); Loading libs/WindowManager/Shell/src/com/android/wm/shell/pip2/phone/PipTransition.java +31 −6 Original line number Diff line number Diff line Loading @@ -17,6 +17,7 @@ package com.android.wm.shell.pip2.phone; import static android.app.WindowConfiguration.WINDOWING_MODE_PINNED; import static android.view.Surface.ROTATION_270; import static android.view.WindowManager.TRANSIT_CLOSE; import static android.view.WindowManager.TRANSIT_OPEN; import static android.view.WindowManager.TRANSIT_PIP; Loading @@ -33,6 +34,7 @@ import android.annotation.NonNull; import android.app.ActivityManager; import android.app.PictureInPictureParams; import android.content.Context; import android.graphics.Matrix; import android.graphics.Rect; import android.os.Bundle; import android.os.IBinder; Loading @@ -49,6 +51,7 @@ import com.android.internal.util.Preconditions; import com.android.wm.shell.ShellTaskOrganizer; import com.android.wm.shell.common.pip.PipBoundsAlgorithm; import com.android.wm.shell.common.pip.PipBoundsState; import com.android.wm.shell.common.pip.PipDisplayLayoutState; import com.android.wm.shell.common.pip.PipMenuController; import com.android.wm.shell.common.pip.PipUtils; import com.android.wm.shell.pip.PipTransitionController; Loading Loading @@ -82,7 +85,7 @@ public class PipTransition extends PipTransitionController implements * The fixed start delay in ms when fading out the content overlay from bounds animation. * The fadeout animation is guaranteed to start after the client has drawn under the new config. */ private static final int CONTENT_OVERLAY_FADE_OUT_DELAY_MS = 400; private static final int CONTENT_OVERLAY_FADE_OUT_DELAY_MS = 500; // // Dependencies Loading @@ -92,6 +95,7 @@ public class PipTransition extends PipTransitionController implements private final PipTaskListener mPipTaskListener; private final PipScheduler mPipScheduler; private final PipTransitionState mPipTransitionState; private final PipDisplayLayoutState mPipDisplayLayoutState; // // Transition caches Loading Loading @@ -124,6 +128,7 @@ public class PipTransition extends PipTransitionController implements PipTaskListener pipTaskListener, PipScheduler pipScheduler, PipTransitionState pipTransitionState, PipDisplayLayoutState pipDisplayLayoutState, PipUiStateChangeController pipUiStateChangeController) { super(shellInit, shellTaskOrganizer, transitions, pipBoundsState, pipMenuController, pipBoundsAlgorithm); Loading @@ -134,6 +139,7 @@ public class PipTransition extends PipTransitionController implements mPipScheduler.setPipTransitionController(this); mPipTransitionState = pipTransitionState; mPipTransitionState.addPipTransitionStateChangedListener(this); mPipDisplayLayoutState = pipDisplayLayoutState; } @Override Loading Loading @@ -321,11 +327,30 @@ public class PipTransition extends PipTransitionController implements (destinationBounds.width() - overlaySize) / 2f, (destinationBounds.height() - overlaySize) / 2f); } startTransaction.merge(finishTransaction); final int startRotation = pipChange.getStartRotation(); final int endRotation = mPipDisplayLayoutState.getRotation(); if (endRotation != startRotation) { boolean isClockwise = (endRotation - startRotation) == -ROTATION_270; // Display bounds were already updated to represent the final orientation, // so we just need to readjust the origin, and perform rotation about (0, 0). Rect displayBounds = mPipDisplayLayoutState.getDisplayBounds(); int originTranslateX = isClockwise ? 0 : -displayBounds.width(); int originTranslateY = isClockwise ? -displayBounds.height() : 0; Matrix transformTensor = new Matrix(); final float[] matrixTmp = new float[9]; transformTensor.setTranslate(originTranslateX + destinationBounds.left, originTranslateY + destinationBounds.top); final float degrees = (endRotation - startRotation) * 90f; transformTensor.postRotate(degrees); startTransaction.setMatrix(pipLeash, transformTensor, matrixTmp); } startTransaction.apply(); finishCallback.onTransitionFinished(null /* finishWct */); onClientDrawAtTransitionEnd(); finishInner(); return true; } Loading Loading @@ -397,7 +422,7 @@ public class PipTransition extends PipTransitionController implements sourceRectHint, PipEnterExitAnimator.BOUNDS_ENTER, Surface.ROTATION_0); tx.addTransactionCommittedListener(mPipScheduler.getMainExecutor(), this::onClientDrawAtTransitionEnd); this::finishInner); finishWct.setBoundsChangeTransaction(pipTaskToken, tx); animator.setAnimationEndCallback(() -> Loading Loading @@ -430,7 +455,7 @@ public class PipTransition extends PipTransitionController implements animator.setAnimationEndCallback(() -> { finishCallback.onTransitionFinished(null); // This should update the pip transition state accordingly after we stop playing. onClientDrawAtTransitionEnd(); finishInner(); }); animator.start(); Loading Loading @@ -605,7 +630,7 @@ public class PipTransition extends PipTransitionController implements // Miscellaneous callbacks and listeners // private void onClientDrawAtTransitionEnd() { private void finishInner() { if (mPipTransitionState.getSwipePipToHomeOverlay() != null) { startOverlayFadeoutAnimation(); } else if (mPipTransitionState.getState() == PipTransitionState.ENTERING_PIP) { Loading Loading
libs/WindowManager/Shell/src/com/android/wm/shell/dagger/pip/Pip2Module.java +3 −1 Original line number Diff line number Diff line Loading @@ -77,10 +77,12 @@ public abstract class Pip2Module { PipTaskListener pipTaskListener, @NonNull PipScheduler pipScheduler, @NonNull PipTransitionState pipStackListenerController, @NonNull PipDisplayLayoutState pipDisplayLayoutState, @NonNull PipUiStateChangeController pipUiStateChangeController) { return new PipTransition(context, shellInit, shellTaskOrganizer, transitions, pipBoundsState, null, pipBoundsAlgorithm, pipTaskListener, pipScheduler, pipStackListenerController, pipUiStateChangeController); pipScheduler, pipStackListenerController, pipDisplayLayoutState, pipUiStateChangeController); } @WMSingleton Loading
libs/WindowManager/Shell/src/com/android/wm/shell/pip2/phone/PipController.java +8 −2 Original line number Diff line number Diff line Loading @@ -324,10 +324,16 @@ public class PipController implements ConfigurationChangeListener, int launcherRotation, Rect hotseatKeepClearArea) { ProtoLog.d(ShellProtoLogGroup.WM_SHELL_PICTURE_IN_PICTURE, "getSwipePipToHomeBounds: %s", componentName); // preemptively add the keep clear area for Hotseat, so that it is taken into account // when calculating the entry destination bounds of PiP window // Preemptively add the keep clear area for Hotseat, so that it is taken into account // when calculating the entry destination bounds of PiP window. mPipBoundsState.setNamedUnrestrictedKeepClearArea( PipBoundsState.NAMED_KCA_LAUNCHER_SHELF, hotseatKeepClearArea); // Set the display layout rotation early to calculate final orientation bounds that // the animator expects, this will also be used to detect the fixed rotation when // Shell resolves the type of the animation we are undergoing. mPipDisplayLayoutState.rotateTo(launcherRotation); mPipBoundsState.setBoundsStateForEntry(componentName, activityInfo, pictureInPictureParams, mPipBoundsAlgorithm); return mPipBoundsAlgorithm.getEntryDestinationBounds(); Loading
libs/WindowManager/Shell/src/com/android/wm/shell/pip2/phone/PipTransition.java +31 −6 Original line number Diff line number Diff line Loading @@ -17,6 +17,7 @@ package com.android.wm.shell.pip2.phone; import static android.app.WindowConfiguration.WINDOWING_MODE_PINNED; import static android.view.Surface.ROTATION_270; import static android.view.WindowManager.TRANSIT_CLOSE; import static android.view.WindowManager.TRANSIT_OPEN; import static android.view.WindowManager.TRANSIT_PIP; Loading @@ -33,6 +34,7 @@ import android.annotation.NonNull; import android.app.ActivityManager; import android.app.PictureInPictureParams; import android.content.Context; import android.graphics.Matrix; import android.graphics.Rect; import android.os.Bundle; import android.os.IBinder; Loading @@ -49,6 +51,7 @@ import com.android.internal.util.Preconditions; import com.android.wm.shell.ShellTaskOrganizer; import com.android.wm.shell.common.pip.PipBoundsAlgorithm; import com.android.wm.shell.common.pip.PipBoundsState; import com.android.wm.shell.common.pip.PipDisplayLayoutState; import com.android.wm.shell.common.pip.PipMenuController; import com.android.wm.shell.common.pip.PipUtils; import com.android.wm.shell.pip.PipTransitionController; Loading Loading @@ -82,7 +85,7 @@ public class PipTransition extends PipTransitionController implements * The fixed start delay in ms when fading out the content overlay from bounds animation. * The fadeout animation is guaranteed to start after the client has drawn under the new config. */ private static final int CONTENT_OVERLAY_FADE_OUT_DELAY_MS = 400; private static final int CONTENT_OVERLAY_FADE_OUT_DELAY_MS = 500; // // Dependencies Loading @@ -92,6 +95,7 @@ public class PipTransition extends PipTransitionController implements private final PipTaskListener mPipTaskListener; private final PipScheduler mPipScheduler; private final PipTransitionState mPipTransitionState; private final PipDisplayLayoutState mPipDisplayLayoutState; // // Transition caches Loading Loading @@ -124,6 +128,7 @@ public class PipTransition extends PipTransitionController implements PipTaskListener pipTaskListener, PipScheduler pipScheduler, PipTransitionState pipTransitionState, PipDisplayLayoutState pipDisplayLayoutState, PipUiStateChangeController pipUiStateChangeController) { super(shellInit, shellTaskOrganizer, transitions, pipBoundsState, pipMenuController, pipBoundsAlgorithm); Loading @@ -134,6 +139,7 @@ public class PipTransition extends PipTransitionController implements mPipScheduler.setPipTransitionController(this); mPipTransitionState = pipTransitionState; mPipTransitionState.addPipTransitionStateChangedListener(this); mPipDisplayLayoutState = pipDisplayLayoutState; } @Override Loading Loading @@ -321,11 +327,30 @@ public class PipTransition extends PipTransitionController implements (destinationBounds.width() - overlaySize) / 2f, (destinationBounds.height() - overlaySize) / 2f); } startTransaction.merge(finishTransaction); final int startRotation = pipChange.getStartRotation(); final int endRotation = mPipDisplayLayoutState.getRotation(); if (endRotation != startRotation) { boolean isClockwise = (endRotation - startRotation) == -ROTATION_270; // Display bounds were already updated to represent the final orientation, // so we just need to readjust the origin, and perform rotation about (0, 0). Rect displayBounds = mPipDisplayLayoutState.getDisplayBounds(); int originTranslateX = isClockwise ? 0 : -displayBounds.width(); int originTranslateY = isClockwise ? -displayBounds.height() : 0; Matrix transformTensor = new Matrix(); final float[] matrixTmp = new float[9]; transformTensor.setTranslate(originTranslateX + destinationBounds.left, originTranslateY + destinationBounds.top); final float degrees = (endRotation - startRotation) * 90f; transformTensor.postRotate(degrees); startTransaction.setMatrix(pipLeash, transformTensor, matrixTmp); } startTransaction.apply(); finishCallback.onTransitionFinished(null /* finishWct */); onClientDrawAtTransitionEnd(); finishInner(); return true; } Loading Loading @@ -397,7 +422,7 @@ public class PipTransition extends PipTransitionController implements sourceRectHint, PipEnterExitAnimator.BOUNDS_ENTER, Surface.ROTATION_0); tx.addTransactionCommittedListener(mPipScheduler.getMainExecutor(), this::onClientDrawAtTransitionEnd); this::finishInner); finishWct.setBoundsChangeTransaction(pipTaskToken, tx); animator.setAnimationEndCallback(() -> Loading Loading @@ -430,7 +455,7 @@ public class PipTransition extends PipTransitionController implements animator.setAnimationEndCallback(() -> { finishCallback.onTransitionFinished(null); // This should update the pip transition state accordingly after we stop playing. onClientDrawAtTransitionEnd(); finishInner(); }); animator.start(); Loading Loading @@ -605,7 +630,7 @@ public class PipTransition extends PipTransitionController implements // Miscellaneous callbacks and listeners // private void onClientDrawAtTransitionEnd() { private void finishInner() { if (mPipTransitionState.getSwipePipToHomeOverlay() != null) { startOverlayFadeoutAnimation(); } else if (mPipTransitionState.getState() == PipTransitionState.ENTERING_PIP) { Loading