diff options
| -rw-r--r-- | packages/SystemUI/src/com/android/systemui/qs/external/CustomTile.java | 1 | ||||
| -rw-r--r-- | packages/SystemUI/tests/src/com/android/systemui/qs/external/CustomTileTest.kt | 8 |
2 files changed, 9 insertions, 0 deletions
diff --git a/packages/SystemUI/src/com/android/systemui/qs/external/CustomTile.java b/packages/SystemUI/src/com/android/systemui/qs/external/CustomTile.java index 21a424c77a05..ef8a23df2cf9 100644 --- a/packages/SystemUI/src/com/android/systemui/qs/external/CustomTile.java +++ b/packages/SystemUI/src/com/android/systemui/qs/external/CustomTile.java @@ -327,6 +327,7 @@ public class CustomTile extends QSTileImpl<State> implements TileChangeListener final Drawable drawableF = drawable; state.iconSupplier = () -> { + if (drawableF == null) return null; Drawable.ConstantState cs = drawableF.getConstantState(); if (cs != null) { return new DrawableIcon(cs.newDrawable()); diff --git a/packages/SystemUI/tests/src/com/android/systemui/qs/external/CustomTileTest.kt b/packages/SystemUI/tests/src/com/android/systemui/qs/external/CustomTileTest.kt index 9fe2569177d7..c6715350d777 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/qs/external/CustomTileTest.kt +++ b/packages/SystemUI/tests/src/com/android/systemui/qs/external/CustomTileTest.kt @@ -125,4 +125,12 @@ class CustomTileTest : SysuiTestCase() { customTile.handleUpdateState(state, null) assertFalse(state.value) } + + @Test + fun testNoCrashOnNullDrawable() { + customTile.qsTile.icon = mock(Icon::class.java) + `when`(customTile.qsTile.icon.loadDrawable(any(Context::class.java))) + .thenReturn(null) + customTile.handleUpdateState(customTile.newTileState(), null) + } }
\ No newline at end of file |