diff --git a/core/java/com/android/internal/policy/BackdropFrameRenderer.java b/core/java/com/android/internal/policy/BackdropFrameRenderer.java index f227bf35a4a08..b101733a1a14a 100644 --- a/core/java/com/android/internal/policy/BackdropFrameRenderer.java +++ b/core/java/com/android/internal/policy/BackdropFrameRenderer.java @@ -210,7 +210,7 @@ public class BackdropFrameRenderer extends Thread implements Choreographer.Frame // 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 @@ public class BackdropFrameRenderer extends Thread implements Choreographer.Frame * @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 b15ccb25d5b52..077cebc4ebf93 100644 --- a/core/java/com/android/internal/policy/DecorView.java +++ b/core/java/com/android/internal/policy/DecorView.java @@ -1551,6 +1551,8 @@ public class DecorView extends FrameLayout implements RootViewSurfaceTaker, Wind } View onResourcesLoaded(LayoutInflater inflater, int layoutResource) { + mWorkspaceId = getWorkspaceId(); + mResizingBackgroundDrawable = getResizingBackgroundDrawable( mWindow.mBackgroundResource, mWindow.mBackgroundFallbackResource); mCaptionBackgroundDrawable = @@ -1591,12 +1593,10 @@ public class DecorView extends FrameLayout implements RootViewSurfaceTaker, Wind 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 @@ public class DecorView extends FrameLayout implements RootViewSurfaceTaker, Wind 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 @@ public class DecorView extends FrameLayout implements RootViewSurfaceTaker, Wind } } + 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 232e308a3c25f..33b8e0515ab07 100644 --- a/core/java/com/android/internal/widget/NonClientDecorView.java +++ b/core/java/com/android/internal/widget/NonClientDecorView.java @@ -68,7 +68,7 @@ public class NonClientDecorView extends LinearLayout 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 class NonClientDecorView extends LinearLayout } } } + + public boolean isShowingDecor() { + return mShowDecor; + } + + public int getDecorCaptionHeight() { + final View caption = getChildAt(0); + return (caption != null) ? caption.getHeight() : 0; + } }