Iterate over a copy in QSTileHost#changeTiles

Prevent OOB exception when iterating over the list of previous tiles, as
it could be modified.

As we just need to find out what changed, there's no need to add extra
locking.

Test: no test
Fixes: 150212857
Change-Id: I129660a81771acba3d6a5da58fb14ed19659d4ea
This commit is contained in:
Fabian Kozynski
2020-02-25 13:00:04 -05:00
parent 7b27da1d8f
commit 9e40da9026

View File

@@ -326,10 +326,10 @@ public class QSTileHost implements QSHost, Tunable, PluginListener<QSFactory>, D
}
public void changeTiles(List<String> previousTiles, List<String> newTiles) {
final int NP = previousTiles.size();
final int NA = newTiles.size();
final List<String> copy = new ArrayList<>(previousTiles);
final int NP = copy.size();
for (int i = 0; i < NP; i++) {
String tileSpec = previousTiles.get(i);
String tileSpec = copy.get(i);
if (!tileSpec.startsWith(CustomTile.PREFIX)) continue;
if (!newTiles.contains(tileSpec)) {
ComponentName component = CustomTile.getComponentFromSpec(tileSpec);