From ee7c65d539cb12fe7f8b753fa4b94c2734469fdf Mon Sep 17 00:00:00 2001 From: Alan Viverette Date: Fri, 27 Mar 2015 10:57:34 -0700 Subject: [PATCH] Only verify resolved theme attributes Bug: 19962473 Change-Id: I62eb2faea7b09fd483194b41e815179cb2141fcb --- .../android/graphics/drawable/BitmapDrawable.java | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/graphics/java/android/graphics/drawable/BitmapDrawable.java b/graphics/java/android/graphics/drawable/BitmapDrawable.java index 68ffed6585531..dc10a813caa3b 100644 --- a/graphics/java/android/graphics/drawable/BitmapDrawable.java +++ b/graphics/java/android/graphics/drawable/BitmapDrawable.java @@ -721,7 +721,7 @@ public class BitmapDrawable extends Drawable { final TypedArray a = obtainAttributes(r, theme, attrs, R.styleable.BitmapDrawable); updateStateFromTypedArray(a); - verifyState(a); + verifyRequiredAttributes(a); a.recycle(); // Update local properties. @@ -733,11 +733,13 @@ public class BitmapDrawable extends Drawable { * * @throws XmlPullParserException if any required attributes are missing */ - private void verifyState(TypedArray a) throws XmlPullParserException { + private void verifyRequiredAttributes(TypedArray a) throws XmlPullParserException { + // If we're not waiting on a theme, verify required attributes. final BitmapState state = mBitmapState; - if (state.mBitmap == null) { + if (state.mBitmap == null && (state.mThemeAttrs == null + || state.mThemeAttrs[R.styleable.BitmapDrawable_src] == 0)) { throw new XmlPullParserException(a.getPositionDescription() + - ": requires a valid src attribute"); + ": requires a valid 'src' attribute"); } } @@ -759,7 +761,7 @@ public class BitmapDrawable extends Drawable { final Bitmap bitmap = BitmapFactory.decodeResource(r, srcResId); if (bitmap == null) { throw new XmlPullParserException(a.getPositionDescription() + - ": requires a valid src attribute"); + ": requires a valid 'src' attribute"); } state.mBitmap = bitmap;