Merge "Prevent NPE in CustomTile" into rvc-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
c8bb1b3286
@@ -327,6 +327,7 @@ public class CustomTile extends QSTileImpl<State> implements TileChangeListener
|
|||||||
|
|
||||||
final Drawable drawableF = drawable;
|
final Drawable drawableF = drawable;
|
||||||
state.iconSupplier = () -> {
|
state.iconSupplier = () -> {
|
||||||
|
if (drawableF == null) return null;
|
||||||
Drawable.ConstantState cs = drawableF.getConstantState();
|
Drawable.ConstantState cs = drawableF.getConstantState();
|
||||||
if (cs != null) {
|
if (cs != null) {
|
||||||
return new DrawableIcon(cs.newDrawable());
|
return new DrawableIcon(cs.newDrawable());
|
||||||
|
|||||||
@@ -125,4 +125,12 @@ class CustomTileTest : SysuiTestCase() {
|
|||||||
customTile.handleUpdateState(state, null)
|
customTile.handleUpdateState(state, null)
|
||||||
assertFalse(state.value)
|
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)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user