From 2757128940c35d8007e1817b32e7128e2569ad6e Mon Sep 17 00:00:00 2001 From: Teng-Hui Zhu Date: Thu, 12 May 2016 15:53:53 -0700 Subject: [PATCH] Update the light center when the root view's layout changed b/26208900 Change-Id: I0594b2801d54a489e7d858b7a0f9549fcc30f9a0 --- core/java/android/view/View.java | 5 +++++ core/java/android/view/ViewRootImpl.java | 13 ++++++++++--- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/core/java/android/view/View.java b/core/java/android/view/View.java index 4e7d19143385e..10ee1f59051f2 100644 --- a/core/java/android/view/View.java +++ b/core/java/android/view/View.java @@ -22840,6 +22840,11 @@ public class View implements Drawable.Callback, KeyEvent.Callback, */ boolean mKeepScreenOn; + /** + * Set during a traveral if the light center needs to be updated. + */ + boolean mNeedsUpdateLightCenter; + /** * Bitwise-or of all of the values that views have passed to setSystemUiVisibility(). */ diff --git a/core/java/android/view/ViewRootImpl.java b/core/java/android/view/ViewRootImpl.java index 8cabf42dadf82..e2bad643df222 100644 --- a/core/java/android/view/ViewRootImpl.java +++ b/core/java/android/view/ViewRootImpl.java @@ -80,7 +80,6 @@ import android.view.accessibility.IAccessibilityInteractionConnection; import android.view.accessibility.IAccessibilityInteractionConnectionCallback; import android.view.animation.AccelerateDecelerateInterpolator; import android.view.animation.Interpolator; -import android.view.inputmethod.InputConnection; import android.view.inputmethod.InputMethodManager; import android.widget.Scroller; @@ -916,6 +915,11 @@ public final class ViewRootImpl implements ViewParent, // Recompute system ui visibility. mAttachInfo.mRecomputeGlobalAttributes = true; } + if ((mWindowAttributesChangesFlag + & WindowManager.LayoutParams.LAYOUT_CHANGED) != 0) { + // Request to update light center. + mAttachInfo.mNeedsUpdateLightCenter = true; + } if (mWindowAttributes.packageName == null) { mWindowAttributes.packageName = mBasePackageName; } @@ -2222,13 +2226,16 @@ public final class ViewRootImpl implements ViewParent, } mAttachInfo.mWindowLeft = frame.left; mAttachInfo.mWindowTop = frame.top; - - // Update the light position for the new window offsets. + } + if (windowMoved || mAttachInfo.mNeedsUpdateLightCenter) { + // Update the light position for the new offsets. if (mAttachInfo.mHardwareRenderer != null) { mAttachInfo.mHardwareRenderer.setLightCenter(mAttachInfo); } + mAttachInfo.mNeedsUpdateLightCenter = false; } } + private void handleOutOfResourcesException(Surface.OutOfResourcesException e) { Log.e(mTag, "OutOfResourcesException initializing HW surface", e); try {