Loading packages/SystemUI/src/com/android/systemui/qs/tileimpl/QSTileImpl.java +2 −14 Original line number Original line Diff line number Diff line Loading @@ -14,7 +14,6 @@ package com.android.systemui.qs.tileimpl; package com.android.systemui.qs.tileimpl; import static androidx.lifecycle.Lifecycle.State.CREATED; import static androidx.lifecycle.Lifecycle.State.DESTROYED; import static androidx.lifecycle.Lifecycle.State.DESTROYED; import static androidx.lifecycle.Lifecycle.State.RESUMED; import static androidx.lifecycle.Lifecycle.State.RESUMED; import static androidx.lifecycle.Lifecycle.State.STARTED; import static androidx.lifecycle.Lifecycle.State.STARTED; Loading Loading @@ -174,7 +173,6 @@ public abstract class QSTileImpl<TState extends State> implements QSTile, Lifecy mState = newTileState(); mState = newTileState(); mTmpState = newTileState(); mTmpState = newTileState(); mUiHandler.post(() -> mLifecycle.setCurrentState(CREATED)); } } protected final void resetStates() { protected final void resetStates() { Loading Loading @@ -455,9 +453,6 @@ public abstract class QSTileImpl<TState extends State> implements QSTile, Lifecy if (DEBUG) Log.d(TAG, "handleSetListening true"); if (DEBUG) Log.d(TAG, "handleSetListening true"); handleSetListening(listening); handleSetListening(listening); mUiHandler.post(() -> { mUiHandler.post(() -> { // This tile has been destroyed, the state should not change anymore and we // should not refresh it anymore. if (mLifecycle.getCurrentState().equals(DESTROYED)) return; mLifecycle.setCurrentState(RESUMED); mLifecycle.setCurrentState(RESUMED); refreshState(); // Ensure we get at least one refresh after listening. refreshState(); // Ensure we get at least one refresh after listening. }); }); Loading @@ -466,11 +461,7 @@ public abstract class QSTileImpl<TState extends State> implements QSTile, Lifecy if (mListeners.remove(listener) && mListeners.size() == 0) { if (mListeners.remove(listener) && mListeners.size() == 0) { if (DEBUG) Log.d(TAG, "handleSetListening false"); if (DEBUG) Log.d(TAG, "handleSetListening false"); handleSetListening(listening); handleSetListening(listening); mUiHandler.post(() -> { mUiHandler.post(() -> mLifecycle.setCurrentState(STARTED)); // This tile has been destroyed, the state should not change anymore. if (mLifecycle.getCurrentState().equals(DESTROYED)) return; mLifecycle.setCurrentState(STARTED); }); } } } } updateIsFullQs(); updateIsFullQs(); Loading @@ -497,14 +488,11 @@ public abstract class QSTileImpl<TState extends State> implements QSTile, Lifecy mQSLogger.logTileDestroyed(mTileSpec, "Handle destroy"); mQSLogger.logTileDestroyed(mTileSpec, "Handle destroy"); if (mListeners.size() != 0) { if (mListeners.size() != 0) { handleSetListening(false); handleSetListening(false); mListeners.clear(); } } mCallbacks.clear(); mCallbacks.clear(); mHandler.removeCallbacksAndMessages(null); mHandler.removeCallbacksAndMessages(null); // This will force it to be removed from all controllers that may have it registered. // This will force it to be removed from all controllers that may have it registered. mUiHandler.post(() -> { mLifecycle.setCurrentState(DESTROYED); mLifecycle.setCurrentState(DESTROYED); }); } } protected void checkIfRestrictionEnforcedByAdminOnly(State state, String userRestriction) { protected void checkIfRestrictionEnforcedByAdminOnly(State state, String userRestriction) { Loading packages/SystemUI/tests/src/com/android/systemui/qs/tileimpl/QSTileImplTest.java +0 −21 Original line number Original line Diff line number Diff line Loading @@ -244,8 +244,6 @@ public class QSTileImplTest extends SysuiTestCase { assertNotEquals(DESTROYED, mTile.getLifecycle().getCurrentState()); assertNotEquals(DESTROYED, mTile.getLifecycle().getCurrentState()); mTile.handleDestroy(); mTile.handleDestroy(); mTestableLooper.processAllMessages(); assertEquals(DESTROYED, mTile.getLifecycle().getCurrentState()); assertEquals(DESTROYED, mTile.getLifecycle().getCurrentState()); } } Loading Loading @@ -300,25 +298,6 @@ public class QSTileImplTest extends SysuiTestCase { assertNotEquals(DESTROYED, mTile.getLifecycle().getCurrentState()); assertNotEquals(DESTROYED, mTile.getLifecycle().getCurrentState()); } } @Test public void testRefreshStateAfterDestroyedDoesNotCrash() { mTile.destroy(); mTile.refreshState(); mTestableLooper.processAllMessages(); } @Test public void testSetListeningAfterDestroyedDoesNotCrash() { Object o = new Object(); mTile.destroy(); mTile.setListening(o, true); mTile.setListening(o, false); mTestableLooper.processAllMessages(); } private void assertEvent(UiEventLogger.UiEventEnum eventType, private void assertEvent(UiEventLogger.UiEventEnum eventType, UiEventLoggerFake.FakeUiEvent fakeEvent) { UiEventLoggerFake.FakeUiEvent fakeEvent) { assertEquals(eventType.getId(), fakeEvent.eventId); assertEquals(eventType.getId(), fakeEvent.eventId); Loading Loading
packages/SystemUI/src/com/android/systemui/qs/tileimpl/QSTileImpl.java +2 −14 Original line number Original line Diff line number Diff line Loading @@ -14,7 +14,6 @@ package com.android.systemui.qs.tileimpl; package com.android.systemui.qs.tileimpl; import static androidx.lifecycle.Lifecycle.State.CREATED; import static androidx.lifecycle.Lifecycle.State.DESTROYED; import static androidx.lifecycle.Lifecycle.State.DESTROYED; import static androidx.lifecycle.Lifecycle.State.RESUMED; import static androidx.lifecycle.Lifecycle.State.RESUMED; import static androidx.lifecycle.Lifecycle.State.STARTED; import static androidx.lifecycle.Lifecycle.State.STARTED; Loading Loading @@ -174,7 +173,6 @@ public abstract class QSTileImpl<TState extends State> implements QSTile, Lifecy mState = newTileState(); mState = newTileState(); mTmpState = newTileState(); mTmpState = newTileState(); mUiHandler.post(() -> mLifecycle.setCurrentState(CREATED)); } } protected final void resetStates() { protected final void resetStates() { Loading Loading @@ -455,9 +453,6 @@ public abstract class QSTileImpl<TState extends State> implements QSTile, Lifecy if (DEBUG) Log.d(TAG, "handleSetListening true"); if (DEBUG) Log.d(TAG, "handleSetListening true"); handleSetListening(listening); handleSetListening(listening); mUiHandler.post(() -> { mUiHandler.post(() -> { // This tile has been destroyed, the state should not change anymore and we // should not refresh it anymore. if (mLifecycle.getCurrentState().equals(DESTROYED)) return; mLifecycle.setCurrentState(RESUMED); mLifecycle.setCurrentState(RESUMED); refreshState(); // Ensure we get at least one refresh after listening. refreshState(); // Ensure we get at least one refresh after listening. }); }); Loading @@ -466,11 +461,7 @@ public abstract class QSTileImpl<TState extends State> implements QSTile, Lifecy if (mListeners.remove(listener) && mListeners.size() == 0) { if (mListeners.remove(listener) && mListeners.size() == 0) { if (DEBUG) Log.d(TAG, "handleSetListening false"); if (DEBUG) Log.d(TAG, "handleSetListening false"); handleSetListening(listening); handleSetListening(listening); mUiHandler.post(() -> { mUiHandler.post(() -> mLifecycle.setCurrentState(STARTED)); // This tile has been destroyed, the state should not change anymore. if (mLifecycle.getCurrentState().equals(DESTROYED)) return; mLifecycle.setCurrentState(STARTED); }); } } } } updateIsFullQs(); updateIsFullQs(); Loading @@ -497,14 +488,11 @@ public abstract class QSTileImpl<TState extends State> implements QSTile, Lifecy mQSLogger.logTileDestroyed(mTileSpec, "Handle destroy"); mQSLogger.logTileDestroyed(mTileSpec, "Handle destroy"); if (mListeners.size() != 0) { if (mListeners.size() != 0) { handleSetListening(false); handleSetListening(false); mListeners.clear(); } } mCallbacks.clear(); mCallbacks.clear(); mHandler.removeCallbacksAndMessages(null); mHandler.removeCallbacksAndMessages(null); // This will force it to be removed from all controllers that may have it registered. // This will force it to be removed from all controllers that may have it registered. mUiHandler.post(() -> { mLifecycle.setCurrentState(DESTROYED); mLifecycle.setCurrentState(DESTROYED); }); } } protected void checkIfRestrictionEnforcedByAdminOnly(State state, String userRestriction) { protected void checkIfRestrictionEnforcedByAdminOnly(State state, String userRestriction) { Loading
packages/SystemUI/tests/src/com/android/systemui/qs/tileimpl/QSTileImplTest.java +0 −21 Original line number Original line Diff line number Diff line Loading @@ -244,8 +244,6 @@ public class QSTileImplTest extends SysuiTestCase { assertNotEquals(DESTROYED, mTile.getLifecycle().getCurrentState()); assertNotEquals(DESTROYED, mTile.getLifecycle().getCurrentState()); mTile.handleDestroy(); mTile.handleDestroy(); mTestableLooper.processAllMessages(); assertEquals(DESTROYED, mTile.getLifecycle().getCurrentState()); assertEquals(DESTROYED, mTile.getLifecycle().getCurrentState()); } } Loading Loading @@ -300,25 +298,6 @@ public class QSTileImplTest extends SysuiTestCase { assertNotEquals(DESTROYED, mTile.getLifecycle().getCurrentState()); assertNotEquals(DESTROYED, mTile.getLifecycle().getCurrentState()); } } @Test public void testRefreshStateAfterDestroyedDoesNotCrash() { mTile.destroy(); mTile.refreshState(); mTestableLooper.processAllMessages(); } @Test public void testSetListeningAfterDestroyedDoesNotCrash() { Object o = new Object(); mTile.destroy(); mTile.setListening(o, true); mTile.setListening(o, false); mTestableLooper.processAllMessages(); } private void assertEvent(UiEventLogger.UiEventEnum eventType, private void assertEvent(UiEventLogger.UiEventEnum eventType, UiEventLoggerFake.FakeUiEvent fakeEvent) { UiEventLoggerFake.FakeUiEvent fakeEvent) { assertEquals(eventType.getId(), fakeEvent.eventId); assertEquals(eventType.getId(), fakeEvent.eventId); Loading