Fix race condition in QSTileHost
QSTileHost had three problems that caused a race condition:
* Calls to add/remove tiles could come and be executed in any thread.
* Different paths to add/remove tiles used different ground truths on
what tiles were currently active.
* The list of tiles contained in mTileSpecs was not necessarily the
same as the visible tiles.
This caused the following problem:
* If two tiles (usually CustomTile) were removed roughly at the same
time, only one of them would actually be removed from the Setting, as
both of them would race to remove from the same list. This caused...
* There would be leftover tiles that cannot connect to a TileService
and therefore show empty UI.
The solution is as follows:
* Make sure that all operations that modify the tiles are performed in
the main thread.
* Make sure that all operations that modify the tiles use the same
truth for the current state.
* Make sure that mTileSpecs always reflects the setting at the end of
onTuningChanged. This means that tiles that are destroyed or removed
will never be in this list.
Test: atest com.android.systemui.qs
Test: manual, start Guest user and notice that there are no blank tiles.
(cherry picked from commit 7f2bb15f4e40c0e1d1d0b2308444f4f9f449bd3f)
(cherry picked from commit 2d3949485591a31a90e7abec5ac7a3dc8597072a)
10 files changed