Only add NonClientDecorView when needed
We were previously adding it to all decor views because it was
required to be able to draw the resizing backdrop. We now manage
the resizing backdrop independently of the NonClientDecorView.
Bug: 25082500
Change-Id: Ib786d55eacd221e5d36a4afca9117d5409499674
diff --git a/core/java/com/android/internal/policy/BackdropFrameRenderer.java b/core/java/com/android/internal/policy/BackdropFrameRenderer.java
index f227bf3..b101733 100644
--- a/core/java/com/android/internal/policy/BackdropFrameRenderer.java
+++ b/core/java/com/android/internal/policy/BackdropFrameRenderer.java
@@ -210,7 +210,7 @@
// If this was the first call and changeWindowSizeLocked got already called prior
// to us, we should re-issue a changeWindowSizeLocked now.
return firstCall
- && (mLastCaptionHeight != 0 || !mDecorView.mNonClientDecorView.mShowDecor);
+ && (mLastCaptionHeight != 0 || !mDecorView.isShowingCaption());
}
}
@@ -227,25 +227,25 @@
* @param newBounds The window bounds which needs to be drawn.
*/
private void changeWindowSizeLocked(Rect newBounds) {
+
// While a configuration change is taking place the view hierarchy might become
// inaccessible. For that case we remember the previous metrics to avoid flashes.
// Note that even when there is no visible caption, the caption child will exist.
- View caption = mDecorView.mNonClientDecorView.getChildAt(0);
- if (caption != null) {
- final int captionHeight = caption.getHeight();
- // The caption height will probably never dynamically change while we are resizing.
- // Once set to something other then 0 it should be kept that way.
- if (captionHeight != 0) {
- // Remember the height of the caption.
- mLastCaptionHeight = captionHeight;
- }
+ final int captionHeight = mDecorView.getCaptionHeight();
+ // The caption height will probably never dynamically change while we are resizing.
+ // Once set to something other then 0 it should be kept that way.
+ if (captionHeight != 0) {
+ // Remember the height of the caption.
+ mLastCaptionHeight = captionHeight;
}
+
// Make sure that the other thread has already prepared the render draw calls for the
// content. If any size is 0, we have to wait for it to be drawn first.
- if ((mLastCaptionHeight == 0 && mDecorView.mNonClientDecorView.mShowDecor) ||
+ if ((mLastCaptionHeight == 0 && mDecorView.isShowingCaption()) ||
mLastContentWidth == 0 || mLastContentHeight == 0) {
return;
}
+
// Since the surface is spanning the entire screen, we have to add the start offset of
// the bounds to get to the surface location.
final int left = mLastXOffset + newBounds.left;
diff --git a/core/java/com/android/internal/policy/DecorView.java b/core/java/com/android/internal/policy/DecorView.java
index b15ccb2..077cebc 100644
--- a/core/java/com/android/internal/policy/DecorView.java
+++ b/core/java/com/android/internal/policy/DecorView.java
@@ -1551,6 +1551,8 @@
}
View onResourcesLoaded(LayoutInflater inflater, int layoutResource) {
+ mWorkspaceId = getWorkspaceId();
+
mResizingBackgroundDrawable = getResizingBackgroundDrawable(
mWindow.mBackgroundResource, mWindow.mBackgroundFallbackResource);
mCaptionBackgroundDrawable =
@@ -1591,12 +1593,10 @@
final WindowManager.LayoutParams attrs = mWindow.getAttributes();
boolean isApplication = attrs.type == TYPE_BASE_APPLICATION ||
attrs.type == TYPE_APPLICATION;
- mWorkspaceId = getWorkspaceId();
// Only a non floating application window on one of the allowed workspaces can get a non
// client decor.
- if (!mWindow.isFloating()
- && isApplication
- && ActivityManager.StackId.isStaticStack(mWorkspaceId)) {
+ final boolean hasNonClientDecor = ActivityManager.StackId.hasWindowDecor(mWorkspaceId);
+ if (!mWindow.isFloating() && isApplication && hasNonClientDecor) {
// Dependent on the brightness of the used title we either use the
// dark or the light button frame.
if (nonClientDecorView == null) {
@@ -1615,11 +1615,12 @@
nonClientDecorView.setPhoneWindow(mWindow,
ActivityManager.StackId.hasWindowDecor(mWorkspaceId),
ActivityManager.StackId.hasWindowShadow(mWorkspaceId));
+ } else {
+ nonClientDecorView = null;
}
- // Tell the decor if it has a visible non client decor.
- enableNonClientDecor(
- nonClientDecorView != null && ActivityManager.StackId.hasWindowDecor(mWorkspaceId));
+ // Tell the decor if it has a visible non client decor.
+ enableNonClientDecor(nonClientDecorView != null && hasNonClientDecor);
return nonClientDecorView;
}
@@ -1754,6 +1755,14 @@
}
}
+ boolean isShowingCaption() {
+ return mNonClientDecorView != null && mNonClientDecorView.isShowingDecor();
+ }
+
+ int getCaptionHeight() {
+ return isShowingCaption() ? mNonClientDecorView.getDecorCaptionHeight() : 0;
+ }
+
private static class ColorViewState {
View view = null;
int targetVisibility = View.INVISIBLE;
diff --git a/core/java/com/android/internal/widget/NonClientDecorView.java b/core/java/com/android/internal/widget/NonClientDecorView.java
index 232e308..33b8e05 100644
--- a/core/java/com/android/internal/widget/NonClientDecorView.java
+++ b/core/java/com/android/internal/widget/NonClientDecorView.java
@@ -68,7 +68,7 @@
private final int DECOR_SHADOW_UNFOCUSED_HEIGHT_IN_DIP = 5;
private PhoneWindow mOwner = null;
private boolean mWindowHasShadow = false;
- public boolean mShowDecor = false;
+ private boolean mShowDecor = false;
// True if the window is being dragged.
private boolean mDragging = false;
@@ -298,4 +298,13 @@
}
}
}
+
+ public boolean isShowingDecor() {
+ return mShowDecor;
+ }
+
+ public int getDecorCaptionHeight() {
+ final View caption = getChildAt(0);
+ return (caption != null) ? caption.getHeight() : 0;
+ }
}