Making workspaceData immutable

BgDataModel holds a mutable handle of the data, which ensures that all edits go through this class and there is a single place to keep the repository updated

Bug: 390572144
Test: Updated existing model tests
Flag: EXEMPT refactor
Change-Id: I991b707dd21801d1abd00510f676549947285012
This commit is contained in:
Sunny Goyal committed 2025-05-07 13:21:21 -07:00
1 parent 51343f74d5
commit 57a195b790
30 files changed
+382 -377

No files matched your search

@@ -71,7 +71,7 @@ public class PredictionUpdateTask implements ModelUpdateTask {
LauncherPrefs.get(context).put(LAST_PREDICTION_ENABLED, !mTargets.isEmpty());
Set<UserHandle> usersForChangedShortcuts =
dataModel.getPredictedContents(mPredictorState.containerId).stream()
dataModel.itemsIdMap.getPredictedContents(mPredictorState.containerId).stream()
.filter(info -> info.itemType == ITEM_TYPE_DEEP_SHORTCUT)
.map(info -> info.user)
.collect(Collectors.toSet());
@@ -120,7 +120,7 @@ public class PredictionUpdateTask implements ModelUpdateTask {
}
PredictedContainerInfo pci = new PredictedContainerInfo(mPredictorState.containerId, items);
dataModel.itemsIdMap.put(pci.id, pci);
dataModel.updateAndDispatchItem(pci /* item */, null /* owner */);
taskController.bindUpdatedWorkspaceItems(Collections.singleton(pci));
usersForChangedShortcuts.forEach(u -> dataModel.updateShortcutPinnedState(context, u));