Merge "Add localBounds in RemoteAnimationTarget" into rvc-dev am: bd8e715c01 am: c2fb1de0b8

Change-Id: Ib291dbc5f20ec19ef0f101046df50f42b17f694a
This commit is contained in:
Automerger Merge Worker
2020-03-10 03:35:05 +00:00
9 changed files with 84 additions and 34 deletions

View File

@@ -20,9 +20,11 @@ import static android.view.RemoteAnimationTargetProto.CLIP_RECT;
import static android.view.RemoteAnimationTargetProto.CONTENT_INSETS;
import static android.view.RemoteAnimationTargetProto.IS_TRANSLUCENT;
import static android.view.RemoteAnimationTargetProto.LEASH;
import static android.view.RemoteAnimationTargetProto.LOCAL_BOUNDS;
import static android.view.RemoteAnimationTargetProto.MODE;
import static android.view.RemoteAnimationTargetProto.POSITION;
import static android.view.RemoteAnimationTargetProto.PREFIX_ORDER_INDEX;
import static android.view.RemoteAnimationTargetProto.SCREEN_SPACE_BOUNDS;
import static android.view.RemoteAnimationTargetProto.SOURCE_CONTAINER_BOUNDS;
import static android.view.RemoteAnimationTargetProto.START_BOUNDS;
import static android.view.RemoteAnimationTargetProto.START_LEASH;
@@ -130,18 +132,37 @@ public class RemoteAnimationTarget implements Parcelable {
* The source position of the app, in screen spaces coordinates. If the position of the leash
* is modified from the controlling app, any animation transform needs to be offset by this
* amount.
* @deprecated Use {@link #localBounds} instead.
*/
@Deprecated
@UnsupportedAppUsage
public final Point position;
/**
* Bounds of the target relative to its parent.
* When the app target animating on its parent, we need to use the local coordinates relative to
* its parent with {@code localBounds.left} & {@code localBounds.top} rather than using
* {@code position} in screen coordinates.
*/
public final Rect localBounds;
/**
* The bounds of the source container the app lives in, in screen space coordinates. If the crop
* of the leash is modified from the controlling app, it needs to take the source container
* bounds into account when calculating the crop.
* @deprecated Renamed to {@link #screenSpaceBounds}
*/
@Deprecated
@UnsupportedAppUsage
public final Rect sourceContainerBounds;
/**
* Bounds of the target relative to the screen. If the crop of the leash is modified from the
* controlling app, it needs to take the screen space bounds into account when calculating the
* crop.
*/
public final Rect screenSpaceBounds;
/**
* The starting bounds of the source container in screen space coordinates. This is {@code null}
* if the animation target isn't MODE_CHANGING. Since this is the starting bounds, it's size
@@ -165,7 +186,8 @@ public class RemoteAnimationTarget implements Parcelable {
public RemoteAnimationTarget(int taskId, int mode, SurfaceControl leash, boolean isTranslucent,
Rect clipRect, Rect contentInsets, int prefixOrderIndex, Point position,
Rect sourceContainerBounds, WindowConfiguration windowConfig, boolean isNotInRecents,
Rect localBounds, Rect screenSpaceBounds,
WindowConfiguration windowConfig, boolean isNotInRecents,
SurfaceControl startLeash, Rect startBounds) {
this.mode = mode;
this.taskId = taskId;
@@ -175,7 +197,9 @@ public class RemoteAnimationTarget implements Parcelable {
this.contentInsets = new Rect(contentInsets);
this.prefixOrderIndex = prefixOrderIndex;
this.position = new Point(position);
this.sourceContainerBounds = new Rect(sourceContainerBounds);
this.localBounds = new Rect(localBounds);
this.sourceContainerBounds = new Rect(screenSpaceBounds);
this.screenSpaceBounds = new Rect(screenSpaceBounds);
this.windowConfiguration = windowConfig;
this.isNotInRecents = isNotInRecents;
this.startLeash = startLeash;
@@ -191,7 +215,9 @@ public class RemoteAnimationTarget implements Parcelable {
contentInsets = in.readParcelable(null);
prefixOrderIndex = in.readInt();
position = in.readParcelable(null);
localBounds = in.readParcelable(null);
sourceContainerBounds = in.readParcelable(null);
screenSpaceBounds = in.readParcelable(null);
windowConfiguration = in.readParcelable(null);
isNotInRecents = in.readBoolean();
startLeash = in.readParcelable(null);
@@ -213,7 +239,9 @@ public class RemoteAnimationTarget implements Parcelable {
dest.writeParcelable(contentInsets, 0 /* flags */);
dest.writeInt(prefixOrderIndex);
dest.writeParcelable(position, 0 /* flags */);
dest.writeParcelable(localBounds, 0 /* flags */);
dest.writeParcelable(sourceContainerBounds, 0 /* flags */);
dest.writeParcelable(screenSpaceBounds, 0 /* flags */);
dest.writeParcelable(windowConfiguration, 0 /* flags */);
dest.writeBoolean(isNotInRecents);
dest.writeParcelable(startLeash, 0 /* flags */);
@@ -229,6 +257,8 @@ public class RemoteAnimationTarget implements Parcelable {
pw.print(" prefixOrderIndex="); pw.print(prefixOrderIndex);
pw.print(" position="); position.printShortString(pw);
pw.print(" sourceContainerBounds="); sourceContainerBounds.printShortString(pw);
pw.print(" screenSpaceBounds="); screenSpaceBounds.printShortString(pw);
pw.print(" localBounds="); localBounds.printShortString(pw);
pw.println();
pw.print(prefix); pw.print("windowConfiguration="); pw.println(windowConfiguration);
pw.print(prefix); pw.print("leash="); pw.println(leash);
@@ -245,6 +275,8 @@ public class RemoteAnimationTarget implements Parcelable {
proto.write(PREFIX_ORDER_INDEX, prefixOrderIndex);
position.dumpDebug(proto, POSITION);
sourceContainerBounds.dumpDebug(proto, SOURCE_CONTAINER_BOUNDS);
screenSpaceBounds.dumpDebug(proto, SCREEN_SPACE_BOUNDS);
localBounds.dumpDebug(proto, LOCAL_BOUNDS);
windowConfiguration.dumpDebug(proto, WINDOW_CONFIGURATION);
if (startLeash != null) {
startLeash.dumpDebug(proto, START_LEASH);

View File

@@ -44,4 +44,6 @@ message RemoteAnimationTargetProto {
optional .android.app.WindowConfigurationProto window_configuration = 10;
optional .android.view.SurfaceControlProto start_leash = 11;
optional .android.graphics.RectProto start_bounds = 12;
optional .android.graphics.RectProto local_bounds = 13;
optional .android.graphics.RectProto screen_space_bounds = 14;
}

View File

@@ -44,7 +44,9 @@ public class RemoteAnimationTargetCompat {
public final Rect clipRect;
public final int prefixOrderIndex;
public final Point position;
public final Rect localBounds;
public final Rect sourceContainerBounds;
public final Rect screenSpaceBounds;
public final boolean isNotInRecents;
public final Rect contentInsets;
@@ -57,7 +59,9 @@ public class RemoteAnimationTargetCompat {
isTranslucent = app.isTranslucent;
clipRect = app.clipRect;
position = app.position;
localBounds = app.localBounds;
sourceContainerBounds = app.sourceContainerBounds;
screenSpaceBounds = app.screenSpaceBounds;
prefixOrderIndex = app.prefixOrderIndex;
isNotInRecents = app.isNotInRecents;
contentInsets = app.contentInsets;

View File

@@ -7620,7 +7620,7 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A
return new RemoteAnimationTarget(task.mTaskId, record.getMode(),
record.mAdapter.mCapturedLeash, !fillsParent(),
mainWindow.mWinAnimator.mLastClipRect, insets,
getPrefixOrderIndex(), record.mAdapter.mPosition,
getPrefixOrderIndex(), record.mAdapter.mPosition, record.mAdapter.mLocalBounds,
record.mAdapter.mStackBounds, task.getWindowConfiguration(),
false /*isNotInRecents*/,
record.mThumbnailAdapter != null ? record.mThumbnailAdapter.mCapturedLeash : null,

View File

@@ -820,15 +820,19 @@ public class RecentsAnimationController implements DeathRecipient {
private @AnimationType int mLastAnimationType;
private final boolean mIsRecentTaskInvisible;
private RemoteAnimationTarget mTarget;
private final Point mPosition = new Point();
private final Rect mBounds = new Rect();
// The bounds of the target relative to its parent.
private Rect mLocalBounds = new Rect();
TaskAnimationAdapter(Task task, boolean isRecentTaskInvisible) {
mTask = task;
mIsRecentTaskInvisible = isRecentTaskInvisible;
final WindowContainer container = mTask.getParent();
mBounds.set(container.getDisplayedBounds());
mPosition.set(mBounds.left, mBounds.top);
mBounds.set(mTask.getDisplayedBounds());
mLocalBounds.set(mBounds);
Point tmpPos = new Point();
mTask.getRelativeDisplayedPosition(tmpPos);
mLocalBounds.offsetTo(tmpPos.x, tmpPos.y);
}
RemoteAnimationTarget createRemoteAnimationTarget() {
@@ -847,8 +851,9 @@ public class RecentsAnimationController implements DeathRecipient {
: MODE_CLOSING;
mTarget = new RemoteAnimationTarget(mTask.mTaskId, mode, mCapturedLeash,
!topApp.fillsParent(), mainWindow.mWinAnimator.mLastClipRect,
insets, mTask.getPrefixOrderIndex(), mPosition, mBounds,
mTask.getWindowConfiguration(), mIsRecentTaskInvisible, null, null);
insets, mTask.getPrefixOrderIndex(), new Point(mBounds.left, mBounds.top),
mLocalBounds, mBounds, mTask.getWindowConfiguration(),
mIsRecentTaskInvisible, null, null);
return mTarget;
}
@@ -862,8 +867,8 @@ public class RecentsAnimationController implements DeathRecipient {
@AnimationType int type, OnAnimationFinishedCallback finishCallback) {
// Restore z-layering, position and stack crop until client has a chance to modify it.
t.setLayer(animationLeash, mTask.getPrefixOrderIndex());
t.setPosition(animationLeash, mPosition.x, mPosition.y);
mTmpRect.set(mBounds);
t.setPosition(animationLeash, mLocalBounds.left, mLocalBounds.top);
mTmpRect.set(mLocalBounds);
mTmpRect.offsetTo(0, 0);
t.setWindowCrop(animationLeash, mTmpRect);
mCapturedLeash = animationLeash;
@@ -897,7 +902,7 @@ public class RecentsAnimationController implements DeathRecipient {
pw.print(prefix); pw.println("Target: null");
}
pw.println("mIsRecentTaskInvisible=" + mIsRecentTaskInvisible);
pw.println("mPosition=" + mPosition);
pw.println("mLocalBounds=" + mLocalBounds);
pw.println("mBounds=" + mBounds);
pw.println("mIsRecentTaskInvisible=" + mIsRecentTaskInvisible);
}

View File

@@ -80,16 +80,17 @@ class RemoteAnimationController implements DeathRecipient {
*
* @param windowContainer The windows to animate.
* @param position The position app bounds, in screen coordinates.
* @param localBounds The bounds of the app relative to its parent.
* @param stackBounds The stack bounds of the app relative to position.
* @param startBounds The stack bounds before the transition, in screen coordinates
* @return The record representing animation(s) to run on the app.
*/
RemoteAnimationRecord createRemoteAnimationRecord(WindowContainer windowContainer,
Point position, Rect stackBounds, Rect startBounds) {
Point position, Rect localBounds, Rect stackBounds, Rect startBounds) {
ProtoLog.d(WM_DEBUG_REMOTE_ANIMATIONS, "createAnimationAdapter(): container=%s",
windowContainer);
final RemoteAnimationRecord adapters =
new RemoteAnimationRecord(windowContainer, position, stackBounds, startBounds);
final RemoteAnimationRecord adapters = new RemoteAnimationRecord(windowContainer, position,
localBounds, stackBounds, startBounds);
mPendingAnimations.add(adapters);
return adapters;
}
@@ -355,17 +356,18 @@ class RemoteAnimationController implements DeathRecipient {
final WindowContainer mWindowContainer;
final Rect mStartBounds;
RemoteAnimationRecord(WindowContainer windowContainer, Point endPos, Rect endBounds,
Rect startBounds) {
RemoteAnimationRecord(WindowContainer windowContainer, Point endPos, Rect localBounds,
Rect endBounds, Rect startBounds) {
mWindowContainer = windowContainer;
mAdapter = new RemoteAnimationAdapterWrapper(this, endPos, endBounds);
mAdapter = new RemoteAnimationAdapterWrapper(this, endPos, localBounds, endBounds);
if (startBounds != null) {
mStartBounds = new Rect(startBounds);
mTmpRect.set(startBounds);
mTmpRect.offsetTo(0, 0);
if (mRemoteAnimationAdapter.getChangeNeedsSnapshot()) {
mThumbnailAdapter =
new RemoteAnimationAdapterWrapper(this, new Point(0, 0), mTmpRect);
new RemoteAnimationAdapterWrapper(this, new Point(0, 0), localBounds,
mTmpRect);
}
} else {
mStartBounds = null;
@@ -401,12 +403,14 @@ class RemoteAnimationController implements DeathRecipient {
private OnAnimationFinishedCallback mCapturedFinishCallback;
private @AnimationType int mAnimationType;
final Point mPosition = new Point();
final Rect mLocalBounds;
final Rect mStackBounds = new Rect();
RemoteAnimationAdapterWrapper(RemoteAnimationRecord record, Point position,
Rect stackBounds) {
Rect localBounds, Rect stackBounds) {
mRecord = record;
mPosition.set(position.x, position.y);
mLocalBounds = localBounds;
mStackBounds.set(stackBounds);
}

View File

@@ -92,7 +92,7 @@ class WallpaperAnimationAdapter implements AnimationAdapter {
*/
RemoteAnimationTarget createRemoteAnimationTarget() {
mTarget = new RemoteAnimationTarget(-1, -1, getLeash(), false, null, null,
mWallpaperToken.getPrefixOrderIndex(), new Point(), null,
mWallpaperToken.getPrefixOrderIndex(), new Point(), null, null,
mWallpaperToken.getWindowConfiguration(), true, null, null);
return mTarget;
}

View File

@@ -2086,9 +2086,11 @@ class WindowContainer<E extends WindowContainer> extends ConfigurationContainer<
// Delaying animation start isn't compatible with remote animations at all.
if (controller != null && !mSurfaceAnimator.isAnimationStartDelayed()) {
final Rect localBounds = new Rect(mTmpRect);
localBounds.offsetTo(mTmpPoint.x, mTmpPoint.y);
final RemoteAnimationController.RemoteAnimationRecord adapters =
controller.createRemoteAnimationRecord(this, mTmpPoint, mTmpRect,
(isChanging ? mSurfaceFreezer.mFreezeBounds : null));
controller.createRemoteAnimationRecord(this, mTmpPoint, localBounds,
mTmpRect, (isChanging ? mSurfaceFreezer.mFreezeBounds : null));
resultAdapters = new Pair<>(adapters.mAdapter, adapters.mThumbnailAdapter);
} else if (isChanging) {
final float durationScale = mWmService.getTransitionAnimationScaleLocked();

View File

@@ -98,7 +98,7 @@ public class RemoteAnimationControllerTest extends WindowTestsBase {
mDisplayContent.mOpeningApps.add(win.mActivityRecord);
try {
final AnimationAdapter adapter = mController.createRemoteAnimationRecord(win.mActivityRecord,
new Point(50, 100), new Rect(50, 100, 150, 150), null).mAdapter;
new Point(50, 100), null, new Rect(50, 100, 150, 150), null).mAdapter;
adapter.startAnimation(mMockLeash, mMockTransaction, ANIMATION_TYPE_APP_TRANSITION,
mFinishedCallback);
mController.goodToGo();
@@ -136,7 +136,7 @@ public class RemoteAnimationControllerTest extends WindowTestsBase {
public void testCancel() throws Exception {
final WindowState win = createWindow(null /* parent */, TYPE_BASE_APPLICATION, "testWin");
final AnimationAdapter adapter = mController.createRemoteAnimationRecord(win.mActivityRecord,
new Point(50, 100), new Rect(50, 100, 150, 150), null).mAdapter;
new Point(50, 100), null, new Rect(50, 100, 150, 150), null).mAdapter;
adapter.startAnimation(mMockLeash, mMockTransaction, ANIMATION_TYPE_APP_TRANSITION,
mFinishedCallback);
mController.goodToGo();
@@ -150,7 +150,7 @@ public class RemoteAnimationControllerTest extends WindowTestsBase {
public void testTimeout() throws Exception {
final WindowState win = createWindow(null /* parent */, TYPE_BASE_APPLICATION, "testWin");
final AnimationAdapter adapter = mController.createRemoteAnimationRecord(win.mActivityRecord,
new Point(50, 100), new Rect(50, 100, 150, 150), null).mAdapter;
new Point(50, 100), null, new Rect(50, 100, 150, 150), null).mAdapter;
adapter.startAnimation(mMockLeash, mMockTransaction, ANIMATION_TYPE_APP_TRANSITION,
mFinishedCallback);
mController.goodToGo();
@@ -170,7 +170,8 @@ public class RemoteAnimationControllerTest extends WindowTestsBase {
final WindowState win = createWindow(null /* parent */, TYPE_BASE_APPLICATION,
"testWin");
final AnimationAdapter adapter = mController.createRemoteAnimationRecord(
win.mActivityRecord, new Point(50, 100), new Rect(50, 100, 150, 150), null).mAdapter;
win.mActivityRecord, new Point(50, 100), null, new Rect(50, 100, 150, 150),
null).mAdapter;
adapter.startAnimation(mMockLeash, mMockTransaction, ANIMATION_TYPE_APP_TRANSITION,
mFinishedCallback);
mController.goodToGo();
@@ -201,7 +202,7 @@ public class RemoteAnimationControllerTest extends WindowTestsBase {
public void testNotReallyStarted() {
final WindowState win = createWindow(null /* parent */, TYPE_BASE_APPLICATION, "testWin");
mController.createRemoteAnimationRecord(win.mActivityRecord,
new Point(50, 100), new Rect(50, 100, 150, 150), null);
new Point(50, 100), null, new Rect(50, 100, 150, 150), null);
mController.goodToGo();
verifyNoMoreInteractionsExceptAsBinder(mMockRunner);
}
@@ -211,9 +212,9 @@ public class RemoteAnimationControllerTest extends WindowTestsBase {
final WindowState win1 = createWindow(null /* parent */, TYPE_BASE_APPLICATION, "testWin1");
final WindowState win2 = createWindow(null /* parent */, TYPE_BASE_APPLICATION, "testWin2");
mController.createRemoteAnimationRecord(win1.mActivityRecord,
new Point(50, 100), new Rect(50, 100, 150, 150), null);
new Point(50, 100), null, new Rect(50, 100, 150, 150), null);
final AnimationAdapter adapter = mController.createRemoteAnimationRecord(win2.mActivityRecord,
new Point(50, 100), new Rect(50, 100, 150, 150), null).mAdapter;
new Point(50, 100), null, new Rect(50, 100, 150, 150), null).mAdapter;
adapter.startAnimation(mMockLeash, mMockTransaction, ANIMATION_TYPE_APP_TRANSITION,
mFinishedCallback);
mController.goodToGo();
@@ -234,7 +235,7 @@ public class RemoteAnimationControllerTest extends WindowTestsBase {
public void testRemovedBeforeStarted() {
final WindowState win = createWindow(null /* parent */, TYPE_BASE_APPLICATION, "testWin");
final AnimationAdapter adapter = mController.createRemoteAnimationRecord(win.mActivityRecord,
new Point(50, 100), new Rect(50, 100, 150, 150), null).mAdapter;
new Point(50, 100), null, new Rect(50, 100, 150, 150), null).mAdapter;
adapter.startAnimation(mMockLeash, mMockTransaction, ANIMATION_TYPE_APP_TRANSITION,
mFinishedCallback);
win.mActivityRecord.removeImmediately();
@@ -250,7 +251,7 @@ public class RemoteAnimationControllerTest extends WindowTestsBase {
mDisplayContent.mChangingContainers.add(win.mActivityRecord);
try {
final RemoteAnimationRecord record = mController.createRemoteAnimationRecord(
win.mActivityRecord, new Point(50, 100), new Rect(50, 100, 150, 150),
win.mActivityRecord, new Point(50, 100), null, new Rect(50, 100, 150, 150),
new Rect(0, 0, 200, 200));
assertNotNull(record.mThumbnailAdapter);
((AnimationAdapter) record.mAdapter)
@@ -304,7 +305,7 @@ public class RemoteAnimationControllerTest extends WindowTestsBase {
mDisplayContent.mOpeningApps.add(win.mActivityRecord);
try {
final AnimationAdapter adapter = mController.createRemoteAnimationRecord(win.mActivityRecord,
new Point(50, 100), new Rect(50, 100, 150, 150), null).mAdapter;
new Point(50, 100), null, new Rect(50, 100, 150, 150), null).mAdapter;
adapter.startAnimation(mMockLeash, mMockTransaction, ANIMATION_TYPE_APP_TRANSITION,
mFinishedCallback);
mController.goodToGo();
@@ -333,7 +334,7 @@ public class RemoteAnimationControllerTest extends WindowTestsBase {
mDisplayContent.mOpeningApps.add(win.mActivityRecord);
try {
final AnimationAdapter adapter = mController.createRemoteAnimationRecord(win.mActivityRecord,
new Point(50, 100), new Rect(50, 100, 150, 150), null).mAdapter;
new Point(50, 100), null, new Rect(50, 100, 150, 150), null).mAdapter;
adapter.startAnimation(mMockLeash, mMockTransaction, ANIMATION_TYPE_APP_TRANSITION,
mFinishedCallback);
mController.goodToGo();