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

Commit bcb76351 authored by Doris Ling's avatar Doris Ling
Browse files

Fix ConcurrentModificationException in SummaryLoader.

When the dashboard summary is being initialized, it will rebuild the UI
while the summary loader tries to to go through the tiles to update the
summary. Both is being done on a separate backgroud thread, and it will
run into concurrent modification issue if the thread is being swapped
while one is looping through the list.

Instead of letting clients access the list of tiles directly, add a
getter method in DashboardCategory to get a copy of the list of tiles
for all read-only operations.

Change-Id: I479669abd8d1d0a8ee9a4113d8ad2244da56f4d8
Fixes: 69677575
Test: make RunSettingsRoboTests
parent c2d84d8d
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -477,7 +477,7 @@ public class DashboardAdapter extends RecyclerView.Adapter<DashboardAdapter.Dash
        final int tintColor = a.getColor(0, mContext.getColor(R.color.fallback_tintColor));
        a.recycle();
        if (category != null) {
            for (Tile tile : category.tiles) {
            for (Tile tile : category.getTiles()) {
                if (tile.isIconTintable) {
                    // If this drawable is tintable, tint it to match the color.
                    tile.icon.setTint(tintColor);
+3 −2
Original line number Diff line number Diff line
@@ -268,8 +268,9 @@ public class DashboardData {
                        && hiddenSuggestion == 0);

        if (mCategory != null) {
            for (int j = 0; j < mCategory.tiles.size(); j++) {
                final Tile tile = mCategory.tiles.get(j);
            final List<Tile> tiles = mCategory.getTiles();
            for (int j = 0; j < tiles.size(); j++) {
                final Tile tile = tiles.get(j);
                addToItemList(tile, R.layout.dashboard_tile, Objects.hash(tile.title),
                        true /* add */);
            }
+1 −1
Original line number Diff line number Diff line
@@ -91,7 +91,7 @@ public class DashboardFeatureProviderImpl implements DashboardFeatureProvider {
            Log.d(TAG, "NO dashboard tiles for " + TAG);
            return null;
        }
        final List<Tile> tiles = category.tiles;
        final List<Tile> tiles = category.getTiles();
        if (tiles == null || tiles.isEmpty()) {
            Log.d(TAG, "tile list is empty, skipping category " + category.title);
            return null;
+1 −1
Original line number Diff line number Diff line
@@ -307,7 +307,7 @@ public abstract class DashboardFragment extends SettingsPreferenceFragment
            Log.d(TAG, "NO dashboard tiles for " + TAG);
            return;
        }
        List<Tile> tiles = category.tiles;
        final List<Tile> tiles = category.getTiles();
        if (tiles == null) {
            Log.d(TAG, "tile list is empty, skipping category " + category.title);
            return;
+1 −1
Original line number Diff line number Diff line
@@ -154,7 +154,7 @@ public class SiteMapManager {
                continue;
            }
            // Build parent-child mPairs for all children listed under this key.
            for (Tile tile : category.tiles) {
            for (Tile tile : category.getTiles()) {
                final String childTitle = tile.title.toString();
                String childClass = null;
                if (tile.metaData != null) {
Loading