Merge "Revert "Introduce updateVisibility and updateLayout"" into tm-qpr-dev

This commit is contained in:
Tiger Huang
2022-06-24 03:23:21 +00:00
committed by Android (Google) Code Review
7 changed files with 30 additions and 212 deletions

View File

@@ -24,7 +24,6 @@ import static android.graphics.Matrix.MSKEW_X;
import static android.graphics.Matrix.MSKEW_Y;
import static android.view.SurfaceControl.METADATA_WINDOW_TYPE;
import static android.view.View.SYSTEM_UI_FLAG_VISIBLE;
import static android.view.ViewRootImpl.LOCAL_LAYOUT;
import static android.view.WindowManager.LayoutParams.TYPE_WALLPAPER;
import android.animation.AnimationHandler;
@@ -41,7 +40,6 @@ import android.app.Service;
import android.app.WallpaperColors;
import android.app.WallpaperInfo;
import android.app.WallpaperManager;
import android.app.WindowConfiguration;
import android.compat.annotation.UnsupportedAppUsage;
import android.content.Context;
import android.content.Intent;
@@ -260,8 +258,6 @@ public abstract class WallpaperService extends Service {
private final Point mLastSurfaceSize = new Point();
private final Matrix mTmpMatrix = new Matrix();
private final float[] mTmpValues = new float[9];
private final WindowLayout mWindowLayout = new WindowLayout();
private final Rect mTempRect = new Rect();
final WindowManager.LayoutParams mLayout
= new WindowManager.LayoutParams();
@@ -1100,8 +1096,7 @@ public abstract class WallpaperService extends Service {
| WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE;
final Configuration config = mMergedConfiguration.getMergedConfiguration();
final WindowConfiguration winConfig = config.windowConfiguration;
final Rect maxBounds = winConfig.getMaxBounds();
final Rect maxBounds = config.windowConfiguration.getMaxBounds();
if (myWidth == ViewGroup.LayoutParams.MATCH_PARENT
&& myHeight == ViewGroup.LayoutParams.MATCH_PARENT) {
mLayout.width = myWidth;
@@ -1158,28 +1153,9 @@ public abstract class WallpaperService extends Service {
} else {
mLayout.surfaceInsets.set(0, 0, 0, 0);
}
int relayoutResult = 0;
if (LOCAL_LAYOUT) {
if (!mSurfaceControl.isValid()) {
relayoutResult = mSession.updateVisibility(mWindow, mLayout,
View.VISIBLE, mMergedConfiguration, mSurfaceControl,
mInsetsState, mTempControls);
}
final Rect displayCutoutSafe = mTempRect;
mInsetsState.getDisplayCutoutSafe(displayCutoutSafe);
mWindowLayout.computeFrames(mLayout, mInsetsState, displayCutoutSafe,
winConfig.getBounds(), winConfig.getWindowingMode(), mWidth,
mHeight, mRequestedVisibilities, 1f /* compatScale */, mWinFrames);
mSession.updateLayout(mWindow, mLayout, 0 /* flags */, mWinFrames, mWidth,
mHeight);
} else {
relayoutResult = mSession.relayout(mWindow, mLayout, mWidth, mHeight,
View.VISIBLE, 0, mWinFrames, mMergedConfiguration,
mSurfaceControl, mInsetsState, mTempControls, mSyncSeqIdBundle);
}
final int relayoutResult = mSession.relayout(mWindow, mLayout, mWidth, mHeight,
View.VISIBLE, 0, mWinFrames, mMergedConfiguration, mSurfaceControl,
mInsetsState, mTempControls, mSyncSeqIdBundle);
final int transformHint = SurfaceControl.rotationToBufferTransform(
(mDisplayInstallOrientation + mDisplay.getRotation()) % 4);
@@ -1228,7 +1204,7 @@ public abstract class WallpaperService extends Service {
null /* ignoringVisibilityState */, config.isScreenRound(),
false /* alwaysConsumeSystemBars */, mLayout.softInputMode,
mLayout.flags, SYSTEM_UI_FLAG_VISIBLE, mLayout.type,
winConfig.getWindowingMode(), null /* typeSideMap */);
config.windowConfiguration.getWindowingMode(), null /* typeSideMap */);
if (!fixedSize) {
final Rect padding = mIWallpaperEngine.mDisplayPadding;

View File

@@ -109,41 +109,6 @@ interface IWindowSession {
out InsetsState insetsState, out InsetsSourceControl[] activeControls,
out Bundle bundle);
/**
* Changes the view visibility and the attributes of a window. This should only be called when
* the visibility of the root view is changed. This returns a valid surface if the root view is
* visible. This also returns the latest information for the caller to compute its window frame.
*
* @param window The window being updated.
* @param attrs If non-null, new attributes to apply to the window.
* @param viewVisibility Window root view's visibility.
* @param outMergedConfiguration New config container that holds global, override and merged
* config for window, if it is now becoming visible and the merged configuration has changed
* since it was last displayed.
* @param outSurfaceControl Object in which is placed the new display surface.
* @param outInsetsState The current insets state in the system.
* @param outActiveControls The insets source controls for the caller to override the insets
* state in the system.
*
* @return int Result flags: {@link WindowManagerGlobal#RELAYOUT_FIRST_TIME}.
*/
int updateVisibility(IWindow window, in WindowManager.LayoutParams attrs, int viewVisibility,
out MergedConfiguration outMergedConfiguration, out SurfaceControl outSurfaceControl,
out InsetsState outInsetsState, out InsetsSourceControl[] outActiveControls);
/**
* Reports the layout results and the attributes of a window to the server.
*
* @param window The window being reported.
* @param attrs If non-null, new attributes to apply to the window.
* @param flags Request flags: {@link WindowManagerGlobal#RELAYOUT_INSETS_PENDING}.
* @param clientFrames the window frames computed by the client.
* @param requestedWidth The width the window wants to be.
* @param requestedHeight The height the window wants to be.
*/
oneway void updateLayout(IWindow window, in WindowManager.LayoutParams attrs, int flags,
in ClientWindowFrames clientFrames, int requestedWidth, int requestedHeight);
/*
* Notify the window manager that an application is relaunching and
* windows should be prepared for replacement.

View File

@@ -75,7 +75,6 @@ import static android.view.WindowManager.LayoutParams.PRIVATE_FLAG_INSET_PARENT_
import static android.view.WindowManager.LayoutParams.PRIVATE_FLAG_LAYOUT_SIZE_EXTENDED_BY_CUTOUT;
import static android.view.WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE;
import static android.view.WindowManager.LayoutParams.SOFT_INPUT_MASK_ADJUST;
import static android.view.WindowManager.LayoutParams.TYPE_APPLICATION_STARTING;
import static android.view.WindowManager.LayoutParams.TYPE_INPUT_METHOD;
import static android.view.WindowManager.LayoutParams.TYPE_STATUS_BAR_ADDITIONAL;
import static android.view.WindowManager.LayoutParams.TYPE_SYSTEM_ALERT;
@@ -8038,70 +8037,20 @@ public final class ViewRootImpl implements ViewParent,
final int requestedWidth = (int) (mView.getMeasuredWidth() * appScale + 0.5f);
final int requestedHeight = (int) (mView.getMeasuredHeight() * appScale + 0.5f);
int relayoutResult = 0;
WindowConfiguration winConfig = getConfiguration().windowConfiguration;
if (LOCAL_LAYOUT) {
if (mFirst || viewVisibility != mViewVisibility) {
relayoutResult = mWindowSession.updateVisibility(mWindow, params, viewVisibility,
mPendingMergedConfiguration, mSurfaceControl, mTempInsets, mTempControls);
if (mTranslator != null) {
mTranslator.translateInsetsStateInScreenToAppWindow(mTempInsets);
mTranslator.translateSourceControlsInScreenToAppWindow(mTempControls);
}
mInsetsController.onStateChanged(mTempInsets);
mInsetsController.onControlsChanged(mTempControls);
mPendingAlwaysConsumeSystemBars =
(relayoutResult & RELAYOUT_RES_CONSUME_ALWAYS_SYSTEM_BARS) != 0;
}
final InsetsState state = mInsetsController.getState();
final Rect displayCutoutSafe = mTempRect;
state.getDisplayCutoutSafe(displayCutoutSafe);
if (mWindowAttributes.type == TYPE_APPLICATION_STARTING) {
// TODO(b/210378379): Remove the special logic.
// Letting starting window use the window bounds from the pending config is for the
// fixed rotation, because the config is not overridden before the starting window
// is created.
winConfig = mPendingMergedConfiguration.getMergedConfiguration()
.windowConfiguration;
}
mWindowLayout.computeFrames(mWindowAttributes, state, displayCutoutSafe,
winConfig.getBounds(), winConfig.getWindowingMode(), requestedWidth,
requestedHeight, mInsetsController.getRequestedVisibilities(),
1f /* compatScale */, mTmpFrames);
mWindowSession.updateLayout(mWindow, params,
insetsPending ? WindowManagerGlobal.RELAYOUT_INSETS_PENDING : 0, mTmpFrames,
requestedWidth, requestedHeight);
} else {
relayoutResult = mWindowSession.relayout(mWindow, params,
requestedWidth, requestedHeight, viewVisibility,
insetsPending ? WindowManagerGlobal.RELAYOUT_INSETS_PENDING : 0,
mTmpFrames, mPendingMergedConfiguration, mSurfaceControl, mTempInsets,
mTempControls, mRelayoutBundle);
final int maybeSyncSeqId = mRelayoutBundle.getInt("seqid");
if (maybeSyncSeqId > 0) {
mSyncSeqId = maybeSyncSeqId;
}
if (mTranslator != null) {
mTranslator.translateRectInScreenToAppWindow(mTmpFrames.frame);
mTranslator.translateRectInScreenToAppWindow(mTmpFrames.displayFrame);
mTranslator.translateRectInScreenToAppWindow(mTmpFrames.attachedFrame);
mTranslator.translateInsetsStateInScreenToAppWindow(mTempInsets);
mTranslator.translateSourceControlsInScreenToAppWindow(mTempControls);
}
mInsetsController.onStateChanged(mTempInsets);
mInsetsController.onControlsChanged(mTempControls);
mPendingAlwaysConsumeSystemBars =
(relayoutResult & RELAYOUT_RES_CONSUME_ALWAYS_SYSTEM_BARS) != 0;
int relayoutResult = mWindowSession.relayout(mWindow, params,
requestedWidth, requestedHeight, viewVisibility,
insetsPending ? WindowManagerGlobal.RELAYOUT_INSETS_PENDING : 0,
mTmpFrames, mPendingMergedConfiguration, mSurfaceControl, mTempInsets,
mTempControls, mRelayoutBundle);
final int maybeSyncSeqId = mRelayoutBundle.getInt("seqid");
if (maybeSyncSeqId > 0) {
mSyncSeqId = maybeSyncSeqId;
}
final int transformHint = SurfaceControl.rotationToBufferTransform(
(mDisplayInstallOrientation + mDisplay.getRotation()) % 4);
final WindowConfiguration winConfig = getConfiguration().windowConfiguration;
WindowLayout.computeSurfaceSize(mWindowAttributes, winConfig.getMaxBounds(), requestedWidth,
requestedHeight, mTmpFrames.frame, mPendingDragResizing, mSurfaceSize);
@@ -8150,10 +8099,23 @@ public final class ViewRootImpl implements ViewParent,
destroySurface();
}
mPendingAlwaysConsumeSystemBars =
(relayoutResult & RELAYOUT_RES_CONSUME_ALWAYS_SYSTEM_BARS) != 0;
if (restore) {
params.restore();
}
if (mTranslator != null) {
mTranslator.translateRectInScreenToAppWindow(mTmpFrames.frame);
mTranslator.translateRectInScreenToAppWindow(mTmpFrames.displayFrame);
mTranslator.translateRectInScreenToAppWindow(mTmpFrames.attachedFrame);
mTranslator.translateInsetsStateInScreenToAppWindow(mTempInsets);
mTranslator.translateSourceControlsInScreenToAppWindow(mTempControls);
}
setFrame(mTmpFrames.frame);
mInsetsController.onStateChanged(mTempInsets);
mInsetsController.onControlsChanged(mTempControls);
return relayoutResult;
}

