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:
Brian Isganitis
2021-12-13 16:52:54 +00:00
parent 7512ab6025
commit f7c2adf861
4 changed files with 22 additions and 20 deletions
@@ -59,8 +59,8 @@ public final class WidgetsPredictionUpdateTask extends BaseModelUpdateTask {
Map<PackageUserKey, List<WidgetItem>> allWidgets =
dataModel.widgetsModel.getAllWidgetsWithoutShortcuts();
FixedContainerItems fixedContainerItems = mPredictorState.items;
fixedContainerItems.items.clear();
FixedContainerItems fixedContainerItems =
new FixedContainerItems(mPredictorState.containerId);
if (FeatureFlags.ENABLE_LOCAL_RECOMMENDED_WIDGETS_FILTER.get()) {
for (AppTarget app : mTargets) {
@@ -100,6 +100,7 @@ public final class WidgetsPredictionUpdateTask extends BaseModelUpdateTask {
}
}
}
dataModel.extraItems.put(mPredictorState.containerId, fixedContainerItems);
bindExtraContainerItems(fixedContainerItems);
// Don't store widgets prediction to disk because it is not used frequently.