From a40fd09fa99fed9526c6603b5af93b7dba259000 Mon Sep 17 00:00:00 2001 From: Filip Gruszczynski Date: Thu, 7 Jan 2016 16:38:11 -0800 Subject: [PATCH] Load background drawable before passing to backdrop renderer. Background renderer always expects that the default background drawable is available. We pass the drawable to the renderer in two places, so we need to make sure to load the drawable before each. Bug: 26345599 Change-Id: I238623ff870e26ba34bb02197611172e316d3083 --- .../policy/BackdropFrameRenderer.java | 3 +++ .../android/internal/policy/DecorView.java | 20 ++++++++++++------- 2 files changed, 16 insertions(+), 7 deletions(-) diff --git a/core/java/com/android/internal/policy/BackdropFrameRenderer.java b/core/java/com/android/internal/policy/BackdropFrameRenderer.java index 1b44ff3ec3fb9..de54d96df78bc 100644 --- a/core/java/com/android/internal/policy/BackdropFrameRenderer.java +++ b/core/java/com/android/internal/policy/BackdropFrameRenderer.java @@ -99,6 +99,9 @@ public class BackdropFrameRenderer extends Thread implements Choreographer.Frame mResizingBackgroundDrawable = resizingBackgroundDrawable; mCaptionBackgroundDrawable = captionBackgroundDrawableDrawable; mUserCaptionBackgroundDrawable = userCaptionBackgroundDrawable; + if (mCaptionBackgroundDrawable == null) { + mCaptionBackgroundDrawable = mResizingBackgroundDrawable; + } if (statusBarColor != 0) { mStatusBarColor = new ColorDrawable(statusBarColor); addSystemBarNodeIfNeeded(); diff --git a/core/java/com/android/internal/policy/DecorView.java b/core/java/com/android/internal/policy/DecorView.java index cc2f7142f8930..cea9867b8d88d 100644 --- a/core/java/com/android/internal/policy/DecorView.java +++ b/core/java/com/android/internal/policy/DecorView.java @@ -1616,14 +1616,8 @@ public class DecorView extends FrameLayout implements RootViewSurfaceTaker, Wind void onResourcesLoaded(LayoutInflater inflater, int layoutResource) { mStackId = getStackId(); - mResizingBackgroundDrawable = getResizingBackgroundDrawable( - mWindow.mBackgroundResource, mWindow.mBackgroundFallbackResource); - if (mCaptionBackgroundDrawable == null) { - mCaptionBackgroundDrawable = getContext().getDrawable( - R.drawable.decor_caption_title_focused); - } - if (mBackdropFrameRenderer != null) { + loadBackgroundDrawablesIfNeeded(); mBackdropFrameRenderer.onResourcesLoaded( this, mResizingBackgroundDrawable, mCaptionBackgroundDrawable, mUserCaptionBackgroundDrawable, getCurrentColor(mStatusColorViewState)); @@ -1645,6 +1639,17 @@ public class DecorView extends FrameLayout implements RootViewSurfaceTaker, Wind initializeElevation(); } + private void loadBackgroundDrawablesIfNeeded() { + if (mResizingBackgroundDrawable == null) { + mResizingBackgroundDrawable = getResizingBackgroundDrawable( + mWindow.mBackgroundResource, mWindow.mBackgroundFallbackResource); + } + if (mCaptionBackgroundDrawable == null) { + mCaptionBackgroundDrawable = getContext().getDrawable( + R.drawable.decor_caption_title_focused); + } + } + // Free floating overlapping windows require a caption. private DecorCaptionView createDecorCaptionView(LayoutInflater inflater) { DecorCaptionView decorCaptionView = null; @@ -1815,6 +1820,7 @@ public class DecorView extends FrameLayout implements RootViewSurfaceTaker, Wind } final ThreadedRenderer renderer = getHardwareRenderer(); if (renderer != null) { + loadBackgroundDrawablesIfNeeded(); mBackdropFrameRenderer = new BackdropFrameRenderer(this, renderer, initialBounds, mResizingBackgroundDrawable, mCaptionBackgroundDrawable, mUserCaptionBackgroundDrawable, getCurrentColor(mStatusColorViewState));