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

Commit 30aa3add authored by Fabian Kozynski's avatar Fabian Kozynski
Browse files

Remove Handler messages on QSTileImpl destroy

This prevents the tiles from being reference kept (as the MessageQueue
will have a reference to it). In particular, because
QSTileImpl#handleStale kepts rescheduling, this will never be collected.

Fixes: 146151014
Test: atest QSTileImpl
Change-Id: I0120953ae7e457a941dbebfcfd5da9dce9c09adb
parent b3321f66
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -413,6 +413,7 @@ public abstract class QSTileImpl<TState extends State> implements QSTile, Lifecy
            handleSetListening(false);
        }
        mCallbacks.clear();
        mHandler.removeCallbacksAndMessages(null);
    }

    protected void checkIfRestrictionEnforcedByAdminOnly(State state, String userRestriction) {
+10 −0
Original line number Diff line number Diff line
@@ -188,6 +188,16 @@ public class QSTileImplTest extends SysuiTestCase {
        verify(mTile).handleSetListening(eq(false));
    }

    @Test
    public void testHandleDestroyClearsHandlerQueue() {
        when(mTile.getStaleTimeout()).thenReturn(0L);
        mTile.handleRefreshState(null); // this will add a delayed H.STALE message
        mTile.handleDestroy();

        mTestableLooper.processAllMessages();
        verify(mTile, never()).handleStale();
    }

    private class TileLogMatcher implements ArgumentMatcher<LogMaker> {

        private final int mCategory;