Merge "Let the client compute the surface size on its own"

This commit is contained in:
Tiger Huang
2022-01-25 14:09:25 +00:00
committed by Android (Google) Code Review
15 changed files with 127 additions and 136 deletions

View File

@@ -20,7 +20,6 @@ import static androidx.test.platform.app.InstrumentationRegistry.getInstrumentat
import android.app.Activity;
import android.content.Context;
import android.graphics.Point;
import android.os.RemoteException;
import android.perftests.utils.BenchmarkState;
import android.perftests.utils.PerfStatusReporter;
@@ -133,7 +132,6 @@ public class RelayoutPerfTest extends WindowManagerPerfTestBase
final WindowManager.LayoutParams mParams;
final int mWidth;
final int mHeight;
final Point mOutSurfaceSize = new Point();
final SurfaceControl mOutSurfaceControl;
final IntSupplier mViewVisibility;
@@ -156,8 +154,7 @@ public class RelayoutPerfTest extends WindowManagerPerfTestBase
while (state.keepRunning()) {
session.relayout(mWindow, mParams, mWidth, mHeight,
mViewVisibility.getAsInt(), mFlags, mFrameNumber, mOutFrames,
mOutMergedConfiguration, mOutSurfaceControl, mOutInsetsState, mOutControls,
mOutSurfaceSize);
mOutMergedConfiguration, mOutSurfaceControl, mOutInsetsState, mOutControls);
}
}
}

View File

