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

Commit 8c4a19c8 authored by Amin Shaikh's avatar Amin Shaikh
Browse files

Fix QSTileImpl NPE on startup.

Do not call protected methods before the object is fully instantiated.
Remove paranoid null check for private final nonnull fields for
sublasses of QSTileImpl.

Fixes: 75995708
Test: runtest systemui
Change-Id: I0a11131d796e08d598d696babdf3d7db30e02149
parent d41fed72
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -348,7 +348,7 @@ public class CustomTile extends QSTileImpl<State> implements TileChangeListener
        return ComponentName.unflattenFromString(action);
    }

    public static QSTile create(QSTileHost host, String spec) {
    public static CustomTile create(QSTileHost host, String spec) {
        if (spec == null || !spec.startsWith(PREFIX) || !spec.endsWith(")")) {
            throw new IllegalArgumentException("Bad custom tile spec: " + spec);
        }
+8 −0
Original line number Diff line number Diff line
@@ -52,6 +52,14 @@ public class QSFactoryImpl implements QSFactory {
    }

    public QSTile createTile(String tileSpec) {
        QSTileImpl tile = createTileInternal(tileSpec);
        if (tile != null) {
            tile.handleStale(); // Tile was just created, must be stale.
        }
        return tile;
    }

    private QSTileImpl createTileInternal(String tileSpec) {
        if (tileSpec.equals("wifi")) return new WifiTile(mHost);
        else if (tileSpec.equals("bt")) return new BluetoothTile(mHost);
        else if (tileSpec.equals("cell")) return new CellularTile(mHost);
+0 −1
Original line number Diff line number Diff line
@@ -103,7 +103,6 @@ public abstract class QSTileImpl<TState extends State> implements QSTile {
    protected QSTileImpl(QSHost host) {
        mHost = host;
        mContext = host.getContext();
        handleStale(); // Tile was just created, must be stale.
    }

    /**
+0 −1
Original line number Diff line number Diff line
@@ -78,7 +78,6 @@ public class BluetoothTile extends QSTileImpl<BooleanState> {

    @Override
    public void handleSetListening(boolean listening) {
        if (mController == null) return;
        if (listening) {
            mController.addCallback(mCallback);
        } else {
+0 −2
Original line number Diff line number Diff line
@@ -83,7 +83,6 @@ public class CastTile extends QSTileImpl<BooleanState> {

    @Override
    public void handleSetListening(boolean listening) {
        if (mController == null) return;
        if (DEBUG) Log.d(TAG, "handleSetListening " + listening);
        if (listening) {
            mController.addCallback(mCallback);
@@ -98,7 +97,6 @@ public class CastTile extends QSTileImpl<BooleanState> {
    @Override
    protected void handleUserSwitch(int newUserId) {
        super.handleUserSwitch(newUserId);
        if (mController == null) return;
        mController.setCurrentUserId(newUserId);
    }

Loading