View File

@@ -337,21 +337,6 @@ public class WindowlessWindowManager implements IWindowSession {
return 0;
}
@Override
public int updateVisibility(IWindow window, WindowManager.LayoutParams inAttrs,
int viewVisibility, MergedConfiguration outMergedConfiguration,
SurfaceControl outSurfaceControl, InsetsState outInsetsState,
InsetsSourceControl[] outActiveControls) {
// TODO(b/161810301): Finish the implementation.
return 0;
}
@Override
public void updateLayout(IWindow window, WindowManager.LayoutParams inAttrs, int flags,
ClientWindowFrames clientWindowFrames, int requestedWidth, int requestedHeight) {
// TODO(b/161810301): Finish the implementation.
}
@Override
public void prepareToReplaceWindows(android.os.IBinder appToken, boolean childrenOnly) {
}

View File

@@ -20,10 +20,8 @@ import static android.app.WindowConfiguration.ACTIVITY_TYPE_HOME;
import static android.graphics.Color.WHITE;
import static android.graphics.Color.alpha;
import static android.os.Trace.TRACE_TAG_WINDOW_MANAGER;
import static android.view.ViewRootImpl.LOCAL_LAYOUT;
import static android.view.WindowInsetsController.APPEARANCE_LIGHT_NAVIGATION_BARS;
import static android.view.WindowInsetsController.APPEARANCE_LIGHT_STATUS_BARS;
import static android.view.WindowLayout.UNSPECIFIED_LENGTH;
import static android.view.WindowManager.LayoutParams.FLAG_ALT_FOCUSABLE_IM;
import static android.view.WindowManager.LayoutParams.FLAG_HARDWARE_ACCELERATED;
import static android.view.WindowManager.LayoutParams.FLAG_IGNORE_CHEEK_PRESSES;
@@ -53,7 +51,6 @@ import android.annotation.Nullable;
import android.app.ActivityManager;
import android.app.ActivityManager.TaskDescription;
import android.app.ActivityThread;
import android.app.WindowConfiguration;
import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Color;
@@ -80,7 +77,6 @@ import android.view.SurfaceSession;
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;
@@ -212,8 +208,6 @@ public class TaskSnapshotWindow {
final IWindowSession session = WindowManagerGlobal.getWindowSession();
final SurfaceControl surfaceControl = new SurfaceControl();
final ClientWindowFrames tmpFrames = new ClientWindowFrames();
final WindowLayout windowLayout = new WindowLayout();
final Rect displayCutoutSafe = new Rect();
final InsetsSourceControl[] tmpControls = new InsetsSourceControl[0];
final MergedConfiguration tmpMergedConfiguration = new MergedConfiguration();
@@ -251,25 +245,9 @@ public class TaskSnapshotWindow {
window.setOuter(snapshotSurface);
try {
Trace.traceBegin(TRACE_TAG_WINDOW_MANAGER, "TaskSnapshot#relayout");
if (LOCAL_LAYOUT) {
if (!surfaceControl.isValid()) {
session.updateVisibility(window, layoutParams, View.VISIBLE,
tmpMergedConfiguration, surfaceControl, tmpInsetsState, tmpControls);
}
tmpInsetsState.getDisplayCutoutSafe(displayCutoutSafe);
final WindowConfiguration winConfig =
tmpMergedConfiguration.getMergedConfiguration().windowConfiguration;
windowLayout.computeFrames(layoutParams, tmpInsetsState, displayCutoutSafe,
winConfig.getBounds(), winConfig.getWindowingMode(), UNSPECIFIED_LENGTH,
UNSPECIFIED_LENGTH, info.requestedVisibilities, 1f /* compatScale */,
tmpFrames);
session.updateLayout(window, layoutParams, 0 /* flags */, tmpFrames,
UNSPECIFIED_LENGTH, UNSPECIFIED_LENGTH);
} else {
session.relayout(window, layoutParams, -1, -1, View.VISIBLE, 0,
tmpFrames, tmpMergedConfiguration, surfaceControl, tmpInsetsState,
tmpControls, new Bundle());
}
session.relayout(window, layoutParams, -1, -1, View.VISIBLE, 0,
tmpFrames, tmpMergedConfiguration, surfaceControl, tmpInsetsState,
tmpControls, new Bundle());
Trace.traceEnd(TRACE_TAG_WINDOW_MANAGER);
} catch (RemoteException e) {
snapshotSurface.clearWindowSynced();

View File

@@ -115,8 +115,6 @@ class Session extends IWindowSession.Stub implements IBinder.DeathRecipient {
private float mLastReportedAnimatorScale;
private String mPackageName;
private String mRelayoutTag;
private String mUpdateViewVisibilityTag;
private String mUpdateWindowLayoutTag;
private final InsetsVisibilities mDummyRequestedVisibilities = new InsetsVisibilities();
private final InsetsSourceControl[] mDummyControls = new InsetsSourceControl[0];
final boolean mSetsUnrestrictedKeepClearAreas;
@@ -224,27 +222,6 @@ class Session extends IWindowSession.Stub implements IBinder.DeathRecipient {
mService.removeWindow(this, window);
}
@Override
public int updateVisibility(IWindow client, WindowManager.LayoutParams attrs,
int viewVisibility, MergedConfiguration outMergedConfiguration,
SurfaceControl outSurfaceControl, InsetsState outInsetsState,
InsetsSourceControl[] outActiveControls) {
Trace.traceBegin(TRACE_TAG_WINDOW_MANAGER, mUpdateViewVisibilityTag);
int res = mService.updateViewVisibility(this, client, attrs, viewVisibility,
outMergedConfiguration, outSurfaceControl, outInsetsState, outActiveControls);
Trace.traceEnd(TRACE_TAG_WINDOW_MANAGER);
return res;
}
@Override
public void updateLayout(IWindow window, WindowManager.LayoutParams attrs, int flags,
ClientWindowFrames clientFrames, int requestedWidth, int requestedHeight) {
Trace.traceBegin(TRACE_TAG_WINDOW_MANAGER, mUpdateWindowLayoutTag);
mService.updateWindowLayout(this, window, attrs, flags, clientFrames, requestedWidth,
requestedHeight);
Trace.traceEnd(TRACE_TAG_WINDOW_MANAGER);
}
@Override
public void prepareToReplaceWindows(IBinder appToken, boolean childrenOnly) {
mService.setWillReplaceWindows(appToken, childrenOnly);
@@ -717,8 +694,6 @@ class Session extends IWindowSession.Stub implements IBinder.DeathRecipient {
if (wpc != null) {
mPackageName = wpc.mInfo.packageName;
mRelayoutTag = "relayoutWindow: " + mPackageName;
mUpdateViewVisibilityTag = "updateVisibility: " + mPackageName;
mUpdateWindowLayoutTag = "updateLayout: " + mPackageName;
} else {
Slog.e(TAG_WM, "Unknown process pid=" + mPid);
}

View File

@@ -2675,29 +2675,6 @@ public class WindowManagerService extends IWindowManager.Stub
return result;
}
int updateViewVisibility(Session session, IWindow client, LayoutParams attrs,
int viewVisibility, MergedConfiguration outMergedConfiguration,
SurfaceControl outSurfaceControl, InsetsState outInsetsState,
InsetsSourceControl[] outActiveControls) {
// TODO(b/161810301): Finish the implementation.
return 0;
}
void updateWindowLayout(Session session, IWindow client, LayoutParams attrs, int flags,
ClientWindowFrames clientWindowFrames, int requestedWidth, int requestedHeight) {
final long origId = Binder.clearCallingIdentity();
synchronized (mGlobalLock) {
final WindowState win = windowForClientLocked(session, client, false);
if (win == null) {
return;
}
win.setFrames(clientWindowFrames, requestedWidth, requestedHeight);
// TODO(b/161810301): Finish the implementation.
}
Binder.restoreCallingIdentity(origId);
}
public boolean outOfMemoryWindow(Session session, IWindow client) {
final long origId = Binder.clearCallingIdentity();