Merge "Adjust PiP source rect hint for window bounds" into tm-qpr-dev

This commit is contained in:
Hongwei Wang
2022-07-14 23:00:01 +00:00
committed by Android (Google) Code Review
3 changed files with 17 additions and 2 deletions

View File

@@ -1149,7 +1149,6 @@ public class ActivityOptions extends ComponentOptions {
opts.mLaunchIntoPipParams = new PictureInPictureParams.Builder(pictureInPictureParams) opts.mLaunchIntoPipParams = new PictureInPictureParams.Builder(pictureInPictureParams)
.setIsLaunchIntoPip(true) .setIsLaunchIntoPip(true)
.build(); .build();
opts.mLaunchBounds = new Rect(pictureInPictureParams.getSourceRectHint());
return opts; return opts;
} }

View File

@@ -1993,6 +1993,9 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A
if (options.getLaunchIntoPipParams() != null) { if (options.getLaunchIntoPipParams() != null) {
pictureInPictureArgs = options.getLaunchIntoPipParams(); pictureInPictureArgs = options.getLaunchIntoPipParams();
if (sourceRecord != null) {
adjustPictureInPictureParamsIfNeeded(sourceRecord.getBounds());
}
} }
mOverrideTaskTransition = options.getOverrideTaskTransition(); mOverrideTaskTransition = options.getOverrideTaskTransition();
@@ -9764,6 +9767,7 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A
void setPictureInPictureParams(PictureInPictureParams p) { void setPictureInPictureParams(PictureInPictureParams p) {
pictureInPictureArgs.copyOnlySet(p); pictureInPictureArgs.copyOnlySet(p);
adjustPictureInPictureParamsIfNeeded(getBounds());
getTask().getRootTask().onPictureInPictureParamsChanged(); getTask().getRootTask().onPictureInPictureParamsChanged();
} }
@@ -9815,6 +9819,18 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A
return new Point(windowLayout.minWidth, windowLayout.minHeight); return new Point(windowLayout.minWidth, windowLayout.minHeight);
} }
/**
* Adjust the source rect hint in {@link #pictureInPictureArgs} by window bounds since
* it is relative to its root view (see also b/235599028).
* It is caller's responsibility to make sure this is called exactly once when we update
* {@link #pictureInPictureArgs} to avoid double offset.
*/
private void adjustPictureInPictureParamsIfNeeded(Rect windowBounds) {
if (pictureInPictureArgs != null && pictureInPictureArgs.hasSourceBoundsHint()) {
pictureInPictureArgs.getSourceRectHint().offset(windowBounds.left, windowBounds.top);
}
}
static class Builder { static class Builder {
private final ActivityTaskManagerService mAtmService; private final ActivityTaskManagerService mAtmService;
private WindowProcessController mCallerApp; private WindowProcessController mCallerApp;

View File

@@ -2118,7 +2118,7 @@ class RootWindowContainer extends WindowContainer<DisplayContent>
// entering content-pip animation. // entering content-pip animation.
mWindowManager.mTaskSnapshotController.recordTaskSnapshot( mWindowManager.mTaskSnapshotController.recordTaskSnapshot(
task, false /* allowSnapshotHome */); task, false /* allowSnapshotHome */);
rootTask.setBounds(r.getOptions().getLaunchBounds()); rootTask.setBounds(r.pictureInPictureArgs.getSourceRectHint());
} }
rootTask.setDeferTaskAppear(false); rootTask.setDeferTaskAppear(false);