Merge "Update the surface size for tasks when config changes" into rvc-dev am: 177980b87d am: ba990f8813
Change-Id: I15df8412894646f93cddd75f4276121846b9b970
This commit is contained in:
@@ -18,11 +18,8 @@ package com.android.server.wm;
|
||||
|
||||
import static android.app.ActivityTaskManager.INVALID_TASK_ID;
|
||||
import static android.app.ITaskStackListener.FORCED_RESIZEABLE_REASON_SPLIT_SCREEN;
|
||||
import static android.app.WindowConfiguration.ACTIVITY_TYPE_ASSISTANT;
|
||||
import static android.app.WindowConfiguration.ACTIVITY_TYPE_HOME;
|
||||
import static android.app.WindowConfiguration.ACTIVITY_TYPE_STANDARD;
|
||||
import static android.app.WindowConfiguration.ACTIVITY_TYPE_UNDEFINED;
|
||||
import static android.app.WindowConfiguration.PINNED_WINDOWING_MODE_ELEVATION_IN_DIP;
|
||||
import static android.app.WindowConfiguration.WINDOWING_MODE_FULLSCREEN;
|
||||
import static android.app.WindowConfiguration.WINDOWING_MODE_PINNED;
|
||||
import static android.app.WindowConfiguration.WINDOWING_MODE_SPLIT_SCREEN_PRIMARY;
|
||||
@@ -142,13 +139,11 @@ import android.os.SystemClock;
|
||||
import android.os.Trace;
|
||||
import android.os.UserHandle;
|
||||
import android.service.voice.IVoiceInteractionSession;
|
||||
import android.util.DisplayMetrics;
|
||||
import android.util.Log;
|
||||
import android.util.Slog;
|
||||
import android.util.proto.ProtoOutputStream;
|
||||
import android.view.Display;
|
||||
import android.view.DisplayInfo;
|
||||
import android.view.SurfaceControl;
|
||||
|
||||
import com.android.internal.annotations.GuardedBy;
|
||||
import com.android.internal.annotations.VisibleForTesting;
|
||||
@@ -157,7 +152,6 @@ import com.android.internal.os.logging.MetricsLoggerWrapper;
|
||||
import com.android.internal.util.function.pooled.PooledConsumer;
|
||||
import com.android.internal.util.function.pooled.PooledFunction;
|
||||
import com.android.internal.util.function.pooled.PooledLambda;
|
||||
import com.android.internal.util.function.pooled.PooledPredicate;
|
||||
import com.android.server.Watchdog;
|
||||
import com.android.server.am.ActivityManagerService;
|
||||
import com.android.server.am.ActivityManagerService.ItemMatcher;
|
||||
@@ -276,11 +270,6 @@ class ActivityStack extends Task {
|
||||
|
||||
Rect mPreAnimationBounds = new Rect();
|
||||
|
||||
/**
|
||||
* For {@link #prepareSurfaces}.
|
||||
*/
|
||||
private final Point mLastSurfaceSize = new Point();
|
||||
|
||||
private final AnimatingActivityRegistry mAnimatingActivityRegistry =
|
||||
new AnimatingActivityRegistry();
|
||||
|
||||
@@ -606,10 +595,6 @@ class ActivityStack extends Task {
|
||||
|
||||
super.onConfigurationChanged(newParentConfig);
|
||||
|
||||
// Only need to update surface size here since the super method will handle updating
|
||||
// surface position.
|
||||
updateSurfaceSize(getPendingTransaction());
|
||||
|
||||
final TaskDisplayArea taskDisplayArea = getDisplayArea();
|
||||
if (taskDisplayArea == null) {
|
||||
return;
|
||||
@@ -3262,61 +3247,14 @@ class ActivityStack extends Task {
|
||||
scheduleAnimation();
|
||||
}
|
||||
|
||||
/**
|
||||
* Calculate an amount by which to expand the stack bounds in each direction.
|
||||
* Used to make room for shadows in the pinned windowing mode.
|
||||
*/
|
||||
int getStackOutset() {
|
||||
// If we are drawing shadows on the task then don't outset the stack.
|
||||
if (mWmService.mRenderShadowsInCompositor) {
|
||||
return 0;
|
||||
}
|
||||
DisplayContent displayContent = getDisplayContent();
|
||||
if (inPinnedWindowingMode() && displayContent != null) {
|
||||
final DisplayMetrics displayMetrics = displayContent.getDisplayMetrics();
|
||||
|
||||
// We multiply by two to match the client logic for converting view elevation
|
||||
// to insets, as in {@link WindowManager.LayoutParams#setSurfaceInsets}
|
||||
return (int) Math.ceil(
|
||||
mWmService.dipToPixel(PINNED_WINDOWING_MODE_ELEVATION_IN_DIP, displayMetrics)
|
||||
* 2);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
void getRelativePosition(Point outPos) {
|
||||
super.getRelativePosition(outPos);
|
||||
final int outset = getStackOutset();
|
||||
final int outset = getTaskOutset();
|
||||
outPos.x -= outset;
|
||||
outPos.y -= outset;
|
||||
}
|
||||
|
||||
private void updateSurfaceSize(SurfaceControl.Transaction transaction) {
|
||||
if (mSurfaceControl == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
final Rect stackBounds = getBounds();
|
||||
int width = stackBounds.width();
|
||||
int height = stackBounds.height();
|
||||
|
||||
final int outset = getStackOutset();
|
||||
width += 2 * outset;
|
||||
height += 2 * outset;
|
||||
|
||||
if (width == mLastSurfaceSize.x && height == mLastSurfaceSize.y) {
|
||||
return;
|
||||
}
|
||||
transaction.setWindowCrop(mSurfaceControl, width, height);
|
||||
mLastSurfaceSize.set(width, height);
|
||||
}
|
||||
|
||||
@VisibleForTesting
|
||||
Point getLastSurfaceSize() {
|
||||
return mLastSurfaceSize;
|
||||
}
|
||||
|
||||
@Override
|
||||
void onDisplayChanged(DisplayContent dc) {
|
||||
super.onDisplayChanged(dc);
|
||||
|
||||
@@ -120,6 +120,7 @@ import android.content.pm.ApplicationInfo;
|
||||
import android.content.pm.IPackageManager;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.content.res.Configuration;
|
||||
import android.graphics.Point;
|
||||
import android.graphics.Rect;
|
||||
import android.os.Debug;
|
||||
import android.os.IBinder;
|
||||
@@ -213,7 +214,6 @@ class Task extends WindowContainer<WindowContainer> {
|
||||
|
||||
static final int INVALID_MIN_SIZE = -1;
|
||||
private float mShadowRadius = 0;
|
||||
private final Rect mLastSurfaceCrop = new Rect();
|
||||
|
||||
/**
|
||||
* The modes to control how the stack is moved to the front when calling {@link Task#reparent}.
|
||||
@@ -397,6 +397,7 @@ class Task extends WindowContainer<WindowContainer> {
|
||||
|
||||
private Dimmer mDimmer = new Dimmer(this);
|
||||
private final Rect mTmpDimBoundsRect = new Rect();
|
||||
private final Point mLastSurfaceSize = new Point();
|
||||
|
||||
/** @see #setCanAffectSystemUiFlags */
|
||||
private boolean mCanAffectSystemUiFlags = true;
|
||||
@@ -1943,6 +1944,10 @@ class Task extends WindowContainer<WindowContainer> {
|
||||
mTmpPrevBounds.set(getBounds());
|
||||
final boolean wasInMultiWindowMode = inMultiWindowMode();
|
||||
super.onConfigurationChanged(newParentConfig);
|
||||
// Only need to update surface size here since the super method will handle updating
|
||||
// surface position.
|
||||
updateSurfaceSize(getPendingTransaction());
|
||||
|
||||
if (wasInMultiWindowMode != inMultiWindowMode()) {
|
||||
mStackSupervisor.scheduleUpdateMultiWindowMode(this);
|
||||
}
|
||||
@@ -1995,6 +2000,57 @@ class Task extends WindowContainer<WindowContainer> {
|
||||
return (prevWinMode == WINDOWING_MODE_FREEFORM) != (newWinMode == WINDOWING_MODE_FREEFORM);
|
||||
}
|
||||
|
||||
void updateSurfaceSize(SurfaceControl.Transaction transaction) {
|
||||
if (mSurfaceControl == null || mCreatedByOrganizer) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Apply crop to root tasks only and clear the crops of the descendant tasks.
|
||||
int width = 0;
|
||||
int height = 0;
|
||||
if (isRootTask()) {
|
||||
final Rect taskBounds = getBounds();
|
||||
width = taskBounds.width();
|
||||
height = taskBounds.height();
|
||||
|
||||
final int outset = getTaskOutset();
|
||||
width += 2 * outset;
|
||||
height += 2 * outset;
|
||||
}
|
||||
if (width == mLastSurfaceSize.x && height == mLastSurfaceSize.y) {
|
||||
return;
|
||||
}
|
||||
transaction.setWindowCrop(mSurfaceControl, width, height);
|
||||
mLastSurfaceSize.set(width, height);
|
||||
}
|
||||
|
||||
/**
|
||||
* Calculate an amount by which to expand the task bounds in each direction.
|
||||
* Used to make room for shadows in the pinned windowing mode.
|
||||
*/
|
||||
int getTaskOutset() {
|
||||
// If we are drawing shadows on the task then don't outset the stack.
|
||||
if (mWmService.mRenderShadowsInCompositor) {
|
||||
return 0;
|
||||
}
|
||||
DisplayContent displayContent = getDisplayContent();
|
||||
if (inPinnedWindowingMode() && displayContent != null) {
|
||||
final DisplayMetrics displayMetrics = displayContent.getDisplayMetrics();
|
||||
|
||||
// We multiply by two to match the client logic for converting view elevation
|
||||
// to insets, as in {@link WindowManager.LayoutParams#setSurfaceInsets}
|
||||
return (int) Math.ceil(
|
||||
mWmService.dipToPixel(PINNED_WINDOWING_MODE_ELEVATION_IN_DIP, displayMetrics)
|
||||
* 2);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
@VisibleForTesting
|
||||
Point getLastSurfaceSize() {
|
||||
return mLastSurfaceSize;
|
||||
}
|
||||
|
||||
@VisibleForTesting
|
||||
boolean isInChangeTransition() {
|
||||
return mSurfaceFreezer.hasLeash() || AppTransition.isChangeTransit(mTransit);
|
||||
@@ -2813,28 +2869,6 @@ class Task extends WindowContainer<WindowContainer> {
|
||||
return boundsChange;
|
||||
}
|
||||
|
||||
private void updateSurfaceCrop() {
|
||||
// Only update the crop if we are drawing shadows on the task.
|
||||
if (mSurfaceControl == null || !mWmService.mRenderShadowsInCompositor || !isRootTask()) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (inSplitScreenWindowingMode()) {
|
||||
// inherit crop from parent
|
||||
mTmpRect.setEmpty();
|
||||
} else {
|
||||
getBounds(mTmpRect);
|
||||
}
|
||||
|
||||
mTmpRect.offsetTo(0, 0);
|
||||
if (mLastSurfaceCrop.equals(mTmpRect)) {
|
||||
return;
|
||||
}
|
||||
|
||||
getPendingTransaction().setWindowCrop(mSurfaceControl, mTmpRect);
|
||||
mLastSurfaceCrop.set(mTmpRect);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onDescendantOrientationChanged(IBinder freezeDisplayToken,
|
||||
ConfigurationContainer requestingContainer) {
|
||||
@@ -3463,7 +3497,6 @@ class Task extends WindowContainer<WindowContainer> {
|
||||
mTmpDimBoundsRect.offsetTo(0, 0);
|
||||
}
|
||||
|
||||
updateSurfaceCrop();
|
||||
updateShadowsRadius(isFocused(), getPendingTransaction());
|
||||
|
||||
if (mDimmer.updateDims(getPendingTransaction(), mTmpDimBoundsRect)) {
|
||||
|
||||
@@ -5289,7 +5289,7 @@ class WindowState extends WindowContainer<WindowState> implements WindowManagerP
|
||||
// to account for it. If we actually have shadows we will
|
||||
// then un-inset ourselves by the surfaceInsets.
|
||||
if (stack != null) {
|
||||
final int outset = stack.getStackOutset();
|
||||
final int outset = stack.getTaskOutset();
|
||||
outPoint.offset(outset, outset);
|
||||
}
|
||||
|
||||
|
||||
@@ -186,7 +186,7 @@ public class TaskStackTests extends WindowTestsBase {
|
||||
final ActivityStack stack = createTaskStackOnDisplay(mDisplayContent);
|
||||
final int stackOutset = 10;
|
||||
spyOn(stack);
|
||||
doReturn(stackOutset).when(stack).getStackOutset();
|
||||
doReturn(stackOutset).when(stack).getTaskOutset();
|
||||
doReturn(true).when(stack).inMultiWindowMode();
|
||||
|
||||
// Mock the resolved override windowing mode to non-fullscreen
|
||||
|
||||
Reference in New Issue
Block a user