Loading packages/SystemUI/src/com/android/systemui/statusbar/StatusBarIconView.java +11 −9 Original line number Diff line number Diff line Loading @@ -427,15 +427,17 @@ public class StatusBarIconView extends AnimatedImageView implements StatusIconDi typedValue, true); float scaleFactor = typedValue.getFloat(); if (icon != null) { // We downscale the loaded drawable to reasonable size to protect against applications // using too much memory. The size can be tweaked in config.xml. Drawables // that are already sized properly won't be touched. // using too much memory. The size can be tweaked in config.xml. Drawables that are // already sized properly won't be touched. boolean isLowRamDevice = ActivityManager.isLowRamDeviceStatic(); Resources res = sysuiContext.getResources(); int maxIconSize = res.getDimensionPixelSize(isLowRamDevice ? com.android.internal.R.dimen.notification_small_icon_size_low_ram : com.android.internal.R.dimen.notification_small_icon_size); icon = DrawableSize.downscaleToSize(res, icon, maxIconSize, maxIconSize); } // No need to scale the icon, so return it as is. if (scaleFactor == 1.f) { Loading packages/SystemUI/tests/src/com/android/systemui/statusbar/StatusBarIconViewTest.java +16 −1 Original line number Diff line number Diff line Loading @@ -155,4 +155,19 @@ public class StatusBarIconViewTest extends SysuiTestCase { mIconView.getIcon(largeIcon); // no crash? good } @Test public void testNullIcon() { Icon mockIcon = mock(Icon.class); when(mockIcon.loadDrawableAsUser(any(), anyInt())).thenReturn(null); mStatusBarIcon.icon = mockIcon; mIconView.set(mStatusBarIcon); 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.getIcon(largeIcon); // No crash? good } } Loading
packages/SystemUI/src/com/android/systemui/statusbar/StatusBarIconView.java +11 −9 Original line number Diff line number Diff line Loading @@ -427,15 +427,17 @@ public class StatusBarIconView extends AnimatedImageView implements StatusIconDi typedValue, true); float scaleFactor = typedValue.getFloat(); if (icon != null) { // We downscale the loaded drawable to reasonable size to protect against applications // using too much memory. The size can be tweaked in config.xml. Drawables // that are already sized properly won't be touched. // using too much memory. The size can be tweaked in config.xml. Drawables that are // already sized properly won't be touched. boolean isLowRamDevice = ActivityManager.isLowRamDeviceStatic(); Resources res = sysuiContext.getResources(); int maxIconSize = res.getDimensionPixelSize(isLowRamDevice ? com.android.internal.R.dimen.notification_small_icon_size_low_ram : com.android.internal.R.dimen.notification_small_icon_size); icon = DrawableSize.downscaleToSize(res, icon, maxIconSize, maxIconSize); } // No need to scale the icon, so return it as is. if (scaleFactor == 1.f) { Loading
packages/SystemUI/tests/src/com/android/systemui/statusbar/StatusBarIconViewTest.java +16 −1 Original line number Diff line number Diff line Loading @@ -155,4 +155,19 @@ public class StatusBarIconViewTest extends SysuiTestCase { mIconView.getIcon(largeIcon); // no crash? good } @Test public void testNullIcon() { Icon mockIcon = mock(Icon.class); when(mockIcon.loadDrawableAsUser(any(), anyInt())).thenReturn(null); mStatusBarIcon.icon = mockIcon; mIconView.set(mStatusBarIcon); 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.getIcon(largeIcon); // No crash? good } }