Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 2e99fc09 authored by Fabian Kozynski's avatar Fabian Kozynski Committed by Android (Google) Code Review
Browse files

Merge "Prevent NPE in CustomTile"

parents 5d83a796 cfdd8d40
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -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());
+8 −0
Original line number Diff line number Diff line
@@ -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