Skip to content

Commit

Permalink
Merge "Clean-up displayed-bounds" into rvc-dev
Browse files Browse the repository at this point in the history
  • Loading branch information
Evan Rosky authored and Android (Google) Code Review committed Apr 16, 2020
2 parents 64ea0ed + 6ecd67c commit 2556dbf
Show file tree
Hide file tree
Showing 12 changed files with 26 additions and 214 deletions.
2 changes: 1 addition & 1 deletion core/proto/android/server/windowmanagerservice.proto
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@ message TaskProto {
reserved 3; // activity
optional bool fills_parent = 4;
optional .android.graphics.RectProto bounds = 5;
optional .android.graphics.RectProto displayed_bounds = 6;
optional .android.graphics.RectProto displayed_bounds = 6 [deprecated=true];
optional bool defer_removal = 7;
optional int32 surface_width = 8;
optional int32 surface_height = 9;
Expand Down
15 changes: 2 additions & 13 deletions services/core/java/com/android/server/wm/ActivityRecord.java
Original file line number Diff line number Diff line change
Expand Up @@ -1374,8 +1374,8 @@ void layoutLetterbox(WindowState winHint) {
final Rect spaceToFill = transformedBounds != null
? transformedBounds
: inMultiWindowMode()
? task.getDisplayedBounds()
: getRootTask().getParent().getDisplayedBounds();
? task.getBounds()
: getRootTask().getParent().getBounds();
mLetterbox.layout(spaceToFill, w.getFrameLw(), mTmpPoint);
} else if (mLetterbox != null) {
mLetterbox.hide();
Expand Down Expand Up @@ -6663,17 +6663,6 @@ public Rect getBounds() {
return super.getBounds();
}

@Override
Rect getDisplayedBounds() {
if (task != null) {
final Rect overrideDisplayedBounds = task.getOverrideDisplayedBounds();
if (!overrideDisplayedBounds.isEmpty()) {
return overrideDisplayedBounds;
}
}
return getBounds();
}

@VisibleForTesting
@Override
Rect getAnimationBounds(int appStackClipMode) {
Expand Down
49 changes: 9 additions & 40 deletions services/core/java/com/android/server/wm/ActivityStack.java
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,6 @@
import static com.android.server.wm.TaskProto.BOUNDS;
import static com.android.server.wm.TaskProto.CREATED_BY_ORGANIZER;
import static com.android.server.wm.TaskProto.DEFER_REMOVAL;
import static com.android.server.wm.TaskProto.DISPLAYED_BOUNDS;
import static com.android.server.wm.TaskProto.DISPLAY_ID;
import static com.android.server.wm.TaskProto.FILLS_PARENT;
import static com.android.server.wm.TaskProto.LAST_NON_FULLSCREEN_BOUNDS;
Expand Down Expand Up @@ -660,8 +659,7 @@ public void onConfigurationChanged(Configuration newParentConfig) {
setBounds(newBounds);
} else if (overrideWindowingMode != WINDOWING_MODE_PINNED) {
// For pinned stack, resize is now part of the {@link WindowContainerTransaction}
resize(new Rect(newBounds), null /* configBounds */,
PRESERVE_WINDOWS, true /* deferResume */);
resize(new Rect(newBounds), PRESERVE_WINDOWS, true /* deferResume */);
}
}
if (prevIsAlwaysOnTop != isAlwaysOnTop()) {
Expand Down Expand Up @@ -835,8 +833,7 @@ && isActivityTypeStandardOrUndefined()) {
}

if (!Objects.equals(getRequestedOverrideBounds(), mTmpRect2)) {
resize(mTmpRect2, null /*configBounds*/,
false /*preserveWindows*/, true /*deferResume*/);
resize(mTmpRect2, false /*preserveWindows*/, true /*deferResume*/);
}
} finally {
mAtmService.continueWindowLayout();
Expand Down Expand Up @@ -894,9 +891,6 @@ void continueUpdateBounds() {
setTaskBounds(mDeferredBounds);
setBounds(mDeferredBounds);
}
if (mUpdateDisplayedBoundsDeferredCalled) {
setTaskDisplayedBounds(mDeferredDisplayedBounds);
}
}
}

