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

am: 0152fd3686

Change-Id: Id14fa9d368f1c121f36ab3b20f0183a8cc5a8934
This commit is contained in:
Winson Chung
2017-04-29 22:44:51 +00:00
committed by android-build-merger
5 changed files with 57 additions and 45 deletions

View File

@@ -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 */);

View File

@@ -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,

View File

@@ -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);

View File

@@ -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(

View File

@@ -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;