summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author chaviw <chaviw@google.com> 2018-04-04 15:14:49 -0700
committer chaviw <chaviw@google.com> 2018-04-10 18:11:19 -0700
commitbe43ac86865c8013bef120f1f327c2cfe98ebfe8 (patch)
treeccdf8e4b281121734c476950ca34370b67053a84
parent6f99da88db2e59bbfba82d079370130d4026ce12 (diff)
Synchronize stack position and size update for split screen
When entering split screen, the secondary window changes position so it's below the primary split screen when minimized. The WSA at the same time is also changing size to fit the area. However, the size doesn't change until the client requests a new size and a frame with the correct size comes in. This causes the stack to update position before the resize which causes content to get cut off and then a jump when the resize completes. This change updates the WSA position as soon as it recognizes that the stack changed position due to entering split screen secondary. The WSA sets its position as the negative of the stack position, making the calculated window position at (0,0). When a relayout is requested, the WSA's position is requested back to (0,0), deferring until the new frame. This will put the WSA position at (0,0) when a frame with the correct size is drawn. This places the window position at the stack's new position in the same transaction that a WSA frame with the new size is drawn. Change-Id: I8c88d7784f827d66926fb5c382af2346028dc48f Fixes: 74354855 Test: Entering split screen with quick step is smooth Test: Entering split screen with old launcher still works
-rw-r--r--config/boot-image-profile.txt4
-rw-r--r--config/hiddenapi-light-greylist.txt2
-rw-r--r--core/java/android/service/wallpaper/WallpaperService.java2
-rw-r--r--core/java/android/view/IWindowSession.aidl3
-rw-r--r--core/java/android/view/ViewRootImpl.java14
-rw-r--r--core/java/android/view/WindowManager.java13
-rw-r--r--services/core/java/com/android/server/am/ActivityStack.java42
-rw-r--r--services/core/java/com/android/server/wm/Session.java12
-rw-r--r--services/core/java/com/android/server/wm/TaskSnapshotSurface.java4
-rw-r--r--services/core/java/com/android/server/wm/TaskStack.java8
-rw-r--r--services/core/java/com/android/server/wm/WindowManagerService.java8
-rw-r--r--services/core/java/com/android/server/wm/WindowState.java15
-rw-r--r--services/core/java/com/android/server/wm/WindowStateAnimator.java51
-rw-r--r--tests/WindowManagerStressTest/src/test/windowmanagerstresstest/MainActivity.java2
14 files changed, 118 insertions, 62 deletions
diff --git a/config/boot-image-profile.txt b/config/boot-image-profile.txt
index 87fb99807ebc..7177336f3810 100644
--- a/config/boot-image-profile.txt
+++ b/config/boot-image-profile.txt
@@ -32326,7 +32326,7 @@ HSPLandroid/view/IWindowSession$Stub$Proxy;->finishDrawing(Landroid/view/IWindow
HSPLandroid/view/IWindowSession$Stub$Proxy;->getDisplayFrame(Landroid/view/IWindow;Landroid/graphics/Rect;)V
HSPLandroid/view/IWindowSession$Stub$Proxy;->getInTouchMode()Z
HSPLandroid/view/IWindowSession$Stub$Proxy;->onRectangleOnScreenRequested(Landroid/os/IBinder;Landroid/graphics/Rect;)V
-HSPLandroid/view/IWindowSession$Stub$Proxy;->relayout(Landroid/view/IWindow;ILandroid/view/WindowManager$LayoutParams;IIIILandroid/graphics/Rect;Landroid/graphics/Rect;Landroid/graphics/Rect;Landroid/graphics/Rect;Landroid/graphics/Rect;Landroid/graphics/Rect;Landroid/graphics/Rect;Landroid/util/MergedConfiguration;Landroid/view/Surface;)I
+HSPLandroid/view/IWindowSession$Stub$Proxy;->relayout(Landroid/view/IWindow;ILandroid/view/WindowManager$LayoutParams;IIIIJLandroid/graphics/Rect;Landroid/graphics/Rect;Landroid/graphics/Rect;Landroid/graphics/Rect;Landroid/graphics/Rect;Landroid/graphics/Rect;Landroid/graphics/Rect;Landroid/util/MergedConfiguration;Landroid/view/Surface;)I
HSPLandroid/view/IWindowSession$Stub$Proxy;->setInsets(Landroid/view/IWindow;ILandroid/graphics/Rect;Landroid/graphics/Rect;Landroid/graphics/Region;)V
HSPLandroid/view/IWindowSession$Stub$Proxy;->setTransparentRegion(Landroid/view/IWindow;Landroid/graphics/Region;)V
HSPLandroid/view/IWindowSession$Stub$Proxy;->setWallpaperPosition(Landroid/os/IBinder;FFFF)V
@@ -32349,7 +32349,7 @@ HSPLandroid/view/IWindowSession;->performHapticFeedback(Landroid/view/IWindow;IZ
HSPLandroid/view/IWindowSession;->pokeDrawLock(Landroid/os/IBinder;)V
HSPLandroid/view/IWindowSession;->prepareDrag(Landroid/view/IWindow;IIILandroid/view/Surface;)Landroid/os/IBinder;
HSPLandroid/view/IWindowSession;->prepareToReplaceWindows(Landroid/os/IBinder;Z)V
-HSPLandroid/view/IWindowSession;->relayout(Landroid/view/IWindow;ILandroid/view/WindowManager$LayoutParams;IIIILandroid/graphics/Rect;Landroid/graphics/Rect;Landroid/graphics/Rect;Landroid/graphics/Rect;Landroid/graphics/Rect;Landroid/graphics/Rect;Landroid/graphics/Rect;Landroid/util/MergedConfiguration;Landroid/view/Surface;)I
+HSPLandroid/view/IWindowSession;->relayout(Landroid/view/IWindow;ILandroid/view/WindowManager$LayoutParams;IIIIJLandroid/graphics/Rect;Landroid/graphics/Rect;Landroid/graphics/Rect;Landroid/graphics/Rect;Landroid/graphics/Rect;Landroid/graphics/Rect;Landroid/graphics/Rect;Landroid/util/MergedConfiguration;Landroid/view/Surface;)I
HSPLandroid/view/IWindowSession;->remove(Landroid/view/IWindow;)V
HSPLandroid/view/IWindowSession;->reportDropResult(Landroid/view/IWindow;Z)V
HSPLandroid/view/IWindowSession;->sendWallpaperCommand(Landroid/os/IBinder;Ljava/lang/String;IIILandroid/os/Bundle;Z)Landroid/os/Bundle;
diff --git a/config/hiddenapi-light-greylist.txt b/config/hiddenapi-light-greylist.txt
index a40ea0857b70..080c9c7a0c2a 100644
--- a/config/hiddenapi-light-greylist.txt
+++ b/config/hiddenapi-light-greylist.txt
@@ -2164,7 +2164,7 @@ Landroid/view/IWindowManager$Stub$Proxy;->getDockedStackSide()I
Landroid/view/IWindowManager$Stub$Proxy;->getInitialDisplayDensity(I)I
Landroid/view/IWindowManager$Stub$Proxy;->hasNavigationBar()Z
Landroid/view/IWindowManager$Stub$Proxy;-><init>(Landroid/os/IBinder;)V
-Landroid/view/IWindowSession$Stub$Proxy;->relayout(Landroid/view/IWindow;ILandroid/view/WindowManager$LayoutParams;IIIILandroid/graphics/Rect;Landroid/graphics/Rect;Landroid/graphics/Rect;Landroid/graphics/Rect;Landroid/graphics/Rect;Landroid/graphics/Rect;Landroid/graphics/Rect;Landroid/view/DisplayCutout$ParcelableWrapper;Landroid/util/MergedConfiguration;Landroid/view/Surface;)I
+Landroid/view/IWindowSession$Stub$Proxy;->relayout(Landroid/view/IWindow;ILandroid/view/WindowManager$LayoutParams;IIIIJLandroid/graphics/Rect;Landroid/graphics/Rect;Landroid/graphics/Rect;Landroid/graphics/Rect;Landroid/graphics/Rect;Landroid/graphics/Rect;Landroid/graphics/Rect;Landroid/view/DisplayCutout$ParcelableWrapper;Landroid/util/MergedConfiguration;Landroid/view/Surface;)I
Landroid/view/KeyCharacterMap$FallbackAction;->keyCode:I
Landroid/view/KeyCharacterMap$FallbackAction;->metaState:I
Landroid/view/KeyCharacterMap;-><init>(J)V
diff --git a/core/java/android/service/wallpaper/WallpaperService.java b/core/java/android/service/wallpaper/WallpaperService.java
index a1327301da67..7f75f0a68660 100644
--- a/core/java/android/service/wallpaper/WallpaperService.java
+++ b/core/java/android/service/wallpaper/WallpaperService.java
@@ -813,7 +813,7 @@ public abstract class WallpaperService extends Service {
}
final int relayoutResult = mSession.relayout(
mWindow, mWindow.mSeq, mLayout, mWidth, mHeight,
- View.VISIBLE, 0, mWinFrame, mOverscanInsets, mContentInsets,
+ View.VISIBLE, 0, -1, mWinFrame, mOverscanInsets, mContentInsets,
mVisibleInsets, mStableInsets, mOutsets, mBackdropFrame,
mDisplayCutout, mMergedConfiguration, mSurfaceHolder.mSurface);
diff --git a/core/java/android/view/IWindowSession.aidl b/core/java/android/view/IWindowSession.aidl
index d8a5609a3c98..f868a00f0359 100644
--- a/core/java/android/view/IWindowSession.aidl
+++ b/core/java/android/view/IWindowSession.aidl
@@ -66,6 +66,7 @@ interface IWindowSession {
* @param viewVisibility Window root view's visibility.
* @param flags Request flags: {@link WindowManagerGlobal#RELAYOUT_INSETS_PENDING},
* {@link WindowManagerGlobal#RELAYOUT_DEFER_SURFACE_DESTROY}.
+ * @param frameNumber A frame number in which changes requested in this layout will be rendered.
* @param outFrame Rect in which is placed the new position/size on
* screen.
* @param outOverscanInsets Rect in which is placed the offsets from
@@ -96,7 +97,7 @@ interface IWindowSession {
*/
int relayout(IWindow window, int seq, in WindowManager.LayoutParams attrs,
int requestedWidth, int requestedHeight, int viewVisibility,
- int flags, out Rect outFrame, out Rect outOverscanInsets,
+ int flags, long frameNumber, out Rect outFrame, out Rect outOverscanInsets,
out Rect outContentInsets, out Rect outVisibleInsets, out Rect outStableInsets,
out Rect outOutsets, out Rect outBackdropFrame,
out DisplayCutout.ParcelableWrapper displayCutout,
diff --git a/core/java/android/view/ViewRootImpl.java b/core/java/android/view/ViewRootImpl.java
index e802232bae33..6d48b653c70c 100644
--- a/core/java/android/view/ViewRootImpl.java
+++ b/core/java/android/view/ViewRootImpl.java
@@ -6482,17 +6482,17 @@ public final class ViewRootImpl implements ViewParent,
params.type = mOrigWindowType;
}
}
+ }
- if (mSurface.isValid()) {
- params.frameNumber = mSurface.getNextFrameNumber();
- }
+ long frameNumber = -1;
+ if (mSurface.isValid()) {
+ frameNumber = mSurface.getNextFrameNumber();
}
- int relayoutResult = mWindowSession.relayout(
- mWindow, mSeq, params,
+ int relayoutResult = mWindowSession.relayout(mWindow, mSeq, params,
(int) (mView.getMeasuredWidth() * appScale + 0.5f),
- (int) (mView.getMeasuredHeight() * appScale + 0.5f),
- viewVisibility, insetsPending ? WindowManagerGlobal.RELAYOUT_INSETS_PENDING : 0,
+ (int) (mView.getMeasuredHeight() * appScale + 0.5f), viewVisibility,
+ insetsPending ? WindowManagerGlobal.RELAYOUT_INSETS_PENDING : 0, frameNumber,
mWinFrame, mPendingOverscanInsets, mPendingContentInsets, mPendingVisibleInsets,
mPendingStableInsets, mPendingOutsets, mPendingBackDropFrame, mPendingDisplayCutout,
mPendingMergedConfiguration, mSurface);
diff --git a/core/java/android/view/WindowManager.java b/core/java/android/view/WindowManager.java
index f6181d701946..0f5c23f7c858 100644
--- a/core/java/android/view/WindowManager.java
+++ b/core/java/android/view/WindowManager.java
@@ -2438,13 +2438,6 @@ public interface WindowManager extends ViewManager {
public long hideTimeoutMilliseconds = -1;
/**
- * A frame number in which changes requested in this layout will be rendered.
- *
- * @hide
- */
- public long frameNumber = -1;
-
- /**
* The color mode requested by this window. The target display may
* not be able to honor the request. When the color mode is not set
* to {@link ActivityInfo#COLOR_MODE_DEFAULT}, it might override the
@@ -2617,7 +2610,6 @@ public interface WindowManager extends ViewManager {
TextUtils.writeToParcel(accessibilityTitle, out, parcelableFlags);
out.writeInt(mColorMode);
out.writeLong(hideTimeoutMilliseconds);
- out.writeLong(frameNumber);
}
public static final Parcelable.Creator<LayoutParams> CREATOR
@@ -2674,7 +2666,6 @@ public interface WindowManager extends ViewManager {
accessibilityTitle = TextUtils.CHAR_SEQUENCE_CREATOR.createFromParcel(in);
mColorMode = in.readInt();
hideTimeoutMilliseconds = in.readLong();
- frameNumber = in.readLong();
}
@SuppressWarnings({"PointlessBitwiseExpression"})
@@ -2875,10 +2866,6 @@ public interface WindowManager extends ViewManager {
changes |= SURFACE_INSETS_CHANGED;
}
- // The frame number changing is only relevant in the context of other
- // changes, and so we don't need to track it with a flag.
- frameNumber = o.frameNumber;
-
if (hasManualSurfaceInsets != o.hasManualSurfaceInsets) {
hasManualSurfaceInsets = o.hasManualSurfaceInsets;
changes |= SURFACE_INSETS_CHANGED;
diff --git a/services/core/java/com/android/server/am/ActivityStack.java b/services/core/java/com/android/server/am/ActivityStack.java
index 649d5770f6a9..92801569f8b6 100644
--- a/services/core/java/com/android/server/am/ActivityStack.java
+++ b/services/core/java/com/android/server/am/ActivityStack.java
@@ -4752,30 +4752,32 @@ class ActivityStack<T extends StackWindowController> extends ConfigurationContai
mTmpBounds.clear();
mTmpInsetBounds.clear();
- for (int i = mTaskHistory.size() - 1; i >= 0; i--) {
- final TaskRecord task = mTaskHistory.get(i);
- if (task.isResizeable()) {
- if (inFreeformWindowingMode()) {
- // TODO: Can be removed now since each freeform task is in its own stack.
- // For freeform stack we don't adjust the size of the tasks to match that
- // of the stack, but we do try to make sure the tasks are still contained
- // with the bounds of the stack.
- mTmpRect2.set(task.getOverrideBounds());
- fitWithinBounds(mTmpRect2, bounds);
- task.updateOverrideConfiguration(mTmpRect2);
- } else {
- task.updateOverrideConfiguration(taskBounds, insetBounds);
+ synchronized (mWindowManager.getWindowManagerLock()) {
+ for (int i = mTaskHistory.size() - 1; i >= 0; i--) {
+ final TaskRecord task = mTaskHistory.get(i);
+ if (task.isResizeable()) {
+ if (inFreeformWindowingMode()) {
+ // TODO: Can be removed now since each freeform task is in its own stack.
+ // For freeform stack we don't adjust the size of the tasks to match that
+ // of the stack, but we do try to make sure the tasks are still contained
+ // with the bounds of the stack.
+ mTmpRect2.set(task.getOverrideBounds());
+ fitWithinBounds(mTmpRect2, bounds);
+ task.updateOverrideConfiguration(mTmpRect2);
+ } else {
+ task.updateOverrideConfiguration(taskBounds, insetBounds);
+ }
}
- }
- mTmpBounds.put(task.taskId, task.getOverrideBounds());
- if (tempTaskInsetBounds != null) {
- mTmpInsetBounds.put(task.taskId, tempTaskInsetBounds);
+ mTmpBounds.put(task.taskId, task.getOverrideBounds());
+ if (tempTaskInsetBounds != null) {
+ mTmpInsetBounds.put(task.taskId, tempTaskInsetBounds);
+ }
}
- }
- mWindowContainerController.resize(bounds, mTmpBounds, mTmpInsetBounds);
- setBounds(bounds);
+ mWindowContainerController.resize(bounds, mTmpBounds, mTmpInsetBounds);
+ setBounds(bounds);
+ }
}
diff --git a/services/core/java/com/android/server/wm/Session.java b/services/core/java/com/android/server/wm/Session.java
index 662d51d6e0e5..8693b3630329 100644
--- a/services/core/java/com/android/server/wm/Session.java
+++ b/services/core/java/com/android/server/wm/Session.java
@@ -233,16 +233,16 @@ class Session extends IWindowSession.Stub implements IBinder.DeathRecipient {
@Override
public int relayout(IWindow window, int seq, WindowManager.LayoutParams attrs,
- int requestedWidth, int requestedHeight, int viewFlags,
- int flags, Rect outFrame, Rect outOverscanInsets, Rect outContentInsets,
- Rect outVisibleInsets, Rect outStableInsets, Rect outsets, Rect outBackdropFrame,
- DisplayCutout.ParcelableWrapper cutout,
- MergedConfiguration mergedConfiguration, Surface outSurface) {
+ int requestedWidth, int requestedHeight, int viewFlags, int flags, long frameNumber,
+ Rect outFrame, Rect outOverscanInsets, Rect outContentInsets, Rect outVisibleInsets,
+ Rect outStableInsets, Rect outsets, Rect outBackdropFrame,
+ DisplayCutout.ParcelableWrapper cutout, MergedConfiguration mergedConfiguration,
+ Surface outSurface) {
if (false) Slog.d(TAG_WM, ">>>>>> ENTERED relayout from "
+ Binder.getCallingPid());
Trace.traceBegin(TRACE_TAG_WINDOW_MANAGER, mRelayoutTag);
int res = mService.relayoutWindow(this, window, seq, attrs,
- requestedWidth, requestedHeight, viewFlags, flags,
+ requestedWidth, requestedHeight, viewFlags, flags, frameNumber,
outFrame, outOverscanInsets, outContentInsets, outVisibleInsets,
outStableInsets, outsets, outBackdropFrame, cutout,
mergedConfiguration, outSurface);
diff --git a/services/core/java/com/android/server/wm/TaskSnapshotSurface.java b/services/core/java/com/android/server/wm/TaskSnapshotSurface.java
index 597b39eaf826..5721bd89b068 100644
--- a/services/core/java/com/android/server/wm/TaskSnapshotSurface.java
+++ b/services/core/java/com/android/server/wm/TaskSnapshotSurface.java
@@ -215,8 +215,8 @@ class TaskSnapshotSurface implements StartingSurface {
currentOrientation);
window.setOuter(snapshotSurface);
try {
- session.relayout(window, window.mSeq, layoutParams, -1, -1, View.VISIBLE, 0, tmpFrame,
- tmpRect, tmpContentInsets, tmpRect, tmpStableInsets, tmpRect, tmpRect,
+ session.relayout(window, window.mSeq, layoutParams, -1, -1, View.VISIBLE, 0, -1,
+ tmpFrame, tmpRect, tmpContentInsets, tmpRect, tmpStableInsets, tmpRect, tmpRect,
tmpCutout, tmpMergedConfiguration, surface);
} catch (RemoteException e) {
// Local call.
diff --git a/services/core/java/com/android/server/wm/TaskStack.java b/services/core/java/com/android/server/wm/TaskStack.java
index 2175c6be5b5f..1fe32941289e 100644
--- a/services/core/java/com/android/server/wm/TaskStack.java
+++ b/services/core/java/com/android/server/wm/TaskStack.java
@@ -827,6 +827,14 @@ public class TaskStack extends WindowContainer<Task> implements
}
}
+ if (inSplitScreenSecondaryWindowingMode()) {
+ // When the stack is resized due to entering split screen secondary, offset the
+ // windows to compensate for the new stack position.
+ forAllWindows(w -> {
+ w.mWinAnimator.setOffsetPositionForStackResize(true);
+ }, true);
+ }
+
updateDisplayInfo(bounds);
updateSurfaceBounds();
}
diff --git a/services/core/java/com/android/server/wm/WindowManagerService.java b/services/core/java/com/android/server/wm/WindowManagerService.java
index fa7eff261409..2294b6be77aa 100644
--- a/services/core/java/com/android/server/wm/WindowManagerService.java
+++ b/services/core/java/com/android/server/wm/WindowManagerService.java
@@ -1831,10 +1831,9 @@ public class WindowManagerService extends IWindowManager.Stub
}
}
- public int relayoutWindow(Session session, IWindow client, int seq,
- LayoutParams attrs, int requestedWidth,
- int requestedHeight, int viewVisibility, int flags,
- Rect outFrame, Rect outOverscanInsets, Rect outContentInsets,
+ public int relayoutWindow(Session session, IWindow client, int seq, LayoutParams attrs,
+ int requestedWidth, int requestedHeight, int viewVisibility, int flags,
+ long frameNumber, Rect outFrame, Rect outOverscanInsets, Rect outContentInsets,
Rect outVisibleInsets, Rect outStableInsets, Rect outOutsets, Rect outBackdropFrame,
DisplayCutout.ParcelableWrapper outCutout, MergedConfiguration mergedConfiguration,
Surface outSurface) {
@@ -1861,6 +1860,7 @@ public class WindowManagerService extends IWindowManager.Stub
win.setRequestedSize(requestedWidth, requestedHeight);
}
+ win.setFrameNumber(frameNumber);
int attrChanges = 0;
int flagChanges = 0;
if (attrs != null) {
diff --git a/services/core/java/com/android/server/wm/WindowState.java b/services/core/java/com/android/server/wm/WindowState.java
index c5269e172f2a..da5bc73e869e 100644
--- a/services/core/java/com/android/server/wm/WindowState.java
+++ b/services/core/java/com/android/server/wm/WindowState.java
@@ -636,6 +636,11 @@ class WindowState extends WindowContainer<WindowState> implements WindowManagerP
private PowerManagerWrapper mPowerManagerWrapper;
/**
+ * A frame number in which changes requested in this layout will be rendered.
+ */
+ private long mFrameNumber = -1;
+
+ /**
* Compares two window sub-layers and returns -1 if the first is lesser than the second in terms
* of z-order and 1 otherwise.
*/
@@ -4655,7 +4660,7 @@ class WindowState extends WindowContainer<WindowState> implements WindowManagerP
mLastSurfaceInsets.set(mAttrs.surfaceInsets);
t.deferTransactionUntil(mSurfaceControl,
mWinAnimator.mSurfaceController.mSurfaceControl.getHandle(),
- mAttrs.frameNumber);
+ getFrameNumber());
}
}
}
@@ -4771,6 +4776,14 @@ class WindowState extends WindowContainer<WindowState> implements WindowManagerP
return mService.mInputMethodTarget == this;
}
+ long getFrameNumber() {
+ return mFrameNumber;
+ }
+
+ void setFrameNumber(long frameNumber) {
+ mFrameNumber = frameNumber;
+ }
+
private final class MoveAnimationSpec implements AnimationSpec {
private final long mDuration;
diff --git a/services/core/java/com/android/server/wm/WindowStateAnimator.java b/services/core/java/com/android/server/wm/WindowStateAnimator.java
index e92d460f2ec6..ab5e24ac5999 100644
--- a/services/core/java/com/android/server/wm/WindowStateAnimator.java
+++ b/services/core/java/com/android/server/wm/WindowStateAnimator.java
@@ -67,7 +67,6 @@ import android.view.animation.AnimationUtils;
import com.android.server.policy.WindowManagerPolicy;
-import java.io.FileDescriptor;
import java.io.PrintWriter;
/**
@@ -217,6 +216,12 @@ class WindowStateAnimator {
int mXOffset = 0;
int mYOffset = 0;
+ /**
+ * A flag to determine if the WSA needs to offset its position to compensate for the stack's
+ * position update before the WSA surface has resized.
+ */
+ private boolean mOffsetPositionForStackResize;
+
private final Rect mTmpSize = new Rect();
private final SurfaceControl.Transaction mReparentTransaction = new SurfaceControl.Transaction();
@@ -230,6 +235,8 @@ class WindowStateAnimator {
// once per animation.
boolean mPipAnimationStarted = false;
+ private final Point mTmpPos = new Point();
+
WindowStateAnimator(final WindowState win) {
final WindowManagerService service = win.mService;
@@ -498,6 +505,8 @@ class WindowStateAnimator {
mSurfaceController = new WindowSurfaceController(mSession.mSurfaceSession,
attrs.getTitle().toString(), width, height, format, flags, this,
windowType, ownerUid);
+
+ setOffsetPositionForStackResize(false);
mSurfaceFormat = format;
w.setHasSurface(true);
@@ -859,7 +868,8 @@ class WindowStateAnimator {
// However, this would be unsafe, as the client may be in the middle
// of producing a frame at the old size, having just completed layout
// to find the surface size changed underneath it.
- if (!w.mRelayoutCalled || w.mInRelayout) {
+ final boolean relayout = !w.mRelayoutCalled || w.mInRelayout;
+ if (relayout) {
mSurfaceResized = mSurfaceController.setSizeInTransaction(
mTmpSize.width(), mTmpSize.height(), recoveringMemory);
} else {
@@ -996,7 +1006,38 @@ class WindowStateAnimator {
mPipAnimationStarted = false;
if (!w.mSeamlesslyRotated) {
- mSurfaceController.setPositionInTransaction(mXOffset, mYOffset, recoveringMemory);
+ // Used to offset the WSA when stack position changes before a resize.
+ int xOffset = mXOffset;
+ int yOffset = mYOffset;
+ if (mOffsetPositionForStackResize) {
+ if (relayout) {
+ // Once a relayout is called, reset the offset back to 0 and defer
+ // setting it until a new frame with the updated size. This ensures that
+ // the WS position is reset (so the stack position is shown) at the same
+ // time that the buffer size changes.
+ setOffsetPositionForStackResize(false);
+ mSurfaceController.deferTransactionUntil(mSurfaceController.getHandle(),
+ mWin.getFrameNumber());
+ } else {
+ final TaskStack stack = mWin.getStack();
+ mTmpPos.x = 0;
+ mTmpPos.y = 0;
+ if (stack != null) {
+ stack.getRelativePosition(mTmpPos);
+ }
+
+ xOffset = -mTmpPos.x;
+ yOffset = -mTmpPos.y;
+
+ // Crop also needs to be extended so the bottom isn't cut off when the WSA
+ // position is moved.
+ if (clipRect != null) {
+ clipRect.right += mTmpPos.x;
+ clipRect.bottom += mTmpPos.y;
+ }
+ }
+ }
+ mSurfaceController.setPositionInTransaction(xOffset, yOffset, recoveringMemory);
}
}
@@ -1499,4 +1540,8 @@ class WindowStateAnimator {
int getLayer() {
return mLastLayer;
}
+
+ void setOffsetPositionForStackResize(boolean offsetPositionForStackResize) {
+ mOffsetPositionForStackResize = offsetPositionForStackResize;
+ }
}
diff --git a/tests/WindowManagerStressTest/src/test/windowmanagerstresstest/MainActivity.java b/tests/WindowManagerStressTest/src/test/windowmanagerstresstest/MainActivity.java
index 9174014dedf4..ae3914ebf162 100644
--- a/tests/WindowManagerStressTest/src/test/windowmanagerstresstest/MainActivity.java
+++ b/tests/WindowManagerStressTest/src/test/windowmanagerstresstest/MainActivity.java
@@ -102,7 +102,7 @@ public class MainActivity extends Activity {
Thread t = new Thread(() -> {
try {
WindowManagerGlobal.getWindowSession().relayout(window,
- window.mSeq, mLayoutParams, -1, -1, View.VISIBLE, 0, mTmpRect,
+ window.mSeq, mLayoutParams, -1, -1, View.VISIBLE, 0, -1, mTmpRect,
mTmpRect, mTmpRect, mTmpRect, mTmpRect, mTmpRect, mTmpRect,
new DisplayCutout.ParcelableWrapper(), new MergedConfiguration(),
new Surface());