From: Jorim Jaggi Date: Wed, 8 May 2019 21:08:02 +0000 (+0200) Subject: Check for null bg insets during initialization X-Git-Url: http://git.osdn.net/view?a=commitdiff_plain;h=d798fd3f99c63bf798271c140876d1228225ce03;p=android-x86%2Fframeworks-base.git Check for null bg insets during initialization Test: Turn on Ambient sensing, toggle ambient sensing in settings Fixes: 132264167 Change-Id: I7f19a91a7d78f8e6ae730871aebb6f7bfb30a0c5 --- diff --git a/core/java/com/android/internal/policy/DecorView.java b/core/java/com/android/internal/policy/DecorView.java index 5c1268ded94a..61d40a82a0bc 100644 --- a/core/java/com/android/internal/policy/DecorView.java +++ b/core/java/com/android/internal/policy/DecorView.java @@ -1226,6 +1226,10 @@ public class DecorView extends FrameLayout implements RootViewSurfaceTaker, Wind * are set. */ private void updateBackgroundDrawable() { + // Background insets can be null if super constructor calls setBackgroundDrawable. + if (mBackgroundInsets == null) { + mBackgroundInsets = Insets.NONE; + } if (mBackgroundInsets.equals(mLastBackgroundInsets) && mLastOriginalBackgroundDrawable == mOriginalBackgroundDrawable) { return; @@ -1549,10 +1553,14 @@ public class DecorView extends FrameLayout implements RootViewSurfaceTaker, Wind return; } - setPadding(mFramePadding.left + mBackgroundPadding.left, - mFramePadding.top + mBackgroundPadding.top, - mFramePadding.right + mBackgroundPadding.right, - mFramePadding.bottom + mBackgroundPadding.bottom); + // Fields can be null if super constructor calls setBackgroundDrawable. + Rect framePadding = mFramePadding != null ? mFramePadding : new Rect(); + Rect backgroundPadding = mBackgroundPadding != null ? mBackgroundPadding : new Rect(); + + setPadding(framePadding.left + backgroundPadding.left, + framePadding.top + backgroundPadding.top, + framePadding.right + backgroundPadding.right, + framePadding.bottom + backgroundPadding.bottom); requestLayout(); invalidate(); @@ -1572,8 +1580,8 @@ public class DecorView extends FrameLayout implements RootViewSurfaceTaker, Wind if (bg != null) { if (fg == null) { opacity = bg.getOpacity(); - } else if (mFramePadding.left <= 0 && mFramePadding.top <= 0 - && mFramePadding.right <= 0 && mFramePadding.bottom <= 0) { + } else if (framePadding.left <= 0 && framePadding.top <= 0 + && framePadding.right <= 0 && framePadding.bottom <= 0) { // If the frame padding is zero, then we can be opaque // if either the frame -or- the background is opaque. int fop = fg.getOpacity();