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

Commit 0696683c authored by Alexander Grund's avatar Alexander Grund Committed by Nolen Johnson
Browse files

Avoid NullPointer access when using the default icon

In the exception case the mDefaultIcon field is accessed but it can be a
NullPointer leading to a hard exception.
Using null in that case allows to catch that later, just like if the
icon could not be loaded.

Based on: I25e3d390091c5fd290c83287ead3718aa7084edd

Change-Id: Ib705294a508741406167965ac7c206d0e9ca3903
parent 2019d1a8
Loading
Loading
Loading
Loading
+8 −2
Original line number Diff line number Diff line
@@ -441,10 +441,16 @@ public class CustomTile extends QSTileImpl<State> implements TileChangeListener
        } catch (Exception e) {
            Log.w(TAG, "Invalid icon, forcing into unavailable state");
            state.state = Tile.STATE_UNAVAILABLE;
            drawable = mDefaultIcon.loadDrawable(mUserContext);
        }

        final Drawable drawableF = drawable;
        final Drawable drawableF;
        if (drawable != null) {
            drawableF = drawable;
        } else if (mDefaultIcon != null) {
            drawableF = mDefaultIcon.loadDrawable(mUserContext);
        } else {
            drawableF = null;
        }
        state.iconSupplier = () -> {
            if (drawableF == null) return null;
            Drawable.ConstantState cs = drawableF.getConstantState();