private void applyBackgroundChanges() {
    if (!mAttached || mLayerWrapper == null) {
      return;
    }

    if (DEBUG) Log.v(TAG, "applyBackgroundChanges drawable " + mBackgroundDrawable);

    int dimAlpha = 0;

    if (mImageOutWrapper != null && mImageOutWrapper.isAnimationPending()) {
      if (DEBUG) Log.v(TAG, "mImageOutWrapper animation starting");
      mImageOutWrapper.startAnimation();
      mImageOutWrapper = null;
      dimAlpha = DIM_ALPHA_ON_SOLID;
    }

    if (mImageInWrapper == null && mBackgroundDrawable != null) {
      if (DEBUG) Log.v(TAG, "creating new imagein drawable");
      mImageInWrapper = new DrawableWrapper(mBackgroundDrawable);
      mLayerDrawable.setDrawableByLayerId(R.id.background_imagein, mBackgroundDrawable);
      if (DEBUG) Log.v(TAG, "mImageInWrapper animation starting");
      mImageInWrapper.setAlpha(0);
      mImageInWrapper.fadeIn(FADE_DURATION_SLOW, 0);
      mImageInWrapper.startAnimation();
      dimAlpha = FULL_ALPHA;
    }

    if (mDimWrapper != null && dimAlpha != 0) {
      if (DEBUG) Log.v(TAG, "dimwrapper animation starting to " + dimAlpha);
      mDimWrapper.fade(FADE_DURATION_SLOW, 0, dimAlpha);
      mDimWrapper.startAnimation();
    }
  }
  /**
   * Set the background to the given color. The timing for when this becomes visible in the app is
   * undefined and may take place after a small delay.
   */
  public void setColor(int color) {
    if (DEBUG) Log.v(TAG, "setColor " + Integer.toHexString(color));

    mBackgroundColor = color;
    mService.setColor(mBackgroundColor);

    if (mColorWrapper != null) {
      mColorWrapper.setColor(mBackgroundColor);
    }
  }
  private void updateImmediate() {
    lazyInit();

    mColorWrapper.setColor(mBackgroundColor);
    if (mDimWrapper != null) {
      mDimWrapper.setAlpha(mBackgroundColor == Color.TRANSPARENT ? 0 : DIM_ALPHA_ON_SOLID);
    }
    showWallpaper(mBackgroundColor == Color.TRANSPARENT);

    mThemeDrawable = getThemeDrawable();
    mLayerDrawable.setDrawableByLayerId(R.id.background_theme, mThemeDrawable);

    if (mBackgroundDrawable == null) {
      mLayerDrawable.setDrawableByLayerId(R.id.background_imagein, createEmptyDrawable());
    } else {
      if (DEBUG) Log.v(TAG, "Background drawable is available");
      mImageInWrapper = new DrawableWrapper(mBackgroundDrawable);
      mLayerDrawable.setDrawableByLayerId(R.id.background_imagein, mBackgroundDrawable);
      if (mDimWrapper != null) {
        mDimWrapper.setAlpha(FULL_ALPHA);
      }
    }
  }