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

Commit a3e340a5 authored by Behnam Heydarshahi's avatar Behnam Heydarshahi
Browse files

Replace invis drawable when ConstantState null

The invisible drawable tried to create a new drawable before, even when
the ConstantState was null. This caused an exception. Now we check for
null pointer, and default to the provided drawable.

Flag: ACONFIG com.android.systemui.qs_new_tiles DEVELOPMENT
Bug: 339201022
Test: Ran the failing build on abtd. The fatal exception did not happen.
Test: atest QSTileImplTest QSIconViewImplTest

Change-Id: I11e6d0d23e3ba005270aff39f111a8bf4c417d55
parent c913a319
Loading
Loading
Loading
Loading
+13 −1
Original line number Diff line number Diff line
@@ -55,6 +55,7 @@ import com.android.internal.logging.MetricsLogger;
import com.android.internal.logging.UiEventLogger;
import com.android.settingslib.RestrictedLockUtils;
import com.android.settingslib.RestrictedLockUtilsInternal;
import com.android.settingslib.graph.SignalDrawable;
import com.android.systemui.Dumpable;
import com.android.systemui.animation.ActivityTransitionAnimator;
import com.android.systemui.animation.Expandable;
@@ -632,12 +633,23 @@ public abstract class QSTileImpl<TState extends State> implements QSTile, Lifecy
    }

    public static class DrawableIcon extends Icon {

        protected final Drawable mDrawable;
        protected final Drawable mInvisibleDrawable;
        private static final String TAG = "QSTileImpl";

        public DrawableIcon(Drawable drawable) {
            mDrawable = drawable;
            mInvisibleDrawable = drawable.getConstantState().newDrawable();
            Drawable.ConstantState nullableConstantState = drawable.getConstantState();
            if (nullableConstantState == null) {
                if (!(drawable instanceof SignalDrawable)) {
                    Log.w(TAG, "DrawableIcon: drawable has null ConstantState"
                            + " and is not a SignalDrawable");
                }
                mInvisibleDrawable = drawable;
            } else {
                mInvisibleDrawable = nullableConstantState.newDrawable();
            }
        }

        @Override
+1 −0
Original line number Diff line number Diff line
@@ -201,6 +201,7 @@ constructor(
        qsTileViewModel.currentState?.let { mapState(context, it, qsTileViewModel.config) }

    override fun getInstanceId(): InstanceId = qsTileViewModel.config.instanceId

    override fun getTileLabel(): CharSequence =
        with(qsTileViewModel.config.uiConfig) {
            when (this) {