diff options
author | Joe Onorato <joeo@android.com> | 2010-05-24 18:36:53 -0400 |
---|---|---|
committer | Joe Onorato <joeo@android.com> | 2010-06-02 14:48:44 -0700 |
commit | 871bdb9867f6630d8bb28e5607263e8bf4eac3ba (patch) | |
tree | 6b3579f5b72d78d3333ba5c2b1d2566775d932b3 | |
parent | 20da8f8ac9cfc8b845231c6b93f5b64a764ab39a (diff) | |
download | frameworks_base-871bdb9867f6630d8bb28e5607263e8bf4eac3ba.zip frameworks_base-871bdb9867f6630d8bb28e5607263e8bf4eac3ba.tar.gz frameworks_base-871bdb9867f6630d8bb28e5607263e8bf4eac3ba.tar.bz2 |
Handle bad icon resources.
Change-Id: I87c5fe68ad8016596068ba7889f3b6d36da3386b
-rw-r--r-- | packages/StatusBarPhone/src/com/android/policy/statusbar/phone/StatusBarIconView.java | 46 | ||||
-rw-r--r-- | tests/StatusBar/src/com/android/statusbartest/NotificationTestList.java | 10 |
2 files changed, 40 insertions, 16 deletions
diff --git a/packages/StatusBarPhone/src/com/android/policy/statusbar/phone/StatusBarIconView.java b/packages/StatusBarPhone/src/com/android/policy/statusbar/phone/StatusBarIconView.java index 58b9822..6b0b6d5 100644 --- a/packages/StatusBarPhone/src/com/android/policy/statusbar/phone/StatusBarIconView.java +++ b/packages/StatusBarPhone/src/com/android/policy/statusbar/phone/StatusBarIconView.java @@ -32,6 +32,7 @@ public class StatusBarIconView extends AnimatedImageView { private StatusBarIcon mIcon; @ViewDebug.ExportedProperty private String mSlot; + @ViewDebug.ExportedProperty private boolean mError; public StatusBarIconView(Context context, String slot) { super(context); @@ -52,24 +53,37 @@ public class StatusBarIconView extends AnimatedImageView { } public void set(StatusBarIcon icon) { - final boolean iconEquals = mIcon != null - && streq(mIcon.iconPackage, icon.iconPackage) - && mIcon.iconId == icon.iconId; - final boolean levelEquals = iconEquals - && mIcon.iconLevel == icon.iconLevel; - final boolean visibilityEquals = mIcon != null - && mIcon.visible == icon.visible; - if (!iconEquals) { - setImageDrawable(getIcon(icon)); - // TODO: What if getIcon returns null? - } - if (!levelEquals) { - setImageLevel(icon.iconLevel); + error: { + final boolean iconEquals = !mError + && mIcon != null + && streq(mIcon.iconPackage, icon.iconPackage) + && mIcon.iconId == icon.iconId; + final boolean levelEquals = !mError + && iconEquals + && mIcon.iconLevel == icon.iconLevel; + final boolean visibilityEquals = !mError + && mIcon != null + && mIcon.visible == icon.visible; + mError = false; + if (!iconEquals) { + Drawable drawable = getIcon(icon); + if (drawable == null) { + mError = true; + break error; + } + setImageDrawable(drawable); + } + if (!levelEquals) { + setImageLevel(icon.iconLevel); + } + if (!visibilityEquals) { + setVisibility(icon.visible ? VISIBLE : GONE); + } + mIcon = icon.clone(); } - if (!visibilityEquals) { - setVisibility(icon.visible ? VISIBLE : GONE); + if (mError) { + setVisibility(GONE); } - mIcon = icon.clone(); } /** diff --git a/tests/StatusBar/src/com/android/statusbartest/NotificationTestList.java b/tests/StatusBar/src/com/android/statusbartest/NotificationTestList.java index 40026fa..c30ace3 100644 --- a/tests/StatusBar/src/com/android/statusbartest/NotificationTestList.java +++ b/tests/StatusBar/src/com/android/statusbartest/NotificationTestList.java @@ -122,6 +122,16 @@ public class NotificationTestList extends TestActivity } }, + new Test("Bad Icon") { + public void run() { + mNM.notify(1, new Notification(NotificationTestList.this, + R.layout.chrono_notification, /* not a drawable! */ + null, System.currentTimeMillis()-(1000*60*60*24), + "(453) 123-2328", + "", null)); + } + }, + new Test("Bad resource #2") { public void run() { |