From b46c4feb66d0e80df8225e6a3775d78f5e2fedcf Mon Sep 17 00:00:00 2001 From: lumark Date: Mon, 16 Mar 2020 19:24:01 +0800 Subject: [PATCH] Fix ActivityRecord#attachCrossProfileAppsThumbnailAnimation issue Since Cross-Profile app thumbnail animation is an transparent animation layer which should be above SnapShotStartWindow (attached in ActivityRecord), and the layer should be attached in its root task. Also, use getRelativeFrameLw to get relative position of its parent for thumbnail surface. Fix: 149692548 Test: manual as below steps: 1. Create a work profile (e.g. via TestDPC - go/testdpc) 2. Launch a personal app that supports the CrossProfileApps API (e.g. Gmail), ensuring that said app is also installed in the work profile 3. Tap "Switch to work profile" Expecting Profile switching animation background to be semi-transparent Change-Id: Ib19f669fac891f1d9d7aa765db89538057dd6318 --- .../core/java/com/android/server/wm/ActivityRecord.java | 8 ++++---- .../com/android/server/wm/WindowContainerThumbnail.java | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/services/core/java/com/android/server/wm/ActivityRecord.java b/services/core/java/com/android/server/wm/ActivityRecord.java index e73c928ef925f..6c31138c00073 100644 --- a/services/core/java/com/android/server/wm/ActivityRecord.java +++ b/services/core/java/com/android/server/wm/ActivityRecord.java @@ -5931,7 +5931,7 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A if (win == null) { return; } - final Rect frame = win.getFrameLw(); + final Rect frame = win.getRelativeFrameLw(); final int thumbnailDrawableRes = task.mUserId == mWmService.mCurrentUserId ? R.drawable.ic_account_circle : R.drawable.ic_corp_badge; @@ -5941,12 +5941,12 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A if (thumbnail == null) { return; } - final Transaction transaction = getAnimatingContainer().getPendingTransaction(); + final Transaction transaction = getPendingTransaction(); mThumbnail = new WindowContainerThumbnail(mWmService.mSurfaceFactory, - transaction, getAnimatingContainer(), thumbnail); + transaction, getTask(), thumbnail); final Animation animation = getDisplayContent().mAppTransition.createCrossProfileAppsThumbnailAnimationLocked( - win.getFrameLw()); + frame); mThumbnail.startAnimation(transaction, animation, new Point(frame.left, frame.top)); } diff --git a/services/core/java/com/android/server/wm/WindowContainerThumbnail.java b/services/core/java/com/android/server/wm/WindowContainerThumbnail.java index 90e3be74c7436..a27a112597728 100644 --- a/services/core/java/com/android/server/wm/WindowContainerThumbnail.java +++ b/services/core/java/com/android/server/wm/WindowContainerThumbnail.java @@ -97,7 +97,7 @@ class WindowContainerThumbnail implements Animatable { // TODO: This should be attached as a child to the app token, once the thumbnail animations // use relative coordinates. Once we start animating task we can also consider attaching // this to the task. - mSurfaceControl = mWindowContainer.makeSurface() + mSurfaceControl = mWindowContainer.makeChildSurface(mWindowContainer.getTopChild()) .setName("thumbnail anim: " + mWindowContainer.toString()) .setBufferSize(mWidth, mHeight) .setFormat(PixelFormat.TRANSLUCENT) @@ -209,7 +209,7 @@ class WindowContainerThumbnail implements Animatable { @Override public Builder makeAnimationLeash() { - return mWindowContainer.makeSurface(); + return mWindowContainer.makeChildSurface(mWindowContainer.getTopChild()); } @Override