Expand Down Expand Up @@ -2966,8 +2960,7 @@ void ensureVisibleActivitiesConfiguration(ActivityRecord start, boolean preserve

// TODO: Can only be called from special methods in ActivityStackSupervisor.
// Need to consolidate those calls points into this resize method so anyone can call directly.
void resize(Rect displayedBounds, Rect configBounds, boolean preserveWindows,
boolean deferResume) {
void resize(Rect displayedBounds, boolean preserveWindows, boolean deferResume) {
if (!updateBoundsAllowed(displayedBounds)) {
return;
}
Expand All @@ -2979,7 +2972,7 @@ void resize(Rect displayedBounds, Rect configBounds, boolean preserveWindows,
// Update override configurations of all tasks in the stack.
final PooledConsumer c = PooledLambda.obtainConsumer(
ActivityStack::processTaskResizeBounds, PooledLambda.__(Task.class),
displayedBounds, configBounds);
displayedBounds);
forAllTasks(c, true /* traverseTopToBottom */);
c.recycle();

Expand All @@ -3000,17 +2993,10 @@ void resize(Rect displayedBounds, Rect configBounds, boolean preserveWindows,
}
}

private static void processTaskResizeBounds(
Task task, Rect displayedBounds, Rect configBounds) {
private static void processTaskResizeBounds(Task task, Rect displayedBounds) {
if (!task.isResizeable()) return;

if (configBounds != null && !configBounds.isEmpty()) {
task.setOverrideDisplayedBounds(displayedBounds);
task.setBounds(configBounds);
} else {
task.setOverrideDisplayedBounds(null);
task.setBounds(displayedBounds);
}
task.setBounds(displayedBounds);
}

/**
Expand All @@ -3032,22 +3018,6 @@ private static void setTaskBounds(Task task, Rect bounds) {
task.setBounds(task.isResizeable() ? bounds : null);
}

/** Helper to setDisplayedBounds on all child tasks */
private void setTaskDisplayedBounds(Rect bounds) {
if (!updateDisplayedBoundsAllowed(bounds)) {
return;
}

final PooledConsumer c = PooledLambda.obtainConsumer(ActivityStack::setTaskDisplayedBounds,
PooledLambda.__(Task.class), bounds);
forAllLeafTasks(c, true /* traverseTopToBottom */);
c.recycle();
}

private static void setTaskDisplayedBounds(Task task, Rect bounds) {
task.setOverrideDisplayedBounds(bounds == null || bounds.isEmpty() ? null : bounds);
}

/**
* Returns the top-most activity that occludes the given one, or @{code null} if none.
*/
Expand Down Expand Up @@ -3569,8 +3539,8 @@ int getStackOutset() {
}

@Override
void getRelativeDisplayedPosition(Point outPos) {
super.getRelativeDisplayedPosition(outPos);
void getRelativePosition(Point outPos) {
super.getRelativePosition(outPos);
final int outset = getStackOutset();
outPos.x -= outset;
outPos.y -= outset;
Expand All @@ -3581,7 +3551,7 @@ private void updateSurfaceSize(SurfaceControl.Transaction transaction) {
return;
}

final Rect stackBounds = getDisplayedBounds();
final Rect stackBounds = getBounds();
int width = stackBounds.width();
int height = stackBounds.height();

Expand Down Expand Up @@ -3776,7 +3746,6 @@ public void dumpDebug(ProtoOutputStream proto, long fieldId,
proto.write(FILLS_PARENT, matchParentBounds());
getRawBounds().dumpDebug(proto, BOUNDS);

getOverrideDisplayedBounds().dumpDebug(proto, DISPLAYED_BOUNDS);
if (mLastNonFullscreenBounds != null) {
mLastNonFullscreenBounds.dumpDebug(proto, LAST_NON_FULLSCREEN_BOUNDS);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1357,7 +1357,7 @@ void findTaskToMoveToFront(Task task, int flags, ActivityOptions options, String
// still need moveTaskToFrontLocked() below for any transition settings.
}
if (stack.shouldResizeStackWithLaunchBounds()) {
stack.resize(bounds, null /* configBounds */, !PRESERVE_WINDOWS, !DEFER_RESUME);
stack.resize(bounds, !PRESERVE_WINDOWS, !DEFER_RESUME);
} else {
// WM resizeTask must be done after the task is moved to the correct stack,
// because Task's setBounds() also updates dim layer's bounds, but that has
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -898,11 +898,11 @@ class TaskAnimationAdapter implements AnimationAdapter {
TaskAnimationAdapter(Task task, boolean isRecentTaskInvisible) {
mTask = task;
mIsRecentTaskInvisible = isRecentTaskInvisible;
mBounds.set(mTask.getDisplayedBounds());
mBounds.set(mTask.getBounds());

mLocalBounds.set(mBounds);
Point tmpPos = new Point();
mTask.getRelativeDisplayedPosition(tmpPos);
mTask.getRelativePosition(tmpPos);
mLocalBounds.offsetTo(tmpPos.x, tmpPos.y);
}

Expand Down
72 changes: 0 additions & 72 deletions services/core/java/com/android/server/wm/Task.java
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@
import static android.content.pm.ActivityInfo.RESIZE_MODE_RESIZEABLE_AND_PIPABLE_DEPRECATED;
import static android.content.pm.ActivityInfo.RESIZE_MODE_RESIZEABLE_VIA_SDK_VERSION;
import static android.content.pm.ActivityInfo.SCREEN_ORIENTATION_UNSET;
import static android.content.res.Configuration.EMPTY;
import static android.content.res.Configuration.ORIENTATION_LANDSCAPE;
import static android.content.res.Configuration.ORIENTATION_PORTRAIT;
import static android.content.res.Configuration.ORIENTATION_UNDEFINED;
Expand Down Expand Up @@ -353,10 +352,6 @@ class Task extends WindowContainer<WindowContainer> {
final Rect mPreparedFrozenBounds = new Rect();
final Configuration mPreparedFrozenMergedConfig = new Configuration();

// If non-empty, bounds used to display the task during animations/interactions.
// TODO(b/119687367): This member is temporary.
private final Rect mOverrideDisplayedBounds = new Rect();

// Id of the previous display the stack was on.
int mPrevDisplayId = INVALID_DISPLAY;

Expand Down Expand Up @@ -2795,29 +2790,6 @@ void onDisplayChanged(DisplayContent dc) {
}
}

/**
* Displayed bounds are used to set where the task is drawn at any given time. This is
* separate from its actual bounds so that the app doesn't see any meaningful configuration
* changes during transitionary periods.
*/
void setOverrideDisplayedBounds(Rect overrideDisplayedBounds) {
if (overrideDisplayedBounds != null) {
adjustForMinimalTaskDimensions(overrideDisplayedBounds, mOverrideDisplayedBounds);
mOverrideDisplayedBounds.set(overrideDisplayedBounds);
} else {
mOverrideDisplayedBounds.setEmpty();
}
updateSurfacePosition();
}

/**
* Gets the bounds that override where the task is displayed. See
* {@link android.app.IActivityTaskManager#resizeDockedStack} why this is needed.
*/
Rect getOverrideDisplayedBounds() {
return mOverrideDisplayedBounds;
}

boolean isResizeable(boolean checkSupportsPip) {
return (mAtmService.mForceResizableActivities || ActivityInfo.isResizeableMode(mResizeMode)
|| (checkSupportsPip && mSupportsPictureInPicture));
Expand Down Expand Up @@ -2851,49 +2823,6 @@ void prepareFreezingBounds() {
mPreparedFrozenMergedConfig.setTo(getConfiguration());
}

/**
* Align the task to the adjusted bounds.
*
* @param adjustedBounds Adjusted bounds to which the task should be aligned.
* @param tempInsetBounds Insets bounds for the task.
* @param alignBottom True if the task's bottom should be aligned to the adjusted
* bounds's bottom; false if the task's top should be aligned
* the adjusted bounds's top.
*/
void alignToAdjustedBounds(Rect adjustedBounds, Rect tempInsetBounds, boolean alignBottom) {
if (!isResizeable() || EMPTY.equals(getRequestedOverrideConfiguration())) {
return;
}

getBounds(mTmpRect2);
if (alignBottom) {
int offsetY = adjustedBounds.bottom - mTmpRect2.bottom;
mTmpRect2.offset(0, offsetY);
} else {
mTmpRect2.offsetTo(adjustedBounds.left, adjustedBounds.top);
}
if (tempInsetBounds == null || tempInsetBounds.isEmpty()) {
setOverrideDisplayedBounds(null);
setBounds(mTmpRect2);
} else {
setOverrideDisplayedBounds(mTmpRect2);
setBounds(tempInsetBounds);
}
}

/**
* Gets the current overridden displayed bounds. These will be empty if the task is not
* currently overriding where it is displayed.
*/
@Override
public Rect getDisplayedBounds() {
if (mOverrideDisplayedBounds.isEmpty()) {
return super.getDisplayedBounds();
} else {
return mOverrideDisplayedBounds;
}
}

@Override
void getAnimationFrames(Rect outFrame, Rect outInsets, Rect outStableInsets,
Rect outSurfaceInsets) {
Expand Down Expand Up @@ -3431,7 +3360,6 @@ void dump(PrintWriter pw, String prefix, boolean dumpAll) {
pw.println(prefix + "taskId=" + mTaskId);
pw.println(doublePrefix + "mBounds=" + getBounds().toShortString());
pw.println(doublePrefix + "appTokens=" + mChildren);
pw.println(doublePrefix + "mDisplayedBounds=" + mOverrideDisplayedBounds.toShortString());

final String triplePrefix = doublePrefix + " ";
final String quadruplePrefix = triplePrefix + " ";
Expand Down
22 changes: 6 additions & 16 deletions services/core/java/com/android/server/wm/WindowContainer.java
Original file line number Diff line number Diff line change
Expand Up @@ -2062,7 +2062,7 @@ SurfaceControl getAppAnimationLayer(@AnimationLayer int animationLayer) {
// TODO: Remove this and use #getBounds() instead once we set an app transition animation
// on TaskStack.
Rect getAnimationBounds(int appStackClipMode) {
return getDisplayedBounds();
return getBounds();
}

/**
Expand Down Expand Up @@ -2124,7 +2124,7 @@ Pair<AnimationAdapter, AnimationAdapter> getAnimationAdapter(WindowManager.Layou
// Separate position and size for use in animators.
mTmpRect.set(getAnimationBounds(appStackClipMode));
if (sHierarchicalAnimations) {
getRelativeDisplayedPosition(mTmpPoint);
getRelativePosition(mTmpPoint);
} else {
mTmpPoint.set(mTmpRect.left, mTmpRect.top);
}
Expand Down Expand Up @@ -2399,7 +2399,7 @@ void updateSurfacePosition(Transaction t) {
return;
}

getRelativeDisplayedPosition(mTmpPos);
getRelativePosition(mTmpPos);
if (mTmpPos.equals(mLastSurfacePosition)) {
return;
}
Expand All @@ -2413,16 +2413,6 @@ Point getLastSurfacePosition() {
return mLastSurfacePosition;
}

/**
* Displayed bounds specify where to display this container at. It differs from bounds during
* certain operations (like animation or interactive dragging).
*
* @return the bounds to display this container at.
*/
Rect getDisplayedBounds() {
return getBounds();
}

/**
* The {@code outFrame} retrieved by this method specifies where the animation will finish
* the entrance animation, as the next frame will display the window at these coordinates. In
Expand All @@ -2443,19 +2433,19 @@ void getAnimationFrames(Rect outFrame, Rect outInsets, Rect outStableInsets,
outSurfaceInsets.setEmpty();
}

void getRelativeDisplayedPosition(Point outPos) {
void getRelativePosition(Point outPos) {
// In addition to updateSurfacePosition, we keep other code that sets
// position from fighting with the organizer
if (isOrganized()) {
outPos.set(0, 0);
return;
}

final Rect dispBounds = getDisplayedBounds();
final Rect dispBounds = getBounds();
outPos.set(dispBounds.left, dispBounds.top);
final WindowContainer parent = getParent();
if (parent != null) {
final Rect parentBounds = parent.getDisplayedBounds();
final Rect parentBounds = parent.getBounds();
outPos.offset(-parentBounds.left, -parentBounds.top);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -320,7 +320,7 @@ private void resizePinnedStackIfNeeded(ConfigurationContainer container, int con
final ActivityStack stack = (ActivityStack) container;
if (stack.inPinnedWindowingMode()) {
stack.resize(config.windowConfiguration.getBounds(),
null /* configBounds */, PRESERVE_WINDOWS, true /* deferResume */);
PRESERVE_WINDOWS, true /* deferResume */);
}
}
}
Expand Down
Loading

0 comments on commit 2556dbf

Please sign in to comment.