summaryrefslogtreecommitdiff
path: root/core/java
diff options
context:
space:
mode:
authorRiddle Hsu <riddlehsu@google.com>2020-09-03 00:29:30 +0800
committerRiddle Hsu <riddlehsu@google.com>2020-09-10 00:26:11 +0800
commitccaeffc03f275525c9fe66539b2d50f1076303fa (patch)
tree9af20a0e157abb1c9c97b752bf8b06c959e895f1 /core/java
parent46969117366fed264cfe0fa8dd49fa5f1b4558cf (diff)
Remove Session#getDisplayFrame
The frame won't be changed if there is no IWindow#resized or IWindowSession#relayout. So it can be retrieved from these methods directly instead of another binder transaction. And because some parameters are usually used together for layout, the parameters are consolidated into a new ClientWindowFrames. That reduces changing the interface in the future if the frame related information needs to be changed. Also refine the resize handling in ViewRootImpl to make it easier to read. There should be no behavior change by this modification. Bug: 161781274 Test: WmTests, DialogFrameTests Change-Id: I9f711ad2023442046fa8582944320b98e7c4ecfa
Diffstat (limited to 'core/java')
-rw-r--r--core/java/android/service/wallpaper/WallpaperService.java69
-rw-r--r--core/java/android/view/IWindow.aidl9
-rw-r--r--core/java/android/view/IWindowSession.aidl12
-rw-r--r--core/java/android/view/View.java16
-rw-r--r--core/java/android/view/ViewDebug.java7
-rw-r--r--core/java/android/view/ViewRootImpl.java184
-rw-r--r--core/java/android/view/WindowlessWindowManager.java13
-rw-r--r--core/java/android/window/ClientWindowFrames.aidl19
-rw-r--r--core/java/android/window/ClientWindowFrames.java125
-rw-r--r--core/java/com/android/internal/view/BaseIWindow.java11
10 files changed, 286 insertions, 179 deletions
diff --git a/core/java/android/service/wallpaper/WallpaperService.java b/core/java/android/service/wallpaper/WallpaperService.java
index e083417644e3..19860eb45fbf 100644
--- a/core/java/android/service/wallpaper/WallpaperService.java
+++ b/core/java/android/service/wallpaper/WallpaperService.java
@@ -71,6 +71,7 @@ import android.view.ViewGroup;
import android.view.WindowInsets;
import android.view.WindowManager;
import android.view.WindowManagerGlobal;
+import android.window.ClientWindowFrames;
import com.android.internal.annotations.VisibleForTesting;
import com.android.internal.os.HandlerCaller;
@@ -186,17 +187,11 @@ public abstract class WallpaperService extends Service {
int mCurWindowFlags = mWindowFlags;
int mCurWindowPrivateFlags = mWindowPrivateFlags;
Rect mPreviewSurfacePosition;
- final Rect mVisibleInsets = new Rect();
- final Rect mWinFrame = new Rect();
- final Rect mContentInsets = new Rect();
- final Rect mStableInsets = new Rect();
+ final ClientWindowFrames mWinFrames = new ClientWindowFrames();
final Rect mDispatchedContentInsets = new Rect();
final Rect mDispatchedStableInsets = new Rect();
final Rect mFinalSystemInsets = new Rect();
final Rect mFinalStableInsets = new Rect();
- final Rect mBackdropFrame = new Rect();
- final DisplayCutout.ParcelableWrapper mDisplayCutout =
- new DisplayCutout.ParcelableWrapper();
DisplayCutout mDispatchedDisplayCutout = DisplayCutout.NO_CUTOUT;
final InsetsState mInsetsState = new InsetsState();
final InsetsSourceControl[] mTempControls = new InsetsSourceControl[0];
@@ -332,11 +327,9 @@ public abstract class WallpaperService extends Service {
final BaseIWindow mWindow = new BaseIWindow() {
@Override
- public void resized(Rect frame, Rect contentInsets,
- Rect visibleInsets, Rect stableInsets, boolean reportDraw,
- MergedConfiguration mergedConfiguration, Rect backDropRect, boolean forceLayout,
- boolean alwaysConsumeSystemBars, int displayId,
- DisplayCutout.ParcelableWrapper displayCutout) {
+ 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);
mCaller.sendMessage(msg);
@@ -749,10 +742,7 @@ public abstract class WallpaperService extends Service {
out.print(" mCurWindowFlags="); out.println(mCurWindowFlags);
out.print(prefix); out.print("mWindowPrivateFlags="); out.print(mWindowPrivateFlags);
out.print(" mCurWindowPrivateFlags="); out.println(mCurWindowPrivateFlags);
- out.print(prefix); out.print("mVisibleInsets=");
- out.print(mVisibleInsets.toShortString());
- out.print(" mWinFrame="); out.print(mWinFrame.toShortString());
- out.print(" mContentInsets="); out.println(mContentInsets.toShortString());
+ out.print(prefix); out.println("mWinFrames="); out.println(mWinFrames);
out.print(prefix); out.print("mConfiguration=");
out.println(mMergedConfiguration.getMergedConfiguration());
out.print(prefix); out.print("mLayout="); out.println(mLayout);
@@ -890,8 +880,8 @@ public abstract class WallpaperService extends Service {
InputChannel inputChannel = new InputChannel();
if (mSession.addToDisplay(mWindow, mWindow.mSeq, mLayout, View.VISIBLE,
- mDisplay.getDisplayId(), mWinFrame, mContentInsets, mStableInsets,
- mDisplayCutout, inputChannel,
+ mDisplay.getDisplayId(), mWinFrames.frame, mWinFrames.contentInsets,
+ mWinFrames.stableInsets, mWinFrames.displayCutout, inputChannel,
mInsetsState, mTempControls) < 0) {
Log.w(TAG, "Failed to add window while updating wallpaper surface.");
return;
@@ -914,34 +904,32 @@ public abstract class WallpaperService extends Service {
final int relayoutResult = mSession.relayout(
mWindow, mWindow.mSeq, mLayout, mWidth, mHeight,
- View.VISIBLE, 0, -1, mWinFrame, mContentInsets,
- mVisibleInsets, mStableInsets, mBackdropFrame,
- mDisplayCutout, mMergedConfiguration, mSurfaceControl,
+ View.VISIBLE, 0, -1, mWinFrames, mMergedConfiguration, mSurfaceControl,
mInsetsState, mTempControls, mSurfaceSize, mTmpSurfaceControl);
if (mSurfaceControl.isValid()) {
mSurfaceHolder.mSurface.copyFrom(mSurfaceControl);
}
if (DEBUG) Log.v(TAG, "New surface: " + mSurfaceHolder.mSurface
- + ", frame=" + mWinFrame);
+ + ", frame=" + mWinFrames);
- int w = mWinFrame.width();
- int h = mWinFrame.height();
+ int w = mWinFrames.frame.width();
+ int h = mWinFrames.frame.height();
if (!fixedSize) {
final Rect padding = mIWallpaperEngine.mDisplayPadding;
w += padding.left + padding.right;
h += padding.top + padding.bottom;
- mContentInsets.left += padding.left;
- mContentInsets.top += padding.top;
- mContentInsets.right += padding.right;
- mContentInsets.bottom += padding.bottom;
- mStableInsets.left += padding.left;
- mStableInsets.top += padding.top;
- mStableInsets.right += padding.right;
- mStableInsets.bottom += padding.bottom;
- mDisplayCutout.set(mDisplayCutout.get().inset(-padding.left, -padding.top,
- -padding.right, -padding.bottom));
+ mWinFrames.contentInsets.left += padding.left;
+ mWinFrames.contentInsets.top += padding.top;
+ mWinFrames.contentInsets.right += padding.right;
+ mWinFrames.contentInsets.bottom += padding.bottom;
+ mWinFrames.stableInsets.left += padding.left;
+ mWinFrames.stableInsets.top += padding.top;
+ mWinFrames.stableInsets.right += padding.right;
+ mWinFrames.stableInsets.bottom += padding.bottom;
+ mWinFrames.displayCutout.set(mWinFrames.displayCutout.get().inset(
+ -padding.left, -padding.top, -padding.right, -padding.bottom));
} else {
w = myWidth;
h = myHeight;
@@ -960,9 +948,10 @@ public abstract class WallpaperService extends Service {
Log.v(TAG, "Wallpaper size has changed: (" + mCurWidth + ", " + mCurHeight);
}
- insetsChanged |= !mDispatchedContentInsets.equals(mContentInsets);
- insetsChanged |= !mDispatchedStableInsets.equals(mStableInsets);
- insetsChanged |= !mDispatchedDisplayCutout.equals(mDisplayCutout.get());
+ final DisplayCutout displayCutout = mWinFrames.displayCutout.get();
+ insetsChanged |= !mDispatchedContentInsets.equals(mWinFrames.contentInsets);
+ insetsChanged |= !mDispatchedStableInsets.equals(mWinFrames.stableInsets);
+ insetsChanged |= !mDispatchedDisplayCutout.equals(displayCutout);
mSurfaceHolder.setSurfaceFrameSize(w, h);
mSurfaceHolder.mSurfaceLock.unlock();
@@ -1021,9 +1010,9 @@ public abstract class WallpaperService extends Service {
}
if (insetsChanged) {
- mDispatchedContentInsets.set(mContentInsets);
- mDispatchedStableInsets.set(mStableInsets);
- mDispatchedDisplayCutout = mDisplayCutout.get();
+ mDispatchedContentInsets.set(mWinFrames.contentInsets);
+ mDispatchedStableInsets.set(mWinFrames.stableInsets);
+ mDispatchedDisplayCutout = displayCutout;
mFinalStableInsets.set(mDispatchedStableInsets);
WindowInsets insets = new WindowInsets(mFinalSystemInsets,
mFinalStableInsets,
diff --git a/core/java/android/view/IWindow.aidl b/core/java/android/view/IWindow.aidl
index e09bf9d2e80a..94e641c62b25 100644
--- a/core/java/android/view/IWindow.aidl
+++ b/core/java/android/view/IWindow.aidl
@@ -29,6 +29,7 @@ import android.view.InsetsState;
import android.view.IScrollCaptureController;
import android.view.KeyEvent;
import android.view.MotionEvent;
+import android.window.ClientWindowFrames;
import com.android.internal.os.IResultReceiver;
@@ -52,11 +53,9 @@ oneway interface IWindow {
*/
void executeCommand(String command, String parameters, in ParcelFileDescriptor descriptor);
- void resized(in Rect frame, in Rect contentInsets,
- in Rect visibleInsets, in Rect stableInsets, boolean reportDraw,
- in MergedConfiguration newMergedConfiguration, in Rect backDropFrame,
- boolean forceLayout, boolean alwaysConsumeSystemBars, int displayId,
- in DisplayCutout.ParcelableWrapper displayCutout);
+ void resized(in ClientWindowFrames frames, boolean reportDraw,
+ in MergedConfiguration newMergedConfiguration,
+ boolean forceLayout, boolean alwaysConsumeSystemBars, int displayId);
/**
* Called when the window location in parent display has changed. The offset will only be a
diff --git a/core/java/android/view/IWindowSession.aidl b/core/java/android/view/IWindowSession.aidl
index 819e89b67b38..70850d855161 100644
--- a/core/java/android/view/IWindowSession.aidl
+++ b/core/java/android/view/IWindowSession.aidl
@@ -34,6 +34,7 @@ import android.view.InsetsState;
import android.view.Surface;
import android.view.SurfaceControl;
import android.view.SurfaceControl.Transaction;
+import android.window.ClientWindowFrames;
import java.util.List;
@@ -107,10 +108,7 @@ interface IWindowSession {
*/
int relayout(IWindow window, int seq, in WindowManager.LayoutParams attrs,
int requestedWidth, int requestedHeight, int viewVisibility,
- int flags, long frameNumber, out Rect outFrame,
- out Rect outContentInsets, out Rect outVisibleInsets, out Rect outStableInsets,
- out Rect outBackdropFrame,
- out DisplayCutout.ParcelableWrapper displayCutout,
+ int flags, long frameNumber, out ClientWindowFrames outFrames,
out MergedConfiguration outMergedConfiguration, out SurfaceControl outSurfaceControl,
out InsetsState insetsState, out InsetsSourceControl[] activeControls,
out Point outSurfaceSize, out SurfaceControl outBlastSurfaceControl);
@@ -152,12 +150,6 @@ interface IWindowSession {
in Rect visibleInsets, in Region touchableRegion);
/**
- * Return the current display size in which the window is being laid out,
- * accounting for screen decorations around it.
- */
- void getDisplayFrame(IWindow window, out Rect outDisplayFrame);
-
- /**
* Called when the client has finished drawing the surface, if needed.
*
* @param postDrawTransaction transaction filled by the client that can be
diff --git a/core/java/android/view/View.java b/core/java/android/view/View.java
index 89178217366f..92a0f633aba0 100644
--- a/core/java/android/view/View.java
+++ b/core/java/android/view/View.java
@@ -14940,20 +14940,12 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
* inside. In effect, this tells you the available area where content can
* be placed and remain visible to users.
*
- * <p>This function requires an IPC back to the window manager to retrieve
- * the requested information, so should not be used in performance critical
- * code like drawing.
- *
* @param outRect Filled in with the visible display frame. If the view
* is not attached to a window, this is simply the raw display size.
*/
public void getWindowVisibleDisplayFrame(Rect outRect) {
if (mAttachInfo != null) {
- try {
- mAttachInfo.mSession.getDisplayFrame(mAttachInfo.mWindow, outRect);
- } catch (RemoteException e) {
- return;
- }
+ mAttachInfo.mViewRootImpl.getDisplayFrame(outRect);
// XXX This is really broken, and probably all needs to be done
// in the window manager, and we need to know more about whether
// we want the area behind or in front of the IME.
@@ -14979,11 +14971,7 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
@UnsupportedAppUsage
public void getWindowDisplayFrame(Rect outRect) {
if (mAttachInfo != null) {
- try {
- mAttachInfo.mSession.getDisplayFrame(mAttachInfo.mWindow, outRect);
- } catch (RemoteException e) {
- return;
- }
+ mAttachInfo.mViewRootImpl.getDisplayFrame(outRect);
return;
}
// The view is not attached to a display so we don't have a context.
diff --git a/core/java/android/view/ViewDebug.java b/core/java/android/view/ViewDebug.java
index 8a5be75b6c31..4303d705f945 100644
--- a/core/java/android/view/ViewDebug.java
+++ b/core/java/android/view/ViewDebug.java
@@ -33,7 +33,6 @@ import android.os.Debug;
import android.os.Handler;
import android.os.Looper;
import android.os.Message;
-import android.os.RemoteException;
import android.util.DisplayMetrics;
import android.util.Log;
import android.util.TypedValue;
@@ -755,11 +754,7 @@ public class ViewDebug {
try {
Rect outRect = new Rect();
- try {
- root.mAttachInfo.mSession.getDisplayFrame(root.mAttachInfo.mWindow, outRect);
- } catch (RemoteException e) {
- // Ignore
- }
+ root.mAttachInfo.mViewRootImpl.getDisplayFrame(outRect);
clientStream.writeInt(outRect.width());
clientStream.writeInt(outRect.height());
diff --git a/core/java/android/view/ViewRootImpl.java b/core/java/android/view/ViewRootImpl.java
index f3a8d9754fd4..96ed131a716a 100644
--- a/core/java/android/view/ViewRootImpl.java
+++ b/core/java/android/view/ViewRootImpl.java
@@ -137,7 +137,6 @@ import android.view.View.MeasureSpec;
import android.view.Window.OnContentApplyWindowInsetsListener;
import android.view.WindowInsets.Type;
import android.view.WindowInsets.Type.InsetsType;
-import android.view.WindowManager.LayoutParams;
import android.view.WindowManager.LayoutParams.SoftInputModeFlags;
import android.view.accessibility.AccessibilityEvent;
import android.view.accessibility.AccessibilityManager;
@@ -160,6 +159,7 @@ import android.view.contentcapture.ContentCaptureSession;
import android.view.contentcapture.MainContentCaptureSession;
import android.view.inputmethod.InputMethodManager;
import android.widget.Scroller;
+import android.window.ClientWindowFrames;
import com.android.internal.R;
import com.android.internal.annotations.GuardedBy;
@@ -559,8 +559,11 @@ public final class ViewRootImpl implements ViewParent,
boolean mAdded;
boolean mAddedTouchMode;
- final Rect mTmpFrame = new Rect();
- final Rect mTmpRect = new Rect();
+ /**
+ * It usually keeps the latest layout result from {@link IWindow#resized} or
+ * {@link IWindowSession#relayout}.
+ */
+ private final ClientWindowFrames mTmpFrames = new ClientWindowFrames();
// These are accessed by multiple threads.
final Rect mWinFrame; // frame given by window manager.
@@ -1032,11 +1035,11 @@ public final class ViewRootImpl implements ViewParent,
collectViewAttributes();
adjustLayoutParamsForCompatibility(mWindowAttributes);
res = mWindowSession.addToDisplayAsUser(mWindow, mSeq, mWindowAttributes,
- getHostVisibility(), mDisplay.getDisplayId(), userId, mTmpFrame,
+ getHostVisibility(), mDisplay.getDisplayId(), userId, mTmpFrames.frame,
mAttachInfo.mContentInsets, mAttachInfo.mStableInsets,
mAttachInfo.mDisplayCutout, inputChannel,
mTempInsets, mTempControls);
- setFrame(mTmpFrame);
+ setFrame(mTmpFrames.frame);
} catch (RemoteException e) {
mAdded = false;
mView = null;
@@ -1474,6 +1477,55 @@ public final class ViewRootImpl implements ViewParent,
scheduleTraversals();
}
+ /** Handles messages {@link #MSG_RESIZED} and {@link #MSG_RESIZED_REPORT}. */
+ private void handleResized(int msg, SomeArgs args) {
+ if (!mAdded) {
+ return;
+ }
+
+ final ClientWindowFrames frames = (ClientWindowFrames) args.arg1;
+ final MergedConfiguration mergedConfiguration = (MergedConfiguration) args.arg2;
+ final boolean forceNextWindowRelayout = args.argi1 != 0;
+ final int displayId = args.argi3;
+ final Rect backdropFrame = frames.backdropFrame;
+ final DisplayCutout displayCutout = frames.displayCutout.get();
+
+ final boolean frameChanged = !mWinFrame.equals(frames.frame);
+ final boolean cutoutChanged = !mPendingDisplayCutout.get().equals(displayCutout);
+ final boolean backdropFrameChanged = !mPendingBackDropFrame.equals(backdropFrame);
+ final boolean configChanged = !mLastReportedMergedConfiguration.equals(mergedConfiguration);
+ final boolean displayChanged = mDisplay.getDisplayId() != displayId;
+ if (msg == MSG_RESIZED && !frameChanged && !cutoutChanged && !backdropFrameChanged
+ && !configChanged && !displayChanged && !forceNextWindowRelayout) {
+ return;
+ }
+
+ if (configChanged) {
+ // If configuration changed - notify about that and, maybe, about move to display.
+ performConfigurationChange(mergedConfiguration, false /* force */,
+ displayChanged ? displayId : INVALID_DISPLAY /* same display */);
+ } else if (displayChanged) {
+ // Moved to display without config change - report last applied one.
+ onMovedToDisplay(displayId, mLastConfigurationFromResources);
+ }
+
+ setFrame(frames.frame);
+ mTmpFrames.displayFrame.set(frames.displayFrame);
+ mPendingDisplayCutout.set(displayCutout);
+ mPendingBackDropFrame.set(backdropFrame);
+ mForceNextWindowRelayout = forceNextWindowRelayout;
+ mPendingAlwaysConsumeSystemBars = args.argi2 != 0;
+
+ if (msg == MSG_RESIZED_REPORT) {
+ reportNextDraw();
+ }
+
+ if (mView != null && (frameChanged || cutoutChanged || configChanged)) {
+ forceLayout(mView);
+ }
+ requestLayout();
+ }
+
private final DisplayListener mDisplayListener = new DisplayListener() {
@Override
public void onDisplayChanged(int displayId) {
@@ -4919,60 +4971,13 @@ public final class ViewRootImpl implements ViewParent,
case MSG_DISPATCH_GET_NEW_SURFACE:
handleGetNewSurface();
break;
- case MSG_RESIZED: {
- // Recycled in the fall through...
- SomeArgs args = (SomeArgs) msg.obj;
- if (mWinFrame.equals(args.arg1)
- && mPendingDisplayCutout.get().equals(args.arg9)
- && mPendingBackDropFrame.equals(args.arg8)
- && mLastReportedMergedConfiguration.equals(args.arg4)
- && args.argi1 == 0
- && mDisplay.getDisplayId() == args.argi3) {
- break;
- }
- } // fall through...
- case MSG_RESIZED_REPORT:
- if (mAdded) {
- SomeArgs args = (SomeArgs) msg.obj;
-
- final int displayId = args.argi3;
- MergedConfiguration mergedConfiguration = (MergedConfiguration) args.arg4;
- final boolean displayChanged = mDisplay.getDisplayId() != displayId;
- boolean configChanged = false;
-
- if (!mLastReportedMergedConfiguration.equals(mergedConfiguration)) {
- // If configuration changed - notify about that and, maybe,
- // about move to display.
- performConfigurationChange(mergedConfiguration, false /* force */,
- displayChanged
- ? displayId : INVALID_DISPLAY /* same display */);
- configChanged = true;
- } else if (displayChanged) {
- // Moved to display without config change - report last applied one.
- onMovedToDisplay(displayId, mLastConfigurationFromResources);
- }
-
- final boolean framesChanged = !mWinFrame.equals(args.arg1)
- || !mPendingDisplayCutout.get().equals(args.arg9);
-
- setFrame((Rect) args.arg1);
- mPendingDisplayCutout.set((DisplayCutout) args.arg9);
- mPendingBackDropFrame.set((Rect) args.arg8);
- mForceNextWindowRelayout = args.argi1 != 0;
- mPendingAlwaysConsumeSystemBars = args.argi2 != 0;
-
- args.recycle();
-
- if (msg.what == MSG_RESIZED_REPORT) {
- reportNextDraw();
- }
-
- if (mView != null && (framesChanged || configChanged)) {
- forceLayout(mView);
- }
- requestLayout();
- }
+ case MSG_RESIZED:
+ case MSG_RESIZED_REPORT: {
+ final SomeArgs args = (SomeArgs) msg.obj;
+ handleResized(msg.what, args);
+ args.recycle();
break;
+ }
case MSG_INSETS_CHANGED:
mInsetsController.onStateChanged((InsetsState) msg.obj);
break;
@@ -5007,11 +5012,11 @@ public final class ViewRootImpl implements ViewParent,
final int h = mWinFrame.height();
final int l = msg.arg1;
final int t = msg.arg2;
- mTmpFrame.left = l;
- mTmpFrame.right = l + w;
- mTmpFrame.top = t;
- mTmpFrame.bottom = t + h;
- setFrame(mTmpFrame);
+ mTmpFrames.frame.left = l;
+ mTmpFrames.frame.right = l + w;
+ mTmpFrames.frame.top = t;
+ mTmpFrames.frame.bottom = t + h;
+ setFrame(mTmpFrames.frame);
mPendingBackDropFrame.set(mWinFrame);
maybeHandleWindowMove(mWinFrame);
@@ -7418,9 +7423,10 @@ public final class ViewRootImpl implements ViewParent,
(int) (mView.getMeasuredWidth() * appScale + 0.5f),
(int) (mView.getMeasuredHeight() * appScale + 0.5f), viewVisibility,
insetsPending ? WindowManagerGlobal.RELAYOUT_INSETS_PENDING : 0, frameNumber,
- mTmpFrame, mTmpRect, mTmpRect, mTmpRect, mPendingBackDropFrame,
- mPendingDisplayCutout, mPendingMergedConfiguration, mSurfaceControl, mTempInsets,
+ mTmpFrames, mPendingMergedConfiguration, mSurfaceControl, mTempInsets,
mTempControls, mSurfaceSize, mBlastSurfaceControl);
+ mPendingDisplayCutout.set(mTmpFrames.displayCutout);
+ mPendingBackDropFrame.set(mTmpFrames.backdropFrame);
if (mSurfaceControl.isValid()) {
if (!useBLAST()) {
mSurface.copyFrom(mSurfaceControl);
@@ -7446,9 +7452,9 @@ public final class ViewRootImpl implements ViewParent,
}
if (mTranslator != null) {
- mTranslator.translateRectInScreenToAppWinFrame(mTmpFrame);
+ mTranslator.translateRectInScreenToAppWinFrame(mTmpFrames.frame);
}
- setFrame(mTmpFrame);
+ setFrame(mTmpFrames.frame);
mInsetsController.onStateChanged(mTempInsets);
mInsetsController.onControlsChanged(mTempControls);
return relayoutResult;
@@ -7460,6 +7466,14 @@ public final class ViewRootImpl implements ViewParent,
}
/**
+ * Gets the current display size in which the window is being laid out, accounting for screen
+ * decorations around it.
+ */
+ void getDisplayFrame(Rect outFrame) {
+ outFrame.set(mTmpFrames.displayFrame);
+ }
+
+ /**
* {@inheritDoc}
*/
@Override
@@ -7742,11 +7756,14 @@ public final class ViewRootImpl implements ViewParent,
}
@UnsupportedAppUsage
- private void dispatchResized(Rect frame, Rect contentInsets,
- Rect visibleInsets, Rect stableInsets, boolean reportDraw,
- MergedConfiguration mergedConfiguration, Rect backDropFrame, boolean forceLayout,
- boolean alwaysConsumeSystemBars, int displayId,
- DisplayCutout.ParcelableWrapper displayCutout) {
+ private void dispatchResized(ClientWindowFrames frames, boolean reportDraw,
+ MergedConfiguration mergedConfiguration, boolean forceLayout,
+ boolean alwaysConsumeSystemBars, int displayId) {
+ final Rect frame = frames.frame;
+ final Rect contentInsets = frames.contentInsets;
+ final Rect visibleInsets = frames.visibleInsets;
+ final Rect stableInsets = frames.stableInsets;
+ final Rect backDropFrame = frames.backdropFrame;
if (DEBUG_LAYOUT) Log.v(mTag, "Resizing " + this + ": frame=" + frame.toShortString()
+ " contentInsets=" + contentInsets.toShortString()
+ " visibleInsets=" + visibleInsets.toShortString()
@@ -7773,14 +7790,9 @@ public final class ViewRootImpl implements ViewParent,
}
SomeArgs args = SomeArgs.obtain();
final boolean sameProcessCall = (Binder.getCallingPid() == android.os.Process.myPid());
- args.arg1 = sameProcessCall ? new Rect(frame) : frame;
- args.arg2 = sameProcessCall ? new Rect(contentInsets) : contentInsets;
- args.arg3 = sameProcessCall ? new Rect(visibleInsets) : visibleInsets;
- args.arg4 = sameProcessCall && mergedConfiguration != null
+ args.arg1 = sameProcessCall ? new ClientWindowFrames(frames) : frames;
+ args.arg2 = sameProcessCall && mergedConfiguration != null
? new MergedConfiguration(mergedConfiguration) : mergedConfiguration;
- args.arg6 = sameProcessCall ? new Rect(stableInsets) : stableInsets;
- args.arg8 = sameProcessCall ? new Rect(backDropFrame) : backDropFrame;
- args.arg9 = displayCutout.get(); // DisplayCutout is immutable.
args.argi1 = forceLayout ? 1 : 0;
args.argi2 = alwaysConsumeSystemBars ? 1 : 0;
args.argi3 = displayId;
@@ -9074,17 +9086,13 @@ public final class ViewRootImpl implements ViewParent,
}
@Override
- public void resized(Rect frame, Rect contentInsets,
- Rect visibleInsets, Rect stableInsets, boolean reportDraw,
- MergedConfiguration mergedConfiguration, Rect backDropFrame, boolean forceLayout,
- boolean alwaysConsumeSystemBars, int displayId,
- DisplayCutout.ParcelableWrapper displayCutout) {
+ public void resized(ClientWindowFrames frames, boolean reportDraw,
+ MergedConfiguration mergedConfiguration, boolean forceLayout,
+ boolean alwaysConsumeSystemBars, int displayId) {
final ViewRootImpl viewAncestor = mViewAncestor.get();
if (viewAncestor != null) {
- viewAncestor.dispatchResized(frame, contentInsets,
- visibleInsets, stableInsets, reportDraw, mergedConfiguration,
- backDropFrame, forceLayout, alwaysConsumeSystemBars, displayId,
- displayCutout);
+ viewAncestor.dispatchResized(frames, reportDraw, mergedConfiguration, forceLayout,
+ alwaysConsumeSystemBars, displayId);
}
}
diff --git a/core/java/android/view/WindowlessWindowManager.java b/core/java/android/view/WindowlessWindowManager.java
index 060311ec3da8..368918d28f80 100644
--- a/core/java/android/view/WindowlessWindowManager.java
+++ b/core/java/android/view/WindowlessWindowManager.java
@@ -26,6 +26,7 @@ import android.os.IBinder;
import android.os.RemoteException;
import android.util.Log;
import android.util.MergedConfiguration;
+import android.window.ClientWindowFrames;
import java.util.HashMap;
import java.util.Objects;
@@ -224,9 +225,7 @@ public class WindowlessWindowManager implements IWindowSession {
@Override
public int relayout(IWindow window, int seq, WindowManager.LayoutParams inAttrs,
int requestedWidth, int requestedHeight, int viewFlags, int flags, long frameNumber,
- Rect outFrame, Rect outContentInsets, Rect outVisibleInsets,
- Rect outStableInsets, Rect outBackdropFrame,
- DisplayCutout.ParcelableWrapper cutout, MergedConfiguration mergedConfiguration,
+ ClientWindowFrames outFrames, MergedConfiguration mergedConfiguration,
SurfaceControl outSurfaceControl, InsetsState outInsetsState,
InsetsSourceControl[] outActiveControls, Point outSurfaceSize,
SurfaceControl outBLASTSurfaceControl) {
@@ -255,7 +254,8 @@ public class WindowlessWindowManager implements IWindowSession {
t.hide(sc).apply();
outSurfaceControl.release();
}
- outFrame.set(0, 0, attrs.width, attrs.height);
+ outFrames.frame.set(0, 0, attrs.width, attrs.height);
+ outFrames.displayFrame.set(outFrames.frame);
mergedConfiguration.setConfiguration(mConfiguration, mConfiguration);
@@ -292,11 +292,6 @@ public class WindowlessWindowManager implements IWindowSession {
}
@Override
- public void getDisplayFrame(android.view.IWindow window,
- android.graphics.Rect outDisplayFrame) {
- }
-
- @Override
public void finishDrawing(android.view.IWindow window,
android.view.SurfaceControl.Transaction postDrawTransaction) {
synchronized (this) {
diff --git a/core/java/android/window/ClientWindowFrames.aidl b/core/java/android/window/ClientWindowFrames.aidl
new file mode 100644
index 000000000000..22bbea90d35a
--- /dev/null
+++ b/core/java/android/window/ClientWindowFrames.aidl
@@ -0,0 +1,19 @@
+/*
+ * Copyright (C) 2020 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.window;
+
+parcelable ClientWindowFrames;
diff --git a/core/java/android/window/ClientWindowFrames.java b/core/java/android/window/ClientWindowFrames.java
new file mode 100644
index 000000000000..0523e64f3e7a
--- /dev/null
+++ b/core/java/android/window/ClientWindowFrames.java
@@ -0,0 +1,125 @@
+/*
+ * Copyright (C) 2020 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.window;
+
+import android.annotation.NonNull;
+import android.graphics.Rect;
+import android.os.Parcel;
+import android.os.Parcelable;
+import android.view.DisplayCutout;
+
+/**
+ * The window frame container class used by client side for layout.
+ * @hide
+ */
+public class ClientWindowFrames implements Parcelable {
+ /** The actual window bounds. */
+ public final @NonNull Rect frame;
+
+ /**
+ * The container frame that is usually the same as display size. It may exclude the area of
+ * insets if the window layout parameter has specified fit-insets-sides.
+ */
+ public final @NonNull Rect displayFrame;
+
+ /** The background area while the window is resizing. */
+ public final @NonNull Rect backdropFrame;
+
+ /** The area cut from the display. */
+ public final @NonNull DisplayCutout.ParcelableWrapper displayCutout;
+
+ // TODO(b/149813814): Remove legacy insets.
+ public final Rect contentInsets;
+ public final Rect visibleInsets;
+ public final Rect stableInsets;
+
+ public ClientWindowFrames() {
+ frame = new Rect();
+ displayFrame = new Rect();
+ backdropFrame = new Rect();
+ displayCutout = new DisplayCutout.ParcelableWrapper();
+ contentInsets = new Rect();
+ visibleInsets = new Rect();
+ stableInsets = new Rect();
+ }
+
+ public ClientWindowFrames(ClientWindowFrames other) {
+ frame = new Rect(other.frame);
+ displayFrame = new Rect(other.displayFrame);
+ backdropFrame = new Rect(other.backdropFrame);
+ displayCutout = new DisplayCutout.ParcelableWrapper(other.displayCutout.get());
+ contentInsets = new Rect(other.contentInsets);
+ visibleInsets = new Rect(other.visibleInsets);
+ stableInsets = new Rect(other.stableInsets);
+ }
+
+ private ClientWindowFrames(Parcel in) {
+ frame = Rect.CREATOR.createFromParcel(in);
+ displayFrame = Rect.CREATOR.createFromParcel(in);
+ backdropFrame = Rect.CREATOR.createFromParcel(in);
+ displayCutout = DisplayCutout.ParcelableWrapper.CREATOR.createFromParcel(in);
+ contentInsets = Rect.CREATOR.createFromParcel(in);
+ visibleInsets = Rect.CREATOR.createFromParcel(in);
+ stableInsets = Rect.CREATOR.createFromParcel(in);
+ }
+
+ /** Needed for AIDL out parameters. */
+ public void readFromParcel(Parcel in) {
+ frame.set(Rect.CREATOR.createFromParcel(in));
+ displayFrame.set(Rect.CREATOR.createFromParcel(in));
+ backdropFrame.set(Rect.CREATOR.createFromParcel(in));
+ displayCutout.set(DisplayCutout.ParcelableWrapper.CREATOR.createFromParcel(in));
+ contentInsets.set(Rect.CREATOR.createFromParcel(in));
+ visibleInsets.set(Rect.CREATOR.createFromParcel(in));
+ stableInsets.set(Rect.CREATOR.createFromParcel(in));
+ }
+
+ @Override
+ public void writeToParcel(Parcel dest, int flags) {
+ frame.writeToParcel(dest, flags);
+ displayFrame.writeToParcel(dest, flags);
+ backdropFrame.writeToParcel(dest, flags);
+ displayCutout.writeToParcel(dest, flags);
+ contentInsets.writeToParcel(dest, flags);
+ visibleInsets.writeToParcel(dest, flags);
+ stableInsets.writeToParcel(dest, flags);
+ }
+
+ @Override
+ public String toString() {
+ final StringBuilder sb = new StringBuilder(32);
+ return "ClientWindowFrames{frame=" + frame.toShortString(sb)
+ + " display=" + displayFrame.toShortString(sb)
+ + " backdrop=" + backdropFrame.toShortString(sb)
+ + " cutout=" + displayCutout + "}";
+ }
+
+ @Override
+ public int describeContents() {
+ return 0;
+ }
+
+ public static final Creator<ClientWindowFrames> CREATOR = new Creator<ClientWindowFrames>() {
+ public ClientWindowFrames createFromParcel(Parcel in) {
+ return new ClientWindowFrames(in);
+ }
+
+ public ClientWindowFrames[] newArray(int size) {
+ return new ClientWindowFrames[size];
+ }
+ };
+}
diff --git a/core/java/com/android/internal/view/BaseIWindow.java b/core/java/com/android/internal/view/BaseIWindow.java
index 7f3eb4515654..d5f54a199828 100644
--- a/core/java/com/android/internal/view/BaseIWindow.java
+++ b/core/java/com/android/internal/view/BaseIWindow.java
@@ -18,13 +18,11 @@ package com.android.internal.view;
import android.compat.annotation.UnsupportedAppUsage;
import android.graphics.Point;
-import android.graphics.Rect;
import android.hardware.input.InputManager;
import android.os.Bundle;
import android.os.ParcelFileDescriptor;
import android.os.RemoteException;
import android.util.MergedConfiguration;
-import android.view.DisplayCutout;
import android.view.DragEvent;
import android.view.IScrollCaptureController;
import android.view.IWindow;
@@ -33,6 +31,7 @@ import android.view.InsetsSourceControl;
import android.view.InsetsState;
import android.view.PointerIcon;
import android.view.WindowInsets.Type.InsetsType;
+import android.window.ClientWindowFrames;
import com.android.internal.os.IResultReceiver;
@@ -51,11 +50,9 @@ public class BaseIWindow extends IWindow.Stub {
}
@Override
- public void resized(Rect frame, Rect contentInsets, Rect visibleInsets,
- Rect stableInsets, boolean reportDraw,
- MergedConfiguration mergedConfiguration, Rect backDropFrame, boolean forceLayout,
- boolean alwaysConsumeSystemBars, int displayId,
- DisplayCutout.ParcelableWrapper displayCutout) {
+ public void resized(ClientWindowFrames frames, boolean reportDraw,
+ MergedConfiguration mergedConfiguration, boolean forceLayout,
+ boolean alwaysConsumeSystemBars, int displayId) {
if (reportDraw) {
try {
mSession.finishDrawing(this, null /* postDrawTransaction */);