mirror of
https://github.com/LawnchairLauncher/lawnchair.git
synced 2026-02-20 03:08:19 +00:00
Avoid race condition with hotseat predictions.
Make sure that the ArrayList cannot be cleared on the model thread while it is being used on the UI thread to render a launcher preview. Test: Manual Fix: 210123588 Change-Id: I5a47cb3f28f5ac9e400f6ae535e410c345e14ee1
This commit is contained in:
@@ -119,18 +119,19 @@ public class QuickstepModelDelegate extends ModelDelegate {
|
||||
|
||||
WorkspaceItemFactory allAppsFactory = new WorkspaceItemFactory(
|
||||
mApp, ums, pinnedShortcuts, mIDP.numDatabaseAllAppsColumns);
|
||||
mAllAppsState.items.setItems(
|
||||
FixedContainerItems allAppsItems = new FixedContainerItems(mAllAppsState.containerId,
|
||||
mAllAppsState.storage.read(mApp.getContext(), allAppsFactory, ums.allUsers::get));
|
||||
mDataModel.extraItems.put(CONTAINER_PREDICTION, mAllAppsState.items);
|
||||
mDataModel.extraItems.put(mAllAppsState.containerId, allAppsItems);
|
||||
|
||||
WorkspaceItemFactory hotseatFactory =
|
||||
new WorkspaceItemFactory(mApp, ums, pinnedShortcuts, mIDP.numDatabaseHotseatIcons);
|
||||
mHotseatState.items.setItems(
|
||||
FixedContainerItems hotseatItems = new FixedContainerItems(mHotseatState.containerId,
|
||||
mHotseatState.storage.read(mApp.getContext(), hotseatFactory, ums.allUsers::get));
|
||||
mDataModel.extraItems.put(CONTAINER_HOTSEAT_PREDICTION, mHotseatState.items);
|
||||
mDataModel.extraItems.put(mHotseatState.containerId, hotseatItems);
|
||||
|
||||
// Widgets prediction isn't used frequently. And thus, it is not persisted on disk.
|
||||
mDataModel.extraItems.put(CONTAINER_WIDGETS_PREDICTION, mWidgetsRecommendationState.items);
|
||||
mDataModel.extraItems.put(mWidgetsRecommendationState.containerId,
|
||||
new FixedContainerItems(mWidgetsRecommendationState.containerId));
|
||||
mActive = true;
|
||||
}
|
||||
|
||||
@@ -371,14 +372,14 @@ public class QuickstepModelDelegate extends ModelDelegate {
|
||||
|
||||
static class PredictorState {
|
||||
|
||||
public final FixedContainerItems items;
|
||||
public final int containerId;
|
||||
public final PersistedItemArray<ItemInfo> storage;
|
||||
public AppPredictor predictor;
|
||||
|
||||
private List<AppTarget> mLastTargets;
|
||||
|
||||
PredictorState(int container, String storageName) {
|
||||
items = new FixedContainerItems(container);
|
||||
PredictorState(int containerId, String storageName) {
|
||||
this.containerId = containerId;
|
||||
storage = new PersistedItemArray<>(storageName);
|
||||
mLastTargets = Collections.emptyList();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user