Loading core/java/com/android/internal/policy/DecorView.java +17 −0 Original line number Diff line number Diff line Loading @@ -249,6 +249,14 @@ public class DecorView extends FrameLayout implements RootViewSurfaceTaker, Wind private Drawable mOriginalBackgroundDrawable; private Drawable mLastOriginalBackgroundDrawable; private Drawable mResizingBackgroundDrawable; /** * Temporary holder for a window background when it is set before {@link #mWindow} is * initialized. It will be set as the actual background once {@link #setWindow(PhoneWindow)} is * called. */ @Nullable private Drawable mPendingWindowBackground; private Drawable mCaptionBackgroundDrawable; private Drawable mUserCaptionBackgroundDrawable; Loading Loading @@ -961,6 +969,10 @@ public class DecorView extends FrameLayout implements RootViewSurfaceTaker, Wind } public void setWindowBackground(Drawable drawable) { if (mWindow == null) { mPendingWindowBackground = drawable; return; } if (mOriginalBackgroundDrawable != drawable) { mOriginalBackgroundDrawable = drawable; updateBackgroundDrawable(); Loading Loading @@ -2003,6 +2015,11 @@ public class DecorView extends FrameLayout implements RootViewSurfaceTaker, Wind DecorContext decorContext = (DecorContext) context; decorContext.setPhoneWindow(mWindow); } if (mPendingWindowBackground != null) { Drawable background = mPendingWindowBackground; mPendingWindowBackground = null; setWindowBackground(background); } } @Override Loading core/tests/coretests/res/values/styles.xml +3 −0 Original line number Diff line number Diff line Loading @@ -39,4 +39,7 @@ <item name="android:colorBackground">@null</item> <item name="android:windowBackgroundFallback">#0000FF</item> </style> <style name="ViewDefaultBackground"> <item name="android:background">#00000000</item> </style> </resources> core/tests/coretests/src/com/android/internal/policy/DecorViewTest.java +9 −0 Original line number Diff line number Diff line Loading @@ -76,4 +76,13 @@ public class DecorViewTest { expectedBitmap.getPixels(expPixels, 0, w, 0, 0, w, h); assertThat(Arrays.toString(expPixels)).isEqualTo(Arrays.toString(resPixels)); } @Test public void setBackgroundWithNoWindow() { PhoneWindow phoneWindow = new PhoneWindow(mContext); // Set a theme that defines a non-null value for android:background mContext.setTheme(R.style.ViewDefaultBackground); DecorView decorView = (DecorView) phoneWindow.getDecorView(); assertThat(decorView.getBackground()).isNotNull(); } } Loading
core/java/com/android/internal/policy/DecorView.java +17 −0 Original line number Diff line number Diff line Loading @@ -249,6 +249,14 @@ public class DecorView extends FrameLayout implements RootViewSurfaceTaker, Wind private Drawable mOriginalBackgroundDrawable; private Drawable mLastOriginalBackgroundDrawable; private Drawable mResizingBackgroundDrawable; /** * Temporary holder for a window background when it is set before {@link #mWindow} is * initialized. It will be set as the actual background once {@link #setWindow(PhoneWindow)} is * called. */ @Nullable private Drawable mPendingWindowBackground; private Drawable mCaptionBackgroundDrawable; private Drawable mUserCaptionBackgroundDrawable; Loading Loading @@ -961,6 +969,10 @@ public class DecorView extends FrameLayout implements RootViewSurfaceTaker, Wind } public void setWindowBackground(Drawable drawable) { if (mWindow == null) { mPendingWindowBackground = drawable; return; } if (mOriginalBackgroundDrawable != drawable) { mOriginalBackgroundDrawable = drawable; updateBackgroundDrawable(); Loading Loading @@ -2003,6 +2015,11 @@ public class DecorView extends FrameLayout implements RootViewSurfaceTaker, Wind DecorContext decorContext = (DecorContext) context; decorContext.setPhoneWindow(mWindow); } if (mPendingWindowBackground != null) { Drawable background = mPendingWindowBackground; mPendingWindowBackground = null; setWindowBackground(background); } } @Override Loading
core/tests/coretests/res/values/styles.xml +3 −0 Original line number Diff line number Diff line Loading @@ -39,4 +39,7 @@ <item name="android:colorBackground">@null</item> <item name="android:windowBackgroundFallback">#0000FF</item> </style> <style name="ViewDefaultBackground"> <item name="android:background">#00000000</item> </style> </resources>
core/tests/coretests/src/com/android/internal/policy/DecorViewTest.java +9 −0 Original line number Diff line number Diff line Loading @@ -76,4 +76,13 @@ public class DecorViewTest { expectedBitmap.getPixels(expPixels, 0, w, 0, 0, w, h); assertThat(Arrays.toString(expPixels)).isEqualTo(Arrays.toString(resPixels)); } @Test public void setBackgroundWithNoWindow() { PhoneWindow phoneWindow = new PhoneWindow(mContext); // Set a theme that defines a non-null value for android:background mContext.setTheme(R.style.ViewDefaultBackground); DecorView decorView = (DecorView) phoneWindow.getDecorView(); assertThat(decorView.getBackground()).isNotNull(); } }