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

Commit 334d1bce authored by Amin Shaikh's avatar Amin Shaikh
Browse files

Never clear QS tile state.

QSTile#clearState puts QS tiles in an invalid state that may not be
immediately rectified through QSTile#refreshState. In the case of
configuration changes, if a subclass implementation of
QSTile#handleSetListening does not trigger a refresh state, the
invalid state causes incorrect click handling.

Change-Id: I17eba133cf08c45a768e9e0ed8fda623e85b4370
Fixes: 69738120
Fixes: 110480955
Test: manual
(cherry picked from commit 299c45c8)
parent e4e1b4fb
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -43,7 +43,7 @@ public interface QSTile {
    boolean isAvailable();
    void setTileSpec(String tileSpec);

    void clearState();
    @Deprecated default void clearState() {}
    void refreshState();

    void addCallback(Callback callback);
+0 −3
Original line number Diff line number Diff line
@@ -285,9 +285,6 @@ public class QSPanel extends LinearLayout implements Tunable, Callback, Brightne

        updatePageIndicator();

        for (TileRecord r : mRecords) {
            r.tile.clearState();
        }
        if (mListening) {
            refreshAllTiles();
        }
+0 −1
Original line number Diff line number Diff line
@@ -95,7 +95,6 @@ public class TileQueryHelper {
                continue;
            }
            tile.setListening(this, true);
            tile.clearState();
            tile.refreshState();
            tile.setListening(this, false);
            tile.setTileSpec(spec);
+4 −17
Original line number Diff line number Diff line
@@ -211,10 +211,6 @@ public abstract class QSTileImpl<TState extends State> implements QSTile {
        mHandler.obtainMessage(H.REFRESH_STATE, arg).sendToTarget();
    }

    public void clearState() {
        mHandler.sendEmptyMessage(H.CLEAR_STATE);
    }

    public void userSwitch(int newUserId) {
        mHandler.obtainMessage(H.USER_SWITCH, newUserId, 0).sendToTarget();
    }
@@ -266,11 +262,6 @@ public abstract class QSTileImpl<TState extends State> implements QSTile {

    public abstract Intent getLongClickIntent();

    protected void handleClearState() {
        mTmpState = newTileState();
        mState = newTileState();
    }

    protected void handleRefreshState(Object arg) {
        handleUpdateState(mTmpState, arg);
        final boolean changed = mTmpState.copyTo(mState);
@@ -409,11 +400,10 @@ public abstract class QSTileImpl<TState extends State> implements QSTile {
        private static final int TOGGLE_STATE_CHANGED = 8;
        private static final int SCAN_STATE_CHANGED = 9;
        private static final int DESTROY = 10;
        private static final int CLEAR_STATE = 11;
        private static final int REMOVE_CALLBACKS = 12;
        private static final int REMOVE_CALLBACK = 13;
        private static final int SET_LISTENING = 14;
        private static final int STALE = 15;
        private static final int REMOVE_CALLBACKS = 11;
        private static final int REMOVE_CALLBACK = 12;
        private static final int SET_LISTENING = 13;
        private static final int STALE = 14;

        @VisibleForTesting
        protected H(Looper looper) {
@@ -467,9 +457,6 @@ public abstract class QSTileImpl<TState extends State> implements QSTile {
                } else if (msg.what == DESTROY) {
                    name = "handleDestroy";
                    handleDestroy();
                } else if (msg.what == CLEAR_STATE) {
                    name = "handleClearState";
                    handleClearState();
                } else if (msg.what == SET_LISTENING) {
                    name = "handleSetListeningInternal";
                    handleSetListeningInternal(msg.obj, msg.arg1 != 0);