Synchronizing model data access

Test: Presubmit
Bug: 173328873
Change-Id: Ifc1724e17ebfa2ee5f21bb3f272986b8a14fdbc1
This commit is contained in:
Sunny Goyal
2020-12-10 16:22:41 -08:00
parent cbf8fe08da
commit cfcefb0c47
4 changed files with 25 additions and 17 deletions

View File

@@ -375,6 +375,16 @@ public class BgDataModel {
}
}
/**
* Returns a list containing all workspace items including widgets.
*/
public synchronized ArrayList<ItemInfo> getAllWorkspaceItems() {
ArrayList<ItemInfo> items = new ArrayList<>(workspaceItems.size() + appWidgets.size());
items.addAll(workspaceItems);
items.addAll(appWidgets);
return items;
}
/**
* Calls the provided {@code op} for all workspaceItems in the in-memory model (both persisted
* items and dynamic/predicted items for the provided {@code userHandle}.