Merge "Prevent NPE in CustomTile" into rvc-dev am: c8bb1b3286

Change-Id: I4b1dfb34700fdc5f83385d810a05fe69780d85e1
This commit is contained in:
Automerger Merge Worker
2020-02-28 18:05:44 +00:00
2 changed files with 9 additions and 0 deletions

View File

@@ -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());

View File

@@ -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)
}
}