Implement new window cropping.
The window manager now performs the crop internally, evaluating
it every animation from, to be able to update it along with
the surface position.
Change-Id: I960a2161b9defb6fba4840fa35aee4e411c39b32
diff --git a/core/java/android/view/IWindow.aidl b/core/java/android/view/IWindow.aidl
index 555f306..b4caad3 100644
--- a/core/java/android/view/IWindow.aidl
+++ b/core/java/android/view/IWindow.aidl
@@ -45,7 +45,7 @@
*/
void executeCommand(String command, String parameters, in ParcelFileDescriptor descriptor);
- void resized(int w, int h, in Rect systemInsets, in Rect contentInsets,
+ void resized(int w, int h, in Rect contentInsets,
in Rect visibleInsets, boolean reportDraw, in Configuration newConfig);
void dispatchAppVisibility(boolean visible);
void dispatchGetNewSurface();
diff --git a/core/java/android/view/IWindowSession.aidl b/core/java/android/view/IWindowSession.aidl
index f26d5e1..d4a03ce 100644
--- a/core/java/android/view/IWindowSession.aidl
+++ b/core/java/android/view/IWindowSession.aidl
@@ -58,10 +58,6 @@
* {@link WindowManagerImpl#RELAYOUT_DEFER_SURFACE_DESTROY}.
* @param outFrame Rect in which is placed the new position/size on
* screen.
- * @param outSystemInsets Rect in which is placed the offsets from
- * <var>outFrame</var> over which any core system UI elements are
- * currently covering the window. This is not generally used for
- * layout, but just to know where the window is obscured.
* @param outContentInsets Rect in which is placed the offsets from
* <var>outFrame</var> in which the content of the window should be
* placed. This can be used to modify the window layout to ensure its
@@ -83,7 +79,7 @@
*/
int relayout(IWindow window, int seq, in WindowManager.LayoutParams attrs,
int requestedWidth, int requestedHeight, int viewVisibility,
- int flags, out Rect outFrame, out Rect outSystemInsets,
+ int flags, out Rect outFrame,
out Rect outContentInsets, out Rect outVisibleInsets,
out Configuration outConfig, out Surface outSurface);
diff --git a/core/java/android/view/SurfaceView.java b/core/java/android/view/SurfaceView.java
index ee322f8..f4ca9d2 100644
--- a/core/java/android/view/SurfaceView.java
+++ b/core/java/android/view/SurfaceView.java
@@ -98,7 +98,6 @@
MyWindow mWindow;
final Rect mVisibleInsets = new Rect();
final Rect mWinFrame = new Rect();
- final Rect mSystemInsets = new Rect();
final Rect mContentInsets = new Rect();
final Configuration mConfiguration = new Configuration();
@@ -472,7 +471,7 @@
mWindow, mWindow.mSeq, mLayout, mWidth, mHeight,
visible ? VISIBLE : GONE,
WindowManagerImpl.RELAYOUT_DEFER_SURFACE_DESTROY,
- mWinFrame, mSystemInsets, mContentInsets,
+ mWinFrame, mContentInsets,
mVisibleInsets, mConfiguration, mNewSurface);
if ((relayoutResult&WindowManagerImpl.RELAYOUT_RES_FIRST_TIME) != 0) {
mReportDrawNeeded = true;
@@ -606,7 +605,7 @@
mSurfaceView = new WeakReference<SurfaceView>(surfaceView);
}
- public void resized(int w, int h, Rect systemInsets, Rect contentInsets,
+ public void resized(int w, int h, Rect contentInsets,
Rect visibleInsets, boolean reportDraw, Configuration newConfig) {
SurfaceView surfaceView = mSurfaceView.get();
if (surfaceView != null) {
diff --git a/core/java/android/view/View.java b/core/java/android/view/View.java
index 4d13e8a..cec27fc 100644
--- a/core/java/android/view/View.java
+++ b/core/java/android/view/View.java
@@ -17161,12 +17161,6 @@
boolean mUse32BitDrawingCache;
/**
- * Describes the parts of the window that are currently completely
- * obscured by system UI elements.
- */
- final Rect mSystemInsets = new Rect();
-
- /**
* For windows that are full-screen but using insets to layout inside
* of the screen decorations, these are the current insets for the
* content of the window.
diff --git a/core/java/android/view/ViewRootImpl.java b/core/java/android/view/ViewRootImpl.java
index 1310719..90e6034 100644
--- a/core/java/android/view/ViewRootImpl.java
+++ b/core/java/android/view/ViewRootImpl.java
@@ -262,7 +262,6 @@
final Rect mPendingVisibleInsets = new Rect();
final Rect mPendingContentInsets = new Rect();
- final Rect mPendingSystemInsets = new Rect();
final ViewTreeObserver.InternalInsetsInfo mLastGivenInsets
= new ViewTreeObserver.InternalInsetsInfo();
@@ -272,7 +271,6 @@
final Configuration mPendingConfiguration = new Configuration();
class ResizedInfo {
- Rect systemInsets;
Rect contentInsets;
Rect visibleInsets;
Configuration newConfig;
@@ -568,7 +566,6 @@
if (mTranslator != null) {
mTranslator.translateRectInScreenToAppWindow(mAttachInfo.mContentInsets);
}
- mPendingSystemInsets.set(0, 0, 0, 0);
mPendingContentInsets.set(mAttachInfo.mContentInsets);
mPendingVisibleInsets.set(0, 0, 0, 0);
if (DEBUG_LAYOUT) Log.v(TAG, "Added window " + mWindow);
@@ -1235,7 +1232,6 @@
getRunQueue().executeActions(attachInfo.mHandler);
boolean insetsChanged = false;
- boolean activeRectChanged = false;
boolean layoutRequested = mLayoutRequested && !mStopped;
if (layoutRequested) {
@@ -1247,12 +1243,7 @@
// to opposite of the added touch mode.
mAttachInfo.mInTouchMode = !mAddedTouchMode;
ensureTouchModeLocally(mAddedTouchMode);
- activeRectChanged = true;
} else {
- if (!mPendingSystemInsets.equals(mAttachInfo.mSystemInsets)) {
- mAttachInfo.mSystemInsets.set(mPendingSystemInsets);
- activeRectChanged = true;
- }
if (!mPendingContentInsets.equals(mAttachInfo.mContentInsets)) {
insetsChanged = true;
}
@@ -1406,10 +1397,6 @@
mPendingConfiguration.seq = 0;
}
- if (!mPendingSystemInsets.equals(mAttachInfo.mSystemInsets)) {
- activeRectChanged = true;
- mAttachInfo.mSystemInsets.set(mPendingSystemInsets);
- }
contentInsetsChanged = !mPendingContentInsets.equals(
mAttachInfo.mContentInsets);
visibleInsetsChanged = !mPendingVisibleInsets.equals(
@@ -1512,7 +1499,6 @@
// before actually drawing them, so it can display then
// all at once.
newSurface = true;
- activeRectChanged = true;
mFullRedrawNeeded = true;
mPreviousTransparentRegion.setEmpty();
@@ -1578,7 +1564,6 @@
// window size we asked for. We should avoid this by getting a maximum size from
// the window session beforehand.
if (mWidth != frame.width() || mHeight != frame.height()) {
- activeRectChanged = true;
mWidth = frame.width();
mHeight = frame.height();
}
@@ -2814,7 +2799,6 @@
ResizedInfo ri = (ResizedInfo)msg.obj;
if (mWinFrame.width() == msg.arg1 && mWinFrame.height() == msg.arg2
- && mPendingSystemInsets.equals(ri.systemInsets)
&& mPendingContentInsets.equals(ri.contentInsets)
&& mPendingVisibleInsets.equals(ri.visibleInsets)
&& ((ResizedInfo)msg.obj).newConfig == null) {
@@ -2831,7 +2815,6 @@
mWinFrame.right = msg.arg1;
mWinFrame.top = 0;
mWinFrame.bottom = msg.arg2;
- mPendingSystemInsets.set(((ResizedInfo)msg.obj).systemInsets);
mPendingContentInsets.set(((ResizedInfo)msg.obj).contentInsets);
mPendingVisibleInsets.set(((ResizedInfo)msg.obj).visibleInsets);
if (msg.what == MSG_RESIZED_REPORT) {
@@ -3866,7 +3849,7 @@
(int) (mView.getMeasuredWidth() * appScale + 0.5f),
(int) (mView.getMeasuredHeight() * appScale + 0.5f),
viewVisibility, insetsPending ? WindowManagerImpl.RELAYOUT_INSETS_PENDING : 0,
- mWinFrame, mPendingSystemInsets, mPendingContentInsets, mPendingVisibleInsets,
+ mWinFrame, mPendingContentInsets, mPendingVisibleInsets,
mPendingConfiguration, mSurface);
//Log.d(TAG, "<<<<<< BACK FROM relayout");
if (restore) {
@@ -4062,11 +4045,10 @@
mHandler.sendMessage(msg);
}
- public void dispatchResized(int w, int h, Rect systemInsets, Rect contentInsets,
+ public void dispatchResized(int w, int h, Rect contentInsets,
Rect visibleInsets, boolean reportDraw, Configuration newConfig) {
if (DEBUG_LAYOUT) Log.v(TAG, "Resizing " + this + ": w=" + w
- + " h=" + h + " systemInsets=" + systemInsets.toShortString()
- + " contentInsets=" + contentInsets.toShortString()
+ + " h=" + h + " contentInsets=" + contentInsets.toShortString()
+ " visibleInsets=" + visibleInsets.toShortString()
+ " reportDraw=" + reportDraw);
Message msg = mHandler.obtainMessage(reportDraw ? MSG_RESIZED_REPORT :MSG_RESIZED);
@@ -4079,7 +4061,6 @@
msg.arg1 = w;
msg.arg2 = h;
ResizedInfo ri = new ResizedInfo();
- ri.systemInsets = new Rect(systemInsets);
ri.contentInsets = new Rect(contentInsets);
ri.visibleInsets = new Rect(visibleInsets);
ri.newConfig = newConfig;
@@ -4735,11 +4716,11 @@
mViewAncestor = new WeakReference<ViewRootImpl>(viewAncestor);
}
- public void resized(int w, int h, Rect systemInsets, Rect contentInsets,
+ public void resized(int w, int h, Rect contentInsets,
Rect visibleInsets, boolean reportDraw, Configuration newConfig) {
final ViewRootImpl viewAncestor = mViewAncestor.get();
if (viewAncestor != null) {
- viewAncestor.dispatchResized(w, h, systemInsets, contentInsets,
+ viewAncestor.dispatchResized(w, h, contentInsets,
visibleInsets, reportDraw, newConfig);
}
}
diff --git a/core/java/android/view/WindowManagerPolicy.java b/core/java/android/view/WindowManagerPolicy.java
index 388cfb3..ddef59b 100644
--- a/core/java/android/view/WindowManagerPolicy.java
+++ b/core/java/android/view/WindowManagerPolicy.java
@@ -145,10 +145,6 @@
* @param displayFrame The frame of the overall display in which this
* window can appear, used for constraining the overall dimensions
* of the window.
- * @param systemFrame The frame within the display that any system
- * elements are currently covering. These indicate which parts of
- * the window should be considered completely obscured by the screen
- * decorations.
* @param contentFrame The frame within the display in which we would
* like active content to appear. This will cause windows behind to
* be resized to match the given content frame.
@@ -160,7 +156,7 @@
* are visible.
*/
public void computeFrameLw(Rect parentFrame, Rect displayFrame,
- Rect systemFrame, Rect contentFrame, Rect visibleFrame);
+ Rect contentFrame, Rect visibleFrame);
/**
* Retrieve the current frame of the window that has been assigned by
@@ -188,14 +184,6 @@
public Rect getDisplayFrameLw();
/**
- * Retrieve the frame of the system elements that last covered the window.
- * Must be called with the window manager lock held.
- *
- * @return Rect The rectangle holding the system frame.
- */
- public Rect getSystemFrameLw();
-
- /**
* Retrieve the frame of the content area that this window was last
* laid out in. This is the area in which the content of the window
* should be placed. It will be smaller than the display frame to
@@ -770,6 +758,21 @@
public void beginLayoutLw(int displayWidth, int displayHeight, int displayRotation);
/**
+ * Return the rectangle of the screen currently covered by system decorations.
+ * This will be called immediately after {@link #layoutWindowLw}. It can
+ * fill in the rectangle to indicate any part of the screen that it knows
+ * for sure is covered by system decor such as the status bar. The rectangle
+ * is initially set to the actual size of the screen, indicating nothing is
+ * covered.
+ *
+ * @param systemRect The rectangle of the screen that is not covered by
+ * system decoration.
+ * @return Returns the layer above which the system rectangle should
+ * not be applied.
+ */
+ public int getSystemDecorRectLw(Rect systemRect);
+
+ /**
* Called for each window attached to the window manager as layout is
* proceeding. The implementation of this function must take care of
* setting the window's frame, either here or in finishLayout().
@@ -794,7 +797,7 @@
*
*/
public void getContentInsetHintLw(WindowManager.LayoutParams attrs, Rect contentInset);
-
+
/**
* Called when layout of the windows is finished. After this function has
* returned, all windows given to layoutWindow() <em>must</em> have had a