Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 0152fd36 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Fixing test due to null PiP default bounds." into oc-dev

parents 80e1b2fc 9c844410
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -2977,8 +2977,8 @@ public class ActivityStackSupervisor extends ConfigurationContainer implements D

        // Calculate the default bounds (don't use existing stack bounds as we may have just created
        // the stack
        final Rect destBounds = mWindowManager.getPictureInPictureBounds(DEFAULT_DISPLAY,
                aspectRatio, false /* useExistingStackBounds */);
        final Rect destBounds = stack.getPictureInPictureBounds(aspectRatio,
                false /* useExistingStackBounds */);

        stack.animateResizePinnedStack(sourceHintBounds, destBounds, -1 /* animationDuration */,
                true /* schedulePipModeChangedOnAnimationEnd */);
+5 −0
Original line number Diff line number Diff line
@@ -43,6 +43,11 @@ class PinnedActivityStack extends ActivityStack<PinnedStackWindowController>
        return new PinnedStackWindowController(mStackId, this, displayId, onTop, outBounds);
    }

    Rect getPictureInPictureBounds(float aspectRatio, boolean useExistingStackBounds) {
        return getWindowContainerController().getPictureInPictureBounds(aspectRatio,
                useExistingStackBounds);
    }

    void animateResizePinnedStack(Rect sourceHintBounds, Rect toBounds, int animationDuration,
            boolean schedulePipModeChangedOnAnimationEnd) {
        getWindowContainerController().animateResizePinnedStack(toBounds, sourceHintBounds,
+39 −2
Original line number Diff line number Diff line
@@ -17,6 +17,8 @@
package com.android.server.wm;

import static android.app.ActivityManager.StackId.FULLSCREEN_WORKSPACE_STACK_ID;
import static android.app.ActivityManager.StackId.PINNED_STACK_ID;

import static com.android.server.wm.BoundsAnimationController.NO_PIP_MODE_CHANGED_CALLBACKS;
import static com.android.server.wm.BoundsAnimationController.SCHEDULE_PIP_MODE_CHANGED_ON_END;
import static com.android.server.wm.BoundsAnimationController.SCHEDULE_PIP_MODE_CHANGED_ON_START;
@@ -41,6 +43,42 @@ public class PinnedStackWindowController extends StackWindowController {
        super(stackId, listener, displayId, onTop, outBounds, WindowManagerService.getInstance());
    }

    /**
     * @param useExistingStackBounds Apply {@param aspectRatio} to the existing target stack bounds
     *                               if possible
     */
    public Rect getPictureInPictureBounds(float aspectRatio, boolean useExistingStackBounds) {
        synchronized (mWindowMap) {
            if (!mService.mSupportsPictureInPicture || mContainer == null) {
                return null;
            }

            final Rect stackBounds;
            final DisplayContent displayContent = mContainer.getDisplayContent();
            if (displayContent == null) {
                return null;
            }

            final PinnedStackController pinnedStackController =
                    displayContent.getPinnedStackController();
            if (useExistingStackBounds) {
                // If the stack exists, then use its final bounds to calculate the new aspect ratio
                // bounds
                stackBounds = new Rect();
                mContainer.getAnimationOrCurrentBounds(stackBounds);
            } else {
                // Otherwise, just calculate the aspect ratio bounds from the default bounds
                stackBounds = pinnedStackController.getDefaultBounds();
            }

            if (pinnedStackController.isValidPictureInPictureAspectRatio(aspectRatio)) {
                return pinnedStackController.transformBoundsToAspectRatio(stackBounds, aspectRatio);
            } else {
                return stackBounds;
            }
        }
    }

    /**
     * Animates the pinned stack.
     */
@@ -104,8 +142,7 @@ public class PinnedStackWindowController extends StackWindowController {
                return;
            }

            final int displayId = mContainer.getDisplayContent().getDisplayId();
            final Rect toBounds = mService.getPictureInPictureBounds(displayId, aspectRatio,
            final Rect toBounds = getPictureInPictureBounds(aspectRatio,
                    true /* useExistingStackBounds */);
            final Rect targetBounds = new Rect();
            mContainer.getAnimationOrCurrentBounds(targetBounds);
+0 −38
Original line number Diff line number Diff line
@@ -2761,44 +2761,6 @@ public class WindowManagerService extends IWindowManager.Stub
        mDockedStackCreateBounds = bounds;
    }

    /**
     * @param useExistingStackBounds Apply {@param aspectRatio} to the existing target stack bounds
     *                               if possible
     */
    public Rect getPictureInPictureBounds(int displayId, float aspectRatio,
            boolean useExistingStackBounds) {
        synchronized (mWindowMap) {
            if (!mSupportsPictureInPicture) {
                return null;
            }

            final Rect stackBounds;
            final DisplayContent displayContent = mRoot.getDisplayContent(displayId);
            if (displayContent == null) {
                return null;
            }

            final PinnedStackController pinnedStackController =
                    displayContent.getPinnedStackController();
            final TaskStack stack = displayContent.getStackById(PINNED_STACK_ID);
            if (stack != null && useExistingStackBounds) {
                // If the stack exists, then use its final bounds to calculate the new aspect ratio
                // bounds.
                stackBounds = new Rect();
                stack.getAnimationOrCurrentBounds(stackBounds);
            } else {
                // Otherwise, just calculate the aspect ratio bounds from the default bounds
                stackBounds = pinnedStackController.getDefaultBounds();
            }

            if (pinnedStackController.isValidPictureInPictureAspectRatio(aspectRatio)) {
                return pinnedStackController.transformBoundsToAspectRatio(stackBounds, aspectRatio);
            } else {
                return stackBounds;
            }
        }
    }

    public boolean isValidPictureInPictureAspectRatio(int displayId, float aspectRatio) {
        final DisplayContent displayContent = mRoot.getDisplayContent(displayId);
        return displayContent.getPinnedStackController().isValidPictureInPictureAspectRatio(
+11 −3
Original line number Diff line number Diff line
@@ -230,9 +230,17 @@ public class ActivityTestsBase {
                if (mStack == null) {
                    final RecentTasks recents =
                            new RecentTasks(mService, mService.mStackSupervisor);
                    mStack = mStackId == ActivityManager.StackId.PINNED_STACK_ID
                    ? new PinnedActivityStack(this, recents, mOnTop)
                    : new TestActivityStack(this, recents, mOnTop);
                    if (mStackId == ActivityManager.StackId.PINNED_STACK_ID) {
                        mStack = new PinnedActivityStack(this, recents, mOnTop) {
                            @Override
                            Rect getPictureInPictureBounds(float aspectRatio,
                                    boolean useExistingStackBounds) {
                                return new Rect(50, 50, 100, 100);
                            }
                        };
                    } else {
                        mStack = new TestActivityStack(this, recents, mOnTop);
                    }
                }

                return mStack;