Loading packages/SystemUI/src/com/android/systemui/statusbar/StatusBarIconView.java +6 −4 Original line number Diff line number Diff line Loading @@ -416,10 +416,12 @@ public class StatusBarIconView extends AnimatedImageView implements StatusIconDi return mIcon.icon; } private Drawable getIcon(StatusBarIcon icon) { Context notifContext = mNotification != null ? mNotification.getPackageContext(getContext()) : getContext(); return getIcon(getContext(), notifContext, icon); Drawable getIcon(StatusBarIcon icon) { Context notifContext = getContext(); if (mNotification != null) { notifContext = mNotification.getPackageContext(getContext()); } return getIcon(getContext(), notifContext != null ? notifContext : getContext(), icon); } /** Loading packages/SystemUI/tests/src/com/android/systemui/statusbar/StatusBarIconViewTest.java +16 −0 Original line number Diff line number Diff line Loading @@ -39,6 +39,7 @@ import android.graphics.Bitmap; import android.graphics.Color; import android.graphics.drawable.Icon; import android.os.UserHandle; import android.service.notification.StatusBarNotification; import androidx.test.filters.SmallTest; import androidx.test.runner.AndroidJUnit4; Loading Loading @@ -131,4 +132,19 @@ public class StatusBarIconViewTest extends SysuiTestCase { icon, 0, 0, ""); assertFalse(mIconView.set(largeIcon)); } @Test public void testNullNotifInfo() { Bitmap bitmap = Bitmap.createBitmap(60, 60, Bitmap.Config.ARGB_8888); Icon icon = Icon.createWithBitmap(bitmap); StatusBarIcon largeIcon = new StatusBarIcon(UserHandle.ALL, "mockPackage", icon, 0, 0, ""); mIconView.setNotification(mock(StatusBarNotification.class)); mIconView.getIcon(largeIcon); // no crash? good mIconView.setNotification(null); mIconView.getIcon(largeIcon); // no crash? good } } No newline at end of file Loading
packages/SystemUI/src/com/android/systemui/statusbar/StatusBarIconView.java +6 −4 Original line number Diff line number Diff line Loading @@ -416,10 +416,12 @@ public class StatusBarIconView extends AnimatedImageView implements StatusIconDi return mIcon.icon; } private Drawable getIcon(StatusBarIcon icon) { Context notifContext = mNotification != null ? mNotification.getPackageContext(getContext()) : getContext(); return getIcon(getContext(), notifContext, icon); Drawable getIcon(StatusBarIcon icon) { Context notifContext = getContext(); if (mNotification != null) { notifContext = mNotification.getPackageContext(getContext()); } return getIcon(getContext(), notifContext != null ? notifContext : getContext(), icon); } /** Loading
packages/SystemUI/tests/src/com/android/systemui/statusbar/StatusBarIconViewTest.java +16 −0 Original line number Diff line number Diff line Loading @@ -39,6 +39,7 @@ import android.graphics.Bitmap; import android.graphics.Color; import android.graphics.drawable.Icon; import android.os.UserHandle; import android.service.notification.StatusBarNotification; import androidx.test.filters.SmallTest; import androidx.test.runner.AndroidJUnit4; Loading Loading @@ -131,4 +132,19 @@ public class StatusBarIconViewTest extends SysuiTestCase { icon, 0, 0, ""); assertFalse(mIconView.set(largeIcon)); } @Test public void testNullNotifInfo() { Bitmap bitmap = Bitmap.createBitmap(60, 60, Bitmap.Config.ARGB_8888); Icon icon = Icon.createWithBitmap(bitmap); StatusBarIcon largeIcon = new StatusBarIcon(UserHandle.ALL, "mockPackage", icon, 0, 0, ""); mIconView.setNotification(mock(StatusBarNotification.class)); mIconView.getIcon(largeIcon); // no crash? good mIconView.setNotification(null); mIconView.getIcon(largeIcon); // no crash? good } } No newline at end of file