@@ -87,6 +87,7 @@ import android.view.SurfaceHolder;
import android.view.View;
import android.view.ViewGroup;
import android.view.WindowInsets;
import android.view.WindowLayout;
import android.view.WindowManager;
import android.view.WindowManagerGlobal;
import android.window.ClientWindowFrames;
@@ -389,8 +390,9 @@ public abstract class WallpaperService extends Service {
public void resized(ClientWindowFrames frames, boolean reportDraw,
MergedConfiguration mergedConfiguration, boolean forceLayout,
boolean alwaysConsumeSystemBars, int displayId) {
Message msg = mCaller.obtainMessageI(MSG_WINDOW_RESIZED,
reportDraw ? 1 : 0);
Message msg = mCaller.obtainMessageIO(MSG_WINDOW_RESIZED,
reportDraw ? 1 : 0,
mergedConfiguration);
mCaller.sendMessage(msg);
}
@@ -1028,6 +1030,10 @@ public abstract class WallpaperService extends Service {
}
}
private void updateConfiguration(MergedConfiguration mergedConfiguration) {
mMergedConfiguration.setTo(mergedConfiguration);
}
void updateSurface(boolean forceRelayout, boolean forceReport, boolean redrawNeeded) {
if (mDestroyed) {
Log.w(TAG, "Ignoring updateSurface due to destroyed");
@@ -1066,8 +1072,6 @@ public abstract class WallpaperService extends Service {
mLayout.x = 0;
mLayout.y = 0;
mLayout.width = myWidth;
mLayout.height = myHeight;
mLayout.format = mFormat;
mCurWindowFlags = mWindowFlags;
@@ -1076,6 +1080,23 @@ public abstract class WallpaperService extends Service {
| WindowManager.LayoutParams.FLAG_LAYOUT_INSET_DECOR
| WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN
| WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE;
final Configuration config = mMergedConfiguration.getMergedConfiguration();
final Rect maxBounds = config.windowConfiguration.getMaxBounds();
if (myWidth == ViewGroup.LayoutParams.MATCH_PARENT
&& myHeight == ViewGroup.LayoutParams.MATCH_PARENT) {
mLayout.width = myWidth;
mLayout.height = myHeight;
mLayout.flags &= ~WindowManager.LayoutParams.FLAG_SCALED;
} else {
final float layoutScale = Math.max(
maxBounds.width() / (float) myWidth,
maxBounds.height() / (float) myHeight);
mLayout.width = (int) (myWidth * layoutScale + .5f);
mLayout.height = (int) (myHeight * layoutScale + .5f);
mLayout.flags |= WindowManager.LayoutParams.FLAG_SCALED;
}
mCurWindowPrivateFlags = mWindowPrivateFlags;
mLayout.privateFlags = mWindowPrivateFlags;
@@ -1122,11 +1143,13 @@ public abstract class WallpaperService extends Service {
final int relayoutResult = mSession.relayout(
mWindow, mLayout, mWidth, mHeight,
View.VISIBLE, 0, -1, mWinFrames, mMergedConfiguration, mSurfaceControl,
mInsetsState, mTempControls, mSurfaceSize);
mInsetsState, mTempControls);
final int transformHint = SurfaceControl.rotationToBufferTransform(
(mDisplayInstallOrientation + mDisplay.getRotation()) % 4);
mSurfaceControl.setTransformHint(transformHint);
WindowLayout.computeSurfaceSize(mLayout, maxBounds, mWidth, mHeight,
mWinFrames.frame, false /* dragResizing */, mSurfaceSize);
if (mSurfaceControl.isValid()) {
if (mBbqSurfaceControl == null) {
@@ -1164,7 +1187,6 @@ public abstract class WallpaperService extends Service {
int h = mWinFrames.frame.height();
final DisplayCutout rawCutout = mInsetsState.getDisplayCutout();
final Configuration config = getResources().getConfiguration();
final Rect visibleFrame = new Rect(mWinFrames.frame);
visibleFrame.intersect(mInsetsState.getDisplayFrame());
WindowInsets windowInsets = mInsetsState.calculateInsets(visibleFrame,
@@ -2321,6 +2343,7 @@ public abstract class WallpaperService extends Service {
} break;
case MSG_WINDOW_RESIZED: {
final boolean reportDraw = message.arg1 != 0;
mEngine.updateConfiguration(((MergedConfiguration) message.obj));
mEngine.updateSurface(true, false, reportDraw);
mEngine.doOffsetsChanged(true);
mEngine.scaleAndCropScreenshot();

View File

@@ -97,7 +97,6 @@ interface IWindowSession {
* since it was last displayed.
* @param outSurface Object in which is placed the new display surface.
* @param insetsState The current insets state in the system.
* @param outSurfaceSize The width and height of the surface control
*
* @return int Result flags: {@link WindowManagerGlobal#RELAYOUT_SHOW_FOCUS},
* {@link WindowManagerGlobal#RELAYOUT_FIRST_TIME}.
@@ -106,8 +105,7 @@ interface IWindowSession {
int requestedWidth, int requestedHeight, int viewVisibility,
int flags, long frameNumber, out ClientWindowFrames outFrames,
out MergedConfiguration outMergedConfiguration, out SurfaceControl outSurfaceControl,
out InsetsState insetsState, out InsetsSourceControl[] activeControls,
out Point outSurfaceSize);
out InsetsState insetsState, out InsetsSourceControl[] activeControls);
/*
* Notify the window manager that an application is relaunching and

View File

@@ -83,6 +83,8 @@ import static android.view.WindowManager.LayoutParams.TYPE_STATUS_BAR_ADDITIONAL
import static android.view.WindowManager.LayoutParams.TYPE_SYSTEM_ALERT;
import static android.view.WindowManager.LayoutParams.TYPE_TOAST;
import static android.view.WindowManager.LayoutParams.TYPE_VOLUME_OVERLAY;
import static android.view.WindowManagerGlobal.RELAYOUT_RES_DRAG_RESIZING_DOCKED;
import static android.view.WindowManagerGlobal.RELAYOUT_RES_DRAG_RESIZING_FREEFORM;
import static android.view.WindowManagerGlobal.RELAYOUT_RES_SURFACE_CHANGED;
import static android.view.inputmethod.InputMethodEditorTraceProto.InputMethodClientsTraceProto.ClientSideProto.IME_FOCUS_CONTROLLER;
import static android.view.inputmethod.InputMethodEditorTraceProto.InputMethodClientsTraceProto.ClientSideProto.INSETS_CONTROLLER;
@@ -2868,9 +2870,9 @@ public final class ViewRootImpl implements ViewParent,
}
relayoutResult = relayoutWindow(params, viewVisibility, insetsPending);
final boolean freeformResizing = (relayoutResult
& WindowManagerGlobal.RELAYOUT_RES_DRAG_RESIZING_FREEFORM) != 0;
& RELAYOUT_RES_DRAG_RESIZING_FREEFORM) != 0;
final boolean dockedResizing = (relayoutResult
& WindowManagerGlobal.RELAYOUT_RES_DRAG_RESIZING_DOCKED) != 0;
& RELAYOUT_RES_DRAG_RESIZING_DOCKED) != 0;
final boolean dragResizing = freeformResizing || dockedResizing;
if ((relayoutResult & WindowManagerGlobal.RELAYOUT_RES_BLAST_SYNC) != 0) {
if (DEBUG_BLAST) {
@@ -7928,22 +7930,30 @@ public final class ViewRootImpl implements ViewParent,
}
}
final int requestedWidth = (int) (mView.getMeasuredWidth() * appScale + 0.5f);
final int requestedHeight = (int) (mView.getMeasuredHeight() * appScale + 0.5f);
long frameNumber = -1;
if (mSurface.isValid()) {
frameNumber = mSurface.getNextFrameNumber();
}
int relayoutResult = mWindowSession.relayout(mWindow, params,
(int) (mView.getMeasuredWidth() * appScale + 0.5f),
(int) (mView.getMeasuredHeight() * appScale + 0.5f), viewVisibility,
requestedWidth, requestedHeight, viewVisibility,
insetsPending ? WindowManagerGlobal.RELAYOUT_INSETS_PENDING : 0, frameNumber,
mTmpFrames, mPendingMergedConfiguration, mSurfaceControl, mTempInsets,
mTempControls, mSurfaceSize);
mTempControls);
final int transformHint = SurfaceControl.rotationToBufferTransform(
(mDisplayInstallOrientation + mDisplay.getRotation()) % 4);
mSurfaceControl.setTransformHint(transformHint);
final WindowConfiguration winConfig = getConfiguration().windowConfiguration;
final boolean dragResizing = (relayoutResult
& (RELAYOUT_RES_DRAG_RESIZING_DOCKED | RELAYOUT_RES_DRAG_RESIZING_FREEFORM)) != 0;
WindowLayout.computeSurfaceSize(mWindowAttributes, winConfig.getMaxBounds(), requestedWidth,
requestedHeight, mTmpFrames.frame, dragResizing, mSurfaceSize);
if (mAttachInfo.mContentCaptureManager != null) {
MainContentCaptureSession mainSession = mAttachInfo.mContentCaptureManager
.getMainContentCaptureSession();

View File

@@ -36,6 +36,7 @@ import static android.view.WindowManager.LayoutParams.TYPE_SYSTEM_ERROR;
import android.app.WindowConfiguration;
import android.app.WindowConfiguration.WindowingMode;
import android.graphics.Insets;
import android.graphics.Point;
import android.graphics.Rect;
import android.util.Log;
@@ -258,6 +259,7 @@ public class WindowLayout {
+ " outFrame=" + outFrame.toShortString()
+ " outParentFrame=" + outParentFrame.toShortString()
+ " outDisplayFrame=" + outDisplayFrame.toShortString()
+ " windowBounds=" + windowBounds.toShortString()
+ " attachedWindowFrame=" + (attachedWindowFrame != null
? attachedWindowFrame.toShortString()
: "null")
@@ -272,4 +274,45 @@ public class WindowLayout {
return clippedByDisplayCutout;
}
public static void computeSurfaceSize(WindowManager.LayoutParams attrs, Rect maxBounds,
int requestedWidth, int requestedHeight, Rect winFrame, boolean dragResizing,
Point outSurfaceSize) {
int width;
int height;
if ((attrs.flags & WindowManager.LayoutParams.FLAG_SCALED) != 0) {
// For a scaled surface, we always want the requested size.
width = requestedWidth;
height = requestedHeight;
} else {
// When we're doing a drag-resizing, request a surface that's fullscreen size,
// so that we don't need to reallocate during the process. This also prevents
// buffer drops due to size mismatch.
if (dragResizing) {
// The maxBounds should match the display size which applies fixed-rotation
// transformation if there is any.
width = maxBounds.width();
height = maxBounds.height();
} else {
width = winFrame.width();
height = winFrame.height();
}
}
// This doesn't necessarily mean that there is an error in the system. The sizes might be
// incorrect, because it is before the first layout or draw.
if (width < 1) {
width = 1;
}
if (height < 1) {
height = 1;
}
// Adjust for surface insets.
final Rect surfaceInsets = attrs.surfaceInsets;
width += surfaceInsets.left + surfaceInsets.right;
height += surfaceInsets.top + surfaceInsets.bottom;
outSurfaceSize.set(width, height);
}
}

View File

@@ -19,7 +19,6 @@ package android.view;
import android.annotation.Nullable;
import android.content.res.Configuration;
import android.graphics.PixelFormat;
import android.graphics.Point;
import android.graphics.Rect;
import android.graphics.Region;
import android.os.IBinder;
@@ -267,7 +266,7 @@ public class WindowlessWindowManager implements IWindowSession {
int requestedWidth, int requestedHeight, int viewFlags, int flags, long frameNumber,
ClientWindowFrames outFrames, MergedConfiguration mergedConfiguration,
SurfaceControl outSurfaceControl, InsetsState outInsetsState,
InsetsSourceControl[] outActiveControls, Point outSurfaceSize) {
InsetsSourceControl[] outActiveControls) {
final State state;
synchronized (this) {
state = mStateForWindow.get(window.asBinder());
@@ -286,7 +285,6 @@ public class WindowlessWindowManager implements IWindowSession {
WindowManager.LayoutParams attrs = state.mParams;
if (viewFlags == View.VISIBLE) {
outSurfaceSize.set(getSurfaceWidth(attrs), getSurfaceHeight(attrs));
t.setOpaque(sc, isOpaque(attrs)).show(sc).apply();
outSurfaceControl.copyFrom(sc, "WindowlessWindowManager.relayout");
} else {
@@ -480,17 +478,6 @@ public class WindowlessWindowManager implements IWindowSession {
return null;
}
private int getSurfaceWidth(WindowManager.LayoutParams attrs) {
final Rect surfaceInsets = attrs.surfaceInsets;
return surfaceInsets != null
? attrs.width + surfaceInsets.left + surfaceInsets.right : attrs.width;
}
private int getSurfaceHeight(WindowManager.LayoutParams attrs) {
final Rect surfaceInsets = attrs.surfaceInsets;
return surfaceInsets != null
? attrs.height + surfaceInsets.top + surfaceInsets.bottom : attrs.height;
}
@Override
public void grantEmbeddedWindowFocus(IWindow callingWindow, IBinder targetInputToken,
boolean grantFocus) {

View File

@@ -126,9 +126,6 @@ public class TaskSnapshotWindow {
*/
private static final long MAX_DELAY_REMOVAL_TIME_IME_VISIBLE = 600;
//tmp vars for unused relayout params
private static final Point TMP_SURFACE_SIZE = new Point();
private final Window mWindow;
private final Runnable mClearWindowHandler;
private final ShellExecutor mSplashScreenExecutor;
@@ -246,7 +243,7 @@ public class TaskSnapshotWindow {
Trace.traceBegin(TRACE_TAG_WINDOW_MANAGER, "TaskSnapshot#relayout");
session.relayout(window, layoutParams, -1, -1, View.VISIBLE, 0, -1,
tmpFrames, tmpMergedConfiguration, surfaceControl, tmpInsetsState,
tmpControls, TMP_SURFACE_SIZE);
tmpControls);
Trace.traceEnd(TRACE_TAG_WINDOW_MANAGER);
} catch (RemoteException e) {
snapshotSurface.clearWindowSynced();

View File

@@ -45,7 +45,6 @@ import android.content.ClipDescription;
import android.content.Intent;
import android.content.pm.ActivityInfo;
import android.content.pm.ShortcutServiceInternal;
import android.graphics.Point;
import android.graphics.Rect;
import android.graphics.Region;
import android.os.Binder;
@@ -225,14 +224,14 @@ class Session extends IWindowSession.Stub implements IBinder.DeathRecipient {
int requestedWidth, int requestedHeight, int viewFlags, int flags, long frameNumber,
ClientWindowFrames outFrames, MergedConfiguration mergedConfiguration,
SurfaceControl outSurfaceControl, InsetsState outInsetsState,
InsetsSourceControl[] outActiveControls, Point outSurfaceSize) {
InsetsSourceControl[] outActiveControls) {
if (false) Slog.d(TAG_WM, ">>>>>> ENTERED relayout from "
+ Binder.getCallingPid());
Trace.traceBegin(TRACE_TAG_WINDOW_MANAGER, mRelayoutTag);
int res = mService.relayoutWindow(this, window, attrs,
requestedWidth, requestedHeight, viewFlags, flags, frameNumber,
outFrames, mergedConfiguration, outSurfaceControl, outInsetsState,
outActiveControls, outSurfaceSize);
outActiveControls);
Trace.traceEnd(TRACE_TAG_WINDOW_MANAGER);
if (false) Slog.d(TAG_WM, "<<<<<< EXITING relayout to "
+ Binder.getCallingPid());

View File

@@ -28,9 +28,6 @@ import android.annotation.Nullable;
import android.os.Bundle;
import android.os.IBinder;
import android.os.RemoteException;
import android.view.DisplayInfo;
import android.view.ViewGroup;
import android.view.WindowManager;
import android.view.animation.Animation;
import com.android.internal.protolog.common.ProtoLog;
@@ -190,23 +187,6 @@ class WallpaperWindowToken extends WindowToken {
setVisible(visible);
}
@Override
void adjustWindowParams(WindowState win, WindowManager.LayoutParams attrs) {
if (attrs.height == ViewGroup.LayoutParams.MATCH_PARENT
|| attrs.width == ViewGroup.LayoutParams.MATCH_PARENT) {
return;
}
final DisplayInfo displayInfo = win.getDisplayInfo();
final float layoutScale = Math.max(
(float) displayInfo.logicalHeight / (float) attrs.height,
(float) displayInfo.logicalWidth / (float) attrs.width);
attrs.height = (int) (attrs.height * layoutScale);
attrs.width = (int) (attrs.width * layoutScale);
attrs.flags |= WindowManager.LayoutParams.FLAG_SCALED;
}
boolean hasVisibleNotDrawnWallpaper() {
if (!isVisible()) return false;
for (int j = mChildren.size() - 1; j >= 0; --j) {

View File

@@ -2182,7 +2182,7 @@ public class WindowManagerService extends IWindowManager.Stub
int requestedWidth, int requestedHeight, int viewVisibility, int flags,
long frameNumber, ClientWindowFrames outFrames, MergedConfiguration mergedConfiguration,
SurfaceControl outSurfaceControl, InsetsState outInsetsState,
InsetsSourceControl[] outActiveControls, Point outSurfaceSize) {
InsetsSourceControl[] outActiveControls) {
Arrays.fill(outActiveControls, null);
int result = 0;
boolean configChanged;
@@ -2209,7 +2209,6 @@ public class WindowManagerService extends IWindowManager.Stub
int privateFlagChanges = 0;
if (attrs != null) {
displayPolicy.adjustWindowParamsLw(win, attrs);
win.mToken.adjustWindowParams(win, attrs);
attrs.flags = sanitizeFlagSlippery(attrs.flags, win.getName(), uid, pid);
attrs.inputFeatures = sanitizeSpyWindow(attrs.inputFeatures, win.getName(), uid,
pid);
@@ -2497,11 +2496,6 @@ public class WindowManagerService extends IWindowManager.Stub
displayContent.sendNewConfiguration();
Trace.traceEnd(TRACE_TAG_WINDOW_MANAGER);
}
if (winAnimator.mSurfaceController != null) {
win.calculateSurfaceBounds(win.getLayoutingAttrs(
win.getWindowConfiguration().getRotation()), mTmpRect);
outSurfaceSize.set(mTmpRect.width(), mTmpRect.height());
}
getInsetsSourceControls(win, outActiveControls);
}
@@ -2580,7 +2574,7 @@ public class WindowManagerService extends IWindowManager.Stub
WindowSurfaceController surfaceController;
try {
Trace.traceBegin(TRACE_TAG_WINDOW_MANAGER, "createSurfaceControl");
surfaceController = winAnimator.createSurfaceLocked(win.mAttrs.type);
surfaceController = winAnimator.createSurfaceLocked();
} finally {
Trace.traceEnd(TRACE_TAG_WINDOW_MANAGER);
}

View File

@@ -1418,8 +1418,8 @@ class WindowState extends WindowContainer<WindowState> implements WindowManagerP
return mWindowFrames.mParentFrame;
}
void getCompatFrameSize(Rect outFrame) {
outFrame.set(0, 0, mWindowFrames.mCompatFrame.width(), mWindowFrames.mCompatFrame.height());
Rect getCompatFrame() {
return mWindowFrames.mCompatFrame;
}
WindowManager.LayoutParams getAttrs() {
@@ -1608,6 +1608,15 @@ class WindowState extends WindowContainer<WindowState> implements WindowManagerP
return getDisplayContent().getDisplayInfo();
}
@Override
public Rect getMaxBounds() {
final Rect maxBounds = mToken.getFixedRotationTransformMaxBounds();
if (maxBounds != null) {
return maxBounds;
}
return super.getMaxBounds();
}
/**
* Returns the insets state for the window. Its sources may be the copies with visibility
* modification according to the state of transient bars.
@@ -5904,39 +5913,6 @@ class WindowState extends WindowContainer<WindowState> implements WindowManagerP
mRedrawForSyncReported = false;
}
void calculateSurfaceBounds(WindowManager.LayoutParams attrs, Rect outSize) {
outSize.setEmpty();
if ((attrs.flags & FLAG_SCALED) != 0) {
// For a scaled surface, we always want the requested size.
outSize.right = mRequestedWidth;
outSize.bottom = mRequestedHeight;
} else {
// When we're doing a drag-resizing, request a surface that's fullscreen size,
// so that we don't need to reallocate during the process. This also prevents
// buffer drops due to size mismatch.
if (isDragResizing()) {
final DisplayInfo displayInfo = getDisplayInfo();
outSize.right = displayInfo.logicalWidth;
outSize.bottom = displayInfo.logicalHeight;
} else {
getCompatFrameSize(outSize);
}
}
// This doesn't necessarily mean that there is an error in the system. The sizes might be
// incorrect, because it is before the first layout or draw.
if (outSize.width() < 1) {
outSize.right = 1;
}
if (outSize.height() < 1) {
outSize.bottom = 1;
}
// Adjust for surface insets.
outSize.inset(-attrs.surfaceInsets.left, -attrs.surfaceInsets.top,
-attrs.surfaceInsets.right, -attrs.surfaceInsets.bottom);
}
/**
* This method is used to control whether we return the BLAST_SYNC flag
* from relayoutWindow calls on this window (triggering the client to redirect

View File

@@ -150,8 +150,6 @@ class WindowStateAnimator {
int mAttrType;
private final Rect mTmpSize = new Rect();
/**
* Handles surface changes synchronized to after the client has drawn the surface. This
* transaction is currently used to reparent the old surface children to the new surface once
@@ -291,7 +289,7 @@ class WindowStateAnimator {
}
}
WindowSurfaceController createSurfaceLocked(int windowType) {
WindowSurfaceController createSurfaceLocked() {
final WindowState w = mWin;
if (mSurfaceController != null) {
@@ -319,16 +317,9 @@ class WindowStateAnimator {
flags |= SurfaceControl.SKIP_SCREENSHOT;
}
w.calculateSurfaceBounds(attrs, mTmpSize);
final int width = mTmpSize.width();
final int height = mTmpSize.height();
if (DEBUG_VISIBILITY) {
Slog.v(TAG, "Creating surface in session "
+ mSession.mSurfaceSession + " window " + this
+ " w=" + width + " h=" + height
+ " x=" + mTmpSize.left + " y=" + mTmpSize.top
+ " format=" + attrs.format + " flags=" + flags);
}
@@ -339,8 +330,8 @@ class WindowStateAnimator {
final boolean isHwAccelerated = (attrs.flags & FLAG_HARDWARE_ACCELERATED) != 0;
final int format = isHwAccelerated ? PixelFormat.TRANSLUCENT : attrs.format;
mSurfaceController = new WindowSurfaceController(attrs.getTitle().toString(), width,
height, format, flags, this, windowType);
mSurfaceController = new WindowSurfaceController(attrs.getTitle().toString(), format,
flags, this, attrs.type);
mSurfaceController.setColorSpaceAgnostic((attrs.privateFlags
& WindowManager.LayoutParams.PRIVATE_FLAG_COLOR_SPACE_AGNOSTIC) != 0);
@@ -372,8 +363,7 @@ class WindowStateAnimator {
if (SHOW_LIGHT_TRANSACTIONS) {
Slog.i(TAG, ">>> OPEN TRANSACTION createSurfaceLocked");
WindowManagerService.logSurface(w, "CREATE pos=("
+ w.getFrame().left + "," + w.getFrame().top + ") ("
+ width + "x" + height + ")" + " HIDE", false);
+ w.getFrame().left + "," + w.getFrame().top + ") HIDE", false);
}
mLastHidden = true;

View File

@@ -31,7 +31,6 @@ import static com.android.server.wm.WindowManagerDebugConfig.TAG_WM;
import static com.android.server.wm.WindowSurfaceControllerProto.LAYER;
import static com.android.server.wm.WindowSurfaceControllerProto.SHOWN;
import android.graphics.Region;
import android.os.Debug;
import android.os.Trace;
import android.util.Slog;
@@ -76,8 +75,8 @@ class WindowSurfaceController {
// Used to track whether we have called detach children on the way to invisibility.
boolean mChildrenDetached;
WindowSurfaceController(String name, int w, int h, int format,
int flags, WindowStateAnimator animator, int windowType) {
WindowSurfaceController(String name, int format, int flags, WindowStateAnimator animator,
int windowType) {
mAnimator = animator;
title = name;
@@ -91,7 +90,6 @@ class WindowSurfaceController {
final SurfaceControl.Builder b = win.makeSurface()
.setParent(win.getSurfaceControl())
.setName(name)
.setBufferSize(w, h)
.setFormat(format)
.setFlags(flags)
.setMetadata(METADATA_WINDOW_TYPE, windowType)

View File

@@ -430,6 +430,13 @@ class WindowToken extends WindowContainer<WindowState> {
return isFixedRotationTransforming() ? mFixedRotationTransformState.mDisplayFrames : null;
}
Rect getFixedRotationTransformMaxBounds() {
return isFixedRotationTransforming()
? mFixedRotationTransformState.mRotatedOverrideConfiguration.windowConfiguration
.getMaxBounds()
: null;
}
Rect getFixedRotationTransformDisplayBounds() {
return isFixedRotationTransforming()
? mFixedRotationTransformState.mRotatedOverrideConfiguration.windowConfiguration
@@ -646,14 +653,6 @@ class WindowToken extends WindowContainer<WindowState> {
}
}
/**
* Gives a chance to this {@link WindowToken} to adjust the {@link
* android.view.WindowManager.LayoutParams} of its windows.
*/
void adjustWindowParams(WindowState win, WindowManager.LayoutParams attrs) {
}
@CallSuper
@Override
public void dumpDebug(ProtoOutputStream proto, long fieldId,

View File

@@ -20,6 +20,7 @@ import static android.app.WindowConfiguration.WINDOWING_MODE_FREEFORM;
import static android.app.WindowConfiguration.WINDOWING_MODE_FULLSCREEN;
import static android.app.WindowConfiguration.WINDOWING_MODE_UNDEFINED;
import static android.view.WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS;
import static android.view.WindowManager.LayoutParams.FLAG_SCALED;
import static android.view.WindowManager.LayoutParams.FLAG_SHOW_WALLPAPER;
import static android.view.WindowManager.LayoutParams.TYPE_APPLICATION;
import static android.view.WindowManager.LayoutParams.TYPE_BASE_APPLICATION;
@@ -116,6 +117,7 @@ public class WallpaperControllerTests extends WindowTestsBase {
WindowManager.LayoutParams attrs = wallpaperWindow.getAttrs();
Rect bounds = dc.getBounds();
int displayWidth = dc.getBounds().width();
int displayHeight = dc.getBounds().height();
// Use a wallpaper with a different ratio than the display
@@ -123,20 +125,18 @@ public class WallpaperControllerTests extends WindowTestsBase {
int wallpaperHeight = (int) (bounds.height() * 1.10);
// Simulate what would be done on the client's side
attrs.width = wallpaperWidth;
attrs.height = wallpaperHeight;
attrs.flags |= FLAG_LAYOUT_NO_LIMITS;
final float layoutScale = Math.max(
displayWidth / (float) wallpaperWidth, displayHeight / (float) wallpaperHeight);
attrs.width = (int) (wallpaperWidth * layoutScale + .5f);
attrs.height = (int) (wallpaperHeight * layoutScale + .5f);
attrs.flags |= FLAG_LAYOUT_NO_LIMITS | FLAG_SCALED;
attrs.gravity = Gravity.TOP | Gravity.LEFT;
wallpaperWindow.getWindowFrames().mParentFrame.set(dc.getBounds());
// Calling layoutWindowLw a first time, so adjustWindowParams gets the correct data
dc.getDisplayPolicy().layoutWindowLw(wallpaperWindow, null, dc.mDisplayFrames);
wallpaperWindowToken.adjustWindowParams(wallpaperWindow, attrs);
dc.getDisplayPolicy().layoutWindowLw(wallpaperWindow, null, dc.mDisplayFrames);
assertEquals(Configuration.ORIENTATION_PORTRAIT, dc.getConfiguration().orientation);
int expectedWidth = (int) (wallpaperWidth * (displayHeight / (double) wallpaperHeight));
int expectedWidth = (int) (wallpaperWidth * layoutScale + .5f);
// Check that the wallpaper is correctly scaled
assertEquals(expectedWidth, wallpaperWindow.getFrame().width());